Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codex-rs/core/src/otel_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use codex_otel::config::OtelExporter;
use codex_otel::config::OtelHttpProtocol;
use codex_otel::config::OtelSettings;
use codex_otel::config::OtelTlsConfig as OtelTlsSettings;
use codex_otel::traces::otel_provider::OtelProvider;
use codex_otel::otel_provider::OtelProvider;
use std::error::Error;

/// Build an OpenTelemetry provider from the app Config.
Expand Down
9 changes: 5 additions & 4 deletions codex-rs/otel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

`codex-otel` is the OpenTelemetry integration crate for Codex. It provides:

- Trace/log exporters and tracing subscriber layers (`codex_otel::traces::otel_provider`).
- Trace/log/metrics exporters and tracing subscriber layers (`codex_otel::otel_provider`).
- A structured event helper (`codex_otel::OtelManager`).
- OpenTelemetry metrics support via OTLP exporters (`codex_otel::metrics`).
- A metrics facade on `OtelManager` so tracing + metrics share metadata.

## Tracing and logs

Create an OTEL provider from `OtelSettings`, then attach its layers to your
`tracing_subscriber` registry:
Create an OTEL provider from `OtelSettings`. The provider also configures
metrics (when enabled), then attach its layers to your `tracing_subscriber`
registry:

```rust
use codex_otel::config::OtelExporter;
use codex_otel::config::OtelHttpProtocol;
use codex_otel::config::OtelSettings;
use codex_otel::traces::otel_provider::OtelProvider;
use codex_otel::otel_provider::OtelProvider;
use tracing_subscriber::prelude::*;

let settings = OtelSettings {
Expand Down
3 changes: 2 additions & 1 deletion codex-rs/otel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod config;
pub mod metrics;
pub mod otel_provider;
pub mod traces;

mod otlp;
Expand All @@ -11,7 +12,7 @@ use crate::metrics::Result as MetricsResult;
use crate::metrics::timer::Timer;
use crate::metrics::validation::validate_tag_key;
use crate::metrics::validation::validate_tag_value;
use crate::traces::otel_provider::OtelProvider;
use crate::otel_provider::OtelProvider;
use codex_protocol::ThreadId;
use serde::Serialize;
use std::time::Duration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ static TRACEPARENT_CONTEXT: OnceLock<Option<Context>> = OnceLock::new();
thread_local! {
static TRACEPARENT_GUARD: RefCell<Option<ContextGuard>> = const { RefCell::new(None) };
}

// TODO(jif) move OtelProvider out of `traces/`
pub struct OtelProvider {
pub logger: Option<SdkLoggerProvider>,
pub tracer_provider: Option<SdkTracerProvider>,
Expand Down
1 change: 0 additions & 1 deletion codex-rs/otel/src/traces/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pub mod otel_manager;
pub mod otel_provider;
2 changes: 1 addition & 1 deletion codex-rs/otel/src/traces/otel_manager.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::traces::otel_provider::traceparent_context_from_env;
use crate::otel_provider::traceparent_context_from_env;
use chrono::SecondsFormat;
use chrono::Utc;
use codex_api::ResponseEvent;
Expand Down
Loading