@@ -101,9 +101,10 @@ def test_trace_context_injection_with_log_correlation_from_env_var(self):
101101 LoggingInstrumentor ().uninstrument ()
102102 LoggingInstrumentor ().instrument ()
103103 with self .tracer .start_as_current_span ("s1" ) as span :
104- span_id = format (span .get_span_context ().span_id , "016x" )
105- trace_id = format (span .get_span_context ().trace_id , "032x" )
106- trace_sampled = span .get_span_context ().trace_flags .sampled
104+ span_ctx = span .get_span_context ()
105+ span_id = format (span_ctx .span_id , "016x" )
106+ trace_id = format (span_ctx .trace_id , "032x" )
107+ trace_sampled = span_ctx .trace_flags .sampled
107108 self .assert_trace_context_injected (
108109 span_id , trace_id , trace_sampled
109110 )
@@ -112,9 +113,10 @@ def test_trace_context_injection_with_log_correlation_instrument_arg(self):
112113 LoggingInstrumentor ().uninstrument ()
113114 LoggingInstrumentor ().instrument (set_logging_format = True )
114115 with self .tracer .start_as_current_span ("s1" ) as span :
115- span_id = format (span .get_span_context ().span_id , "016x" )
116- trace_id = format (span .get_span_context ().trace_id , "032x" )
117- trace_sampled = span .get_span_context ().trace_flags .sampled
116+ span_ctx = span .get_span_context ()
117+ span_id = format (span_ctx .span_id , "016x" )
118+ trace_id = format (span_ctx .trace_id , "032x" )
119+ trace_sampled = span_ctx .trace_flags .sampled
118120 self .assert_trace_context_injected (
119121 span_id , trace_id , trace_sampled
120122 )
@@ -197,9 +199,10 @@ def test_log_hook_with_set_logging_format(self):
197199 log_hook = log_hook ,
198200 )
199201 with self .tracer .start_as_current_span ("s1" ) as span :
200- span_id = format (span .get_span_context ().span_id , "016x" )
201- trace_id = format (span .get_span_context ().trace_id , "032x" )
202- trace_sampled = span .get_span_context ().trace_flags .sampled
202+ span_ctx = span .get_span_context ()
203+ span_id = format (span_ctx .span_id , "016x" )
204+ trace_id = format (span_ctx .trace_id , "032x" )
205+ trace_sampled = span_ctx .trace_flags .sampled
203206 with self .caplog .at_level (level = logging .INFO ):
204207 logger = logging .getLogger ("test logger" )
205208 logger .info ("hello" )
0 commit comments