: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): default span logs tab to whole-trace scope with filters hidden (#73899)
Frank Hamandee7770abbc98
diff --git a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx b/products/logs/frontend/components/LogsViewer/LogsViewer.tsxindex 05fe12ca5952..910320f1b1de 100644--- a/products/logs/frontend/components/LogsViewer/LogsViewer.tsx+++ b/products/logs/frontend/components/LogsViewer/LogsViewer.tsx@@ -38,6 +38,9 @@ export interface LogsViewerProps {// Filters enforced by the embedding scene. Merged into the user-editable filterGroup// and rendered without an X so users can't accidentally drop the scope.pinnedFilters?: UniversalFiltersGroup+ // Seed the facet/filter rail as collapsed on first mount for this id. Persisted per id,+ // so a user who expands it keeps that choice; the "Show filters" toggle still re-expands.+ defaultFacetRailCollapsed?: boolean}export function LogsViewer({@@ -46,10 +49,11 @@ export function LogsViewer({showSavedViewsButton = false,initialFilters,pinnedFilters,+ defaultFacetRailCollapsed,}: LogsViewerProps): JSX.Element {return (<BindLogic logic={logsViewerFiltersLogic} props={{ id, initialFilters, pinnedFilters }}>- <BindLogic logic={logsViewerConfigLogic} props={{ id }}>+ <BindLogic logic={logsViewerConfigLogic} props={{ id, defaultFacetRailCollapsed }}><BindLogic logic={logsViewerDataLogic} props={{ id }}><BindLogic logic={logDetailsModalLogic} props={{ id }}><BindLogic logic={logsViewerLogic} props={{ id }}>diff --git a/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts b/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.tsindex 0f83755744ac..f4ac84ec2e54 100644--- a/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts+++ b/products/logs/frontend/components/LogsViewer/config/logsViewerConfigLogic.ts@@ -52,6 +52,7 @@ export const MAX_GROUP_BY_DIMENSIONS = 4export interface LogsViewerConfigProps {id: string+ defaultFacetRailCollapsed?: boolean}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -195,7 +196,7 @@ export const logsViewerConfigLogic = kea<logsViewerConfigLogicType>([moveColumn: (id: string, direction: 'left' | 'right') => ({ id, direction }),}),- reducers({+ reducers(({ props }) => ({filters: [DEFAULT_LOGS_VIEWER_CONFIG.filters,{@@ -221,7 +222,7 @@ export const logsViewerConfigLogic = kea<logsViewerConfigLogicType>([},],facetRailCollapsed: [- false,+ props.defaultFacetRailCollapsed ?? false,{ persist: true },{setFacetRailCollapsed: (_, { facetRailCollapsed }) => facetRailCollapsed,@@ -300,7 +301,7 @@ export const logsViewerConfigLogic = kea<logsViewerConfigLogicType>([: state.map((d, i) => (i === index ? groupBy : d)),},],- }),+ })),selectors({config: [(s) => [s.filters], (filters: LogsViewerFilters): LogsViewerConfig => ({ filters })],diff --git a/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx b/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsxindex 1d3d3f702487..d42d80e85a1a 100644--- a/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx+++ b/products/tracing/frontend/components/TraceDrawer/SpanLogsTab.tsx@@ -11,13 +11,12 @@ import { traceLookupDateRange } from '../../traceLinks'import { buildLogScopeFilter, logsDeepLinkUrl, type TraceLogScope } from '../../traceLogScope'import type { Span } from '../../types'-// Logs correlated to the inspected span (default) or the whole trace, via the embedded LogsViewer-// pinned to a trace_id/span_id filter. Span scope keeps the tab coherent with the rest of the-// inspector; the toggle rescues the common case where a span emitted no logs of its own. The-// pinned filter fixes the scope — the viewer's own filters can only narrow within it — and this-// toggle is the scope control.+// Logs correlated to the whole trace (default) or the inspected span, via the embedded LogsViewer+// pinned to a trace_id/span_id filter. Trace scope is the default because a single span often emits+// no logs of its own; narrow to the span with the toggle when needed. The pinned filter fixes the+// scope — the viewer's own filters can only narrow within it — and this toggle is the scope control.export function SpanLogsTab({ span }: { span: Span }): JSX.Element {- const [scope, setScope] = useState<TraceLogScope>('span')+ const [scope, setScope] = useState<TraceLogScope>('trace')// `initialFilters` (the date range) is stable across scope changes — recompute only when the// span timestamp changes. Otherwise a scope toggle would mint a fresh `initialFilters` object;@@ -47,8 +46,8 @@ export function SpanLogsTab({ span }: { span: Span }): JSX.Element {value={scope}onChange={setScope}options={[- { value: 'span', label: 'This span' },{ value: 'trace', label: 'Whole trace' },+ { value: 'span', label: 'This span' },]}data-attr="tracing-logs-scope"/>@@ -73,6 +72,9 @@ export function SpanLogsTab({ span }: { span: Span }): JSX.Element {// the scope via the URL filterGroup instead.showFullScreenButton={false}showSavedViewsButton={false}+ // Start with the facet/filter rail hidden — the drawer is narrow and the pinned+ // scope already covers the common case; "Show filters" re-expands it.+ defaultFacetRailCollapsed/></div>)diff --git a/products/tracing/frontend/components/TraceDrawer/TraceDrawer.tsx b/products/tracing/frontend/components/TraceDrawer/TraceDrawer.tsxindex d1b189b77ef2..bfa9805591c7 100644--- a/products/tracing/frontend/components/TraceDrawer/TraceDrawer.tsx+++ b/products/tracing/frontend/components/TraceDrawer/TraceDrawer.tsx@@ -189,10 +189,11 @@ export function TraceDrawer({{key: 'logs',label: 'Logs',- // Not keyed by span: the embedded viewer (keyed by trace_id) and the memoized- // pinned filter re-query in place when the selected span changes, so a remount- // would only churn its logics and lose scroll.- content: <SpanLogsTab span={inspectedSpan} />,+ // Keyed by trace, not span: a new trace remounts to reset the scope toggle+ // back to whole-trace, while selecting another span within the same trace+ // re-queries in place (the embedded viewer and memoized pinned filter handle+ // it) so we don't churn its logics or lose scroll.+ content: <SpanLogsTab key={inspectedSpan.trace_id} span={inspectedSpan} />,},{key: 'raw',