@@ -46,10 +46,10 @@ pub const OTEL_TRACES_KNOWN_FIELD_LIST: [&str; 32] = [
4646 "span_kind_description" ,
4747 "span_start_time_unix_nano" ,
4848 "span_end_time_unix_nano" ,
49- "span_duration_ms " ,
49+ "span_duration_ns " ,
5050 "event_name" ,
5151 "event_time_unix_nano" ,
52- "event_duration_ms " ,
52+ "event_duration_ns " ,
5353 "event_dropped_attributes_count" ,
5454 "link_span_id" ,
5555 "link_trace_id" ,
@@ -191,11 +191,10 @@ fn flatten_events(events: &[Event], span_start_time_unix_nano: u64) -> Vec<Map<S
191191 let duration_nanos = event
192192 . time_unix_nano
193193 . saturating_sub ( span_start_time_unix_nano) ;
194- let duration_ms = duration_nanos as f64 / 1_000_000.0 ; // Convert nanoseconds to milliseconds
195194 event_json. insert (
196- "event_duration_ms " . to_string ( ) ,
195+ "event_duration_ns " . to_string ( ) ,
197196 Value :: Number (
198- serde_json:: Number :: from_f64 ( duration_ms )
197+ serde_json:: Number :: from_f64 ( duration_nanos as f64 )
199198 . unwrap_or_else ( || serde_json:: Number :: from ( 0 ) ) ,
200199 ) ,
201200 ) ;
@@ -352,17 +351,13 @@ fn flatten_span_record(span_record: &Span) -> Vec<Map<String, Value>> {
352351 ) ) ,
353352 ) ;
354353
355- // Calculate span duration in milliseconds
354+ // Calculate span duration in nanoseconds
356355 let duration_nanos = span_record
357356 . end_time_unix_nano
358357 . saturating_sub ( span_record. start_time_unix_nano ) ;
359- let duration_ms = duration_nanos as f64 / 1_000_000.0 ; // Convert nanoseconds to milliseconds
360358 span_record_json. insert (
361- "span_duration_ms" . to_string ( ) ,
362- Value :: Number (
363- serde_json:: Number :: from_f64 ( duration_ms)
364- . unwrap_or_else ( || serde_json:: Number :: from ( 0 ) ) ,
365- ) ,
359+ "span_duration_ns" . to_string ( ) ,
360+ Value :: Number ( serde_json:: Number :: from ( duration_nanos) ) ,
366361 ) ;
367362
368363 insert_attributes ( & mut span_record_json, & span_record. attributes ) ;
@@ -981,14 +976,14 @@ mod tests {
981976 "event_name" ,
982977 "event_time_unix_nano" ,
983978 "event_dropped_attributes_count" ,
984- "event_duration_ms " ,
979+ "event_duration_ns " ,
985980 "link_span_id" ,
986981 "link_trace_id" ,
987982 "link_dropped_attributes_count" ,
988983 "span_dropped_events_count" ,
989984 "span_dropped_links_count" ,
990985 "span_dropped_attributes_count" ,
991- "span_duration_ms " ,
986+ "span_duration_ns " ,
992987 "span_trace_state" ,
993988 "span_flags" ,
994989 "span_flags_description" ,
0 commit comments