mirror of
https://github.com/openai/codex.git
synced 2026-11-05 16:29:31 +00:00
fix: drop session span at end of the session (#9126)
This commit is contained in:
1 parent
57ba758df5
commit
51d75bb80a
3 files changed
+9
-15
No files matched your search
@@ -29,8 +29,10 @@ impl SessionTask for RegularTask {
|
|||||||
cancellation_token: CancellationToken,
|
cancellation_token: CancellationToken,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let sess = session.clone_session();
|
let sess = session.clone_session();
|
||||||
let run_turn_span =
|
let run_turn_span = trace_span!("run_turn");
|
||||||
trace_span!(parent: sess.services.otel_manager.current_span(), "run_turn");
|
sess.services
|
||||||
|
.otel_manager
|
||||||
|
.apply_traceparent_parent(&run_turn_span);
|
||||||
run_turn(sess, ctx, input, cancellation_token)
|
run_turn(sess, ctx, input, cancellation_token)
|
||||||
.instrument(run_turn_span)
|
.instrument(run_turn_span)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ use codex_protocol::ThreadId;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use strum_macros::Display;
|
use strum_macros::Display;
|
||||||
use tracing::Span;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Display)]
|
#[derive(Debug, Clone, Serialize, Display)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
@@ -42,7 +41,6 @@ pub struct OtelEventMetadata {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct OtelManager {
|
pub struct OtelManager {
|
||||||
pub(crate) metadata: OtelEventMetadata,
|
pub(crate) metadata: OtelEventMetadata,
|
||||||
pub(crate) session_span: Span,
|
|
||||||
pub(crate) metrics: Option<MetricsClient>,
|
pub(crate) metrics: Option<MetricsClient>,
|
||||||
pub(crate) metrics_use_metadata_tags: bool,
|
pub(crate) metrics_use_metadata_tags: bool,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ use std::time::Duration;
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tokio::time::error::Elapsed;
|
use tokio::time::error::Elapsed;
|
||||||
use tracing::Span;
|
use tracing::Span;
|
||||||
use tracing::trace_span;
|
|
||||||
use tracing_opentelemetry::OpenTelemetrySpanExt;
|
use tracing_opentelemetry::OpenTelemetrySpanExt;
|
||||||
|
|
||||||
pub use crate::OtelEventMetadata;
|
pub use crate::OtelEventMetadata;
|
||||||
@@ -41,14 +40,8 @@ impl OtelManager {
|
|||||||
auth_mode: Option<AuthMode>,
|
auth_mode: Option<AuthMode>,
|
||||||
log_user_prompts: bool,
|
log_user_prompts: bool,
|
||||||
terminal_type: String,
|
terminal_type: String,
|
||||||
session_source: SessionSource,
|
_session_source: SessionSource,
|
||||||
) -> OtelManager {
|
) -> OtelManager {
|
||||||
let session_span = trace_span!("new_session", conversation_id = %conversation_id, session_source = %session_source);
|
|
||||||
|
|
||||||
if let Some(context) = traceparent_context_from_env() {
|
|
||||||
let _ = session_span.set_parent(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
metadata: OtelEventMetadata {
|
metadata: OtelEventMetadata {
|
||||||
conversation_id,
|
conversation_id,
|
||||||
@@ -61,14 +54,15 @@ impl OtelManager {
|
|||||||
app_version: env!("CARGO_PKG_VERSION"),
|
app_version: env!("CARGO_PKG_VERSION"),
|
||||||
terminal_type,
|
terminal_type,
|
||||||
},
|
},
|
||||||
session_span,
|
|
||||||
metrics: crate::metrics::global(),
|
metrics: crate::metrics::global(),
|
||||||
metrics_use_metadata_tags: true,
|
metrics_use_metadata_tags: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_span(&self) -> &Span {
|
pub fn apply_traceparent_parent(&self, span: &Span) {
|
||||||
&self.session_span
|
if let Some(context) = traceparent_context_from_env() {
|
||||||
|
let _ = span.set_parent(context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn record_responses(&self, handle_responses_span: &Span, event: &ResponseEvent) {
|
pub fn record_responses(&self, handle_responses_span: &Span, event: &ResponseEvent) {
|
||||||
|
|||||||
Reference in new issue
Block a user