mirror of
https://github.com/katanemo/plano.git
synced 2026-06-17 15:25:17 +02:00
fix logging
This commit is contained in:
parent
86ed415e8a
commit
482b402fdd
5 changed files with 38 additions and 11 deletions
|
|
@ -79,6 +79,11 @@ impl RootContext for FilterContext {
|
|||
}
|
||||
|
||||
fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>> {
|
||||
trace!(
|
||||
"||| create_http_context called with context_id: {:?} |||",
|
||||
context_id
|
||||
);
|
||||
|
||||
Some(Box::new(StreamContext::new(
|
||||
context_id,
|
||||
Rc::clone(&self.metrics),
|
||||
|
|
|
|||
|
|
@ -176,7 +176,6 @@ impl HttpContext for StreamContext {
|
|||
// Envoy's HTTP model is event driven. The WASM ABI has given implementors events to hook onto
|
||||
// the lifecycle of the http request and response.
|
||||
fn on_http_request_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action {
|
||||
let request_path = self.get_http_request_header(":path").unwrap_or_default();
|
||||
self.select_llm_provider();
|
||||
|
||||
// if endpoint is not set then use provider name as routing header so envoy can resolve the cluster name
|
||||
|
|
@ -308,6 +307,12 @@ impl HttpContext for StreamContext {
|
|||
}
|
||||
|
||||
fn on_http_response_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action {
|
||||
trace!(
|
||||
"on_http_response_headers [S={}] end_stream={}",
|
||||
self.context_id,
|
||||
_end_of_stream
|
||||
);
|
||||
|
||||
self.set_property(
|
||||
vec!["metadata", "filter_metadata", "llm_filter", "user_prompt"],
|
||||
Some("hello world from filter".as_bytes()),
|
||||
|
|
@ -317,6 +322,13 @@ impl HttpContext for StreamContext {
|
|||
}
|
||||
|
||||
fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action {
|
||||
trace!(
|
||||
"on_http_response_body [S={}] bytes={} end_stream={}",
|
||||
self.context_id,
|
||||
body_size,
|
||||
end_of_stream
|
||||
);
|
||||
|
||||
if !self.is_chat_completions_request {
|
||||
debug!("non-chatcompletion request");
|
||||
return Action::Continue;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use crate::stream_context::StreamContext;
|
|||
use common::configuration::{Configuration, Overrides, PromptGuards, PromptTarget, Tracing};
|
||||
use common::http::Client;
|
||||
use common::stats::Gauge;
|
||||
use log::trace;
|
||||
use proxy_wasm::traits::*;
|
||||
use proxy_wasm::types::*;
|
||||
use std::cell::RefCell;
|
||||
|
|
@ -83,6 +84,11 @@ impl RootContext for FilterContext {
|
|||
}
|
||||
|
||||
fn create_http_context(&self, context_id: u32) -> Option<Box<dyn HttpContext>> {
|
||||
trace!(
|
||||
"||| create_http_context called with context_id: {:?} |||",
|
||||
context_id
|
||||
);
|
||||
|
||||
Some(Box::new(StreamContext::new(
|
||||
context_id,
|
||||
Rc::clone(&self.metrics),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use common::{
|
|||
},
|
||||
errors::ServerError,
|
||||
http::{CallArgs, Client},
|
||||
pii::obfuscate_auth_header,
|
||||
};
|
||||
use http::StatusCode;
|
||||
use log::{debug, trace, warn};
|
||||
|
|
@ -39,6 +40,12 @@ impl HttpContext for StreamContext {
|
|||
|
||||
self.is_chat_completions_request = request_path == CHAT_COMPLETIONS_PATH;
|
||||
|
||||
trace!(
|
||||
"on_http_request_headers S[{}] req_headers={:?}",
|
||||
self.context_id,
|
||||
obfuscate_auth_header(&mut self.get_http_request_headers())
|
||||
);
|
||||
|
||||
self.request_id = self.get_http_request_header(REQUEST_ID_HEADER);
|
||||
self.traceparent = self.get_http_request_header(TRACE_PARENT_HEADER);
|
||||
Action::Continue
|
||||
|
|
@ -78,10 +85,7 @@ impl HttpContext for StreamContext {
|
|||
}
|
||||
};
|
||||
|
||||
trace!(
|
||||
"request body: {}",
|
||||
String::from_utf8_lossy(&body_bytes)
|
||||
);
|
||||
trace!("request body: {}", String::from_utf8_lossy(&body_bytes));
|
||||
|
||||
// Deserialize body into spec.
|
||||
// Currently OpenAI API.
|
||||
|
|
|
|||
|
|
@ -344,11 +344,11 @@ impl StreamContext {
|
|||
Duration::from_secs(5),
|
||||
);
|
||||
|
||||
debug!("dispatching api call to developer endpoint: {}, path: {}", endpoint.name, path);
|
||||
trace!(
|
||||
"request body: {}",
|
||||
tool_params_json_str
|
||||
debug!(
|
||||
"dispatching api call to developer endpoint: {}, path: {}",
|
||||
endpoint.name, path
|
||||
);
|
||||
trace!("request body: {}", tool_params_json_str);
|
||||
|
||||
callout_context.upstream_cluster = Some(endpoint.name.to_owned());
|
||||
callout_context.upstream_cluster_path = Some(path.to_owned());
|
||||
|
|
@ -363,8 +363,8 @@ impl StreamContext {
|
|||
let http_status = self
|
||||
.get_http_call_response_header(":status")
|
||||
.unwrap_or(StatusCode::OK.as_str().to_string());
|
||||
debug!("api call response received: status code: {}", http_status);
|
||||
if http_status != StatusCode::OK.as_str() {
|
||||
debug!("api call response received: status code: {}", http_status);
|
||||
if http_status != StatusCode::OK.as_str() {
|
||||
warn!(
|
||||
"api server responded with non 2xx status code: {}",
|
||||
http_status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue