GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(observability): add v2 genai tracing by StarpTech · Pull Request #35935 · anomalyco/opencode

Conversation

@StarpTech

@StarpTech StarpTech commented Jul 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Adds end-to-end V2 GenAI observability through OTLP. It records one trace per agent turn, model steps, HTTP and WebSocket transport, local tools, hosted-tool events, retries, compaction, subagents, and structured lifecycle failures. It also documents Dash0 setup and conversation navigation.

Only explicit operation boundaries create spans. Provider trace propagation remains disabled, URL queries are omitted, and prompts, model output, tool arguments, credentials, provider bodies, and raw exception messages are not recorded on spans. Existing retry, scheduling, and tool behavior remains unchanged.

Trace shape

invoke_agent build                       one agent turn
|-- event: session.input.promoted
|-- event: compaction/retry/hosted-tool lifecycle
|
|-- chat <model>                         model step 1
|   `-- POST / websocket.exchange        provider transport
|
|-- execute_tool <name>                  tool owned by the turn
|   `-- GET/POST                         HTTP owned by the tool
|
|-- execute_tool subagent
|   `-- invoke_agent explore             foreground child turn
|       |-- chat <child-model>
|       `-- execute_tool <child-tool>
|
`-- chat <model>                         continuation step
    `-- POST / websocket.exchange

Tool spans are siblings of model spans so concurrent tools can finish without outliving their model parent. Model transport spans require an explicit model span; unrelated Effect and HTTP spans remain disabled.

Conversations and subagents

Each turn is a separate root trace identified by gen_ai.conversation.id. A new turn links to the previous turn with opencode.link.type=previous_turn, allowing linked-trace navigation without keeping a conversation span open for hours. Turn links are bounded and process-local; gen_ai.conversation.id remains the canonical correlation key across restarts.

Foreground subagents remain nested beneath execute_tool subagent. Background subagents start separate root traces and link to the spawning tool with opencode.link.type=subagent. Parent and child Sessions are also correlated with opencode.session.parent.id and opencode.subagent.session.id.

Design principles

  • Trace meaningful operations, not every Effect.
  • Keep one bounded trace per agent turn and one chat <model> span per model step.
  • Put transport and tool spans beneath the operation that owns them.
  • Use span links for asynchronous or cross-turn relationships.
  • Keep telemetry observational and fail-open.
  • Record stable metadata, never sensitive content.
  • Use structured logs for control-plane failures that do not need spans.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@StarpTech
feat(observability): add v2 genai tracing
0271872
@github-actions github-actions Bot added contributor needs:compliance This means the issue will auto-close after 2 hours. labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #34633: feat(observability): Implement OTel telemetry parity for agents and tools
#34633

Why it might be related:

  • Both PRs focus on observability and tracing for agents and tools
  • Both deal with instrumentation and telemetry in the GenAI stack
  • PR feat(observability): Implement OTel telemetry parity for agents and tools #34633 implements "OTel telemetry parity" which overlaps with your PR's goal of semantic-convention spans and OTLP trace export
  • Both address agent, model, transport, and tool activity tracking

Recommendation: Check if PR #34633 is still open/active and review its scope to understand if your v2 implementation is complementary or overlapping with existing work.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 8, 2026
StarpTech added 2 commits July 8, 2026 18:16
@StarpTech
chore(observability): merge v2
a18e5de
@StarpTech
chore(opencode): reorder workspace deps
88173fe
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@StarpTech
feat(observability): add turn links to session traces
a2e640a
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 8, 2026
@StarpTech
feat(observability): refine span linkage and telemetry
0b9f1a4
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@StarpTech
chore(observability): merge v2
18da3de
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jul 8, 2026
@StarpTech
feat(llm): propagate trace context to HTTP requests
aacec8e
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 8, 2026
@StarpTech
chore(observability): merge v2
f4e661f
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 9, 2026
@StarpTech
feat(llm): add GenAI operation telemetry metadata
2ba0817
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jul 9, 2026
@StarpTech
chore(observability): merge v2
9307833
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 9, 2026
@StarpTech
refactor(opencode): pass server endpoint to TUI
00fb739
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 9, 2026
This was referenced Jul 10, 2026
📊 AI CLI 工具社区动态日报 2026-07-10 loxehate/loxehate.github.io#27
Closed
fix: create root span per prompt for OTEL trace isolation #36179
Closed
@jesse-schein

