File tree 1 file changed +7
-7
lines changed
opentelemetry-appender-tracing/src
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,8 @@ use tracing_subscriber::Layer;
11
11
const INSTRUMENTATION_LIBRARY_NAME : & str = "opentelemetry-appender-tracing" ;
12
12
13
13
/// 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 ,
18
16
}
19
17
20
18
/// Logs from the log crate have duplicated attributes that we removed here.
@@ -37,10 +35,12 @@ fn get_filename(filepath: &str) -> &str {
37
35
filepath
38
36
}
39
37
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
+ }
41
42
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 ( ) ) ) ;
44
44
45
45
#[ cfg( feature = "experimental_metadata_attributes" ) ]
46
46
self . visit_experimental_metadata ( meta) ;
You can’t perform that action at this time.
0 commit comments