Skip to content

Commit

Permalink
opentelemetry: forward event metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Feb 7, 2022
1 parent a2ccb98 commit a3ea77d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tracing-opentelemetry/src/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,17 @@ where
builder.status_code = Some(otel::StatusCode::Error);
}

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

if let Some(ref mut events) = builder.events {
events.push(otel_event);
} else {
Expand Down

0 comments on commit a3ea77d

Please sign in to comment.