: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 endpoints display mode (#125512)
Jon McCallum848c28ee662f
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex 8360468589f3..1e19436df6c0 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -2897,6 +2897,7 @@ const api = {limit?: numberoffset?: numberincludeImpact?: boolean+ groupByEndpoint?: boolean},signal?: AbortSignal): Promise<{diff --git a/products/tracing/frontend/OperationsTable.tsx b/products/tracing/frontend/OperationsTable.tsxindex 8029cbe9c77e..3b4f0220d585 100644--- a/products/tracing/frontend/OperationsTable.tsx+++ b/products/tracing/frontend/OperationsTable.tsx@@ -56,7 +56,11 @@ const impactCell =)}-function buildColumns(windowMs: number, showImpact: boolean): VirtualizedTableColumn<AggregatedSpanRow>[] {+function buildColumns(+ windowMs: number,+ showImpact: boolean,+ groupedByEndpoint: boolean+): VirtualizedTableColumn<AggregatedSpanRow>[] {const impactColumns: VirtualizedTableColumn<AggregatedSpanRow>[] = showImpact? [{@@ -96,7 +100,7 @@ function buildColumns(windowMs: number, showImpact: boolean): VirtualizedTableCo},{key: 'name',- title: 'Operation',+ title: groupedByEndpoint ? 'Endpoint' : 'Operation',width: 320,grow: true,sorter: (a, b) => a.name.localeCompare(b.name),@@ -195,6 +199,8 @@ export interface OperationsTableProps {windowMs: number/** Show the Sessions and Users columns. Must match the `includeImpact` the rows were fetched with. */showImpact?: boolean+ /** Rows are `METHOD route` endpoints. Must match the `groupByEndpoint` the rows were fetched with. */+ groupedByEndpoint?: booleanonRowClick?: (row: AggregatedSpanRow) => void}@@ -203,9 +209,13 @@ export function OperationsTable({loading,windowMs,showImpact = false,+ groupedByEndpoint = false,onRowClick,}: OperationsTableProps): JSX.Element {- const columns = useMemo(() => buildColumns(windowMs, showImpact), [windowMs, showImpact])+ const columns = useMemo(+ () => buildColumns(windowMs, showImpact, groupedByEndpoint),+ [windowMs, showImpact, groupedByEndpoint]+ )return (<VirtualizedTable<AggregatedSpanRow>// pinned: identifies stored column widths — renaming resets everyone's widths@@ -216,7 +226,11 @@ export function OperationsTable({rowKey={operationRowKey}onRowClick={onRowClick}defaultSort={{ columnKey: 'total_time', order: -1 }}- emptyLabel="No operations found for these filters"+ emptyLabel={+ groupedByEndpoint+ ? 'No HTTP server spans found for these filters'+ : 'No operations found for these filters'+ }data-attr="tracing-operations-table"/>)diff --git a/products/tracing/frontend/TracingDisplayBar.tsx b/products/tracing/frontend/TracingDisplayBar.tsxindex 49ae57d6e36b..30ec9bef0a48 100644--- a/products/tracing/frontend/TracingDisplayBar.tsx+++ b/products/tracing/frontend/TracingDisplayBar.tsx@@ -1,6 +1,6 @@import { useActions, useValues } from 'kea'-import { IconChevronLeft, IconChevronRight, IconList, IconListTree, IconStack } from '@posthog/icons'+import { IconChevronLeft, IconChevronRight, IconEndpoints, IconList, IconListTree, IconStack } from '@posthog/icons'import { LemonButton, LemonSegmentedButton, type LemonSegmentedButtonOption } from '@posthog/lemon-ui'import { FlaggedFeature } from 'lib/components/FlaggedFeature'@@ -17,20 +17,21 @@ import { tracingSceneLogic, type TracingDisplayMode } from './tracingSceneLogic'/*** The bar above the results, mirroring logs' LogsDisplayBar:*- * - left: the facet rail toggle, the row-mode selector (Traces ⇄ Spans ⇄ Operations — what- * each result row represents), and the matching-count indicator.- * - right: column configuration (span list only) and Compare, both hidden on Operations.+ * - left: the facet rail toggle, the row-mode selector (Traces ⇄ Spans ⇄ Operations ⇄ Endpoints —+ * what each result row represents), and the matching-count indicator.+ * - right: column configuration (span list only) and Compare, both hidden on the aggregate views.*/export function TracingDisplayBar(): JSX.Element {- const { totalMatchingFilters, compareActive, displayMode, operationsViewEnabled } = useValues(tracingSceneLogic())+ const { totalMatchingFilters, compareActive, displayMode, operationsViewEnabled, endpointsViewEnabled } =+ useValues(tracingSceneLogic())const { setDisplayMode } = useActions(tracingSceneLogic())const { featureFlags } = useValues(featureFlagLogic)const { facetRailCollapsed } = useValues(tracingConfigLogic)const { setFacetRailCollapsed } = useActions(tracingConfigLogic)const facetRailEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_FACET_RAIL]- const inTracesView = displayMode !== 'operations'- // The Operations view carries its own counts in table columns, and a comparison covers two+ const inTracesView = displayMode !== 'operations' && displayMode !== 'endpoints'+ // The aggregate views carry their own counts in table columns, and a comparison covers two// windows while both indicators describe one.const showsSingleWindowCounts = inTracesView && !compareActiveconst showCount = showsSingleWindowCounts && totalMatchingFilters > 0@@ -64,6 +65,17 @@ export function TracingDisplayBar(): JSX.Element {},]: []),+ ...(endpointsViewEnabled+ ? [+ {+ value: 'endpoints' as const,+ label: 'Endpoints',+ icon: <IconEndpoints />,+ tooltip: 'Aggregate HTTP server spans by endpoint (method and route)',+ 'data-attr': 'tracing-display-tab-endpoints',+ },+ ]+ : []),]return (diff --git a/products/tracing/frontend/TracingScene.tsx b/products/tracing/frontend/TracingScene.tsxindex 1dac737c1a16..18370ab20d74 100644--- a/products/tracing/frontend/TracingScene.tsx+++ b/products/tracing/frontend/TracingScene.tsx@@ -124,7 +124,7 @@ function TracingSceneContents(): JSX.Element {latencyHeatmapData,latencyHeatmapLoading,showHeatmap,- activeTracingTab,+ displayMode,compareActive,sceneTabsEnabled,activeSceneTab,@@ -154,7 +154,6 @@ function TracingSceneContents(): JSX.Element {} = useActions(tracingSceneLogic())const { addProductIntent } = useActions(teamLogic)const { facetRailCollapsed, spanColumns } = useValues(tracingConfigLogic)- const operationsViewEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_OPERATIONS_VIEW]const facetRailEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_FACET_RAIL]const heatmapEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_LATENCY_HEATMAP]const impactStripEnabled = !!featureFlags[FEATURE_FLAGS.TRACING_IMPACT_STRIP]@@ -312,19 +311,26 @@ function TracingSceneContents(): JSX.Element {{facetRailEnabled && !facetRailCollapsed && <TracingFacetRail />}<div className="flex flex-col gap-2 flex-1 min-w-0 min-h-0"><TracingDisplayBar />- {compareActive && (!operationsViewEnabled || activeTracingTab !== 'operations') && (+ {compareActive && displayMode !== 'operations' && displayMode !== 'endpoints' && (<ComparisonBar />)}- {operationsViewEnabled && activeTracingTab === 'operations' ? (+ {displayMode === 'operations' || displayMode === 'endpoints' ? (<OperationsTablerows={aggregation.current}loading={aggregationLoading}windowMs={operationsWindowMs}showImpact={impactStripEnabled}- onRowClick={(row) =>- router.actions.push(- urls.tracingOperation(row.service_name, row.name, filters.dateRange)- )+ groupedByEndpoint={displayMode === 'endpoints'}+ // No row click on endpoints yet: an endpoint row can merge span+ // names, and the operation page opens one span name. Rows stay+ // unclickable while loading, because they can still be the other tab's.+ onRowClick={+ displayMode === 'operations' && !aggregationLoading+ ? (row) =>+ router.actions.push(+ urls.tracingOperation(row.service_name, row.name, filters.dateRange)+ )+ : undefined}/>) : compareActive ? (diff --git a/products/tracing/frontend/tracingDataLogic.ts b/products/tracing/frontend/tracingDataLogic.tsindex d1ca82ff74ce..f99b1f2fde43 100644--- a/products/tracing/frontend/tracingDataLogic.ts+++ b/products/tracing/frontend/tracingDataLogic.ts@@ -308,9 +308,11 @@ export interface tracingDataLogicActions {fetchAggregation: (options?: {fullRange?: boolean+ groupByEndpoint?: boolean} | null) => {fullRange?: boolean+ groupByEndpoint?: boolean} | nullfetchAggregationFailure: (error: string,@@ -326,6 +328,7 @@ export interface tracingDataLogicActions {},payload?: {fullRange?: boolean+ groupByEndpoint?: boolean} | null) => {aggregation: {@@ -334,6 +337,7 @@ export interface tracingDataLogicActions {}payload?: {fullRange?: boolean+ groupByEndpoint?: boolean} | null}fetchDurationHistogram: () => any@@ -1122,7 +1126,7 @@ export const tracingDataLogic = kea<tracingDataLogicType>([// `fullRange` (the Operations tab) ignores any active comparison: the aggregate// covers the whole selected range with no compare period, matching the rate// denominator the OperationsTable divides by.- fetchAggregation: async (options?: { fullRange?: boolean } | null) => {+ fetchAggregation: async (options?: { fullRange?: boolean; groupByEndpoint?: boolean } | null) => {const controller = new AbortController()actions.cancelInProgressAggregation(controller)@@ -1167,6 +1171,7 @@ export const tracingDataLogic = kea<tracingDataLogicType>([// Only the Operations table renders the Sessions and Users columns, and// the aggregates read attribute maps the rest of the query never touches.includeImpact: fullRange && !!values.featureFlags[FEATURE_FLAGS.TRACING_IMPACT_STRIP],+ groupByEndpoint: options?.groupByEndpoint || undefined,},controller.signal)diff --git a/products/tracing/frontend/tracingSceneLogic.test.ts b/products/tracing/frontend/tracingSceneLogic.test.tsindex 38a22a373a16..8c22effa2320 100644--- a/products/tracing/frontend/tracingSceneLogic.test.ts+++ b/products/tracing/frontend/tracingSceneLogic.test.ts@@ -143,14 +143,19 @@ describe('tracingSceneLogic', () => {expect(filtersLogic.values.comparison).toMatchObject({ preset: 'yesterday' })})- it('opens the operations view from a ?view=operations deep link', () => {- enableOperationsView()- mountAt({ view: 'operations' })- expect(logic.values.activeTracingTab).toBe('operations')+ it.each([+ ['operations', FEATURE_FLAGS.TRACING_OPERATIONS_VIEW, undefined],+ ['endpoints', FEATURE_FLAGS.TRACING_ENDPOINTS_VIEW, true],+ ] as const)('opens the %s view from a deep link and fetches its aggregate', (view, flag, groupByEndpoint) => {+ const aggregate = jest.spyOn(api.tracing, 'aggregate')+ featureFlagLogic.actions.setFeatureFlags([], { [flag]: true })+ mountAt({ view })+ expect(logic.values.activeTracingTab).toBe(view)+ expect(aggregate).toHaveBeenLastCalledWith(expect.objectContaining({ groupByEndpoint }), expect.anything())})- it('ignores ?view=operations when the operations view flag is off', () => {- const filtersLogic = mountAt({ view: 'operations' })+ it.each(['operations', 'endpoints'])('ignores ?view=%s when its flag is off', (view) => {+ const filtersLogic = mountAt({ view })expect(logic.values.activeTracingTab).toBe('traces')expect(filtersLogic.values.viewMode).toBe('spans')})@@ -290,6 +295,37 @@ describe('tracingSceneLogic', () => {resumeKeaLoadersErrors()})+ it.each([+ ['a comparison window drag', 'drag'],+ ['a refresh', 'refresh'],+ ])('keeps endpoint grouping on the full range after %s while comparing', async (_label, trigger) => {+ silenceKeaLoadersErrors()+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TRACING_ENDPOINTS_VIEW]: true })+ const filtersLogic = mountAt({ comparison: JSON.stringify({ mode: 'time', preset: 'custom' }) })+ expect(filtersLogic.values.compareActive).toBe(true)++ const aggregateSpy = jest.spyOn(api.tracing, 'aggregate')+ logic.actions.setActiveTracingTab('endpoints')+ await new Promise((resolve) => setTimeout(resolve, 0))+ aggregateSpy.mockClear()++ if (trigger === 'drag') {+ filtersLogic.actions.updateComparisonWindows({ startMs: 0, endMs: 1000 }, { startMs: 2000, endMs: 3000 })+ } else {+ logic.actions.refreshQuery()+ }+ await new Promise((resolve) => setTimeout(resolve, 0))++ expect(aggregateSpy).toHaveBeenLastCalledWith(+ expect.objectContaining({+ groupByEndpoint: true,+ compareFilter: expect.objectContaining({ compare: false }),+ }),+ expect.anything()+ )+ resumeKeaLoadersErrors()+ })+// Same denominator guard for the bulk-restore path (back/forward, saved views): setFilters routes// through the data logic's runQuery, which fires a windowed aggregate while comparing. Without the// scene's full-range refetch the operations table would divide by the narrow compare sub-window.diff --git a/products/tracing/frontend/tracingSceneLogic.ts b/products/tracing/frontend/tracingSceneLogic.tsindex b3d869a673b8..899fb42f9fcf 100644--- a/products/tracing/frontend/tracingSceneLogic.ts+++ b/products/tracing/frontend/tracingSceneLogic.ts@@ -52,8 +52,25 @@ import type {import { tracingViewerLogic } from './tracingViewerLogic'import type { Span, SpanInspectorTab } from './types'-/** What each result row represents: a trace (its root span), an individual span, or an operation aggregate. */-export type TracingDisplayMode = TracingViewMode | 'operations'+/** What each result row represents: a trace (its root span), an individual span, or an operation or endpoint aggregate. */+export type TracingDisplayMode = TracingViewMode | 'operations' | 'endpoints'++export type TracingResultsTab = 'traces' | 'operations' | 'endpoints'++function resultsTabFromView(view: unknown, operationsEnabled: boolean, endpointsEnabled: boolean): TracingResultsTab {+ if (operationsEnabled && view === 'operations') {+ return 'operations'+ }+ if (endpointsEnabled && view === 'endpoints') {+ return 'endpoints'+ }+ return 'traces'+}++/** The aggregate tables always cover the whole selected range, even while a comparison is active. */+function aggregateFetchOptions(tab: TracingResultsTab): { fullRange: boolean; groupByEndpoint: boolean } {+ return { fullRange: true, groupByEndpoint: tab === 'endpoints' }+}const TRACING_SCENE_TABS = ['viewer', 'sql'] as constexport type TracingSceneTab = (typeof TRACING_SCENE_TABS)[number]@@ -130,9 +147,10 @@ export interface tracingSceneLogicValues {traceIdentity: TraceIdentity // tracingViewerLogictraceSessionId: string | null // tracingViewerLogicactiveSceneTab: TracingSceneTab- activeTracingTab: 'operations' | 'traces'+ activeTracingTab: TracingResultsTabbreadcrumbs: Breadcrumb[]displayMode: TracingDisplayMode+ endpointsViewEnabled: booleanoperationsViewEnabled: booleansceneTab: TracingSceneTabsceneTabsEnabled: boolean@@ -154,11 +172,13 @@ export interface tracingSceneLogicActions {options?:| {fullRange?: boolean+ groupByEndpoint?: boolean}| null| undefined) => {fullRange?: boolean+ groupByEndpoint?: boolean} | null // tracingDataLogicfetchNextPage: () => {value: true@@ -183,6 +203,9 @@ export interface tracingSceneLogicActions {traceId: stringts?: string | null} // tracingDataLogic+ refreshQuery: () => {+ value: true+ } // tracingDataLogicrunQuery: () => {value: true} // tracingDataLogic@@ -284,8 +307,8 @@ export interface tracingSceneLogicActions {selectSceneTab: (tab: TracingSceneTab) => {tab: 'sql' | 'viewer'}- setActiveTracingTab: (tab: 'operations' | 'traces') => {- tab: 'operations' | 'traces'+ setActiveTracingTab: (tab: TracingResultsTab) => {+ tab: TracingResultsTab}setDisplayMode: (mode: TracingDisplayMode) => {mode: TracingDisplayMode@@ -302,9 +325,11 @@ export interface tracingSceneLogicActions {export interface tracingSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {operationsViewEnabled: (featureFlags: FeatureFlagsSet) => boolean+ endpointsViewEnabled: (featureFlags: FeatureFlagsSet) => booleandisplayMode: (operationsViewEnabled: boolean,- activeTracingTab: 'operations' | 'traces',+ endpointsViewEnabled: boolean,+ activeTracingTab: TracingResultsTab,filters: TracingFilters) => TracingDisplayModesceneTabsEnabled: (featureFlags: FeatureFlagsSet) => boolean@@ -398,6 +423,7 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>(['setVisibleRowRange','handleFilterChange','applyHeatmapBrush',+ 'refreshQuery',],tracingFiltersLogic({ id: TRACING_SCENE_VIEWER_ID }),[@@ -429,7 +455,7 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([actions({syncUrl: true,- setActiveTracingTab: (tab: 'traces' | 'operations') => ({ tab }),+ setActiveTracingTab: (tab: TracingResultsTab) => ({ tab }),setDisplayMode: (mode: TracingDisplayMode) => ({ mode }),setSceneTab: (tab: TracingSceneTab) => ({ tab }),selectSceneTab: (tab: TracingSceneTab) => ({ tab }),@@ -438,7 +464,7 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([reducers({activeTracingTab: [- 'traces' as 'traces' | 'operations',+ 'traces' as TracingResultsTab,{setActiveTracingTab: (_, { tab }) => tab,},@@ -466,16 +492,23 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([(s) => [s.featureFlags],(featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.TRACING_OPERATIONS_VIEW],],+ endpointsViewEnabled: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): boolean => !!featureFlags[FEATURE_FLAGS.TRACING_ENDPOINTS_VIEW],+ ],// The one user-facing mode: what each result row represents. Spans two states —- // traces/spans is the viewMode filter, operations is the scene tab.+ // traces/spans is the viewMode filter, operations/endpoints is the scene tab.displayMode: [- (s) => [s.operationsViewEnabled, s.activeTracingTab, s.filters],+ (s) => [s.operationsViewEnabled, s.endpointsViewEnabled, s.activeTracingTab, s.filters],(operationsViewEnabled: boolean,- activeTracingTab: 'operations' | 'traces',+ endpointsViewEnabled: boolean,+ activeTracingTab: TracingResultsTab,filters: TracingFilters- ): TracingDisplayMode =>- operationsViewEnabled && activeTracingTab === 'operations' ? 'operations' : filters.viewMode,+ ): TracingDisplayMode => {+ const tab = resultsTabFromView(activeTracingTab, operationsViewEnabled, endpointsViewEnabled)+ return tab === 'traces' ? filters.viewMode : tab+ },],sceneTabsEnabled: [(s) => [s.featureFlags],@@ -525,8 +558,8 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([// dispatched wins. The data logic mounts before this scene logic, so its listener runs// first and the full-range fetch here beats the windowed one deterministically —// otherwise the Operations table would divide by the narrow compare sub-window.- if (values.activeTracingTab === 'operations') {- actions.fetchAggregation({ fullRange: true })+ if (values.activeTracingTab !== 'traces') {+ actions.fetchAggregation(aggregateFetchOptions(values.activeTracingTab))}},setFilters: () => {@@ -535,8 +568,8 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([// listener → runQuery, which fires a windowed fetchAggregation when a comparison is// active. Mirror handleFilterChange so the Operations tab keeps its full-range aggregate// instead of the narrow compare sub-window (same mount-order guarantee applies).- if (values.activeTracingTab === 'operations') {- actions.fetchAggregation({ fullRange: true })+ if (values.activeTracingTab !== 'traces') {+ actions.fetchAggregation(aggregateFetchOptions(values.activeTracingTab))}},// Flags resolve asynchronously, so one that arrives after the Operations fetch would show@@ -544,13 +577,13 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([// late-flag refetch in tracingDataLogic.setFeatureFlags: () => {if (- values.activeTracingTab === 'operations' &&+ values.activeTracingTab !== 'traces' &&values.featureFlags[FEATURE_FLAGS.TRACING_IMPACT_STRIP] &&values.aggregation.current.length > 0 &&values.aggregation.current[0].sessions == null &&!values.aggregationLoading) {- actions.fetchAggregation({ fullRange: true })+ actions.fetchAggregation(aggregateFetchOptions(values.activeTracingTab))}// Flags can arrive after the URL parse, so a tab=sql deep link waits here for the verdict.if (!values.sceneTabsEnabled && values.sceneTab !== DEFAULT_SCENE_TAB) {@@ -558,9 +591,20 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([actions.syncUrl()}},+ // The data logic refetches a windowed aggregate on these, so restore the tab's own query after it.+ updateComparisonWindows: () => {+ if (values.activeTracingTab !== 'traces') {+ actions.fetchAggregation(aggregateFetchOptions(values.activeTracingTab))+ }+ },+ refreshQuery: () => {+ if (values.activeTracingTab !== 'traces') {+ actions.fetchAggregation(aggregateFetchOptions(values.activeTracingTab))+ }+ },setActiveTracingTab: ({ tab }) => {- if (tab === 'operations') {- actions.fetchAggregation({ fullRange: true })+ if (tab !== 'traces') {+ actions.fetchAggregation(aggregateFetchOptions(tab))} else if (values.compareActive) {// Returning to the traces tab with a comparison active: the aggregation state// holds the operations full-range data — refetch the windowed compare version.@@ -571,9 +615,11 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([// URL write per interaction: setViewMode cascades its own syncUrl (via the data logic's// handleFilterChange), so this only writes directly when that cascade won't run.setDisplayMode: ({ mode }) => {- if (mode === 'operations') {- if (values.activeTracingTab !== 'operations') {- actions.setActiveTracingTab('operations')+ // pinned: analytics event name and property — renaming breaks dashboards+ posthog.capture('tracing display mode changed', { mode })+ if (mode === 'operations' || mode === 'endpoints') {+ if (values.activeTracingTab !== mode) {+ actions.setActiveTracingTab(mode)}actions.syncUrl()return@@ -589,21 +635,26 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([},})),- subscriptions(({ actions, values }) => ({+ subscriptions(({ actions, values }) => {// Feature flags can resolve AFTER the initial URL parse, and urlToAction only re-runs on// URL changes. Without this, a late-arriving flag leaves the tab and the URL disagreeing:// enabling it on a ?view=operations page keeps the tab stuck on traces, and disabling it// mid-session strands the tab on operations. Re-reconcile the tab against the current URL- // whenever the flag flips, then write the URL back through the flag-aware displayMode.- operationsViewEnabled: (enabled) => {- const shouldBeOperations = enabled && router.values.searchParams.view === 'operations'- if (shouldBeOperations === (values.activeTracingTab === 'operations')) {+ // whenever a flag flips, then write the URL back through the flag-aware displayMode.+ const reconcileTab = (): void => {+ const tab = resultsTabFromView(+ router.values.searchParams.view,+ values.operationsViewEnabled,+ values.endpointsViewEnabled+ )+ if (tab === values.activeTracingTab) {return}- actions.setActiveTracingTab(shouldBeOperations ? 'operations' : 'traces')+ actions.setActiveTracingTab(tab)actions.syncUrl()- },- })),+ }+ return { operationsViewEnabled: reconcileTab, endpointsViewEnabled: reconcileTab }+ }),urlToAction(({ actions, values, cache }) => ({'/tracing': (_, searchParams) => {@@ -693,18 +744,21 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([hasChanges = true}- // `view` spans two states: 'operations' round-trips the scene tab, 'spans'/'traces'/absent- // round-trips the viewMode filter. While the URL says operations the viewMode filter+ // `view` spans two states: 'operations'/'endpoints' round-trips the scene tab, 'spans'/'traces'/absent+ // round-trips the viewMode filter. While the URL names an aggregate tab the viewMode filter// is left untouched — it has no effect on that view and shouldn't be reset under it.- // The whole operations leg is flag-gated on BOTH the read side (here) and the write+ // Each aggregate leg is flag-gated on BOTH the read side (here) and the write// side (buildUrl, via the flag-aware displayMode selector): gating only one of them// would make them fight over the tab state.- const operationsEnabled = values.operationsViewEnabled- const operationsFromUrl = operationsEnabled && searchParams.view === 'operations'- if (operationsEnabled && operationsFromUrl !== (values.activeTracingTab === 'operations')) {- actions.setActiveTracingTab(operationsFromUrl ? 'operations' : 'traces')- }- if (!operationsFromUrl) {+ const tabFromUrl = resultsTabFromView(+ searchParams.view,+ values.operationsViewEnabled,+ values.endpointsViewEnabled+ )+ if (tabFromUrl !== values.activeTracingTab) {+ actions.setActiveTracingTab(tabFromUrl)+ }+ if (tabFromUrl === 'traces') {const viewModeFromUrl: TracingViewMode =searchParams.view === 'spans' || searchParams.view === 'traces'? searchParams.view@@ -803,7 +857,7 @@ export const tracingSceneLogic = kea<tracingSceneLogicType>([if (comparisonParam) {searchParams.comparison = comparisonParam}- // displayMode already folds in the flag gate and resolves to viewMode off-operations.+ // displayMode already folds in the flag gates and resolves to viewMode off the aggregate tabs.if (values.displayMode !== DEFAULT_VIEW_MODE) {searchParams.view = values.displayMode}diff --git a/products/tracing/frontend/tracingViewerLogic.ts b/products/tracing/frontend/tracingViewerLogic.tsindex 5d5eb8f054e1..5550e821c7a9 100644--- a/products/tracing/frontend/tracingViewerLogic.ts+++ b/products/tracing/frontend/tracingViewerLogic.ts@@ -145,11 +145,13 @@ export interface tracingViewerLogicActions {options?:| {fullRange?: boolean+ groupByEndpoint?: boolean}| null| undefined) => {fullRange?: boolean+ groupByEndpoint?: boolean} | null // tracingDataLogicfetchSpanTree: (params: { serviceName: string; spanName: string }) => {serviceName: string