Skip to content

Commit ddd1afd

Browse files
committed
ref(relay): Remove transaction extraction config
1 parent dca7d73 commit ddd1afd

6 files changed

Lines changed: 0 additions & 150 deletions

File tree

src/sentry/relay/config/__init__.py

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import Any, Literal, NotRequired, TypedDict
88

99
import sentry_sdk
10-
from sentry_sdk import capture_exception
1110

1211
from sentry import features, killswitches, options, quotas, utils
1312
from sentry.constants import (
@@ -51,8 +50,6 @@
5150
from sentry.utils.http import get_origins
5251
from sentry.utils.options import sample_modulo
5352

54-
from .measurements import CUSTOM_MEASUREMENT_LIMIT
55-
5653
# These features will be listed in the project config.
5754
EXPOSABLE_FEATURES = [
5855
"organizations:continuous-profiling",
@@ -1049,14 +1046,6 @@ def _get_project_config(
10491046
add_experimental_config(config, "metrics", get_metrics_config, project)
10501047

10511048
if _should_extract_transaction_metrics(project):
1052-
add_experimental_config(
1053-
config,
1054-
"transactionMetrics",
1055-
get_transaction_metrics_settings,
1056-
project,
1057-
config.get("breakdownsV2"),
1058-
)
1059-
10601049
# This config key is technically not specific to _transaction_ metrics,
10611050
# is however currently both only applied to transaction metrics in
10621051
# Relay, and only used to tag transaction metrics in Sentry.
@@ -1285,67 +1274,9 @@ def _filter_option_to_config_setting(flt: _FilterSpec, setting: str) -> Mapping[
12851274
return ret_val
12861275

12871276

1288-
#: Version of the transaction metrics extraction.
1289-
#: When you increment this version, outdated Relays will stop extracting
1290-
#: transaction metrics.
1291-
#: See https://github.com/getsentry/relay/blob/6181c6e80b9485ed394c40bc860586ae934704e2/relay-dynamic-config/src/metrics.rs#L85
1292-
TRANSACTION_METRICS_EXTRACTION_VERSION = 6
1293-
1294-
1295-
class CustomMeasurementSettings(TypedDict):
1296-
limit: int
1297-
1298-
1299-
TransactionNameStrategy = Literal["strict", "clientBased"]
1300-
1301-
1302-
class TransactionMetricsSettings(TypedDict):
1303-
version: int
1304-
extractCustomTags: list[str]
1305-
customMeasurements: CustomMeasurementSettings
1306-
acceptTransactionNames: TransactionNameStrategy
1307-
1308-
13091277
def _should_extract_transaction_metrics(project: Project) -> bool:
13101278
return features.has(
13111279
"organizations:transaction-metrics-extraction", project.organization
13121280
) and not killswitches.killswitch_matches_context(
13131281
"relay.drop-transaction-metrics", {"project_id": project.id}
13141282
)
1315-
1316-
1317-
def get_transaction_metrics_settings(
1318-
timeout: TimeChecker, project: Project, breakdowns_config: Mapping[str, Any] | None
1319-
) -> TransactionMetricsSettings:
1320-
"""This function assumes that the corresponding feature flag has been checked.
1321-
See _should_extract_transaction_metrics.
1322-
"""
1323-
custom_tags: list[str] = []
1324-
1325-
if breakdowns_config is not None:
1326-
# we already have a breakdown configuration that tells relay which
1327-
# breakdowns to compute for an event. metrics extraction should
1328-
# probably be in sync with that, or at least not extract more metrics
1329-
# than there are breakdowns configured.
1330-
try:
1331-
for _, breakdown_config in breakdowns_config.items():
1332-
assert breakdown_config["type"] == "spanOperations"
1333-
1334-
except Exception:
1335-
capture_exception()
1336-
1337-
# Tells relay which user-defined tags to add to each extracted
1338-
# transaction metric. This cannot include things such as `os.name`
1339-
# which are computed on the server, they have to come from the SDK as
1340-
# event tags.
1341-
try:
1342-
custom_tags.extend(project.get_option("sentry:transaction_metrics_custom_tags") or ())
1343-
except Exception:
1344-
capture_exception()
1345-
1346-
return {
1347-
"version": TRANSACTION_METRICS_EXTRACTION_VERSION,
1348-
"extractCustomTags": custom_tags,
1349-
"customMeasurements": {"limit": CUSTOM_MEASUREMENT_LIMIT},
1350-
"acceptTransactionNames": "clientBased",
1351-
}

tests/sentry/relay/snapshots/test_config/test_project_config_with_breakdown/MONOLITH/with_metrics.pysnap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,9 +915,3 @@ metricConditionalTagging:
915915
- d:transactions/measurements.fcp@millisecond
916916
- d:transactions/measurements.lcp@millisecond
917917
targetTag: histogram_outlier
918-
transactionMetrics:
919-
acceptTransactionNames: clientBased
920-
customMeasurements:
921-
limit: 10
922-
extractCustomTags: []
923-
version: 3

tests/sentry/relay/snapshots/test_config/test_project_config_with_breakdown/MONOLITH/without_metrics.pysnap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ breakdownsV2:
1313
- ui
1414
type: spanOperations
1515
metricConditionalTagging: null
16-
transactionMetrics: null

tests/sentry/relay/snapshots/test_config/test_project_config_with_breakdown/REGION/with_metrics.pysnap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,3 @@ metricConditionalTagging:
4646
- d:transactions/measurements.lcp@millisecond
4747
- s:transactions/user@none
4848
targetTag: satisfaction
49-
transactionMetrics:
50-
acceptTransactionNames: clientBased
51-
customMeasurements:
52-
limit: 10
53-
extractCustomTags: []
54-
version: 6

tests/sentry/relay/snapshots/test_config/test_project_config_with_breakdown/REGION/without_metrics.pysnap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ breakdownsV2:
1313
- ui
1414
type: spanOperations
1515
metricConditionalTagging: null
16-
transactionMetrics: null

tests/sentry/relay/test_config.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,6 @@ def test_get_experimental_config_dyn_sampling(mock_logger, _, default_project) -
152152
assert mock_logger.exception.call_args == mock.call(ANY)
153153

154154

155-
@django_db_all
156-
@cell_silo_test
157-
@mock.patch("sentry.relay.config.capture_exception")
158-
def test_get_experimental_config_transaction_metrics_exception(
159-
mock_capture_exception, default_project
160-
):
161-
keys = ProjectKey.objects.filter(project=default_project)
162-
default_project.update_option("sentry:breakdowns", {"invalid_breakdowns": "test"})
163-
# wrong type
164-
default_project.update_option("sentry:transaction_metrics_custom_tags", 42)
165-
166-
with Feature({"organizations:transaction-metrics-extraction": True}):
167-
cfg = get_project_config(default_project, project_keys=keys)
168-
169-
config = cfg.to_dict()["config"]
170-
171-
assert config["transactionMetrics"]["extractCustomTags"] == []
172-
assert mock_capture_exception.call_count == 2
173-
174-
175155
@django_db_all
176156
@cell_silo_test
177157
@pytest.mark.parametrize("has_custom_filters", [False, True])
@@ -539,7 +519,6 @@ def test_project_config_with_breakdown(
539519
insta_snapshot(
540520
{
541521
"breakdownsV2": cfg["config"]["breakdownsV2"],
542-
"transactionMetrics": cfg["config"].get("transactionMetrics"),
543522
"metricConditionalTagging": cfg["config"].get("metricConditionalTagging"),
544523
}
545524
)
@@ -606,52 +585,6 @@ def test_project_config_satisfaction_thresholds(
606585
insta_snapshot(cfg["config"]["metricConditionalTagging"])
607586

608587

609-
@django_db_all
610-
@cell_silo_test
611-
@pytest.mark.parametrize("feature_flag", (False, True), ids=("feature_disabled", "feature_enabled"))
612-
@pytest.mark.parametrize(
613-
"killswitch", (False, True), ids=("killswitch_disabled", "killswitch_enabled")
614-
)
615-
def test_has_metric_extraction(default_project, feature_flag, killswitch) -> None:
616-
options = override_options(
617-
{
618-
"relay.drop-transaction-metrics": (
619-
[{"project_id": default_project.id}] if killswitch else []
620-
)
621-
}
622-
)
623-
feature = Feature(
624-
{
625-
"organizations:transaction-metrics-extraction": feature_flag,
626-
}
627-
)
628-
with feature, options:
629-
project_config = get_project_config(default_project)
630-
config = project_config.to_dict()["config"]
631-
_validate_project_config(config)
632-
if killswitch or not feature_flag:
633-
assert "transactionMetrics" not in config
634-
else:
635-
config = config["transactionMetrics"]
636-
assert config["customMeasurements"]["limit"] > 0
637-
638-
639-
@django_db_all
640-
def test_accept_transaction_names(default_project) -> None:
641-
feature = Feature(
642-
{
643-
"organizations:transaction-metrics-extraction": True,
644-
}
645-
)
646-
with feature:
647-
config = get_project_config(default_project).to_dict()["config"]
648-
649-
_validate_project_config(config)
650-
transaction_metrics_config = config["transactionMetrics"]
651-
652-
assert transaction_metrics_config["acceptTransactionNames"] == "clientBased"
653-
654-
655588
@pytest.mark.parametrize("num_clusterer_runs", [9, 10])
656589
@django_db_all
657590
def test_txnames_ready(default_project, num_clusterer_runs) -> None:

0 commit comments

Comments
 (0)