feat(otel): propagate session.id to spans and log records (#7490)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user