mirror of
https://github.com/katanemo/plano.git
synced 2026-05-11 00:32:42 +02:00
Add service to stream custom otel traces to otel-collector (#262)
This commit is contained in:
parent
d87105882b
commit
30647fd508
12 changed files with 368 additions and 9 deletions
|
|
@ -33,7 +33,7 @@ use std::cell::RefCell;
|
|||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ResponseHandlerType {
|
||||
|
|
@ -77,6 +77,8 @@ pub struct StreamContext {
|
|||
pub chat_completions_request: Option<ChatCompletionsRequest>,
|
||||
pub prompt_guards: Rc<PromptGuards>,
|
||||
pub request_id: Option<String>,
|
||||
pub start_upstream_llm_request_time: u128,
|
||||
pub time_to_first_token: Option<u128>,
|
||||
pub traceparent: Option<String>,
|
||||
pub tracing: Rc<Option<Tracing>>,
|
||||
}
|
||||
|
|
@ -113,6 +115,8 @@ impl StreamContext {
|
|||
request_id: None,
|
||||
traceparent: None,
|
||||
tracing,
|
||||
start_upstream_llm_request_time: 0,
|
||||
time_to_first_token: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1003,6 +1007,11 @@ impl StreamContext {
|
|||
};
|
||||
debug!("archgw => llm request: {}", llm_request_str);
|
||||
|
||||
self.start_upstream_llm_request_time = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_nanos();
|
||||
|
||||
self.set_http_request_body(0, self.request_body_size, &llm_request_str.into_bytes());
|
||||
self.resume_http_request();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue