Skip to content

Commit 433d94c

Browse files
committed
fix: Immutable type, ignoring call to set attribute on span_context
Signed-off-by: Varsha GS <[email protected]>
1 parent c245b1c commit 433d94c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/instana/propagators/http_propagator.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from instana.log import logger
66
from instana.propagators.base_propagator import BasePropagator
77
from instana.util.ids import define_server_timing, hex_id_limited
8+
from instana.span_context import SpanContext
89

910
from opentelemetry.trace.span import format_span_id
1011

@@ -27,7 +28,26 @@ def inject(self, span_context, carrier, disable_w3c_trace_context=False):
2728
# Suppression `level` made in the child context or in the parent context
2829
# has priority over any non-suppressed `level` setting
2930
child_level = int(self.extract_instana_headers(dictionary_carrier)[2] or "1")
30-
span_context.level = min(child_level, span_context.level)
31+
new_level = min(child_level, span_context.level)
32+
33+
if new_level != span_context.level:
34+
# Create a new span context with the updated level
35+
span_context = SpanContext(
36+
trace_id=span_context.trace_id,
37+
span_id=span_context.span_id,
38+
is_remote=span_context.is_remote,
39+
trace_flags=span_context.trace_flags,
40+
trace_state=span_context.trace_state,
41+
level=new_level,
42+
synthetic=span_context.synthetic,
43+
trace_parent=span_context.trace_parent,
44+
instana_ancestor=span_context.instana_ancestor,
45+
long_trace_id=span_context.long_trace_id,
46+
correlation_type=span_context.correlation_type,
47+
correlation_id=span_context.correlation_id,
48+
traceparent=span_context.traceparent,
49+
tracestate=span_context.tracestate
50+
)
3151

3252
serializable_level = str(span_context.level)
3353

0 commit comments

Comments
 (0)