Skip to content

Commit

Permalink
opentelemetry: fix event source locations (#2099)
Browse files Browse the repository at this point in the history
Fixes: #2094

## Motivation 

Properly attach event's source locations.

## Solution

Append the locations to events' attributes instead of span's
attributes.
  • Loading branch information
hubertbudzynski authored and hawkw committed Jun 7, 2022
1 parent a29fbc6 commit 6c9bc9b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tracing-opentelemetry/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,6 @@ where
}

if self.event_location {
let builder_attrs = builder.attributes.get_or_insert(Vec::new());

#[cfg(not(feature = "tracing-log"))]
let normalized_meta: Option<tracing_core::Metadata<'_>> = None;
let (file, module) = match &normalized_meta {
Expand All @@ -618,13 +616,19 @@ where
};

if let Some(file) = file {
builder_attrs.push(KeyValue::new("code.filepath", file));
otel_event
.attributes
.push(KeyValue::new("code.filepath", file));
}
if let Some(module) = module {
builder_attrs.push(KeyValue::new("code.namespace", module));
otel_event
.attributes
.push(KeyValue::new("code.namespace", module));
}
if let Some(line) = meta.line() {
builder_attrs.push(KeyValue::new("code.lineno", line as i64));
otel_event
.attributes
.push(KeyValue::new("code.lineno", line as i64));
}
}

Expand Down

0 comments on commit 6c9bc9b

Please sign in to comment.