diff --git a/static/app/views/insights/queues/charts/latencyChart.tsx b/static/app/views/insights/queues/charts/latencyChart.tsx index 361102f7d0f537..18cd0442756837 100644 --- a/static/app/views/insights/queues/charts/latencyChart.tsx +++ b/static/app/views/insights/queues/charts/latencyChart.tsx @@ -1,4 +1,7 @@ +import cloneDeep from 'lodash/cloneDeep'; + import {t} from 'sentry/locale'; +import {defined} from 'sentry/utils'; import {useProcessQueuesTimeSeriesQuery} from 'sentry/views/insights/queues/queries/useProcessQueuesTimeSeriesQuery'; import type {Referrer} from 'sentry/views/insights/queues/referrers'; @@ -21,13 +24,36 @@ export function LatencyChart({error, destination, referrer}: Props) { referrer, }); + const messageReceiveLatencySeries = cloneDeep( + data['avg(messaging.message.receive.latency)'] + ); + + if ( + !isPending && + !error && + defined(messageReceiveLatencySeries.data) && + defined(messageReceiveLatencySeries.meta) && + !defined( + messageReceiveLatencySeries.meta?.fields['avg(messaging.message.receive.latency)'] + ) + ) { + // This is a tricky data issue. If Snuba doesn't find any data for a field, + // it doesn't return a unit. If Discover can't guess the type based on the + // unit, there's no entry in the meta for the field. If there's no field, + // `TimeSeriesWidgetVisualization` dumps that data onto its own "number" + // axis, which looks weird. This is a rare case, and I'm hoping that in the + // future, backend will be able to determine types most of the time. For + // now, backfill the type, since we know it. + messageReceiveLatencySeries.meta.fields['avg(messaging.message.receive.latency)'] = + 'duration'; + messageReceiveLatencySeries.meta.units['avg(messaging.message.receive.latency)'] = + 'millisecond'; + } + return (