feat(bottlecap): add invocation span#394
Conversation
…onzalez/bottlecap/create-lambda-invocation-span
also added some more fields and refactored it
…ion into jordan.gonzalez/bottlecap/create-lambda-invocation-span
…to jordan.gonzalez/bottlecap/create-lambda-invocation-span
| } | ||
|
|
||
| #[allow(clippy::module_name_repetitions)] | ||
| pub struct ContextBuffer { |
There was a problem hiding this comment.
I decided to use the ContextBuffer so we can keep relevant data from the past 5 invocations in cache.
5 is just an arbitrary number, we can reduce/increase this number as desired.
There was a problem hiding this comment.
should we remove it once it's read and used? In theory this setup would allow us to drop invocation contexts which we haven't used for some reason yet.
There was a problem hiding this comment.
When a PlatformRuntime done hits, we effectively remove the Context in question, is this what you mean?
What do you mean by drop invocation context which we haven't used for some reason yet?
| let span_size = std::mem::size_of_val(&self.span); | ||
| let header_tags = tracer_header_tags::TracerHeaderTags { | ||
| lang: "", | ||
| lang_version: "", | ||
| lang_interpreter: "", | ||
| lang_vendor: "", | ||
| tracer_version: "", | ||
| container_id: "", | ||
| client_computed_top_level: false, | ||
| client_computed_stats: false, | ||
| }; |
There was a problem hiding this comment.
definitely missing a lot of data here
There was a problem hiding this comment.
Added a todo comment, not sure how we can get these ones easily
| span.meta | ||
| .insert("request_id".to_string(), request_id.clone()); | ||
| } |
There was a problem hiding this comment.
Missing a bunch of other tags here too
…to jordan.gonzalez/bottlecap/create-lambda-invocation-span
| lambda_enhanced_metrics | ||
| .set_runtime_duration_metric(metrics.duration_ms); | ||
| } |
There was a problem hiding this comment.
I might want to delegate some of this metrics to the lifecycle processor eventually, maybe?
There was a problem hiding this comment.
it'd be good to push this out somewhere which can do the work asynchronously, you're blocking the loop right now
| Event::Telemetry(event) => | ||
| match event.record { | ||
| TelemetryRecord::PlatformStart { request_id, .. } => { | ||
| let mut p = invocation_processor.lock().await; |
There was a problem hiding this comment.
do we need a lock here? this prevents us from processing any messages until it's acquired, what's it fully protecting here?
There was a problem hiding this comment.
Looking what improvements I can make here
There was a problem hiding this comment.
As per our conversation, will move the lock out of this in another PR when the time comes, will add a ticket for this
d4e37d2
into
jordan.gonzalez/bottlecap/universal-instrumentation
* decouple `hyper` from `trace_processor` * add `handle_traces` * fix tests * removed unused import * move `invocation_context` to `invocation::context` module also added some more fields and refactored it * add `new` and `get_sender_copy` to `trace_agent` * add `get_canonical_resource_name` to `tags_provider` * add `get_function_name` to `lambda::tags` * add `MS_TO_NS` constant * add `invocation::processor` * update use of `invocation::context` * make `lifecycle::listener` to use `invocation::processor` * use `invocation::processor` in `main.rs` * move `MS_TO_NS` to `invocation::processor` * remove unnecessary constant * add `Box::new` back to `trace_agent` * add some comments * add unit tests for `context.rs` * use `on_invocation_start` * rename `lambda_library_detected` to `tracer_detected` * fmt * remove `current_request_id` I think we dont need it * add comment * fmt
* decouple `hyper` from `trace_processor` * add `handle_traces` * fix tests * removed unused import * move `invocation_context` to `invocation::context` module also added some more fields and refactored it * add `new` and `get_sender_copy` to `trace_agent` * add `get_canonical_resource_name` to `tags_provider` * add `get_function_name` to `lambda::tags` * add `MS_TO_NS` constant * add `invocation::processor` * update use of `invocation::context` * make `lifecycle::listener` to use `invocation::processor` * use `invocation::processor` in `main.rs` * move `MS_TO_NS` to `invocation::processor` * remove unnecessary constant * add `Box::new` back to `trace_agent` * add some comments * add unit tests for `context.rs` * use `on_invocation_start` * rename `lambda_library_detected` to `tracer_detected` * fmt * remove `current_request_id` I think we dont need it * add comment * fmt
* decouple `hyper` from `trace_processor` * add `handle_traces` * fix tests * removed unused import * move `invocation_context` to `invocation::context` module also added some more fields and refactored it * add `new` and `get_sender_copy` to `trace_agent` * add `get_canonical_resource_name` to `tags_provider` * add `get_function_name` to `lambda::tags` * add `MS_TO_NS` constant * add `invocation::processor` * update use of `invocation::context` * make `lifecycle::listener` to use `invocation::processor` * use `invocation::processor` in `main.rs` * move `MS_TO_NS` to `invocation::processor` * remove unnecessary constant * add `Box::new` back to `trace_agent` * add some comments * add unit tests for `context.rs` * use `on_invocation_start` * rename `lambda_library_detected` to `tracer_detected` * fmt * remove `current_request_id` I think we dont need it * add comment * fmt
* decouple `hyper` from `trace_processor` * add `handle_traces` * fix tests * removed unused import * move `invocation_context` to `invocation::context` module also added some more fields and refactored it * add `new` and `get_sender_copy` to `trace_agent` * add `get_canonical_resource_name` to `tags_provider` * add `get_function_name` to `lambda::tags` * add `MS_TO_NS` constant * add `invocation::processor` * update use of `invocation::context` * make `lifecycle::listener` to use `invocation::processor` * use `invocation::processor` in `main.rs` * move `MS_TO_NS` to `invocation::processor` * remove unnecessary constant * add `Box::new` back to `trace_agent` * add some comments * add unit tests for `context.rs` * use `on_invocation_start` * rename `lambda_library_detected` to `tracer_detected` * fmt * remove `current_request_id` I think we dont need it * add comment * fmt
What?
Adds the
aws.lambdainvocation span to Universally Instrumented runtimes like .NET, Go, Java, and Ruby.Motivation
#374 and SVLS-5438
Testing
Notes
Some tags will be missing from the top-level span