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(logs, tracing): calmer facet error state with retry (#113393)

Frank Hamand53c2a12677ac
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx b/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
index e0bfcbde5d18..92cfb4114000 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/Facet.tsx
@@ -2,7 +2,7 @@ import { CSSProperties, useMemo } from 'react'
import { List } from 'react-window'
import { IconChevronDown, IconChevronRight, IconMinusSmall, IconWarning, IconX } from '@posthog/icons'
-import { LemonButton, LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'
+import { LemonButton, LemonCheckbox, LemonInput, Link, Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
@@ -43,6 +43,8 @@ interface FacetProps {
removeDisabledReason?: string
/** The facet's latest fetch failed — show an error icon and line instead of pretending the list is fresh (suppresses emptyLabel). */
error?: boolean
+ /** Renders a Retry link next to the error message. */
+ onRetry?: () => void
}
/** A single rail facet: a collapsible field title and its selectable values (multi-select = OR), each with a count. */
@@ -62,10 +64,12 @@ export function Facet({
maxHeight,
dimZeroCounts = false,
error = false,
+ onRetry,
onRemove,
removeDisabledReason,
}: FacetProps): JSX.Element {
const slug = title.toLowerCase().replace(/\s+/g, '-')
+ const errorMessage = options.length > 0 ? "Couldn't refresh values." : "Couldn't load values."
const rowProps = useMemo<FacetValueRowProps>(
() => ({ options, selected, excluded, slug, onToggle, dimZeroCounts }),
@@ -84,12 +88,12 @@ export function Facet({
>
{collapsed ? <IconChevronRight /> : <IconChevronDown />}
<span className="truncate">{title}</span>
+ {error && !loading && (
+ <Tooltip title={collapsed ? `${errorMessage} Expand to retry.` : errorMessage}>
+ <IconWarning className="shrink-0 text-xs text-danger" />
+ </Tooltip>
+ )}
</button>
- {error && !loading && (
- <Tooltip title="Couldn't load values. Change the filters or expand the facet to retry.">
- <IconWarning className="text-danger shrink-0" />
- </Tooltip>
- )}
{onRemove && (
<LemonButton
size="small"
@@ -115,8 +119,13 @@ export function Facet({
)}
{/* A failed fetch shows inline (options may be stale-but-usable below) rather than blanking the facet. */}
{!collapsed && error && !loading && (
- <div className="px-1 pb-1 text-xs text-danger" data-attr={`logs-facet-${slug}-error`}>
- Couldn't load values
+ <div className="px-1 pb-1 text-xs text-secondary" data-attr={`logs-facet-${slug}-error`}>
+ {errorMessage}{' '}
+ {onRetry && (
+ <Link onClick={onRetry} data-attr={`logs-facet-${slug}-retry`}>
+ Retry
+ </Link>
+ )}
</div>
)}
{!collapsed &&
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx b/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
index 5bd4dc2ee141..80f3b75e9213 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/RailFacet.tsx
@@ -27,7 +27,7 @@ export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element |
const { facetValues, facetValuesLoading, facetSearch, collapsed, fetchFailed } = useValues(
facetValuesLogic(logicProps)
)
- const { setFacetSearch } = useActions(facetValuesLogic(logicProps))
+ const { setFacetSearch, retryFacetValues } = useActions(facetValuesLogic(logicProps))
const { filterGroup } = useValues(logsViewerFiltersLogic({ id }))
const { toggleFacetValue, toggleFacetCollapsed } = useActions(facetRailLogic({ id }))
const { removeCustomFacet } = useActions(customFacetsLogic)
@@ -92,6 +92,7 @@ export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element |
onToggleCollapsed={onToggleCollapsed}
dimZeroCounts
error={fetchFailed}
+ onRetry={retryFacetValues}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
@@ -114,6 +115,7 @@ export function RailFacet({ id, facet, hidden }: RailFacetProps): JSX.Element |
onToggleCollapsed={onToggleCollapsed}
maxHeight={facet.maxHeight}
error={fetchFailed}
+ onRetry={retryFacetValues}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
index 32c6e7c10e4f..d132dc06a236 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.test.ts
@@ -72,15 +72,17 @@ describe('facetValuesLogic', () => {
expect(selectedLogic.values.facetValuesLoading).toBe(false)
})
- it('a failed fetch shows in place and clears on the next fetch', async () => {
+ it('a failed fetch shows in place and a retry refetches the same scope', async () => {
mockFacetValues.mockRejectedValueOnce(new Error('facet values failed'))
const logic = mountFacet(SERVICE)
await expectLogic(logic).toDispatchActions(['loadFacetValuesFailure'])
expect(logic.values.fetchFailed).toBe(true)
- logic.actions.setFacetSearch('api')
+ logic.actions.retryFacetValues()
await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])
expect(logic.values.fetchFailed).toBe(false)
+ expect(mockFacetValues).toHaveBeenCalledTimes(2)
+ expect(mockFacetValues.mock.calls[1]).toEqual(mockFacetValues.mock.calls[0])
})
it('a type-ahead search refetches this facet with the search term', async () => {
diff --git a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
index 211f41b21c23..75638a7b6e7c 100644
--- a/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
+++ b/products/logs/frontend/components/LogsViewer/FacetRail/facetValuesLogic.ts
@@ -1,4 +1,4 @@
-import { MakeLogicType, actions, connect, kea, key, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
@@ -70,6 +70,9 @@ export interface facetValuesLogicActions {
signature: string
}
}
+ retryFacetValues: () => {
+ value: true
+ }
setFacetSearch: (search: string) => {
search: string
}
@@ -139,6 +142,7 @@ export const facetValuesLogic = kea<facetValuesLogicType>([
// and the signature payload is only there for the reducer below to record.
loadFacetValues: (signature: string) => ({ signature }),
clearFetchedSignature: true,
+ retryFacetValues: true,
}),
reducers({
@@ -261,6 +265,10 @@ export const facetValuesLogic = kea<facetValuesLogicType>([
],
}),
+ listeners(({ actions, values }) => ({
+ retryFacetValues: () => actions.loadFacetValues(values.fetchSignature),
+ })),
+
subscriptions(({ actions, values }) => {
// Subscriptions fire with their initial value, so this is also the mount fetch.
const loadIfStale = (): void => {
diff --git a/products/tracing/frontend/components/FacetRail/Facet.tsx b/products/tracing/frontend/components/FacetRail/Facet.tsx
index 588a9b42ab14..16796b699d00 100644
--- a/products/tracing/frontend/components/FacetRail/Facet.tsx
+++ b/products/tracing/frontend/components/FacetRail/Facet.tsx
@@ -2,7 +2,7 @@ import { CSSProperties, useMemo } from 'react'
import { List } from 'react-window'
import { IconChevronDown, IconChevronRight, IconMinusSmall, IconWarning, IconX } from '@posthog/icons'
-import { LemonButton, LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'
+import { LemonButton, LemonCheckbox, LemonInput, Link, Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
@@ -32,6 +32,8 @@ interface FacetProps {
dimZeroCounts?: boolean
/** The facet's latest fetch failed — show an inline error instead of pretending the list is fresh (suppresses emptyLabel). */
error?: boolean
+ /** Renders a Retry link next to the error message. */
+ onRetry?: () => void
/** When set, renders a remove control in the header — for user-added custom facets only. */
onRemove?: () => void
/** Disables the remove control (with this explanation) while a custom-facet update is in flight. */
@@ -67,10 +69,12 @@ export function Facet({
maxHeight,
dimZeroCounts = false,
error = false,
+ onRetry,
onRemove,
removeDisabledReason,
}: FacetProps): JSX.Element {
const slug = slugify(title)
+ const errorMessage = options.length > 0 ? "Couldn't refresh values." : "Couldn't load values."
const rowProps = useMemo<FacetValueRowProps>(
() => ({ options, selected, excluded, slug, onToggle, dimZeroCounts }),
@@ -89,12 +93,12 @@ export function Facet({
>
{collapsed ? <IconChevronRight /> : <IconChevronDown />}
<span className="truncate">{title}</span>
+ {error && !loading && (
+ <Tooltip title={collapsed ? `${errorMessage} Expand to retry.` : errorMessage}>
+ <IconWarning className="shrink-0 text-xs text-danger" />
+ </Tooltip>
+ )}
</button>
- {error && !loading && (
- <Tooltip title="Couldn't load values. Change the filters or expand the facet to retry.">
- <IconWarning className="text-danger shrink-0" />
- </Tooltip>
- )}
{onRemove && (
<LemonButton
size="small"
@@ -120,8 +124,13 @@ export function Facet({
)}
{/* A failed fetch shows inline (options may be stale-but-usable below) rather than blanking the facet. */}
{!collapsed && error && !loading && (
- <div className="px-1 pb-1 text-xs text-danger" data-attr={`tracing-facet-${slug}-error`}>
- Couldn't load values
+ <div className="px-1 pb-1 text-xs text-secondary" data-attr={`tracing-facet-${slug}-error`}>
+ {errorMessage}{' '}
+ {onRetry && (
+ <Link onClick={onRetry} data-attr={`tracing-facet-${slug}-retry`}>
+ Retry
+ </Link>
+ )}
</div>
)}
{!collapsed &&
diff --git a/products/tracing/frontend/components/FacetRail/RailFacet.tsx b/products/tracing/frontend/components/FacetRail/RailFacet.tsx
index 4448496794cb..5825504ee698 100644
--- a/products/tracing/frontend/components/FacetRail/RailFacet.tsx
+++ b/products/tracing/frontend/components/FacetRail/RailFacet.tsx
@@ -33,7 +33,7 @@ export function RailFacet({ facet, id = TRACING_SCENE_VIEWER_ID, hidden }: RailF
const { facetValues, facetValuesLoading, fetchFailed, facetSearch, collapsed } = useValues(
facetValuesLogic(logicProps)
)
- const { setFacetSearch } = useActions(facetValuesLogic(logicProps))
+ const { setFacetSearch, retryFacetValues } = useActions(facetValuesLogic(logicProps))
const { serviceNames, filters } = useValues(tracingFiltersLogic({ id }))
const { toggleFacetValue, toggleFacetCollapsed } = useActions(facetRailLogic({ id }))
const { removeCustomFacet } = useActions(customFacetsLogic)
@@ -79,6 +79,7 @@ export function RailFacet({ facet, id = TRACING_SCENE_VIEWER_ID, hidden }: RailF
onToggleCollapsed={onToggleCollapsed}
dimZeroCounts
error={fetchFailed}
+ onRetry={retryFacetValues}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
@@ -104,6 +105,7 @@ export function RailFacet({ facet, id = TRACING_SCENE_VIEWER_ID, hidden }: RailF
onToggleCollapsed={onToggleCollapsed}
maxHeight={facet.maxHeight}
error={fetchFailed}
+ onRetry={retryFacetValues}
onRemove={onRemove}
removeDisabledReason={removeDisabledReason}
/>
diff --git a/products/tracing/frontend/components/FacetRail/facetValuesLogic.test.ts b/products/tracing/frontend/components/FacetRail/facetValuesLogic.test.ts
index 5086bf5670ad..90b7da981bc1 100644
--- a/products/tracing/frontend/components/FacetRail/facetValuesLogic.test.ts
+++ b/products/tracing/frontend/components/FacetRail/facetValuesLogic.test.ts
@@ -141,17 +141,19 @@ describe('facetValuesLogic', () => {
)
})
- it('a failed breakdown shows in place and clears on the next fetch', async () => {
+ it('a failed breakdown shows in place and a retry refetches the same scope', async () => {
// One broken breakdown must show on its own facet, not blank the rail.
mockBreakdown.mockRejectedValueOnce(new Error('breakdown failed'))
const logic = mountFacet(SERVICE)
await expectLogic(logic).toDispatchActions(['loadFacetValuesFailure'])
expect(logic.values.fetchFailed).toBe(true)
- logic.actions.setFacetSearch('api')
+ logic.actions.retryFacetValues()
await expectLogic(logic).toDispatchActions(['loadFacetValuesSuccess'])
expect(logic.values.fetchFailed).toBe(false)
expect(logic.values.facetValues).toEqual([row('api', 10)])
+ expect(mockBreakdown).toHaveBeenCalledTimes(2)
+ expect(mockBreakdown.mock.calls[1]).toEqual(mockBreakdown.mock.calls[0])
})
it('a collapsed facet defers its fetch until it is expanded, then only if the scope moved', async () => {
diff --git a/products/tracing/frontend/components/FacetRail/facetValuesLogic.ts b/products/tracing/frontend/components/FacetRail/facetValuesLogic.ts
index 1a30a2f11e2d..870b6e0a05a6 100644
--- a/products/tracing/frontend/components/FacetRail/facetValuesLogic.ts
+++ b/products/tracing/frontend/components/FacetRail/facetValuesLogic.ts
@@ -1,4 +1,4 @@
-import { MakeLogicType, actions, connect, kea, key, path, props, reducers, selectors } from 'kea'
+import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
@@ -70,6 +70,9 @@ export interface facetValuesLogicActions {
signature: string
}
}
+ retryFacetValues: () => {
+ value: true
+ }
setFacetSearch: (search: string) => {
search: string
}
@@ -135,6 +138,7 @@ export const facetValuesLogic = kea<facetValuesLogicType>([
// and the signature payload is only there for the reducer below to record.
loadFacetValues: (signature: string) => ({ signature }),
clearFetchedSignature: true,
+ retryFacetValues: true,
}),
reducers({
@@ -246,6 +250,10 @@ export const facetValuesLogic = kea<facetValuesLogicType>([
],
}),
+ listeners(({ actions, values }) => ({
+ retryFacetValues: () => actions.loadFacetValues(values.fetchSignature),
+ })),
+
subscriptions(({ actions, values }) => {
// Subscriptions fire with their initial value, so this is also the mount fetch.
const loadIfStale = (): void => {