Skip to content

chore(otel): reorganize codex-otel crate#13800

Merged
owenlin0 merged 2 commits intomainfrom
owen/refactor_otel_crate
Mar 6, 2026
Merged

chore(otel): reorganize codex-otel crate#13800
owenlin0 merged 2 commits intomainfrom
owen/refactor_otel_crate

Conversation

@owenlin0
Copy link
Copy Markdown
Collaborator

@owenlin0 owenlin0 commented Mar 6, 2026

Summary

This is a structural cleanup of codex-otel to make the ownership boundaries a lot clearer.

For example, previously it was quite confusing that OtelManager which emits log + trace event telemetry lived under codex-rs/otel/src/traces/. Also, there were two places that defined methods on OtelManager via impl OtelManager (lib.rs and otel_manager.rs).

What changed:

  • move the OtelProvider implementation into src/provider.rs
  • move OtelManager and session-scoped event emission into src/events/otel_manager.rs
  • collapse the shared log/trace event helpers into src/events/shared.rs
  • pull target classification into src/targets.rs
  • move traceparent_context_from_env() into src/trace_context.rs
  • keep src/otel_provider.rs as a compatibility shim for existing imports
  • update the codex-otel README to reflect the new layout

Why

lib.rs and otel_provider.rs were doing too many different jobs at once: provider setup, export routing, trace-context helpers, and session event emission all lived together.

This refactor separates those concerns without trying to change the behavior of the crate. The goal is to make future OTEL work easier to reason about and easier to review.

Notes

  • no intended behavior change
  • OtelManager remains the session-scoped event emitter in this PR
  • the otel_provider shim keeps downstream churn low while the internals move around

Validation

  • just fmt
  • cargo test -p codex-otel
  • just fix -p codex-otel
@owenlin0 owenlin0 changed the title chore(otel): refactor crate Mar 6, 2026
@owenlin0 owenlin0 changed the title chore(otel): split codex-otel into provider, events, and trace-context modules Mar 6, 2026
@owenlin0 owenlin0 marked this pull request as ready for review March 6, 2026 22:49
@owenlin0
Copy link
Copy Markdown
Collaborator Author

owenlin0 commented Mar 6, 2026

@codex review

Copy link
Copy Markdown
Contributor

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

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: b3f493326e

ℹ️ 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 1 to 6
pub mod config;
mod events;
pub mod metrics;
pub mod otel_provider;
pub mod provider;
pub mod trace_context;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve legacy traces module re-export

lib.rs no longer exports pub mod traces, and src/traces/mod.rs was removed. Downstream imports like codex_otel::traces::otel_manager::{OtelManager, OtelEventMetadata, ToolDecisionSource} will now fail to compile. That is a public API break despite the stated compatibility/no-behavior-change intent; add a shim module that re-exports the moved items.

Useful? React with 👍 / 👎.

@owenlin0 owenlin0 merged commit dd4a521 into main Mar 6, 2026
50 of 52 checks passed
@owenlin0 owenlin0 deleted the owen/refactor_otel_crate branch March 6, 2026 22:58
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants