Skip to content

Commit

Permalink
feat(spans): Config stub for span.op inference (#77851)
Browse files Browse the repository at this point in the history
Add a first rule to derive missing `span.op`s in Relay.
  • Loading branch information
jjbayer authored Oct 3, 2024
1 parent 6e5bccc commit 42cb4be
Showing 1 changed file with 31 additions and 1 deletion.
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

0 comments on commit 42cb4be

Please sign in to comment.