Skip to content
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

Only add to trace state if key does not exist #3645

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
use correct trace state
  • Loading branch information
sentrivana committed Oct 11, 2024
commit 8d3abc4b77c0b21d7c8c5ca1eecf8eca0cbf7705
6 changes: 3 additions & 3 deletions sentry_sdk/integrations/opentelemetry/sampler.py
Original file line number Diff line number Diff line change
@@ -51,8 +51,8 @@ def dropped_result(span_context, attributes, sample_rate=None):
# these will only be added the first time in a root span sampling decision
trace_state = span_context.trace_state

if TRACESTATE_SAMPLED_KEY not in span_context.trace_state:
trace_state = span_context.trace_state.add(TRACESTATE_SAMPLED_KEY, "false")
if TRACESTATE_SAMPLED_KEY not in trace_state:
trace_state = trace_state.add(TRACESTATE_SAMPLED_KEY, "false")

if sample_rate and TRACESTATE_SAMPLE_RATE_KEY not in trace_state:
trace_state = trace_state.add(TRACESTATE_SAMPLE_RATE_KEY, str(sample_rate))
@@ -70,7 +70,7 @@ def sampled_result(span_context, attributes, sample_rate):
trace_state = span_context.trace_state

if TRACESTATE_SAMPLED_KEY not in trace_state:
trace_state = span_context.trace_state.add(TRACESTATE_SAMPLED_KEY, "true")
trace_state = trace_state.add(TRACESTATE_SAMPLED_KEY, "true")
if TRACESTATE_SAMPLE_RATE_KEY not in trace_state:
trace_state = trace_state.add(TRACESTATE_SAMPLE_RATE_KEY, str(sample_rate))

Loading