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(spans): Config stub for span.op inference #77851

Merged
merged 10 commits into from
Oct 3, 2024
32 changes: 31 additions & 1 deletion src/sentry/relay/globalconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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]


Expand All @@ -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."""
Expand All @@ -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()
Expand Down
Loading