Skip to content

Commit

Permalink
opentelemetry: fix event source locations
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertbudzynski committed Apr 27, 2022
1 parent 14eff63 commit d62891b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tracing-opentelemetry/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,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 @@ -596,13 +594,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 d62891b

Please sign in to comment.