fix: drop session span at end of the session (#9126)
This commit is contained in:
parent
57ba758df5
commit
51d75bb80a
3 changed files with 9 additions and 15 deletions
|
|
@ -29,8 +29,10 @@ impl SessionTask for RegularTask {
|
|||
cancellation_token: CancellationToken,
|
||||
) -> Option<String> {
|
||||
let sess = session.clone_session();
|
||||
let run_turn_span =
|
||||
trace_span!(parent: sess.services.otel_manager.current_span(), "run_turn");
|
||||
let run_turn_span = trace_span!("run_turn");
|
||||
sess.services
|
||||
.otel_manager
|
||||
.apply_traceparent_parent(&run_turn_span);
|
||||
run_turn(sess, ctx, input, cancellation_token)
|
||||
.instrument(run_turn_span)
|
||||
.await
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ use codex_protocol::ThreadId;
|
|||
use serde::Serialize;
|
||||
use std::time::Duration;
|
||||
use strum_macros::Display;
|
||||
use tracing::Span;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Display)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
|
@ -42,7 +41,6 @@ pub struct OtelEventMetadata {
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct OtelManager {
|
||||
pub(crate) metadata: OtelEventMetadata,
|
||||
pub(crate) session_span: Span,
|
||||
pub(crate) metrics: Option<MetricsClient>,
|
||||
pub(crate) metrics_use_metadata_tags: bool,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ use std::time::Duration;
|
|||
use std::time::Instant;
|
||||
use tokio::time::error::Elapsed;
|
||||
use tracing::Span;
|
||||
use tracing::trace_span;
|
||||
use tracing_opentelemetry::OpenTelemetrySpanExt;
|
||||
|
||||
pub use crate::OtelEventMetadata;
|
||||
|
|
@ -41,14 +40,8 @@ impl OtelManager {
|
|||
auth_mode: Option<AuthMode>,
|
||||
log_user_prompts: bool,
|
||||
terminal_type: String,
|
||||
session_source: SessionSource,
|
||||
_session_source: SessionSource,
|
||||
) -> 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 {
|
||||
metadata: OtelEventMetadata {
|
||||
conversation_id,
|
||||
|
|
@ -61,14 +54,15 @@ impl OtelManager {
|
|||
app_version: env!("CARGO_PKG_VERSION"),
|
||||
terminal_type,
|
||||
},
|
||||
session_span,
|
||||
metrics: crate::metrics::global(),
|
||||
metrics_use_metadata_tags: true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn current_span(&self) -> &Span {
|
||||
&self.session_span
|
||||
pub fn apply_traceparent_parent(&self, span: &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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue