1
+ import cloneDeep from 'lodash/cloneDeep' ;
2
+
1
3
import { t } from 'sentry/locale' ;
4
+ import { defined } from 'sentry/utils' ;
2
5
import { useProcessQueuesTimeSeriesQuery } from 'sentry/views/insights/queues/queries/useProcessQueuesTimeSeriesQuery' ;
3
6
import type { Referrer } from 'sentry/views/insights/queues/referrers' ;
4
7
@@ -21,13 +24,36 @@ export function LatencyChart({error, destination, referrer}: Props) {
21
24
referrer,
22
25
} ) ;
23
26
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
+
24
53
return (
25
54
< InsightsAreaChartWidget
26
55
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)' ] ] }
31
57
aliases = { FIELD_ALIASES }
32
58
error = { error ?? latencyError }
33
59
isLoading = { isPending }
0 commit comments