Skip to content

Commit 5ca18b3

Browse files
authored
fix(insights): Backfill value type for message latency chart (#87454)
See code comment for details.
1 parent b9244f6 commit 5ca18b3

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

static/app/views/insights/queues/charts/latencyChart.tsx

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import cloneDeep from 'lodash/cloneDeep';
2+
13
import {t} from 'sentry/locale';
4+
import {defined} from 'sentry/utils';
25
import {useProcessQueuesTimeSeriesQuery} from 'sentry/views/insights/queues/queries/useProcessQueuesTimeSeriesQuery';
36
import type {Referrer} from 'sentry/views/insights/queues/referrers';
47

@@ -21,13 +24,36 @@ export function LatencyChart({error, destination, referrer}: Props) {
2124
referrer,
2225
});
2326

27+
const messageReceiveLatencySeries = cloneDeep(
28+
data['avg(messaging.message.receive.latency)']
29+
);
30+
31+
if (
32+
!isPending &&
33+
!error &&
34+
defined(messageReceiveLatencySeries.data) &&
35+
defined(messageReceiveLatencySeries.meta) &&
36+
!defined(
37+
messageReceiveLatencySeries.meta?.fields['avg(messaging.message.receive.latency)']
38+
)
39+
) {
40+
// This is a tricky data issue. If Snuba doesn't find any data for a field,
41+
// it doesn't return a unit. If Discover can't guess the type based on the
42+
// unit, there's no entry in the meta for the field. If there's no field,
43+
// `TimeSeriesWidgetVisualization` dumps that data onto its own "number"
44+
// axis, which looks weird. This is a rare case, and I'm hoping that in the
45+
// future, backend will be able to determine types most of the time. For
46+
// now, backfill the type, since we know it.
47+
messageReceiveLatencySeries.meta.fields['avg(messaging.message.receive.latency)'] =
48+
'duration';
49+
messageReceiveLatencySeries.meta.units['avg(messaging.message.receive.latency)'] =
50+
'millisecond';
51+
}
52+
2453
return (
2554
<InsightsAreaChartWidget
2655
title={t('Average Duration')}
27-
series={[
28-
data['avg(messaging.message.receive.latency)'],
29-
data['avg(span.duration)'],
30-
]}
56+
series={[messageReceiveLatencySeries, data['avg(span.duration)']]}
3157
aliases={FIELD_ALIASES}
3258
error={error ?? latencyError}
3359
isLoading={isPending}

0 commit comments

Comments
 (0)