Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(tracing): add column facets and own-filter exclusion to attribute breakdown (#69300)

Jon McCallumf73a7c54d6fe
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index dbfbbda67389..cac6bbcffe3f 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -44550,7 +44550,7 @@
"type": "string"
},
"TraceSpanBreakdownType": {
- "enum": ["span_attribute", "span_resource_attribute"],
+ "enum": ["span", "span_attribute", "span_resource_attribute"],
"type": "string"
},
"TraceSpansAggregationQuery": {
@@ -44656,12 +44656,12 @@
"additionalProperties": false,
"properties": {
"breakdownKey": {
- "description": "Attribute key to group by (e.g. `http.response.status_code`, `server.address`).",
+ "description": "Attribute key to group by (e.g. `http.response.status_code`, `server.address`). For the `span` breakdown type, must be an allowlisted top-level column (`service_name`, `status_code`).",
"type": "string"
},
"breakdownType": {
"$ref": "#/definitions/TraceSpanBreakdownType",
- "description": "Where the key lives: span-level attributes or resource-level attributes."
+ "description": "Where the key lives: an allowlisted top-level span column, span-level attributes, or resource-level attributes."
},
"compareFilter": {
"$ref": "#/definitions/CompareFilter",
@@ -44670,6 +44670,10 @@
"dateRange": {
"$ref": "#/definitions/DateRange"
},
+ "excludeBreakdownFilter": {
+ "description": "Drop filters targeting the breakdown key itself (including `serviceNames` for a `service_name` breakdown) so a facet's value list stays complete while one of its values is selected.",
+ "type": "boolean"
+ },
"filterGroup": {
"$ref": "#/definitions/PropertyGroupFilter"
},
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 64553141ebde..c77ad953011a 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -3657,15 +3657,18 @@ export interface AttributeBreakdownRow {
p95_duration_nano: number
}
-export type TraceSpanBreakdownType = 'span_attribute' | 'span_resource_attribute'
+export type TraceSpanBreakdownType = 'span' | 'span_attribute' | 'span_resource_attribute'
export type TraceSpanBreakdownOrderBy = 'count' | 'error_count'
export interface TraceSpansAttributeBreakdownQuery extends DataNode<TraceSpansAttributeBreakdownQueryResponse> {
kind: NodeKind.TraceSpansAttributeBreakdownQuery
dateRange: DateRange
- /** Attribute key to group by (e.g. `http.response.status_code`, `server.address`). */
+ /**
+ * Attribute key to group by (e.g. `http.response.status_code`, `server.address`).
+ * For the `span` breakdown type, must be an allowlisted top-level column (`service_name`, `status_code`).
+ */
breakdownKey: string
- /** Where the key lives: span-level attributes or resource-level attributes. */
+ /** Where the key lives: an allowlisted top-level span column, span-level attributes, or resource-level attributes. */
breakdownType: TraceSpanBreakdownType
/** Order rows by span count or error count, descending. Defaults to count. */
orderBy?: TraceSpanBreakdownOrderBy
@@ -3673,6 +3676,11 @@ export interface TraceSpansAttributeBreakdownQuery extends DataNode<TraceSpansAt
compareFilter?: CompareFilter
filterGroup?: PropertyGroupFilter
serviceNames?: string[]
+ /**
+ * Drop filters targeting the breakdown key itself (including `serviceNames` for a `service_name`
+ * breakdown) so a facet's value list stays complete while one of its values is selected.
+ */
+ excludeBreakdownFilter?: boolean
}
export interface TraceSpansAttributeBreakdownQueryResponse extends AnalyticsQueryResponseBase {
diff --git a/posthog/schema.py b/posthog/schema.py
index bda1d074acfc..273db27a7996 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -23943,11 +23943,18 @@ class TraceSpansAttributeBreakdownQuery(BaseModel):
)
breakdownKey: str = Field(
...,
- description=("Attribute key to group by (e.g. `http.response.status_code`, `server.address`)."),
+ description=(
+ "Attribute key to group by (e.g. `http.response.status_code`,"
+ " `server.address`). For the `span` breakdown type, must be an allowlisted"
+ " top-level column (`service_name`, `status_code`)."
+ ),
)
breakdownType: TraceSpanBreakdownType = Field(
...,
- description=("Where the key lives: span-level attributes or resource-level attributes."),
+ description=(
+ "Where the key lives: an allowlisted top-level span column, span-level"
+ " attributes, or resource-level attributes."
+ ),
)
compareFilter: CompareFilter | None = Field(
default=None,
@@ -23956,6 +23963,14 @@ class TraceSpansAttributeBreakdownQuery(BaseModel):
),
)
dateRange: DateRange
+ excludeBreakdownFilter: bool | None = Field(
+ default=None,
+ description=(
+ "Drop filters targeting the breakdown key itself (including `serviceNames`"
+ " for a `service_name` breakdown) so a facet's value list stays complete"
+ " while one of its values is selected."
+ ),
+ )
filterGroup: PropertyGroupFilter | None = None
kind: Literal["TraceSpansAttributeBreakdownQuery"] = "TraceSpansAttributeBreakdownQuery"
modifiers: HogQLQueryModifiers | None = Field(default=None, description="Modifiers used when performing the query")
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index f2b6d2c6c61a..b3d678712181 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3286,6 +3286,7 @@ class TraceSpanBreakdownOrderBy(StrEnum):
class TraceSpanBreakdownType(StrEnum):
+ SPAN = "span"
SPAN_ATTRIBUTE = "span_attribute"
SPAN_RESOURCE_ATTRIBUTE = "span_resource_attribute"
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index 8f46a45d6272..9bfea0032d7d 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -554,6 +554,9 @@ SPECTACULAR_SETTINGS = {
# AgentRevision.state (model ChoiceField) and RevisionNotDraftError.state (the
# bundle-edit 409 body) share one choice set — pin them to a single named enum.
"AgentRevisionStateEnum": ["draft", "ready", "live", "archived"],
+ # Tracing's span-filter `type` and attribute-breakdown `breakdownType` share one
+ # choice set (top-level column vs span attribute vs resource attribute).
+ "SpanPropertyTypeEnum": ["span", "span_attribute", "span_resource_attribute"],
"CustomPropertyDisplayTypeEnum": [
"text",
"number",
diff --git a/products/tracing/backend/attribute_breakdown_query_runner.py b/products/tracing/backend/attribute_breakdown_query_runner.py
index aa50f20cb2f3..dbff6d1a48de 100644
--- a/products/tracing/backend/attribute_breakdown_query_runner.py
+++ b/products/tracing/backend/attribute_breakdown_query_runner.py
@@ -31,6 +31,10 @@ _ORDER_COLUMNS: dict[TraceSpanBreakdownOrderBy, str] = {
TraceSpanBreakdownOrderBy.ERROR_COUNT: "error_count",
}
+# Top-level columns the `span` breakdown type may group by. The allowlist (enforced at both the
+# API and runner level) keeps arbitrary column names out of the generated SQL.
+FACET_COLUMNS: frozenset[str] = frozenset({"service_name", "status_code"})
+
class TraceSpansAttributeBreakdownQueryRunner(
_SpanAggregationMixin, AnalyticsQueryRunner[TraceSpansAttributeBreakdownQueryResponse]
@@ -46,24 +50,50 @@ class TraceSpansAttributeBreakdownQueryRunner(
def __init__(self, query: TraceSpansAttributeBreakdownQuery, *args, **kwargs) -> None:
super().__init__(query, *args, **kwargs)
+ if self.query.breakdownType == TraceSpanBreakdownType.SPAN and self.query.breakdownKey not in FACET_COLUMNS:
+ raise ValueError(f"Unsupported span column for breakdown: {self.query.breakdownKey!r}")
self.modifiers.convertToProjectTimezone = False
self.modifiers.propertyGroupsMode = PropertyGroupsMode.OPTIMIZED
self._extract_filters()
+ def _extract_filters(self) -> None:
+ super()._extract_filters()
+ if not self.query.excludeBreakdownFilter:
+ return
+ # Facet semantics: a facet's value list must ignore its own selection (otherwise selecting
+ # a value collapses the facet to one row), while all other filters still apply.
+ key = self.query.breakdownKey
+ if self.query.breakdownType == TraceSpanBreakdownType.SPAN:
+ self.span_filters = [f for f in self.span_filters if f.key != key]
+ if key == "service_name":
+ # The dedicated service filter targets the same column as the breakdown.
+ self.query.serviceNames = None
+ elif self.query.breakdownType == TraceSpanBreakdownType.SPAN_ATTRIBUTE:
+ # Extraction suffixed the keys with their physical-map type (`__str` / `__float`).
+ suffixed = {f"{key}__str", f"{key}__float"}
+ self.span_attribute_filters = [f for f in self.span_attribute_filters if f.key not in suffixed]
+ else:
+ self.resource_attribute_filters = [f for f in self.resource_attribute_filters if f.key != key]
+
def _calculate(self) -> TraceSpansAttributeBreakdownQueryResponse:
current_rows, previous_rows = self._run_with_compare()
return TraceSpansAttributeBreakdownQueryResponse(results=current_rows, compare=previous_rows)
def _build_query(self, query_date_range: QueryDateRange) -> ast.SelectQuery:
- if self.query.breakdownType == TraceSpanBreakdownType.SPAN_RESOURCE_ATTRIBUTE:
+ breakdown_field: ast.Expr
+ if self.query.breakdownType == TraceSpanBreakdownType.SPAN:
+ # Allowlisted top-level column (validated in __init__). toString keeps the response
+ # shape uniform — status_code is an Int16 (0/1/2) but rows always carry string values.
+ breakdown_field = ast.Call(name="toString", args=[ast.Field(chain=[self.query.breakdownKey])])
+ elif self.query.breakdownType == TraceSpanBreakdownType.SPAN_RESOURCE_ATTRIBUTE:
# resource_attributes' property group matches any key as-is.
- breakdown_chain: list[str | int] = ["resource_attributes", self.query.breakdownKey]
+ breakdown_field = ast.Field(chain=["resource_attributes", self.query.breakdownKey])
else:
# Span attribute keys carry a type suffix in the physical map (attributes_map_str);
# the property-group resolver only rewrites suffixed keys to map access — a bare key
# falls through to a JSON read, which is illegal on the Map column. Every value is
# present in the __str map (the float/datetime maps are derived from it).
- breakdown_chain = ["attributes", f"{self.query.breakdownKey}__str"]
+ breakdown_field = ast.Field(chain=["attributes", f"{self.query.breakdownKey}__str"])
order_column = _ORDER_COLUMNS[self.query.orderBy or TraceSpanBreakdownOrderBy.COUNT]
query = parse_select(
@@ -88,7 +118,7 @@ class TraceSpansAttributeBreakdownQueryRunner(
LIMIT {limit}
""",
placeholders={
- "breakdown_field": ast.Field(chain=breakdown_chain),
+ "breakdown_field": breakdown_field,
"where": self._where_without_date_range(),
"limit": ast.Constant(value=_ROW_LIMIT),
**query_date_range.to_placeholders(),
@@ -117,6 +147,7 @@ def run_attribute_breakdown_query(
compare_filter: CompareFilter | None = None,
filter_group: PropertyGroupFilter | None = None,
service_names: list[str] | None = None,
+ exclude_breakdown_filter: bool = False,
) -> TraceSpansAttributeBreakdownQueryResponse | CachedTraceSpansAttributeBreakdownQueryResponse:
"""Facade-friendly entry point for running an attribute breakdown query."""
query = TraceSpansAttributeBreakdownQuery(
@@ -127,6 +158,7 @@ def run_attribute_breakdown_query(
compareFilter=compare_filter,
filterGroup=filter_group,
serviceNames=service_names,
+ excludeBreakdownFilter=exclude_breakdown_filter,
)
runner = TraceSpansAttributeBreakdownQueryRunner(query, team)
response = runner.run(ExecutionMode.CALCULATE_BLOCKING_ALWAYS)
diff --git a/products/tracing/backend/facade/api.py b/products/tracing/backend/facade/api.py
index c74160e49316..a6bc7fc167a5 100644
--- a/products/tracing/backend/facade/api.py
+++ b/products/tracing/backend/facade/api.py
@@ -34,6 +34,7 @@ from posthog.schema import (
)
from products.tracing.backend.attribute_breakdown_query_runner import (
+ FACET_COLUMNS as _FACET_COLUMNS,
run_attribute_breakdown_query as _run_attribute_breakdown_query,
)
from products.tracing.backend.count_query_runner import run_count_query as _run_count_query
@@ -47,6 +48,11 @@ if TYPE_CHECKING:
from posthog.models import Team
+# Allowlisted top-level span columns for the "span" breakdown type. Re-exported so the
+# presentation layer can validate `breakdownKey` without reaching into the query runner.
+FACET_COLUMNS = _FACET_COLUMNS
+
+
# --- Converters (model -> frozen dataclass) ---
#
# These look repetitive when fields align 1:1. The value is having ONE place
@@ -82,6 +88,7 @@ def run_attribute_breakdown_query(
compare_filter: CompareFilter | None = None,
filter_group: PropertyGroupFilter | None = None,
service_names: list[str] | None = None,
+ exclude_breakdown_filter: bool = False,
) -> TraceSpansAttributeBreakdownQueryResponse | CachedTraceSpansAttributeBreakdownQueryResponse:
"""Run a span breakdown grouped by one attribute's value within a filtered span set."""
return _run_attribute_breakdown_query(
@@ -93,6 +100,7 @@ def run_attribute_breakdown_query(
compare_filter=compare_filter,
filter_group=filter_group,
service_names=service_names,
+ exclude_breakdown_filter=exclude_breakdown_filter,
)
diff --git a/products/tracing/backend/presentation/views.py b/products/tracing/backend/presentation/views.py
index 6beee48e831c..809fbae2a0be 100644
--- a/products/tracing/backend/presentation/views.py
+++ b/products/tracing/backend/presentation/views.py
@@ -42,6 +42,7 @@ from posthog.event_usage import report_user_action
from posthog.hogql_queries.query_runner import ExecutionMode
from ..facade.api import (
+ FACET_COLUMNS,
annotate_self_time,
run_attribute_breakdown_query,
run_count_query,
@@ -365,11 +366,16 @@ class _TracingAggregationRequestSerializer(serializers.Serializer):
class _TracingAttributeBreakdownQueryBodySerializer(serializers.Serializer):
breakdownKey = serializers.CharField(
required=True,
- help_text='Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list.',
+ help_text='Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. For the "span" breakdown type, must be one of the allowlisted top-level columns: "service_name", "status_code".',
)
breakdownType = serializers.ChoiceField(
- choices=["span_attribute", "span_resource_attribute"],
- help_text='Where the key lives: "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.',
+ choices=["span", "span_attribute", "span_resource_attribute"],
+ help_text='Where the key lives: "span" for allowlisted top-level span columns, "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.',
+ )
+ excludeBreakdownFilter = serializers.BooleanField(
+ required=False,
+ default=False,
+ help_text="Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected.",
)
orderBy = serializers.ChoiceField(
choices=["count", "error_count"],
@@ -1034,7 +1040,13 @@ class SpansViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet)
breakdown_type = TraceSpanBreakdownType(query_data.get("breakdownType") or "")
except ValueError:
return Response(
- {"detail": '`breakdownType` must be "span_attribute" or "span_resource_attribute".'},
+ {"detail": '`breakdownType` must be "span", "span_attribute" or "span_resource_attribute".'},
+ status=status.HTTP_400_BAD_REQUEST,
+ )
+
+ if breakdown_type == TraceSpanBreakdownType.SPAN and breakdown_key not in FACET_COLUMNS:
+ return Response(
+ {"detail": f"`breakdownKey` for a span column breakdown must be one of: {sorted(FACET_COLUMNS)}."},
status=status.HTTP_400_BAD_REQUEST,
)
@@ -1076,6 +1088,7 @@ class SpansViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet)
compare_filter=compare_filter,
filter_group=filter_group,
service_names=query_data.get("serviceNames", None),
+ exclude_breakdown_filter=bool(query_data.get("excludeBreakdownFilter")),
)
return Response(
diff --git a/products/tracing/backend/tests/test_attribute_breakdown.py b/products/tracing/backend/tests/test_attribute_breakdown.py
index ee549726c0b2..0ee8c971708e 100644
--- a/products/tracing/backend/tests/test_attribute_breakdown.py
+++ b/products/tracing/backend/tests/test_attribute_breakdown.py
@@ -118,3 +118,102 @@ class TestTraceSpansAttributeBreakdown(_TraceSpansTestBase):
{(row["value"], row["count"]) for row in rows},
{("api2.amplitude.com", 4)},
)
+
+ @parameterized.expand(
+ [
+ ("service_name", {("cdp", 9, 4), ("other", 1, 0)}),
+ # Int16 column: values come back stringified so the response shape stays uniform.
+ ("status_code", {("2", 4, 4), ("0", 6, 0)}),
+ ]
+ )
+ def test_span_column_breakdown(self, breakdown_key, expected):
+ rows = self._breakdown(breakdownKey=breakdown_key, breakdownType="span")
+ self.assertEqual(
+ {(row["value"], row["count"], row["error_count"]) for row in rows},
+ expected,
+ )
+
+ def test_span_column_breakdown_rejects_non_allowlisted_key(self):
+ response = self.client.post(
+ f"/api/projects/{self.team.id}/tracing/spans/attribute-breakdown/",
+ {
+ "query": {
+ "dateRange": {"date_from": DATE_FROM, "date_to": DATE_TO},
+ "breakdownKey": "timestamp",
+ "breakdownType": "span",
+ }
+ },
+ format="json",
+ )
+ self.assertEqual(response.status_code, 400, response.content)
+
+ @parameterized.expand(
+ [
+ # Each case selects one value of the facet's own dimension; with exclusion the facet
+ # must still list every value (not collapse to the selected one).
+ (
+ "service_names_filter",
+ {"breakdownKey": "service_name", "breakdownType": "span", "serviceNames": ["other"]},
+ {"cdp", "other"},
+ ),
+ (
+ "span_column_filter",
+ {
+ "breakdownKey": "status_code",
+ "breakdownType": "span",
+ "filterGroup": [{"key": "status_code", "operator": "exact", "type": "span", "value": "Error"}],
+ },
+ {"0", "2"},
+ ),
+ (
+ "span_attribute_filter",
+ {
+ "breakdownKey": "server.address",
+ "breakdownType": "span_attribute",
+ "filterGroup": [
+ {
+ "key": "server.address",
+ "operator": "exact",
+ "type": "span_attribute",
+ "value": "api.mixpanel.com",
+ }
+ ],
+ },
+ {"api2.amplitude.com", "api.mixpanel.com", ""},
+ ),
+ (
+ "resource_attribute_filter",
+ {
+ "breakdownKey": "k8s.pod.name",
+ "breakdownType": "span_resource_attribute",
+ "filterGroup": [
+ {
+ "key": "k8s.pod.name",
+ "operator": "exact",
+ "type": "span_resource_attribute",
+ "value": "pod-a",
+ }
+ ],
+ },
+ {"pod-a", "pod-b", "pod-c"},
+ ),
+ ]
+ )
+ def test_exclude_breakdown_filter_keeps_facet_complete(self, _name, query_fields, expected_values):
+ rows = self._breakdown(excludeBreakdownFilter=True, **query_fields)
+ self.assertEqual({row["value"] for row in rows}, expected_values)
+
+ def test_exclude_breakdown_filter_keeps_other_filters(self):
+ # Exclusion only drops the facet's own filter — the serviceNames scope must still apply,
+ # so the amplitude span in the "other" service stays excluded (5, not 6).
+ rows = self._breakdown(
+ breakdownKey="server.address",
+ breakdownType="span_attribute",
+ serviceNames=["cdp"],
+ excludeBreakdownFilter=True,
+ filterGroup=[
+ {"key": "server.address", "operator": "exact", "type": "span_attribute", "value": "api.mixpanel.com"}
+ ],
+ )
+ by_value = {row["value"]: row["count"] for row in rows}
+ self.assertEqual(by_value["api2.amplitude.com"], 5)
diff --git a/products/tracing/frontend/generated/api.schemas.ts b/products/tracing/frontend/generated/api.schemas.ts
index 5fa581da3ffd..7c003c07899b 100644
--- a/products/tracing/frontend/generated/api.schemas.ts
+++ b/products/tracing/frontend/generated/api.schemas.ts
@@ -35,10 +35,9 @@ export interface _CompareFilterApi {
* * `span_attribute` - span_attribute
* * `span_resource_attribute` - span_resource_attribute
*/
-export type _SpanPropertyFilterTypeEnumApi =
- (typeof _SpanPropertyFilterTypeEnumApi)[keyof typeof _SpanPropertyFilterTypeEnumApi]
+export type SpanPropertyTypeEnumApi = (typeof SpanPropertyTypeEnumApi)[keyof typeof SpanPropertyTypeEnumApi]
-export const _SpanPropertyFilterTypeEnumApi = {
+export const SpanPropertyTypeEnumApi = {
Span: 'span',
SpanAttribute: 'span_attribute',
SpanResourceAttribute: 'span_resource_attribute',
@@ -80,7 +79,7 @@ export interface _SpanPropertyFilterApi {
* * `span` - span
* * `span_attribute` - span_attribute
* * `span_resource_attribute` - span_resource_attribute */
- type: _SpanPropertyFilterTypeEnumApi
+ type: SpanPropertyTypeEnumApi
/** Comparison operator.
*
* * `exact` - exact
@@ -114,17 +113,6 @@ export interface _TracingAggregationRequestApi {
query: _TracingAggregationQueryBodyApi
}
-/**
- * * `span_attribute` - span_attribute
- * * `span_resource_attribute` - span_resource_attribute
- */
-export type BreakdownTypeEnumApi = (typeof BreakdownTypeEnumApi)[keyof typeof BreakdownTypeEnumApi]
-
-export const BreakdownTypeEnumApi = {
- SpanAttribute: 'span_attribute',
- SpanResourceAttribute: 'span_resource_attribute',
-} as const
-
/**
* * `count` - count
* * `error_count` - error_count
@@ -138,13 +126,16 @@ export const _TracingAttributeBreakdownQueryBodyOrderByEnumApi = {
} as const
export interface _TracingAttributeBreakdownQueryBodyApi {
- /** Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. */
+ /** Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. For the "span" breakdown type, must be one of the allowlisted top-level columns: "service_name", "status_code". */
breakdownKey: string
- /** Where the key lives: "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.
+ /** Where the key lives: "span" for allowlisted top-level span columns, "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.
*
+ * * `span` - span
* * `span_attribute` - span_attribute
* * `span_resource_attribute` - span_resource_attribute */
- breakdownType: BreakdownTypeEnumApi
+ breakdownType: SpanPropertyTypeEnumApi
+ /** Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected. */
+ excludeBreakdownFilter?: boolean
/** Order rows by span count or error count, descending. Defaults to count.
*
* * `count` - count
diff --git a/products/tracing/frontend/generated/api.zod.ts b/products/tracing/frontend/generated/api.zod.ts
index 558f70cddfbb..c3aa23b3e9d4 100644
--- a/products/tracing/frontend/generated/api.zod.ts
+++ b/products/tracing/frontend/generated/api.zod.ts
@@ -99,6 +99,7 @@ export const TracingSpansAggregateCreateBody = /* @__PURE__ */ zod.object({
.describe('The span aggregation query to execute.'),
})
+export const tracingSpansAttributeBreakdownCreateBodyQueryOneExcludeBreakdownFilterDefault = false
export const tracingSpansAttributeBreakdownCreateBodyQueryOneCompareFilterOneCompareDefault = false
export const tracingSpansAttributeBreakdownCreateBodyQueryOneFilterGroupDefault = []
@@ -108,15 +109,21 @@ export const TracingSpansAttributeBreakdownCreateBody = /* @__PURE__ */ zod.obje
breakdownKey: zod
.string()
.describe(
- 'Attribute key to group by (e.g. \"server.address\", \"http.response.status_code\"). Discover keys with apm-attributes-list.'
+ 'Attribute key to group by (e.g. \"server.address\", \"http.response.status_code\"). Discover keys with apm-attributes-list. For the \"span\" breakdown type, must be one of the allowlisted top-level columns: \"service_name\", \"status_code\".'
),
breakdownType: zod
- .enum(['span_attribute', 'span_resource_attribute'])
+ .enum(['span', 'span_attribute', 'span_resource_attribute'])
.describe(
- '\* `span_attribute` - span_attribute\n\* `span_resource_attribute` - span_resource_attribute'
+ '\* `span` - span\n\* `span_attribute` - span_attribute\n\* `span_resource_attribute` - span_resource_attribute'
)
.describe(
- 'Where the key lives: \"span_attribute\" for span-level attributes, \"span_resource_attribute\" for resource-level attributes.\n\n\* `span_attribute` - span_attribute\n\* `span_resource_attribute` - span_resource_attribute'
+ 'Where the key lives: \"span\" for allowlisted top-level span columns, \"span_attribute\" for span-level attributes, \"span_resource_attribute\" for resource-level attributes.\n\n\* `span` - span\n\* `span_attribute` - span_attribute\n\* `span_resource_attribute` - span_resource_attribute'
+ ),
+ excludeBreakdownFilter: zod
+ .boolean()
+ .default(tracingSpansAttributeBreakdownCreateBodyQueryOneExcludeBreakdownFilterDefault)
+ .describe(
+ "Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected."
),
orderBy: zod
.enum(['count', 'error_count'])
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index e5619e67ffd7..95d521b1ad34 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -11792,18 +11792,6 @@ export namespace Schemas {
value: string | number;
}
- /**
- * * `span_attribute` - span_attribute
- * * `span_resource_attribute` - span_resource_attribute
- */
- export type BreakdownTypeEnum = typeof BreakdownTypeEnum[keyof typeof BreakdownTypeEnum];
-
-
- export const BreakdownTypeEnum = {
- SpanAttribute: 'span_attribute',
- SpanResourceAttribute: 'span_resource_attribute',
- } as const;
-
export interface BreakdownValue {
count: number;
value: string;
@@ -27463,6 +27451,7 @@ export namespace Schemas {
export const TraceSpanBreakdownType = {
+ Span: 'span',
SpanAttribute: 'span_attribute',
SpanResourceAttribute: 'span_resource_attribute',
} as const;
@@ -27498,13 +27487,15 @@ export namespace Schemas {
}
export interface TraceSpansAttributeBreakdownQuery {
- /** Attribute key to group by (e.g. `http.response.status_code`, `server.address`). */
+ /** Attribute key to group by (e.g. `http.response.status_code`, `server.address`). For the `span` breakdown type, must be an allowlisted top-level column (`service_name`, `status_code`). */
breakdownKey: string;
- /** Where the key lives: span-level attributes or resource-level attributes. */
+ /** Where the key lives: an allowlisted top-level span column, span-level attributes, or resource-level attributes. */
breakdownType: TraceSpanBreakdownType;
/** Optional comparison window — when `compare` is true, the runner returns an extra `compare` result set. */
compareFilter?: CompareFilter | null;
dateRange: DateRange;
+ /** Drop filters targeting the breakdown key itself (including `serviceNames` for a `service_name` breakdown) so a facet's value list stays complete while one of its values is selected. */
+ excludeBreakdownFilter?: boolean | null;
filterGroup?: PropertyGroupFilter | null;
kind?: 'TraceSpansAttributeBreakdownQuery';
/** Modifiers used when performing the query */
@@ -53383,6 +53374,20 @@ export namespace Schemas {
webhook?: SourceSetupWebhook;
}
+ /**
+ * * `span` - span
+ * * `span_attribute` - span_attribute
+ * * `span_resource_attribute` - span_resource_attribute
+ */
+ export type SpanPropertyTypeEnum = typeof SpanPropertyTypeEnum[keyof typeof SpanPropertyTypeEnum];
+
+
+ export const SpanPropertyTypeEnum = {
+ Span: 'span',
+ SpanAttribute: 'span_attribute',
+ SpanResourceAttribute: 'span_resource_attribute',
+ } as const;
+
/**
* * `severity` - severity
* * `service` - service
@@ -57559,20 +57564,6 @@ export namespace Schemas {
results: _MetricEventSample[];
}
- /**
- * * `span` - span
- * * `span_attribute` - span_attribute
- * * `span_resource_attribute` - span_resource_attribute
- */
- export type _SpanPropertyFilterTypeEnum = typeof _SpanPropertyFilterTypeEnum[keyof typeof _SpanPropertyFilterTypeEnum];
-
-
- export const _SpanPropertyFilterTypeEnum = {
- Span: 'span',
- SpanAttribute: 'span_attribute',
- SpanResourceAttribute: 'span_resource_attribute',
- } as const;
-
/**
* * `exact` - exact
* * `is_not` - is_not
@@ -57609,7 +57600,7 @@ export namespace Schemas {
* * `span` - span
* * `span_attribute` - span_attribute
* * `span_resource_attribute` - span_resource_attribute */
- type: _SpanPropertyFilterTypeEnum;
+ type: SpanPropertyTypeEnum;
/** Comparison operator.
*
* * `exact` - exact
@@ -57786,13 +57777,16 @@ export namespace Schemas {
} as const;
export interface _TracingAttributeBreakdownQueryBody {
- /** Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. */
+ /** Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. For the "span" breakdown type, must be one of the allowlisted top-level columns: "service_name", "status_code". */
breakdownKey: string;
- /** Where the key lives: "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.
+ /** Where the key lives: "span" for allowlisted top-level span columns, "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.
*
+ * * `span` - span
* * `span_attribute` - span_attribute
* * `span_resource_attribute` - span_resource_attribute */
- breakdownType: BreakdownTypeEnum;
+ breakdownType: SpanPropertyTypeEnum;
+ /** Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected. */
+ excludeBreakdownFilter?: boolean;
/** Order rows by span count or error count, descending. Defaults to count.
*
* * `count` - count
diff --git a/services/mcp/src/generated/tracing/api.ts b/services/mcp/src/generated/tracing/api.ts
index 761fa8376cc0..aec1e7a61234 100644
--- a/services/mcp/src/generated/tracing/api.ts
+++ b/services/mcp/src/generated/tracing/api.ts
@@ -114,6 +114,7 @@ export const TracingSpansAttributeBreakdownCreateParams = /* @__PURE__ */ zod.ob
),
})
+export const tracingSpansAttributeBreakdownCreateBodyQueryOneExcludeBreakdownFilterDefault = false
export const tracingSpansAttributeBreakdownCreateBodyQueryOneCompareFilterOneCompareDefault = false
export const tracingSpansAttributeBreakdownCreateBodyQueryOneFilterGroupDefault = []
@@ -123,13 +124,21 @@ export const TracingSpansAttributeBreakdownCreateBody = /* @__PURE__ */ zod.obje
breakdownKey: zod
.string()
.describe(
- 'Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list.'
+ 'Attribute key to group by (e.g. "server.address", "http.response.status_code"). Discover keys with apm-attributes-list. For the "span" breakdown type, must be one of the allowlisted top-level columns: "service_name", "status_code".'
),
breakdownType: zod
- .enum(['span_attribute', 'span_resource_attribute'])
- .describe('* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute')
+ .enum(['span', 'span_attribute', 'span_resource_attribute'])
.describe(
- 'Where the key lives: "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.\n\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute'
+ '* `span` - span\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute'
+ )
+ .describe(
+ 'Where the key lives: "span" for allowlisted top-level span columns, "span_attribute" for span-level attributes, "span_resource_attribute" for resource-level attributes.\n\n* `span` - span\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute'
+ ),
+ excludeBreakdownFilter: zod
+ .boolean()
+ .default(tracingSpansAttributeBreakdownCreateBodyQueryOneExcludeBreakdownFilterDefault)
+ .describe(
+ "Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected."
),
orderBy: zod
.enum(['count', 'error_count'])
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/apm-attribute-breakdown.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/apm-attribute-breakdown.json
index b49984b48442..31e56d1ec014 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/apm-attribute-breakdown.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/apm-attribute-breakdown.json
@@ -5,12 +5,12 @@
"description": "The attribute breakdown query to execute.",
"properties": {
"breakdownKey": {
- "description": "Attribute key to group by (e.g. \"server.address\", \"http.response.status_code\"). Discover keys with apm-attributes-list.",
+ "description": "Attribute key to group by (e.g. \"server.address\", \"http.response.status_code\"). Discover keys with apm-attributes-list. For the \"span\" breakdown type, must be one of the allowlisted top-level columns: \"service_name\", \"status_code\".",
"type": "string"
},
"breakdownType": {
- "description": "Where the key lives: \"span_attribute\" for span-level attributes, \"span_resource_attribute\" for resource-level attributes.\n\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute",
- "enum": ["span_attribute", "span_resource_attribute"],
+ "description": "Where the key lives: \"span\" for allowlisted top-level span columns, \"span_attribute\" for span-level attributes, \"span_resource_attribute\" for resource-level attributes.\n\n* `span` - span\n* `span_attribute` - span_attribute\n* `span_resource_attribute` - span_resource_attribute",
+ "enum": ["span", "span_attribute", "span_resource_attribute"],
"type": "string"
},
"compareFilter": {
@@ -63,6 +63,11 @@
},
"type": "object"
},
+ "excludeBreakdownFilter": {
+ "default": false,
+ "description": "Drop filters targeting the breakdown key itself (including serviceNames for a service_name breakdown), so a facet's value list stays complete while one of its values is selected.",
+ "type": "boolean"
+ },
"filterGroup": {
"default": [],
"description": "Property filters scoping the spans the breakdown runs over (e.g. only error spans).",