@@ -210,7 +210,7 @@ pub unsafe extern "C" fn ddog_get_trace(ptr: *mut TracesBytes, index: usize) ->
210
210
& mut object[ index] as * mut TraceBytes
211
211
}
212
212
213
- // ------------------ TracesBytes ------------------
213
+ // ------------------ TraceBytes ------------------
214
214
215
215
#[ no_mangle]
216
216
#[ allow( clippy:: missing_safety_doc) ]
@@ -247,6 +247,21 @@ pub unsafe extern "C" fn ddog_get_trace_size(ptr: *mut TraceBytes) -> usize {
247
247
object. len ( )
248
248
}
249
249
250
+ #[ no_mangle]
251
+ #[ allow( clippy:: missing_safety_doc) ]
252
+ pub unsafe extern "C" fn ddog_get_span ( ptr : * mut TraceBytes , index : usize ) -> * mut SpanBytes {
253
+ if ptr. is_null ( ) {
254
+ return std:: ptr:: null_mut ( ) ;
255
+ }
256
+
257
+ let object = & mut * ptr;
258
+ if index >= object. len ( ) {
259
+ return std:: ptr:: null_mut ( ) ;
260
+ }
261
+
262
+ & mut object[ index] as * mut SpanBytes
263
+ }
264
+
250
265
// ------------------- SpanBytes -------------------
251
266
252
267
#[ no_mangle]
@@ -347,13 +362,13 @@ pub unsafe extern "C" fn ddog_get_span_trace_id(ptr: *mut SpanBytes) -> u64 {
347
362
348
363
#[ no_mangle]
349
364
#[ allow( clippy:: missing_safety_doc) ]
350
- pub unsafe extern "C" fn ddog_set_span_span_id ( ptr : * mut SpanBytes , value : u64 ) {
365
+ pub unsafe extern "C" fn ddog_set_span_id ( ptr : * mut SpanBytes , value : u64 ) {
351
366
set_numeric_field ! ( ptr, value, span_id) ;
352
367
}
353
368
354
369
#[ no_mangle]
355
370
#[ allow( clippy:: missing_safety_doc) ]
356
- pub unsafe extern "C" fn ddog_get_span_span_id ( ptr : * mut SpanBytes ) -> u64 {
371
+ pub unsafe extern "C" fn ddog_get_span_id ( ptr : * mut SpanBytes ) -> u64 {
357
372
get_numeric_field ! ( ptr, span_id)
358
373
}
359
374
@@ -525,6 +540,47 @@ pub unsafe extern "C" fn ddog_add_span_meta_struct(
525
540
) ;
526
541
}
527
542
543
+ #[ no_mangle]
544
+ #[ allow( clippy:: missing_safety_doc) ]
545
+ pub unsafe extern "C" fn ddog_del_span_meta_struct ( ptr : * mut SpanBytes , key : CharSlice ) {
546
+ remove_hashmap ! ( ptr, key, meta_struct) ;
547
+ }
548
+
549
+ #[ no_mangle]
550
+ #[ allow( clippy:: missing_safety_doc) ]
551
+ pub unsafe extern "C" fn ddog_get_span_meta_struct (
552
+ ptr : * mut SpanBytes ,
553
+ key : CharSlice ,
554
+ ) -> CharSlice < ' static > {
555
+ if ptr. is_null ( ) {
556
+ return CharSlice :: empty ( ) ;
557
+ }
558
+
559
+ let span = & mut * ptr;
560
+
561
+ let bytes_str_key = BytesString :: from_slice ( key. as_bytes ( ) ) . unwrap_or_default ( ) ;
562
+
563
+ match span. meta_struct . get ( & bytes_str_key) {
564
+ Some ( value) => CharSlice :: from_raw_parts ( value. as_ptr ( ) . cast ( ) , value. len ( ) ) ,
565
+ None => CharSlice :: empty ( ) ,
566
+ }
567
+ }
568
+
569
+ #[ no_mangle]
570
+ #[ allow( clippy:: missing_safety_doc) ]
571
+ pub unsafe extern "C" fn ddog_has_span_meta_struct ( ptr : * mut SpanBytes , key : CharSlice ) -> bool {
572
+ exists_hashmap ! ( ptr, key, meta_struct) ;
573
+ }
574
+
575
+ #[ no_mangle]
576
+ #[ allow( clippy:: missing_safety_doc) ]
577
+ pub unsafe extern "C" fn ddog_span_meta_struct_get_keys (
578
+ span_ptr : * mut SpanBytes ,
579
+ out_count : * mut usize ,
580
+ ) -> * mut CharSlice < ' static > {
581
+ get_keys_hashmap ! ( span_ptr, out_count, meta_struct)
582
+ }
583
+
528
584
#[ no_mangle]
529
585
#[ allow( clippy:: missing_safety_doc) ]
530
586
pub unsafe extern "C" fn ddog_span_free_keys_ptr ( keys_ptr : * mut CharSlice < ' static > , count : usize ) {
@@ -681,6 +737,7 @@ pub unsafe extern "C" fn ddog_serialize_trace_into_c_string(
681
737
}
682
738
}
683
739
740
+ #[ allow( clippy:: missing_safety_doc) ]
684
741
pub unsafe fn serialize_traces_into_mapped_memory (
685
742
traces_ptr : * const TracesBytes ,
686
743
buf_ptr : * mut c_void ,
@@ -896,7 +953,7 @@ mod tests {
896
953
ddog_set_span_resource ( span_ptr, CharSlice :: from ( "resource" ) ) ;
897
954
ddog_set_span_type ( span_ptr, CharSlice :: from ( "type" ) ) ;
898
955
ddog_set_span_trace_id ( span_ptr, 1 ) ;
899
- ddog_set_span_span_id ( span_ptr, 2 ) ;
956
+ ddog_set_span_id ( span_ptr, 2 ) ;
900
957
ddog_set_span_parent_id ( span_ptr, 3 ) ;
901
958
ddog_set_span_start ( span_ptr, 4 ) ;
902
959
ddog_set_span_duration ( span_ptr, 5 ) ;
0 commit comments