@@ -176,7 +176,7 @@ static void format_event(cfl_sds_t *buf, struct ctrace_span_event *event, int le
176176
177177}
178178
179- static void format_span (cfl_sds_t * buf , struct ctrace * ctx , struct ctrace_span * span , int level )
179+ static void format_span (cfl_sds_t * buf , struct ctrace * ctx , int id , struct ctrace_span * span , int level )
180180{
181181 int min ;
182182 int off = 1 + (level * 4 );
@@ -188,7 +188,7 @@ static void format_span(cfl_sds_t *buf, struct ctrace *ctx, struct ctrace_span *
188188
189189 min = off + 4 ;
190190
191- snprintf (tmp , sizeof (tmp ) - 1 , "%*s[span '%s']\n" , off , "" , span -> name );
191+ snprintf (tmp , sizeof (tmp ) - 1 , "%*s[span #%i '%s']\n" , off , "" , id , span -> name );
192192 sds_cat_safe (buf , tmp );
193193
194194 /* trace_id */
@@ -244,14 +244,29 @@ static void format_span(cfl_sds_t *buf, struct ctrace *ctx, struct ctrace_span *
244244 span -> dropped_events_count );
245245 sds_cat_safe (buf , tmp );
246246
247+ snprintf (tmp , sizeof (tmp ) - 1 , "%*s- dropped_links_count : %" PRIu32 "\n" , min , "" ,
248+ span -> dropped_links_count );
249+ sds_cat_safe (buf , tmp );
250+
251+ /* trace_state */
252+ snprintf (tmp , sizeof (tmp ) - 1 , "%*s- trace_state : %s\n" , min , "" , span -> trace_state );
253+ sds_cat_safe (buf , tmp );
254+
255+ /* schema_url */
256+ if (span -> schema_url ) {
257+ snprintf (tmp , sizeof (tmp ) - 1 , "%*s- schema_url : %s\n" , min , "" , span -> schema_url );
258+ sds_cat_safe (buf , tmp );
259+ }
260+
247261 /* Status */
248262 snprintf (tmp , sizeof (tmp ) - 1 , "%*s- status:\n" , min , "" );
249263 sds_cat_safe (buf , tmp );
250- snprintf (tmp , sizeof (tmp ) - 1 , "%*s- code : %i\n" , min + 4 , "" , span -> status .code );
264+ snprintf (tmp , sizeof (tmp ) - 1 , "%*s- code : %i\n" , min + 4 , "" , span -> status .code );
251265 sds_cat_safe (buf , tmp );
252266
253267 if (span -> status .message ) {
254268 snprintf (tmp , sizeof (tmp ) - 1 , "%*s- message : '%s'\n" , min + 4 , "" , span -> status .message );
269+ sds_cat_safe (buf , tmp );
255270 }
256271
257272 /* span attributes */
@@ -330,13 +345,14 @@ static void format_span(cfl_sds_t *buf, struct ctrace *ctx, struct ctrace_span *
330345 else {
331346 snprintf (tmp , sizeof (tmp ) - 1 , "%*s- attributes : " , off , "" );
332347 sds_cat_safe (buf , tmp );
333- format_attributes (buf , span -> attr -> kv , off );
348+ format_attributes (buf , link -> attr -> kv , off );
334349 }
335350 }
336351}
337352
338353static void format_spans (cfl_sds_t * buf , struct ctrace * ctx , struct cfl_list * spans )
339354{
355+ int id = 0 ;
340356 struct cfl_list * head ;
341357 struct ctrace_span * span ;
342358
@@ -347,7 +363,8 @@ static void format_spans(cfl_sds_t *buf, struct ctrace *ctx, struct cfl_list *sp
347363 span = cfl_list_entry (head , struct ctrace_span , _head );
348364
349365 /* skip resource if there is no match */
350- format_span (buf , ctx , span , 2 );
366+ format_span (buf , ctx , id , span , 2 );
367+ id ++ ;
351368 }
352369}
353370
@@ -360,7 +377,7 @@ static void format_instrumentation_scope(cfl_sds_t *buf,
360377 cfl_sds_printf (buf , " - dropped_attributes_count: %i\n" , scope -> dropped_attr_count );
361378
362379 if (scope -> attr ) {
363- cfl_sds_printf (buf , " - attributes:\n " );
380+ cfl_sds_printf (buf , " - attributes:" );
364381 format_attributes (buf , scope -> attr -> kv , 8 );
365382 }
366383 else {
@@ -430,10 +447,10 @@ cfl_sds_t ctr_encode_text_create(struct ctrace *ctx)
430447
431448 /* schema_url */
432449 if (resource_span -> schema_url ) {
433- cfl_sds_printf (& buf , " schema_url: %s\n" , resource_span -> schema_url );
450+ cfl_sds_printf (& buf , " - schema_url: %s\n" , resource_span -> schema_url );
434451 }
435452 else {
436- cfl_sds_printf (& buf , " schema_url: \"\"\n" );
453+ cfl_sds_printf (& buf , " - schema_url: \"\"\n" );
437454 }
438455
439456 /* scope spans */
0 commit comments