|
7 | 7 | from typing import Any, Literal, NotRequired, TypedDict |
8 | 8 |
|
9 | 9 | import sentry_sdk |
10 | | -from sentry_sdk import capture_exception |
11 | 10 |
|
12 | 11 | from sentry import features, killswitches, options, quotas, utils |
13 | 12 | from sentry.constants import ( |
|
51 | 50 | from sentry.utils.http import get_origins |
52 | 51 | from sentry.utils.options import sample_modulo |
53 | 52 |
|
54 | | -from .measurements import CUSTOM_MEASUREMENT_LIMIT |
55 | | - |
56 | 53 | # These features will be listed in the project config. |
57 | 54 | EXPOSABLE_FEATURES = [ |
58 | 55 | "organizations:continuous-profiling", |
@@ -1049,14 +1046,6 @@ def _get_project_config( |
1049 | 1046 | add_experimental_config(config, "metrics", get_metrics_config, project) |
1050 | 1047 |
|
1051 | 1048 | 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 | | - |
1060 | 1049 | # This config key is technically not specific to _transaction_ metrics, |
1061 | 1050 | # is however currently both only applied to transaction metrics in |
1062 | 1051 | # 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[ |
1285 | 1274 | return ret_val |
1286 | 1275 |
|
1287 | 1276 |
|
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 | | - |
1309 | 1277 | def _should_extract_transaction_metrics(project: Project) -> bool: |
1310 | 1278 | return features.has( |
1311 | 1279 | "organizations:transaction-metrics-extraction", project.organization |
1312 | 1280 | ) and not killswitches.killswitch_matches_context( |
1313 | 1281 | "relay.drop-transaction-metrics", {"project_id": project.id} |
1314 | 1282 | ) |
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 | | - } |
0 commit comments