feat(otel): propagate session.id to spans and log records (#7490)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Adrian Cole
2026-03-16 13:06:31 +08:00
committed by GitHub
parent 10d597de3b
commit 2631095f20
20 changed files with 193 additions and 126 deletions
+8
View File
@@ -459,6 +459,10 @@ pub trait Provider: Send + Sync {
fn get_name(&self) -> &str;
/// Primary streaming method that all providers must implement.
///
/// Note: Do not add `#[instrument]` here — the call sites (`complete` and
/// `stream_response_from_provider`) create the telemetry span so that
/// `session.id` is set once rather than in every provider.
async fn stream(
&self,
model_config: &ModelConfig,
@@ -469,6 +473,10 @@ pub trait Provider: Send + Sync {
) -> Result<MessageStream, ProviderError>;
/// Complete with a specific model config.
#[tracing::instrument(
skip(self, model_config, session_id, system, messages, tools),
fields(session.id = %session_id, gen_ai.request.model = %model_config.model_name)
)]
async fn complete(
&self,
model_config: &ModelConfig,
-4
View File
@@ -356,10 +356,6 @@ impl Provider for BedrockProvider {
Ok(BEDROCK_KNOWN_MODELS.iter().map(|s| s.to_string()).collect())
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
-4
View File
@@ -668,10 +668,6 @@ impl Provider for CodexProvider {
self.model.clone()
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
@@ -322,10 +322,6 @@ impl Provider for CursorAgentProvider {
.collect())
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
-4
View File
@@ -196,10 +196,6 @@ impl Provider for GeminiCliProvider {
.collect())
}
#[tracing::instrument(
skip(self, model_config, system, messages, _tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
-1
View File
@@ -184,7 +184,6 @@ impl Provider for LiteLLMProvider {
self.model.clone()
}
#[tracing::instrument(skip_all, name = "provider_complete")]
async fn stream(
&self,
model_config: &ModelConfig,
@@ -309,10 +309,6 @@ impl Provider for SageMakerTgiProvider {
self.model.clone()
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
-4
View File
@@ -340,10 +340,6 @@ impl Provider for SnowflakeProvider {
.collect())
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,
-4
View File
@@ -271,10 +271,6 @@ impl Provider for VeniceProvider {
Ok(models)
}
#[tracing::instrument(
skip(self, model_config, system, messages, tools),
fields(model_config, input, output, input_tokens, output_tokens, total_tokens)
)]
async fn stream(
&self,
model_config: &ModelConfig,