Skip to content

Commit 89e939d

Browse files
committed
initial commit
1 parent 9fa13bc commit 89e939d

File tree

1 file changed

+7
-7
lines changed
  • opentelemetry-appender-tracing/src

1 file changed

+7
-7
lines changed

opentelemetry-appender-tracing/src/layer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ use tracing_subscriber::Layer;
1111
const INSTRUMENTATION_LIBRARY_NAME: &str = "opentelemetry-appender-tracing";
1212

1313
/// Visitor to record the fields from the event record.
14-
#[derive(Default)]
15-
struct EventVisitor {
16-
log_record_attributes: Vec<(Key, AnyValue)>,
17-
log_record_body: Option<AnyValue>,
14+
struct EventVisitor<'a, LR: LogRecord> {
15+
log_record: &'a mut LR,
1816
}
1917

2018
/// Logs from the log crate have duplicated attributes that we removed here.
@@ -37,10 +35,12 @@ fn get_filename(filepath: &str) -> &str {
3735
filepath
3836
}
3937

40-
impl EventVisitor {
38+
impl <'a, LR: LogRecord> EventVisitor<'a, LR> {
39+
fn new(log_record: &'a mut LR) -> Self {
40+
EventVisitor{log_record}
41+
}
4142
fn visit_metadata(&mut self, meta: &Metadata) {
42-
self.log_record_attributes
43-
.push(("name".into(), meta.name().into()));
43+
self.log_record.add_attribute(Key::new("name"), AnyValue::from(meta.name()));
4444

4545
#[cfg(feature = "experimental_metadata_attributes")]
4646
self.visit_experimental_metadata(meta);

0 commit comments

Comments
 (0)