Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(insights): Backfill value type for message latency chart #87454

Merged
merged 2 commits into from
Mar 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions static/app/views/insights/queues/charts/latencyChart.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 (
<InsightsAreaChartWidget
title={t('Average Duration')}
series={[
data['avg(messaging.message.receive.latency)'],
data['avg(span.duration)'],
]}
series={[messageReceiveLatencySeries, data['avg(span.duration)']]}
aliases={FIELD_ALIASES}
error={error ?? latencyError}
isLoading={isPending}
Expand Down
Loading