Skip to content

[codex] Add minimal OpenTelemetry instrumentation#2

Merged
jooh merged 3 commits into
mainfrom
codex/minimal-opentelemetry
Jun 8, 2026
Merged

[codex] Add minimal OpenTelemetry instrumentation#2
jooh merged 3 commits into
mainfrom
codex/minimal-opentelemetry

Conversation

@jooh

@jooh jooh commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an internal observability package with safe-by-default OpenTelemetry initialization
  • instrument CLI, web/SSE, OpenResponses proxy calls, and the fake Responses provider
  • add basic chat and upstream metrics plus local collector documentation

Impact

Telemetry remains disabled unless OTLP env vars are configured. When enabled, traces and metrics export over OTLP/gRPC and avoid prompt text, response content, auth tokens, cookies, user/session/turn/message IDs, and other high-cardinality or sensitive values.

Validation

  • make tidy
  • make fmt
  • make imports
  • make test
  • make all-tests

@jooh jooh marked this pull request as ready for review June 8, 2026 19:22

jooh commented Jun 8, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 873668c498

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 269 to +272
func (s *stream) Close() error {
if !s.done {
s.finish(context.Canceled)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't mark completed web streams as cancelled

When a web chat turn reaches response.completed, turnJob.run emits the terminal done event and returns immediately, so the deferred TurnStream.Close() closes the OpenResponses stream before the trailing SSE [DONE] frame is read. In that normal success path s.done is still false here, so finish(context.Canceled) records the openresponses.stream.consume span as an error/cancellation for successful web turns, corrupting the telemetry this change adds. Track the completed event (or let Close distinguish a completed response from an early abort) before recording cancellation.

Useful? React with 👍 / 👎.

@jooh jooh merged commit b0a57b1 into main Jun 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant