diff --git a/src/sentry/relay/globalconfig.py b/src/sentry/relay/globalconfig.py index d9d1e81c8a004..6e58750ec3bdf 100644 --- a/src/sentry/relay/globalconfig.py +++ b/src/sentry/relay/globalconfig.py @@ -7,7 +7,7 @@ MetricExtractionGroups, global_metric_extraction_groups, ) -from sentry.relay.types import GenericFiltersConfig +from sentry.relay.types import GenericFiltersConfig, RuleCondition from sentry.utils import metrics # List of options to include in the global config. @@ -28,11 +28,21 @@ ] +class SpanOpDefaultRule(TypedDict): + condition: RuleCondition + value: str + + +class SpanOpDefaults(TypedDict): + rules: list[SpanOpDefaultRule] + + class GlobalConfig(TypedDict, total=False): measurements: MeasurementsConfig aiModelCosts: AIModelCosts metricExtraction: MetricExtractionGroups filters: GenericFiltersConfig | None + spanOpDefaults: SpanOpDefaults options: dict[str, Any] @@ -43,6 +53,25 @@ def get_global_generic_filters() -> GenericFiltersConfig: } +def span_op_defaults() -> SpanOpDefaults: + return { + "rules": [ + { + # If span.data[messaging.system] is set, use span.op "message": + "condition": { + "op": "not", + "inner": { + "op": "eq", + "name": "span.data.messaging\\.system", + "value": None, + }, + }, + "value": "message", + } + ] + } + + @metrics.wraps("relay.globalconfig.get") def get_global_config(): """Return the global configuration for Relay.""" @@ -51,6 +80,7 @@ def get_global_config(): "measurements": get_measurements_config(), "aiModelCosts": ai_model_costs_config(), "metricExtraction": global_metric_extraction_groups(), + "spanOpDefaults": span_op_defaults(), } filters = get_global_generic_filters()