Skip to content

Commit 2e9dad1

Browse files
committed
Slim down outgoing payload
1 parent c47df82 commit 2e9dad1

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

sentry_sdk/opentelemetry/span_processor.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545

4646
DEFAULT_MAX_SPANS = 1000
4747

48+
# Span attributes internal to the SDK that should be omitted from the final payload
49+
IGNORE_SPAN_ATTRIBUTES = [
50+
"flag.count",
51+
]
52+
4853

4954
class SentrySpanProcessor(SpanProcessor):
5055
"""
@@ -289,8 +294,11 @@ def _span_to_json(self, span):
289294
if parent_span_id:
290295
span_json["parent_span_id"] = parent_span_id
291296

292-
if span.attributes:
293-
span_json["data"] = dict(span.attributes)
297+
if getattr(span, "attributes", {}):
298+
span_json["data"] = {}
299+
for key, value in span.attributes.items():
300+
if key not in IGNORE_SPAN_ATTRIBUTES:
301+
span_json["data"][key] = value
294302

295303
return span_json
296304

tests/test_feature_flags.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,19 @@ def test_flag_limit(sentry_init, capture_events):
259259
}
260260
)
261261
assert "flag.evaluation.10" not in event["spans"][0]["data"]
262+
263+
264+
def test_flag_counter_not_sent(sentry_init, capture_events):
265+
sentry_init(traces_sample_rate=1.0)
266+
267+
events = capture_events()
268+
269+
with start_transaction(name="hi"):
270+
with start_span(op="foo", name="bar"):
271+
add_feature_flag("0", True)
272+
add_feature_flag("1", True)
273+
add_feature_flag("2", True)
274+
add_feature_flag("3", True)
275+
276+
(event,) = events
277+
assert "flag.counter" not in event["spans"][0]["data"]

0 commit comments

Comments
 (0)