mirror of
https://github.com/openai/codex.git
synced 2026-10-30 19:18:49 +00:00
## Summary This is a purely mechanical refactor of `OtelManager` -> `SessionTelemetry` to better convey what the struct is doing. No behavior change. ## Why `OtelManager` ended up sounding much broader than what this type actually does. It doesn't manage OTEL globally; it's the session-scoped telemetry surface for emitting log/trace events and recording metrics with consistent session metadata (`app_version`, `model`, `slug`, `originator`, etc.). `SessionTelemetry` is a more accurate name, and updating the call sites makes that boundary a lot easier to follow. ## Validation - `just fmt` - `cargo test -p codex-otel` - `cargo test -p codex-core`
50 lines
1.4 KiB
Rust
50 lines
1.4 KiB
Rust
use std::sync::Arc;
|
|
|
|
use super::SessionTask;
|
|
use super::SessionTaskContext;
|
|
use crate::codex::TurnContext;
|
|
use crate::state::TaskKind;
|
|
use async_trait::async_trait;
|
|
use codex_protocol::user_input::UserInput;
|
|
use tokio_util::sync::CancellationToken;
|
|
|
|
#[derive(Clone, Copy, Default)]
|
|
pub(crate) struct CompactTask;
|
|
|
|
#[async_trait]
|
|
impl SessionTask for CompactTask {
|
|
fn kind(&self) -> TaskKind {
|
|
TaskKind::Compact
|
|
}
|
|
|
|
fn span_name(&self) -> &'static str {
|
|
"session_task.compact"
|
|
}
|
|
|
|
async fn run(
|
|
self: Arc<Self>,
|
|
session: Arc<SessionTaskContext>,
|
|
ctx: Arc<TurnContext>,
|
|
input: Vec<UserInput>,
|
|
_cancellation_token: CancellationToken,
|
|
) -> Option<String> {
|
|
let session = session.clone_session();
|
|
let _ = if crate::compact::should_use_remote_compact_task(&ctx.provider) {
|
|
let _ = session.services.session_telemetry.counter(
|
|
"codex.task.compact",
|
|
1,
|
|
&[("type", "remote")],
|
|
);
|
|
crate::compact_remote::run_remote_compact_task(session.clone(), ctx).await
|
|
} else {
|
|
let _ = session.services.session_telemetry.counter(
|
|
"codex.task.compact",
|
|
1,
|
|
&[("type", "local")],
|
|
);
|
|
crate::compact::run_compact_task(session.clone(), ctx, input).await
|
|
};
|
|
None
|
|
}
|
|
}
|