Feature Request: Add child spans for detailed OTEL traces
Problem
Currently, OpenClaw's OTEL instrumentation only provides coarse-grained spans. For example, openclaw.message.processed is a single span that encompasses the entire message processing time (~228 seconds), but there is no breakdown of where that time is spent.
Current Spans Observed
openclaw.message.processed - entire message processing (no child spans)
openclaw.model.usage - model API call with attributes but no sub-steps
openclaw.session.stuck - session stuck detection
Desired Behavior
Add child spans under openclaw.message.processed to break down:
- Tool calls - time spent in each tool execution
- Model API latency - time for API request/response round-trip
- Tokenization - time spent calculating/counting tokens
- Response building - time spent constructing the final response
- Other sub-operations - any significant internal steps
Example Use Case
When debugging slow responses, developers need to understand where time is spent:
- Is it waiting on an LLM API?
- Is it running tool executions?
- Is it processing tokens?
Proposed Implementation
Wrap significant internal operations with child spans:
const parentSpan = tracer.startSpan("openclaw.message.processed");
// ...
const toolSpan = tracer.startSpan("openclaw.tool.execution", { parent: parentSpan });
// tool work
toolSpan.end();
// ...
parentSpan.end();
Environment
- OpenClaw Version: 2026.4.5
- OTLP Backend: Jaeger
- Protocol: http/protobuf
Feature Request: Add child spans for detailed OTEL traces
Problem
Currently, OpenClaw's OTEL instrumentation only provides coarse-grained spans. For example,
openclaw.message.processedis a single span that encompasses the entire message processing time (~228 seconds), but there is no breakdown of where that time is spent.Current Spans Observed
openclaw.message.processed- entire message processing (no child spans)openclaw.model.usage- model API call with attributes but no sub-stepsopenclaw.session.stuck- session stuck detectionDesired Behavior
Add child spans under
openclaw.message.processedto break down:Example Use Case
When debugging slow responses, developers need to understand where time is spent:
Proposed Implementation
Wrap significant internal operations with child spans:
Environment