Skip to content

Commit 18ccb8f

Browse files
authored
chore: Remove experimental metric summary options (#2957)
1 parent a422dd7 commit 18ccb8f

File tree

3 files changed

+3
-138
lines changed

3 files changed

+3
-138
lines changed

sentry_sdk/consts.py

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
"transport_zlib_compression_level": Optional[int],
4848
"transport_num_pools": Optional[int],
4949
"enable_metrics": Optional[bool],
50-
"metrics_summary_sample_rate": Optional[float],
51-
"should_summarize_metric": Optional[Callable[[str, MetricTags], bool]],
5250
"before_emit_metric": Optional[Callable[[str, MetricTags], bool]],
5351
"metric_code_locations": Optional[bool],
5452
},

sentry_sdk/metrics.py

+2-15
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,6 @@ def _get_aggregator_and_update_tags(key, tags):
710710
if client is None or client.metrics_aggregator is None:
711711
return None, None, tags
712712

713-
experiments = client.options.get("_experiments", {})
714-
715713
updated_tags = dict(tags or ()) # type: Dict[str, MetricTagValue]
716714
updated_tags.setdefault("release", client.options["release"])
717715
updated_tags.setdefault("environment", client.options["environment"])
@@ -727,20 +725,9 @@ def _get_aggregator_and_update_tags(key, tags):
727725
if transaction_name:
728726
updated_tags.setdefault("transaction", transaction_name)
729727
if scope._span is not None:
730-
sample_rate = experiments.get("metrics_summary_sample_rate")
731-
# We default the sample rate of metrics summaries to 1.0 only when the sample rate is `None` since we
732-
# want to honor the user's decision if they pass a valid float.
733-
if sample_rate is None:
734-
sample_rate = 1.0
735-
should_summarize_metric_callback = experiments.get(
736-
"should_summarize_metric"
737-
)
738-
if random.random() < sample_rate and (
739-
should_summarize_metric_callback is None
740-
or should_summarize_metric_callback(key, updated_tags)
741-
):
742-
local_aggregator = scope._span._get_local_aggregator()
728+
local_aggregator = scope._span._get_local_aggregator()
743729

730+
experiments = client.options.get("_experiments", {})
744731
before_emit_callback = experiments.get("before_emit_metric")
745732
if before_emit_callback is not None:
746733
with recursion_protection() as in_metrics:

tests/test_metrics.py

+1-121
Original file line numberDiff line numberDiff line change
@@ -571,18 +571,13 @@ def test_transaction_name(
571571

572572
@minimum_python_37_with_gevent
573573
@pytest.mark.forked
574-
@pytest.mark.parametrize("sample_rate", [1.0, None])
575574
def test_metric_summaries(
576-
sentry_init, capture_envelopes, sample_rate, maybe_monkeypatched_threading
575+
sentry_init, capture_envelopes, maybe_monkeypatched_threading
577576
):
578577
sentry_init(
579578
release="[email protected]",
580579
environment="not-fun-env",
581580
enable_tracing=True,
582-
_experiments={
583-
"enable_metrics": True,
584-
"metrics_summary_sample_rate": sample_rate,
585-
},
586581
)
587582
ts = time.time()
588583
envelopes = capture_envelopes()
@@ -680,121 +675,6 @@ def test_metric_summaries(
680675
}
681676

682677

683-
@minimum_python_37_with_gevent
684-
@pytest.mark.forked
685-
def test_metrics_summary_disabled(
686-
sentry_init, capture_envelopes, maybe_monkeypatched_threading
687-
):
688-
sentry_init(
689-
release="[email protected]",
690-
environment="not-fun-env",
691-
enable_tracing=True,
692-
_experiments={"enable_metrics": True, "metrics_summary_sample_rate": 0.0},
693-
)
694-
ts = time.time()
695-
envelopes = capture_envelopes()
696-
697-
with start_transaction(
698-
op="stuff", name="/foo", source=TRANSACTION_SOURCE_ROUTE
699-
) as transaction:
700-
with metrics.timing("my-timer-metric", tags={"a": "b"}, timestamp=ts):
701-
pass
702-
703-
Hub.current.flush()
704-
705-
(transaction, envelope) = envelopes
706-
707-
# Metrics Emission
708-
assert envelope.items[0].headers["type"] == "statsd"
709-
m = parse_metrics(envelope.items[0].payload.get_bytes())
710-
711-
assert len(m) == 1
712-
assert m[0][1] == "my-timer-metric@second"
713-
assert m[0][2] == "d"
714-
assert len(m[0][3]) == 1
715-
assert m[0][4] == {
716-
"a": "b",
717-
"transaction": "/foo",
718-
"release": "[email protected]",
719-
"environment": "not-fun-env",
720-
}
721-
722-
# Measurement Attachment
723-
t = transaction.items[0].get_transaction_event()
724-
assert "_metrics_summary" not in t
725-
assert "_metrics_summary" not in t["spans"][0]
726-
727-
728-
@minimum_python_37_with_gevent
729-
@pytest.mark.forked
730-
def test_metrics_summary_filtered(
731-
sentry_init, capture_envelopes, maybe_monkeypatched_threading
732-
):
733-
def should_summarize_metric(key, tags):
734-
return key == "foo"
735-
736-
sentry_init(
737-
release="[email protected]",
738-
environment="not-fun-env",
739-
enable_tracing=True,
740-
_experiments={
741-
"enable_metrics": True,
742-
"metrics_summary_sample_rate": 1.0,
743-
"should_summarize_metric": should_summarize_metric,
744-
},
745-
)
746-
ts = time.time()
747-
envelopes = capture_envelopes()
748-
749-
with start_transaction(
750-
op="stuff", name="/foo", source=TRANSACTION_SOURCE_ROUTE
751-
) as transaction:
752-
metrics.timing("foo", value=3.0, tags={"a": "b"}, timestamp=ts)
753-
metrics.timing("foo", value=2.0, tags={"b": "c"}, timestamp=ts)
754-
metrics.timing("bar", value=1.0, tags={"a": "b"}, timestamp=ts)
755-
756-
Hub.current.flush()
757-
758-
(transaction, envelope) = envelopes
759-
760-
# Metrics Emission
761-
assert envelope.items[0].headers["type"] == "statsd"
762-
m = parse_metrics(envelope.items[0].payload.get_bytes())
763-
764-
assert len(m) == 3
765-
assert m[0][1] == "bar@second"
766-
assert m[1][1] == "foo@second"
767-
assert m[2][1] == "foo@second"
768-
769-
# Measurement Attachment
770-
t = transaction.items[0].get_transaction_event()["_metrics_summary"]
771-
assert len(t["d:foo@second"]) == 2
772-
assert {
773-
"tags": {
774-
"a": "b",
775-
"environment": "not-fun-env",
776-
"release": "[email protected]",
777-
"transaction": "/foo",
778-
},
779-
"min": 3.0,
780-
"max": 3.0,
781-
"count": 1,
782-
"sum": 3.0,
783-
} in t["d:foo@second"]
784-
assert {
785-
"tags": {
786-
"b": "c",
787-
"environment": "not-fun-env",
788-
"release": "[email protected]",
789-
"transaction": "/foo",
790-
},
791-
"min": 2.0,
792-
"max": 2.0,
793-
"count": 1,
794-
"sum": 2.0,
795-
} in t["d:foo@second"]
796-
797-
798678
@minimum_python_37_with_gevent
799679
@pytest.mark.forked
800680
def test_tag_normalization(

0 commit comments

Comments
 (0)