11#[ cfg( all( feature = "gen-tonic-messages" , feature = "zpages" ) ) ]
22mod tonic {
3- use opentelemetry:: trace:: { Event , Status } ;
3+ use opentelemetry:: trace:: Status ;
44 use opentelemetry_sdk:: trace:: SpanData ;
55
66 use crate :: proto:: tonic:: {
7- trace:: v1:: { span:: Event as SpanEvent , Status as SpanStatus } ,
7+ trace:: v1:: { span, span :: Event as SpanEvent , Status as SpanStatus } ,
88 tracez:: v1:: { ErrorData , LatencyData , RunningData } ,
99 } ;
1010 use crate :: transform:: common:: { to_nanos, tonic:: Attributes } ;
@@ -18,8 +18,30 @@ mod tonic {
1818 starttime : to_nanos ( span_data. start_time ) ,
1919 endtime : to_nanos ( span_data. end_time ) ,
2020 attributes : Attributes :: from ( span_data. attributes ) . 0 ,
21- events : span_data. events . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
22- links : span_data. links . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
21+ events : span_data
22+ . events
23+ . events
24+ . into_iter ( )
25+ . map ( |e| SpanEvent {
26+ time_unix_nano : to_nanos ( e. timestamp ) ,
27+ name : e. name . to_string ( ) ,
28+ attributes : Attributes :: from ( e. attributes ) . 0 ,
29+ dropped_attributes_count : span_data. dropped_attributes_count ,
30+ } )
31+ . collect ( ) ,
32+ links : span_data
33+ . links
34+ . iter ( )
35+ . cloned ( )
36+ . map ( |link| span:: Link {
37+ trace_id : link. span_context . trace_id ( ) . to_bytes ( ) . to_vec ( ) ,
38+ span_id : link. span_context . span_id ( ) . to_bytes ( ) . to_vec ( ) ,
39+ trace_state : link. span_context . trace_state ( ) . header ( ) ,
40+ attributes : Attributes :: from ( link. attributes ) . 0 ,
41+ dropped_attributes_count : span_data. dropped_attributes_count ,
42+ flags : link. span_context . trace_flags ( ) . to_u8 ( ) as u32 ,
43+ } )
44+ . collect ( ) ,
2345 }
2446 }
2547 }
@@ -32,8 +54,30 @@ mod tonic {
3254 parentid : span_data. parent_span_id . to_bytes ( ) . to_vec ( ) ,
3355 starttime : to_nanos ( span_data. start_time ) ,
3456 attributes : Attributes :: from ( span_data. attributes ) . 0 ,
35- events : span_data. events . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
36- links : span_data. links . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
57+ events : span_data
58+ . events
59+ . events
60+ . into_iter ( )
61+ . map ( |e| SpanEvent {
62+ time_unix_nano : to_nanos ( e. timestamp ) ,
63+ name : e. name . to_string ( ) ,
64+ attributes : Attributes :: from ( e. attributes ) . 0 ,
65+ dropped_attributes_count : span_data. dropped_attributes_count ,
66+ } )
67+ . collect ( ) ,
68+ links : span_data
69+ . links
70+ . iter ( )
71+ . cloned ( )
72+ . map ( |link| span:: Link {
73+ trace_id : link. span_context . trace_id ( ) . to_bytes ( ) . to_vec ( ) ,
74+ span_id : link. span_context . span_id ( ) . to_bytes ( ) . to_vec ( ) ,
75+ trace_state : link. span_context . trace_state ( ) . header ( ) ,
76+ attributes : Attributes :: from ( link. attributes ) . 0 ,
77+ dropped_attributes_count : span_data. dropped_attributes_count ,
78+ flags : link. span_context . trace_flags ( ) . to_u8 ( ) as u32 ,
79+ } )
80+ . collect ( ) ,
3781 status : match span_data. status {
3882 Status :: Error { description } => Some ( SpanStatus {
3983 message : description. to_string ( ) ,
@@ -53,19 +97,30 @@ mod tonic {
5397 parentid : span_data. parent_span_id . to_bytes ( ) . to_vec ( ) ,
5498 starttime : to_nanos ( span_data. start_time ) ,
5599 attributes : Attributes :: from ( span_data. attributes ) . 0 ,
56- events : span_data. events . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
57- links : span_data. links . iter ( ) . cloned ( ) . map ( Into :: into) . collect ( ) ,
58- }
59- }
60- }
61-
62- impl From < Event > for SpanEvent {
63- fn from ( event : Event ) -> Self {
64- SpanEvent {
65- time_unix_nano : to_nanos ( event. timestamp ) ,
66- name : event. name . to_string ( ) ,
67- attributes : Attributes :: from ( event. attributes ) . 0 ,
68- dropped_attributes_count : event. dropped_attributes_count ,
100+ events : span_data
101+ . events
102+ . events
103+ . into_iter ( )
104+ . map ( |e| SpanEvent {
105+ time_unix_nano : to_nanos ( e. timestamp ) ,
106+ name : e. name . to_string ( ) ,
107+ attributes : Attributes :: from ( e. attributes ) . 0 ,
108+ dropped_attributes_count : span_data. dropped_attributes_count ,
109+ } )
110+ . collect ( ) ,
111+ links : span_data
112+ . links
113+ . iter ( )
114+ . cloned ( )
115+ . map ( |link| span:: Link {
116+ trace_id : link. span_context . trace_id ( ) . to_bytes ( ) . to_vec ( ) ,
117+ span_id : link. span_context . span_id ( ) . to_bytes ( ) . to_vec ( ) ,
118+ trace_state : link. span_context . trace_state ( ) . header ( ) ,
119+ attributes : Attributes :: from ( link. attributes ) . 0 ,
120+ dropped_attributes_count : span_data. links . dropped_count ,
121+ flags : link. span_context . trace_flags ( ) . to_u8 ( ) as u32 ,
122+ } )
123+ . collect ( ) ,
69124 }
70125 }
71126 }
0 commit comments