: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tracing): add facet config and cross-filtered facet counts logic (#69711)
Jon McCallumdd361b502dad
diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex dbfc4397b20e..3395e527028a 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -4377,6 +4377,9 @@ importers:kea-router:specifier: 'catalog:'version: 3.4.1([email protected]([email protected]))+ kea-subscriptions:+ specifier: 'catalog:'+ version: 3.0.1([email protected]([email protected]))posthog-js:specifier: 'catalog:'version: 1.399.2diff --git a/products/tracing/backend/attribute_breakdown_query_runner.py b/products/tracing/backend/attribute_breakdown_query_runner.pyindex dbff6d1a48de..f5d3c1804707 100644--- a/products/tracing/backend/attribute_breakdown_query_runner.py+++ b/products/tracing/backend/attribute_breakdown_query_runner.py@@ -66,8 +66,10 @@ class TraceSpansAttributeBreakdownQueryRunner(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+ # The dedicated service filter targets the same column as the breakdown. Swap in a+ # copy rather than mutating in place — the caller's query object must keep+ # reflecting the request as made.+ self.query = self.query.model_copy(update={"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"}@@ -114,7 +116,7 @@ class TraceSpansAttributeBreakdownQueryRunner(GROUP BY valueORDER BY """+ order_column- + """ DESC+ + """ DESC, value ASCLIMIT {limit}""",placeholders={diff --git a/products/tracing/backend/presentation/views.py b/products/tracing/backend/presentation/views.pyindex 809fbae2a0be..728c13bd7511 100644--- a/products/tracing/backend/presentation/views.py+++ b/products/tracing/backend/presentation/views.py@@ -407,6 +407,28 @@ class _TracingAttributeBreakdownRequestSerializer(serializers.Serializer):query = _TracingAttributeBreakdownQueryBodySerializer(help_text="The attribute breakdown query to execute.")+class _TracingAttributeBreakdownRowSerializer(serializers.Serializer):+ value = serializers.CharField(+ help_text="The attribute's value for this group. Spans without the attribute group under ''."+ )+ count = serializers.IntegerField(help_text="Number of matching spans with this value.")+ error_count = serializers.IntegerField(help_text="Number of matching error spans (status_code = 2).")+ p50_duration_nano = serializers.FloatField(help_text="Median span duration in nanoseconds.")+ p95_duration_nano = serializers.FloatField(help_text="95th percentile span duration in nanoseconds.")+++class _TracingAttributeBreakdownResponseSerializer(serializers.Serializer):+ results = _TracingAttributeBreakdownRowSerializer(+ many=True,+ help_text="One row per distinct attribute value, ordered by the requested column descending.",+ )+ compare = _TracingAttributeBreakdownRowSerializer(+ many=True,+ allow_null=True,+ help_text="Rows for the comparison window when compareFilter.compare is true, else null.",+ )++class _TracingTreeQueryBodySerializer(serializers.Serializer):spanName = serializers.CharField(required=True,@@ -1023,7 +1045,10 @@ class SpansViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet)status=status.HTTP_200_OK,)- @extend_schema(request=_TracingAttributeBreakdownRequestSerializer)+ @extend_schema(+ request=_TracingAttributeBreakdownRequestSerializer,+ responses={200: _TracingAttributeBreakdownResponseSerializer},+ )@action(detail=False, methods=["POST"], url_path="attribute-breakdown", required_scopes=["tracing:read"])def attribute_breakdown(self, request: Request, *args, **kwargs) -> Response:tag_queries(product=ProductKey.TRACING, feature=Feature.QUERY)diff --git a/products/tracing/frontend/components/FacetRail/facetCountsLogic.ts b/products/tracing/frontend/components/FacetRail/facetCountsLogic.tsnew file mode 100644index 000000000000..e938fd73431c--- /dev/null+++ b/products/tracing/frontend/components/FacetRail/facetCountsLogic.ts@@ -0,0 +1,199 @@+import { connect, events, kea, key, listeners, path, props, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'+import { subscriptions } from 'kea-subscriptions'++import { teamLogic } from 'scenes/teamLogic'++import { DateRange } from '~/queries/schema/schema-general'+import { UniversalFiltersGroup } from '~/types'++import {+ TRACING_SCENE_VIEWER_ID,+ tracingFiltersLogic,+ TracingFiltersLogicProps,+} from 'products/tracing/frontend/tracingFiltersLogic'++import { tracingSpansAttributeBreakdownCreate, tracingSpansAttributesRetrieve } from '../../generated/api'+import {+ _SpanPropertyFilterApi,+ _SpanPropertyFilterOperatorEnumApi,+ _TracingAttributeBreakdownRowApi,+ SpanPropertyTypeEnumApi,+ TracingSpansAttributesRetrieveAttributeType,+} from '../../generated/api.schemas'+import type { facetCountsLogicType } from './facetCountsLogicType'+import { FACETS, FacetConfig, innerFilters } from './facets'++export interface FacetCountsLogicProps {+ id: string+}++/** The query-relevant slice of filter state — the breakdown requests read exactly these three. */+export interface BreakdownScope {+ utcDateRange: DateRange+ serviceNames: string[]+ queryFilterGroup: UniversalFiltersGroup+}++/**+ * Per-facet values + counts, cross-filtered server-side: each facet's results reflect every active+ * filter except its own selection (excludeBreakdownFilter drops the facet's own column, serviceNames,+ * or attribute filter). Values come back ordered by count descending. The rail is config-driven, so+ * this fetches one attribute-breakdown request per facet in FACETS, keyed by facet.key.+ */+export const facetCountsLogic = kea<facetCountsLogicType>([+ props({ id: TRACING_SCENE_VIEWER_ID } as FacetCountsLogicProps),+ key((props) => props.id),+ path((key) => ['products', 'tracing', 'frontend', 'components', 'FacetRail', 'facetCountsLogic', key]),++ connect((props: FacetCountsLogicProps) => ({+ values: [+ tracingFiltersLogic({ id: props.id } as TracingFiltersLogicProps),+ ['serviceNames', 'utcDateRange', 'queryFilterGroup'],+ teamLogic,+ ['currentTeamId'],+ ],+ })),++ reducers({+ // Latches true once the presence probe settles (success or failure). Until then the value+ // fetch is deferred, so column facets aren't fetched on mount and then re-fetched once+ // presence resolves and the resource-attribute facets become visible.+ presenceLoaded: [+ false,+ {+ loadPresentResourceKeysSuccess: () => true,+ loadPresentResourceKeysFailure: () => true,+ },+ ],+ }),++ loaders(({ values }) => {+ const fetchFacet = async (facet: FacetConfig): Promise<_TracingAttributeBreakdownRowApi[]> => {+ if (!values.currentTeamId) {+ return []+ }+ // The endpoint takes the flat inner filter list. The stored filters carry the app-side+ // enums (PropertyFilterType/PropertyOperator) which are nominally distinct from the+ // generated string-union enums despite identical runtime values, so mapping onto the+ // generated shape type-checks the field structure (key/value) while casting only the two+ // enum fields.+ const filterGroup: _SpanPropertyFilterApi[] = innerFilters(values.queryFilterGroup).map((f) => ({+ key: f.key,+ type: f.type as unknown as SpanPropertyTypeEnumApi,+ operator: f.operator as unknown as _SpanPropertyFilterOperatorEnumApi,+ value: f.value,+ }))+ const target =+ facet.source.type === 'column'+ ? { breakdownKey: facet.source.column, breakdownType: SpanPropertyTypeEnumApi.Span }+ : { breakdownKey: facet.source.key, breakdownType: SpanPropertyTypeEnumApi.SpanResourceAttribute }+ const response = await tracingSpansAttributeBreakdownCreate(String(values.currentTeamId), {+ query: {+ ...target,+ excludeBreakdownFilter: true,+ dateRange: values.utcDateRange,+ serviceNames: values.serviceNames ?? [],+ filterGroup,+ },+ })+ return response.results+ }++ // Fetch each facet independently and merge into the existing record. allSettled (not all) so+ // one facet's failed request leaves the others' counts intact instead of wiping the batch.+ const mergeFetched = async (+ facets: FacetConfig[]+ ): Promise<Record<string, _TracingAttributeBreakdownRowApi[]>> => {+ const settled = await Promise.allSettled(+ facets.map(async (facet) => [facet.key, await fetchFacet(facet)] as const)+ )+ const fetched = settled+ .filter(+ (s): s is PromiseFulfilledResult<readonly [string, _TracingAttributeBreakdownRowApi[]]> =>+ s.status === 'fulfilled'+ )+ .map((s) => s.value)+ return { ...values.facetValues, ...Object.fromEntries(fetched) }+ }++ return {+ facetValues: [+ {} as Record<string, _TracingAttributeBreakdownRowApi[]>,+ {+ // Refetch all facets (null) or a subset — used when filters change.+ loadFacetValues: async (facetKeys: string[] | null, breakpoint) => {+ await breakpoint(300)+ const facets = facetKeys+ ? values.visibleFacets.filter((f) => facetKeys.includes(f.key))+ : values.visibleFacets+ const result = await mergeFetched(facets)+ breakpoint()+ return result+ },+ },+ ],+ presentResourceKeys: [+ [] as string[],+ {+ // Which resource attribute keys the tenant emits — gates which curated facets render.+ // Reads the trace_attributes rollup keys-only; no date range parameter (server default window).+ loadPresentResourceKeys: async () => {+ if (!values.currentTeamId) {+ return []+ }+ const response = await tracingSpansAttributesRetrieve(String(values.currentTeamId), {+ attribute_type: TracingSpansAttributesRetrieveAttributeType.SpanResourceAttribute,+ limit: 100,+ })+ return response.results.map((r) => r.name)+ },+ },+ ],+ }+ }),++ selectors({+ // Column facets always render; resource-attribute facets only when the tenant emits the key.+ visibleFacets: [+ (s) => [s.presentResourceKeys],+ (presentResourceKeys): FacetConfig[] =>+ FACETS.filter((f) => f.source.type === 'column' || presentResourceKeys.includes(f.source.key)),+ ],+ // The subset of filter state the breakdown queries actually depend on, built from the stable+ // leaf values — not the `filters` roll-up, which also carries presentation state (viewMode,+ // orderBy, compareMode, overlay windows) and gets a new identity whenever any of it changes.+ // Subscribing to this keeps a view-mode or sort toggle from refetching every facet.+ breakdownScope: [+ (s) => [s.utcDateRange, s.serviceNames, s.queryFilterGroup],+ (utcDateRange, serviceNames, queryFilterGroup): BreakdownScope => ({+ utcDateRange,+ serviceNames,+ queryFilterGroup,+ }),+ ],+ }),++ listeners(({ actions }) => ({+ // Presence settled — drive the first full fetch now that visibleFacets is known. On failure+ // we still fetch so the column facets (Service/Status) load even if the probe errored.+ loadPresentResourceKeysSuccess: () => actions.loadFacetValues(null),+ loadPresentResourceKeysFailure: () => actions.loadFacetValues(null),+ })),++ events(({ actions }) => ({+ afterMount: () => actions.loadPresentResourceKeys(),+ })),++ subscriptions(({ actions, values }) => ({+ // Fires on any change to the query-relevant filter state (date range, services, filter group+ // including an embedder's pinned scope). Before the presence probe settles, defer to+ // loadPresentResourceKeys{Success,Failure} so we issue one full fetch over the final visible+ // set instead of two.+ breakdownScope: () => {+ if (values.presenceLoaded) {+ actions.loadFacetValues(null)+ }+ },+ })),+])diff --git a/products/tracing/frontend/components/FacetRail/facets.test.ts b/products/tracing/frontend/components/FacetRail/facets.test.tsnew file mode 100644index 000000000000..574f0cf38fbb--- /dev/null+++ b/products/tracing/frontend/components/FacetRail/facets.test.ts@@ -0,0 +1,74 @@+import { FilterLogicalOperator, PropertyFilterType, PropertyOperator, UniversalFiltersGroup } from '~/types'++import { FilterGroupFacetSource, facetFilterValues, toggleFacetFilter } from './facets'++const STATUS_SOURCE: FilterGroupFacetSource = { type: 'column', column: 'status_code' }+const POD_SOURCE: FilterGroupFacetSource = { type: 'resourceAttribute', key: 'k8s.pod.name' }++function groupWith(values: object[]): UniversalFiltersGroup {+ return {+ type: FilterLogicalOperator.And,+ values: [{ type: FilterLogicalOperator.And, values: values as UniversalFiltersGroup['values'] }],+ }+}++describe('facets', () => {+ describe('toggleFacetFilter / facetFilterValues', () => {+ it.each<[string, FilterGroupFacetSource, PropertyFilterType]>([+ ['column facet writes a span filter', STATUS_SOURCE, PropertyFilterType.Span],+ [+ 'resource-attribute facet writes a span_resource_attribute filter',+ POD_SOURCE,+ PropertyFilterType.SpanResourceAttribute,+ ],+ ])('%s', (_, source, expectedType) => {+ const group = toggleFacetFilter(undefined, source, 'a')+ const inner = (group.values[0] as UniversalFiltersGroup).values+ expect(inner).toEqual([+ expect.objectContaining({ type: expectedType, operator: PropertyOperator.Exact, value: ['a'] }),+ ])+ expect(facetFilterValues(group, source)).toEqual(['a'])+ })++ it('accumulates values on repeated toggles and removes on re-toggle', () => {+ let group = toggleFacetFilter(undefined, POD_SOURCE, 'pod-a')+ group = toggleFacetFilter(group, POD_SOURCE, 'pod-b')+ expect(facetFilterValues(group, POD_SOURCE)).toEqual(['pod-a', 'pod-b'])++ group = toggleFacetFilter(group, POD_SOURCE, 'pod-a')+ expect(facetFilterValues(group, POD_SOURCE)).toEqual(['pod-b'])+ })++ it('drops the filter entirely when the last value is toggled off', () => {+ const group = toggleFacetFilter(toggleFacetFilter(undefined, POD_SOURCE, 'pod-a'), POD_SOURCE, 'pod-a')+ expect((group.values[0] as UniversalFiltersGroup).values).toEqual([])+ })++ it('preserves unrelated filters, including a same-key filter of a different type', () => {+ // A span *attribute* also named k8s.pod.name must not be clobbered by the+ // resource-attribute facet — the two live in different filter types.+ const other = {+ key: 'k8s.pod.name',+ type: PropertyFilterType.SpanAttribute,+ operator: PropertyOperator.IContains,+ value: 'pod',+ }+ const group = toggleFacetFilter(groupWith([other]), POD_SOURCE, 'pod-a')+ const inner = (group.values[0] as UniversalFiltersGroup).values+ expect(inner).toEqual([other, expect.objectContaining({ type: PropertyFilterType.SpanResourceAttribute })])+ expect(facetFilterValues(group, POD_SOURCE)).toEqual(['pod-a'])+ })++ it('reads a scalar filter value written outside the rail as a single selection', () => {+ const group = groupWith([+ {+ key: 'status_code',+ type: PropertyFilterType.Span,+ operator: PropertyOperator.Exact,+ value: 'Error',+ },+ ])+ expect(facetFilterValues(group, STATUS_SOURCE)).toEqual(['Error'])+ })+ })+})diff --git a/products/tracing/frontend/components/FacetRail/facets.ts b/products/tracing/frontend/components/FacetRail/facets.tsnew file mode 100644index 000000000000..a56f79b336f6--- /dev/null+++ b/products/tracing/frontend/components/FacetRail/facets.ts@@ -0,0 +1,207 @@+import {+ FilterLogicalOperator,+ PropertyFilterType,+ PropertyFilterValue,+ PropertyOperator,+ UniversalFiltersGroup,+} from '~/types'++/** One selectable row in a facet: a value with its span count. */+export interface FacetOption {+ value: string+ label: string+ count: number+}++/**+ * Whether a facet's value set is known ahead of time or discovered from the data.+ *+ * - `fixed`: a closed enum defined here in code (e.g. span status). The full list is rendered+ * regardless of the data; values with a zero count show dimmed rather than disappearing.+ * - `dynamic`: values come back from the data at query time (e.g. service names) and change with+ * the active filters. Only values present in the current scope appear — zeros never show.+ */+export type FacetKind = 'fixed' | 'dynamic'++/** Top-level trace_spans columns a facet may group by (matches backend FACET_COLUMNS). */+export type FacetColumn = 'service_name' | 'status_code'++/**+ * Where a facet's field lives, which determines both how it's queried and how its selection is stored.+ *+ * - `column`: an allowlisted top-level span column, queried with breakdownType `span`. `service_name`'s+ * selection lives in the dedicated `serviceNames` filter field; `status_code`'s in a span property filter.+ * - `resourceAttribute`: a `resource_attributes` map key (e.g. k8s.namespace.name), queried with+ * breakdownType `span_resource_attribute`. Selection is a span_resource_attribute property filter.+ */+export type FacetSource = { type: 'column'; column: FacetColumn } | { type: 'resourceAttribute'; key: string }++/**+ * The sources whose selection lives in the filterGroup. `service_name` is deliberately excluded:+ * its selection belongs in `tracingFiltersLogic.serviceNames` (the field the span queries read) —+ * writing it as a filterGroup property filter would silently not scope the trace list.+ */+export type FilterGroupFacetSource =+ | { type: 'column'; column: Exclude<FacetColumn, 'service_name'> }+ | { type: 'resourceAttribute'; key: string }++export interface FacetConfig {+ /** Stable id used for collapse state and data-attrs. */+ key: string+ /** User-facing field name shown as the facet header. */+ title: string+ /** Header the facet is grouped under in the rail (e.g. "Standard"). */+ group: string+ kind: FacetKind+ source: FacetSource+ /** Required for `fixed` facets: the closed value set with labels. */+ fixedOptions?: FacetOption[]+ /** Renders a search box and virtualizes the list — for `dynamic` facets with many values. */+ searchable?: boolean+ searchPlaceholder?: string+ emptyLabel?: string+}++interface SpanFacetFilter {+ key: string+ type: PropertyFilterType.Span | PropertyFilterType.SpanResourceAttribute+ operator: PropertyOperator+ value?: PropertyFilterValue+}++/**+ * The editable property filters of a tracing filterGroup, which is always+ * { AND, values: [{ AND, values: [<property filters>] }] } — the filters live in the single inner group.+ */+export function innerFilters(group: UniversalFiltersGroup | undefined): SpanFacetFilter[] {+ return ((group?.values?.[0] as UniversalFiltersGroup | undefined)?.values ?? []) as SpanFacetFilter[]+}++/** The property filter home for a facet's selection: span filters for status_code, resource-attribute filters otherwise. */+function facetFilterType(+ source: FilterGroupFacetSource+): PropertyFilterType.Span | PropertyFilterType.SpanResourceAttribute {+ return source.type === 'column' ? PropertyFilterType.Span : PropertyFilterType.SpanResourceAttribute+}++function facetFilterKey(source: FilterGroupFacetSource): string {+ return source.type === 'column' ? source.column : source.key+}++function isFacetFilter(filter: SpanFacetFilter, source: FilterGroupFacetSource): boolean {+ return filter?.type === facetFilterType(source) && filter?.key === facetFilterKey(source)+}++/**+ * Values currently selected for a facet whose selection lives in the filterGroup (status_code and+ * resource attributes — service_name reads the dedicated serviceNames field instead).+ */+export function facetFilterValues(group: UniversalFiltersGroup | undefined, source: FilterGroupFacetSource): string[] {+ const existing = innerFilters(group).find((f) => isFacetFilter(f, source))+ const value = existing?.value+ if (Array.isArray(value)) {+ return value.map(String)+ }+ return value != null && value !== '' ? [String(value)] : []+}++/**+ * Add or remove `value` from a facet's filterGroup selection, returning a new filterGroup.+ * Multi-select is one property filter per key with an array value.+ */+export function toggleFacetFilter(+ group: UniversalFiltersGroup | undefined,+ source: FilterGroupFacetSource,+ value: string+): UniversalFiltersGroup {+ const current = facetFilterValues(group, source)+ const next = current.includes(value) ? current.filter((v) => v !== value) : [...current, value]+ const others = innerFilters(group).filter((f) => !isFacetFilter(f, source))+ const values: SpanFacetFilter[] =+ next.length > 0+ ? [+ ...others,+ {+ key: facetFilterKey(source),+ type: facetFilterType(source),+ operator: PropertyOperator.Exact,+ value: next,+ },+ ]+ : others+ return { type: FilterLogicalOperator.And, values: [{ type: FilterLogicalOperator.And, values }] }+}++// OTel span status. Values must stay the digit strings "0"/"1"/"2": breakdown rows arrive+// stringified (the backend toString()s the Int16 column), so these are what counts key on.+// Don't switch to the label strings — the server-side filter normaliser treats "OK" as+// {Unset, OK}, which would silently widen a selection.+const STATUS_OPTIONS: FacetOption[] = [+ { value: '0', label: 'Unset', count: 0 },+ { value: '1', label: 'OK', count: 0 },+ { value: '2', label: 'Error', count: 0 },+]++const SERVICE_FACET: FacetConfig = {+ key: 'service',+ title: 'Service',+ group: 'Standard',+ kind: 'dynamic',+ source: { type: 'column', column: 'service_name' },+ searchable: true,+ searchPlaceholder: 'Search services…',+ emptyLabel: 'No services',+}++const STATUS_FACET: FacetConfig = {+ key: 'status',+ title: 'Status',+ group: 'Standard',+ kind: 'fixed',+ source: { type: 'column', column: 'status_code' },+ fixedOptions: STATUS_OPTIONS,+}++// Curated OTel resource attributes worth faceting. Keys are the stable OTel semantic-convention names;+// `deployment.environment.name` is the 1.27+ stable key (older data may use `deployment.environment`).+function resourceAttributeFacet(key: string, slug: string, title: string, group: string): FacetConfig {+ return {+ key: slug,+ title,+ group,+ kind: 'dynamic',+ source: { type: 'resourceAttribute', key },+ searchable: true,+ searchPlaceholder: `Search ${title.toLowerCase()}…`,+ emptyLabel: `No ${title.toLowerCase()} values`,+ }+}++const ENVIRONMENT_FACET = resourceAttributeFacet(+ 'deployment.environment.name',+ 'environment',+ 'Environment',+ 'Standard'+)+const VERSION_FACET = resourceAttributeFacet('service.version', 'version', 'Version', 'Standard')+const NAMESPACE_FACET = resourceAttributeFacet('k8s.namespace.name', 'namespace', 'Namespace', 'Kubernetes')+const DEPLOYMENT_FACET = resourceAttributeFacet('k8s.deployment.name', 'deployment', 'Deployment', 'Kubernetes')+const HOST_FACET = resourceAttributeFacet('host.name', 'host', 'Host', 'Infrastructure')++/**+ * The rail is rendered entirely from this list — append a config to add a facet (or a new group).+ * Ordered by group (Standard → Kubernetes → Infrastructure) since facetsByGroup keeps first-appearance order.+ * Resource-attribute facets only render when the tenant actually emits the key (see facetCountsLogic).+ */+export const FACETS: FacetConfig[] = [+ SERVICE_FACET,+ STATUS_FACET,+ ENVIRONMENT_FACET,+ VERSION_FACET,+ NAMESPACE_FACET,+ DEPLOYMENT_FACET,+ HOST_FACET,+]++// List-shaping helpers for rendering the rail (grouping, name search, merging selected values+// into fetched options) land with their consumer, the Facet/FacetRail components.diff --git a/products/tracing/frontend/generated/api.schemas.ts b/products/tracing/frontend/generated/api.schemas.tsindex 7c003c07899b..d3596abc0e43 100644--- a/products/tracing/frontend/generated/api.schemas.ts+++ b/products/tracing/frontend/generated/api.schemas.ts@@ -156,6 +156,29 @@ export interface _TracingAttributeBreakdownRequestApi {query: _TracingAttributeBreakdownQueryBodyApi}+export interface _TracingAttributeBreakdownRowApi {+ /** The attribute's value for this group. Spans without the attribute group under ''. */+ value: string+ /** Number of matching spans with this value. */+ count: number+ /** Number of matching error spans (status_code = 2). */+ error_count: number+ /** Median span duration in nanoseconds. */+ p50_duration_nano: number+ /** 95th percentile span duration in nanoseconds. */+ p95_duration_nano: number+}++export interface _TracingAttributeBreakdownResponseApi {+ /** One row per distinct attribute value, ordered by the requested column descending. */+ results: _TracingAttributeBreakdownRowApi[]+ /**+ * Rows for the comparison window when compareFilter.compare is true, else null.+ * @nullable+ */+ compare: _TracingAttributeBreakdownRowApi[] | null+}+/*** * `key` - key* * `value` - valuediff --git a/products/tracing/frontend/generated/api.ts b/products/tracing/frontend/generated/api.tsindex 22b1ccafd67b..1e61210f1e4f 100644--- a/products/tracing/frontend/generated/api.ts+++ b/products/tracing/frontend/generated/api.ts@@ -21,6 +21,7 @@ import type {_SymbolStatsResponseApi,_TracingAggregationRequestApi,_TracingAttributeBreakdownRequestApi,+ _TracingAttributeBreakdownResponseApi,_TracingAttributesResponseApi,_TracingCountRequestApi,_TracingCountResponseApi,@@ -73,8 +74,8 @@ export const tracingSpansAttributeBreakdownCreate = async (projectId: string,_tracingAttributeBreakdownRequestApi: _TracingAttributeBreakdownRequestApi,options?: RequestInit-): Promise<void> => {- return apiMutator<void>(getTracingSpansAttributeBreakdownCreateUrl(projectId), {+): Promise<_TracingAttributeBreakdownResponseApi> => {+ return apiMutator<_TracingAttributeBreakdownResponseApi>(getTracingSpansAttributeBreakdownCreateUrl(projectId), {...options,method: 'POST',headers: { 'Content-Type': 'application/json', ...options?.headers },diff --git a/products/tracing/package.json b/products/tracing/package.jsonindex 3e7b3f89d856..2b41358ccc2f 100644--- a/products/tracing/package.json+++ b/products/tracing/package.json@@ -7,6 +7,7 @@"kea": "catalog:","kea-loaders": "catalog:","kea-router": "catalog:",+ "kea-subscriptions": "catalog:","posthog-js": "catalog:"},"devDependencies": {diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 71ff5a910b19..640a608416a1 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -59625,6 +59625,29 @@ export namespace Schemas {query: _TracingAttributeBreakdownQueryBody;}+ export interface _TracingAttributeBreakdownRow {+ /** The attribute's value for this group. Spans without the attribute group under ''. */+ value: string;+ /** Number of matching spans with this value. */+ count: number;+ /** Number of matching error spans (status_code = 2). */+ error_count: number;+ /** Median span duration in nanoseconds. */+ p50_duration_nano: number;+ /** 95th percentile span duration in nanoseconds. */+ p95_duration_nano: number;+ }++ export interface _TracingAttributeBreakdownResponse {+ /** One row per distinct attribute value, ordered by the requested column descending. */+ results: _TracingAttributeBreakdownRow[];+ /**+ * Rows for the comparison window when compareFilter.compare is true, else null.+ * @nullable+ */+ compare: _TracingAttributeBreakdownRow[] | null;+ }+export interface _TracingAttributeEntry {/** Attribute key name. */name: string;diff --git a/services/mcp/src/tools/generated/tracing.ts b/services/mcp/src/tools/generated/tracing.tsindex f0167395c7e4..ab06266dfb90 100644--- a/services/mcp/src/tools/generated/tracing.ts+++ b/services/mcp/src/tools/generated/tracing.ts@@ -22,7 +22,10 @@ import type { Context, ToolBase, ZodObjectAny } from '@/tools/types'const ApmAttributeBreakdownSchema = TracingSpansAttributeBreakdownCreateBody-const apmAttributeBreakdown = (): ToolBase<typeof ApmAttributeBreakdownSchema, unknown> => ({+const apmAttributeBreakdown = (): ToolBase<+ typeof ApmAttributeBreakdownSchema,+ Schemas._TracingAttributeBreakdownResponse+> => ({name: 'apm-attribute-breakdown',schema: ApmAttributeBreakdownSchema,handler: async (context: Context, params: z.infer<typeof ApmAttributeBreakdownSchema>) => {@@ -31,7 +34,7 @@ const apmAttributeBreakdown = (): ToolBase<typeof ApmAttributeBreakdownSchema, uif (params.query !== undefined) {body['query'] = params.query}- const result = await context.api.request<unknown>({+ const result = await context.api.request<Schemas._TracingAttributeBreakdownResponse>({method: 'POST',path: `/api/projects/${encodeURIComponent(String(projectId))}/tracing/spans/attribute-breakdown/`,body,