Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions bottlecap/src/lifecycle/invocation/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,19 @@ impl Processor {
// - error.msg
// - error.type
// - error.stack
// - trigger tags (from inferred spans)
// - metrics tags (for asm)
}

if let Some(trigger_tags) = self.inferrer.get_trigger_tags() {
self.span.meta.extend(trigger_tags);
}

self.inferrer.complete_inferred_span(&self.span);

if self.tracer_detected {
let mut body_size = std::mem::size_of_val(&self.span);
let mut traces = vec![self.span.clone()];
if let Some(inferred_span) = self.inferrer.get_inferred_span() {
if let Some(inferred_span) = &self.inferrer.inferred_span {
body_size += std::mem::size_of_val(inferred_span);
traces.push(inferred_span.clone());
}
Expand Down Expand Up @@ -215,15 +218,15 @@ impl Processor {

// Set the right data to the correct root level span,
// If there's an inferred span, then that should be the root.
if self.inferrer.get_inferred_span().is_some() {
if self.inferrer.inferred_span.is_some() {
self.inferrer.set_parent_id(sc.span_id);
self.inferrer.extend_meta(sc.tags.clone());
} else {
self.span.meta.extend(sc.tags.clone());
}
}

if let Some(inferred_span) = self.inferrer.get_inferred_span() {
if let Some(inferred_span) = &self.inferrer.inferred_span {
self.span.parent_id = inferred_span.span_id;
}
}
Expand Down Expand Up @@ -267,7 +270,7 @@ impl Processor {
self.span.trace_id = trace_id;
self.span.span_id = span_id;

if self.inferrer.get_inferred_span().is_some() {
if self.inferrer.inferred_span.is_some() {
if let Some(status_code) = status_code {
self.inferrer.set_status_code(status_code);
}
Expand Down
18 changes: 12 additions & 6 deletions bottlecap/src/lifecycle/invocation/span_inferrer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ const FUNCTION_TRIGGER_EVENT_SOURCE_TAG: &str = "function_trigger.event_source";
const FUNCTION_TRIGGER_EVENT_SOURCE_ARN_TAG: &str = "function_trigger.event_source_arn";

pub struct SpanInferrer {
inferred_span: Option<Span>,
pub inferred_span: Option<Span>,
is_async_span: bool,
carrier: Option<HashMap<String, String>>,
trigger_tags: Option<HashMap<String, String>>,
}

impl Default for SpanInferrer {
Expand All @@ -35,6 +36,7 @@ impl SpanInferrer {
inferred_span: None,
is_async_span: false,
carrier: None,
trigger_tags: None,
}
}

Expand Down Expand Up @@ -64,6 +66,7 @@ impl SpanInferrer {
]);

self.carrier = Some(t.get_carrier());
self.trigger_tags = Some(t.get_tags());
self.is_async_span = t.is_async();
self.inferred_span = Some(span);
}
Expand All @@ -87,6 +90,7 @@ impl SpanInferrer {
]);

self.carrier = Some(t.get_carrier());
self.trigger_tags = Some(t.get_tags());
self.is_async_span = t.is_async();
self.inferred_span = Some(span);
}
Expand Down Expand Up @@ -142,15 +146,17 @@ impl SpanInferrer {
rng.gen()
}

/// Returns a reference to the inner `self.inferred_span`
/// Returns a clone of the carrier associated with the inferred span
///
#[must_use]
pub fn get_inferred_span(&self) -> &Option<Span> {
&self.inferred_span
pub fn get_carrier(&self) -> Option<HashMap<String, String>> {
Comment thread
duncanista marked this conversation as resolved.
self.carrier.clone()
}

/// Returns a clone of the tags associated with the inferred span
///
#[must_use]
pub fn get_carrier(&self) -> Option<HashMap<String, String>> {
self.carrier.clone()
pub fn get_trigger_tags(&self) -> Option<HashMap<String, String>> {
self.trigger_tags.clone()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ impl Trigger for APIGatewayRestEvent {
self.request_context.resource_path.clone(),
),
]));

debug!("Enriched Span: {:?}", span);
// todo: update global(? IsAsync if event payload is `Event`
}

fn get_tags(&self) -> HashMap<String, String> {
Expand Down