jesse-schein commented Jul 27, 2026

Copy link
Copy Markdown

This looks really awesome. I'm eager to get otel really wired up with opencode for a project I am working on. I can sort of hack opencode with the popular otel plugin to do what I want with modifications, but it would be great if opencode itself would accept traceparent header and stamp that on all the otel related traces like tools, sessions, etc.

I had AI write up some of my thoughts that I had it scan everywhere trying to see what was in the works for otel in v2, seems like otel issues/prs arent going anywhere in 1.X, likely in favor of v2 which makes a ton of sense.

One thing I'd love to see: could opencode accept a traceparent on the API (and ideally on the websocket path too) and use it as the parent for that turn?

What we're after

We run opencode serve long-lived in a sandbox and dispatch each turn over HTTP from our own service. Right now our spans and opencode's spans both make it to the backend fine, they just sit in separate traces, so you can't see the whole thing as one flamegraph. In Datadog or SigNoz it'd be really nice to click into a request and see the turn, the model calls and the tool calls hanging underneath whatever actually kicked it off.

OPENCODE_TRACEPARENT doesn't work for our setup because the server outlives any single request, so it's either one giant unbounded trace or nothing.

On the per-turn root thing

I saw each turn is deliberately its own root trace and I think that's the right default, a conversation span held open for hours would be worse. This wouldn't really change that. It'd still be one trace per turn, just rooted at the caller when a caller passes context.

Looks mostly wired already?

SessionTelemetry.TraceParent takes an AnySpan and Tracer.externalSpan() is exactly what you get from decoding a traceparent, so it seems like mostly a question of getting the header into that reference.

Also worth mentioning #37395 landed on v2 after you opened this and makes the server pick up inbound traceparent on request fibers, so you might end up in this code on rebase anyway.

Couple of things to consider

On websockets it'd have to ride on the message rather than the upgrade, since the connection isn't the turn.

And since message content can come from untrusted places it probably wants to be opt-in, so nobody can graft their spans onto someone else's trace.

Otherwise

If parenting isn't something you want to do here, even just a span link to the inbound context would help.

Happy to test against a real OTLP stack if that's useful.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@josephwangrb

josephwangrb commented Jul 28, 2026

Copy link
Copy Markdown

Would you consider supporting opt-in model content capture? The OTel GenAI conventions classify gen_ai.system_instructions, gen_ai.input.messages, and gen_ai.output.messages as opt-in, recommending that instrumentation keep them disabled by default but provide a way to enable them.

A flag such as OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, defaulting to false, could preserve the PR’s safe defaults while enabling debugging and evaluation use cases. Ideally, captured values would follow the OTel schemas and support filtering or truncation. Is this planned here or as a follow-up

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot closed this Aug 8, 2026
@github-actions github-actions Bot added the automated-pr-cleanup label Aug 8, 2026
@pragmaticivan pragmaticivan mentioned this pull request Sep 7, 2026
[FEATURE]: Add stable agent lifecycle telemetry #47701
Open
1 task done
@josephwangrb

josephwangrb commented Sep 10, 2026

Copy link
Copy Markdown

It is sad to see this PR being closed...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jesse-schein

jesse-schein commented Sep 10, 2026

Copy link
Copy Markdown

It is sad to see this PR being closed...

Agree. When opencode v2 comes out I'll release a plugin if there is still a gap.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mradwankhalil mradwankhalil mentioned this pull request Oct 30, 2026
[FEATURE]: Per-request provider transport timing in debug logs (request ID, headers, first event, stream end) #60468
Open
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

automated-pr-cleanup contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@StarpTech @jesse-schein @josephwangrb
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.