openclaw - 💡(How to fix) Fix Feature Request: Add child spans for detailed OTEL traces [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#62964Fetched 2026-04-09 08:00:04
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Code Example

const parentSpan = tracer.startSpan("openclaw.message.processed");
// ...
const toolSpan = tracer.startSpan("openclaw.tool.execution", { parent: parentSpan });
// tool work
toolSpan.end();
// ...
parentSpan.end();
RAW_BUFFERClick to expand / collapse

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:

  1. Tool calls - time spent in each tool execution
  2. Model API latency - time for API request/response round-trip
  3. Tokenization - time spent calculating/counting tokens
  4. Response building - time spent constructing the final response
  5. 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

extent analysis

TL;DR

Implementing child spans under the openclaw.message.processed span can provide a detailed breakdown of where time is spent during message processing.

Guidance

  • Identify significant internal operations such as tool calls, model API latency, tokenization, response building, and other sub-operations that can be wrapped with child spans.
  • Use the proposed implementation approach of starting a child span with a specific name (e.g., openclaw.tool.execution) and setting the parent span to openclaw.message.processed.
  • Ensure that each child span is properly ended after its corresponding operation is completed to accurately measure the time spent.
  • Verify the effectiveness of the child spans by checking the OTLP backend (Jaeger) for the presence and accuracy of the detailed traces.

Example

const parentSpan = tracer.startSpan("openclaw.message.processed");
const toolSpan = tracer.startSpan("openclaw.tool.execution", { parent: parentSpan });
// tool execution code here
toolSpan.end();
const modelApiSpan = tracer.startSpan("openclaw.model.api.latency", { parent: parentSpan });
// model API call code here
modelApiSpan.end();
parentSpan.end();

Notes

The implementation of child spans should be tailored to the specific requirements of the OpenClaw application and may need to be adjusted based on the actual performance characteristics and debugging needs.

Recommendation

Apply the proposed workaround of implementing child spans to gain more detailed insights into the message processing time. This approach allows for a more fine-grained understanding of where time is spent without requiring significant changes to the existing instrumentation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING