Skip to content

NH-2313 Bugfixes: propagator gets tracestate from carrier; from_header usage fix #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions opentelemetry_distro_solarwinds/propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ def inject(
context: typing.Optional[Context] = None,
setter: textmap.Setter = textmap.default_setter,
) -> None:
"""Injects sw tracestate and trace options from SpanContext into carrier for HTTP request"""
"""Injects sw tracestate from carrier into carrier for HTTP request, to get
tracestate injected by previous propagators"""
span = trace.get_current_span(context)
span_context = span.get_span_context()
trace_state = span_context.trace_state
sw_value = W3CTransformer.sw_from_context(span_context)
trace_state_header = carrier.get(self._TRACESTATE_HEADER_NAME, None)

# Prepare carrier with context's or new tracestate
if trace_state:
# Prepare carrier with carrier's or new tracestate
if trace_state_header:
trace_state = TraceState.from_header([trace_state_header])
# Check if trace_state already contains sw KV
if SW_TRACESTATE_KEY in trace_state.keys():
# If so, modify current span_id and trace_flags, and move to beginning of list
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry_distro_solarwinds/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ def calculate_attributes(
trace_state_no_response = self.remove_response_from_sw(trace_state)
else:
# Must retain all potential tracestate pairs for attributes
attr_trace_state = TraceState.from_header(
attr_trace_state = TraceState.from_header([
tracestate_capture
)
])
new_attr_trace_state = attr_trace_state.update(
SW_TRACESTATE_KEY,
W3CTransformer.sw_from_span_and_decision(
Expand Down