@@ -21,6 +21,7 @@ pub(crate) struct Req {
2121 pub ( crate ) stream_name : String ,
2222 pub ( crate ) events : Vec < EventData > ,
2323 pub ( crate ) expected_revision : StreamState ,
24+ pub ( crate ) context : Context ,
2425}
2526
2627impl Req {
@@ -30,6 +31,7 @@ impl Req {
3031 stream_name,
3132 events,
3233 expected_revision,
34+ context : Context :: current ( ) ,
3335 }
3436 }
3537}
@@ -200,7 +202,7 @@ mod tests {
200202 DB_COLLECTION_NAME , DB_OPERATION_NAME , TROGON_EVENTSTORE_BATCH_CORRELATION_ID ,
201203 } ;
202204 use opentelemetry:: global;
203- use opentelemetry:: trace:: { Status , noop:: NoopTracerProvider } ;
205+ use opentelemetry:: trace:: { Status , TraceContextExt , noop:: NoopTracerProvider } ;
204206 use opentelemetry_sdk:: trace:: { InMemorySpanExporter , SdkTracerProvider } ;
205207
206208 #[ tokio:: test]
@@ -223,6 +225,7 @@ mod tests {
223225 panic ! ( "expected an inbound batch request" ) ;
224226 } ;
225227 let correlation_id = req. id . to_string ( ) ;
228+ let captured_span_id = req. context . span ( ) . span_context ( ) . span_id ( ) ;
226229 sender
227230 . send ( Ok ( BatchWriteResult :: new (
228231 "stream" . to_string ( ) ,
@@ -239,6 +242,7 @@ mod tests {
239242 . iter ( )
240243 . find ( |span| span. name == "batch_append_to_stream stream" )
241244 . expect ( "batch append client span" ) ;
245+ assert_eq ! ( span. span_context. span_id( ) , captured_span_id) ;
242246 assert ! ( span. attributes. iter( ) . any( |attribute| {
243247 attribute. key. as_str( ) == TROGON_EVENTSTORE_BATCH_CORRELATION_ID
244248 && attribute. value. to_string( ) == correlation_id
0 commit comments