-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hellovai/tracing #1350
base: canary
Are you sure you want to change the base?
hellovai/tracing #1350
Conversation
hellovai
commented
Jan 20, 2025
- tracing impl for context
- add new tracing client impl
- stash everything
- compile again
- move tracing types around
- one more
- Merge latest
- tracing WIP
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThis update enhances the project's tracing capabilities by introducing a new tracing module, adding necessary dependencies, and integrating these features across various components. Key changes include:
Changes
Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
|
// THESE ARE NOT CLONEABLE!! | ||
pub struct LogEvent { | ||
/* | ||
* (span_id, content_span_id) is a unique identifier for a log event | ||
* The query (span_id, *) gets all logs for a function call | ||
*/ | ||
|
||
pub span_id: FunctionId, | ||
pub content_span_id: ContentId, | ||
|
||
// The chain of spans that lead to this log event | ||
// Includes span_id at the last position (content_span_id is not included) | ||
pub span_chain: Vec<FunctionId>, | ||
|
||
// The timestamp of the log | ||
pub timestamp: web_time::Instant, | ||
// The content of the log | ||
pub content: LogEventContent, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LogEvent
struct is missing Clone
, PartialEq
, and Hash
traits which are needed for proper event tracking and comparison. Add these trait derivations.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// THESE ARE NOT CLONEABLE!! | |
pub struct LogEvent { | |
/* | |
* (span_id, content_span_id) is a unique identifier for a log event | |
* The query (span_id, *) gets all logs for a function call | |
*/ | |
pub span_id: FunctionId, | |
pub content_span_id: ContentId, | |
// The chain of spans that lead to this log event | |
// Includes span_id at the last position (content_span_id is not included) | |
pub span_chain: Vec<FunctionId>, | |
// The timestamp of the log | |
pub timestamp: web_time::Instant, | |
// The content of the log | |
pub content: LogEventContent, | |
} | |
#[derive(Clone, PartialEq, Hash)] | |
pub struct LogEvent { | |
/* | |
* (span_id, content_span_id) is a unique identifier for a log event | |
* The query (span_id, *) gets all logs for a function call | |
*/ | |
pub span_id: FunctionId, | |
pub content_span_id: ContentId, | |
// The chain of spans that lead to this log event | |
// Includes span_id at the last position (content_span_id is not included) | |
pub span_chain: Vec<FunctionId>, | |
// The timestamp of the log | |
pub timestamp: web_time::Instant, | |
// The content of the log | |
pub content: LogEventContent, | |
} |
let batch = TraceEventBatch { events }; | ||
let body = serde_json::to_string(&batch).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using unwrap()
on serde_json::to_string()
can panic if serialization fails. Should use proper error handling with ?
operator.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
let batch = TraceEventBatch { events }; | |
let body = serde_json::to_string(&batch).unwrap(); | |
let batch = TraceEventBatch { events }; | |
let body = serde_json::to_string(&batch)? |
let client = reqwest::Client::new(); | ||
let start = Instant::now(); | ||
|
||
let request_body = GetSignedUrlRequest { | ||
bucket: bucket.to_string(), | ||
key: format!("{}/{}.json", key_prefix, uuid::Uuid::new_v4()), | ||
}; | ||
|
||
eprintln!("Making POST request to URL: {}", lambda_url); | ||
eprintln!( | ||
"Request body: {}", | ||
serde_json::to_string_pretty(&request_body)? | ||
); | ||
|
||
let response = client | ||
.post(lambda_url) | ||
.json(&request_body) | ||
.send() | ||
.await | ||
.context("Failed to call lambda function")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new reqwest::Client
for each request is inefficient. The client should be reused across requests by making it static or passing it as a parameter.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
let client = reqwest::Client::new(); | |
let start = Instant::now(); | |
let request_body = GetSignedUrlRequest { | |
bucket: bucket.to_string(), | |
key: format!("{}/{}.json", key_prefix, uuid::Uuid::new_v4()), | |
}; | |
eprintln!("Making POST request to URL: {}", lambda_url); | |
eprintln!( | |
"Request body: {}", | |
serde_json::to_string_pretty(&request_body)? | |
); | |
let response = client | |
.post(lambda_url) | |
.json(&request_body) | |
.send() | |
.await | |
.context("Failed to call lambda function")?; | |
let client = &CLIENT; | |
let start = Instant::now(); | |
let request_body = GetSignedUrlRequest { | |
bucket: bucket.to_string(), | |
key: format!("{}/{}.json", key_prefix, uuid::Uuid::new_v4()), | |
}; | |
eprintln!("Making POST request to URL: {}", lambda_url); | |
eprintln!( | |
"Request body: {}", | |
serde_json::to_string_pretty(&request_body)? | |
); | |
let response = client | |
.post(lambda_url) | |
.json(&request_body) | |
.send() | |
.await | |
.context("Failed to call lambda function")? |
let localset = tokio::task::LocalSet::new(); | ||
localset.spawn_local(async move { | ||
if let Err(e) = run().await { | ||
tracing::error!("server error: {}", e); | ||
} | ||
}); | ||
|
||
println!("shutting down server"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The localset
is created but never executed with .await
or run, causing the server to exit immediately after spawning the task. Fix by adding localset.await;
after spawning.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
let localset = tokio::task::LocalSet::new(); | |
localset.spawn_local(async move { | |
if let Err(e) = run().await { | |
tracing::error!("server error: {}", e); | |
} | |
}); | |
println!("shutting down server"); | |
let localset = tokio::task::LocalSet::new(); | |
localset.spawn_local(async move { | |
if let Err(e) = run().await { | |
tracing::error!("server error: {}", e); | |
} | |
}); | |
localset.await; | |
println!("shutting down server"); |