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

feat(ddm): Enable metrics related settings by default #2685

Merged
merged 13 commits into from
Jan 30, 2024
6 changes: 5 additions & 1 deletion sentry_sdk/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,11 @@
if transaction_name:
updated_tags.setdefault("transaction", transaction_name)
if scope._span is not None:
sample_rate = experiments.get("metrics_summary_sample_rate") or 0.0
sample_rate = experiments.get("metrics_summary_sample_rate")

Check warning on line 722 in sentry_sdk/metrics.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/metrics.py#L722

Added line #L722 was not covered by tests
# We default the sample rate of metrics summaries to 1.0 only when the sample rate is `None` since we
# want to honor the user's decision if they pass a valid float.
if sample_rate is None:
sample_rate = 1.0

Check warning on line 726 in sentry_sdk/metrics.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/metrics.py#L726

Added line #L726 was not covered by tests
should_summarize_metric_callback = experiments.get(
"should_summarize_metric"
)
Expand Down
12 changes: 8 additions & 4 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8

import pytest
import sys
import time
import linecache
Expand Down Expand Up @@ -536,12 +536,16 @@ def test_transaction_name(sentry_init, capture_envelopes):
}


def test_metric_summaries(sentry_init, capture_envelopes):
@pytest.mark.parametrize(
"sample_rate",
[1.0, None]
)
def test_metric_summaries(sentry_init, capture_envelopes, sample_rate):
sentry_init(
release="fun-release@1.0.0",
environment="not-fun-env",
enable_tracing=True,
_experiments={"enable_metrics": True, "metrics_summary_sample_rate": 1.0},
_experiments={"enable_metrics": True, "metrics_summary_sample_rate": sample_rate},
)
ts = time.time()
envelopes = capture_envelopes()
Expand Down Expand Up @@ -644,7 +648,7 @@ def test_metrics_summary_disabled(sentry_init, capture_envelopes):
release="fun-release@1.0.0",
environment="not-fun-env",
enable_tracing=True,
_experiments={"enable_metrics": True},
_experiments={"enable_metrics": True, "metrics_summary_sample_rate": 0.0},
)
ts = time.time()
envelopes = capture_envelopes()
Expand Down