Skip to content

fix(tracemetrics): Parse units off response in events request for alerts#109608

Merged
narsaynorath merged 5 commits intomasterfrom
nar/fix/tracemetrics-parse-units-off-response-in-events-request
Mar 4, 2026
Merged

fix(tracemetrics): Parse units off response in events request for alerts#109608
narsaynorath merged 5 commits intomasterfrom
nar/fix/tracemetrics-parse-units-off-response-in-events-request

Conversation

@narsaynorath
Copy link
Member

@narsaynorath narsaynorath commented Feb 27, 2026

We need to do this because the old alerts UI uses this EventsRequest component. For metrics, we're starting to surface the units properly from the backend which means that the old ways of inferring it from the aggregate do not work anymore. This allows the charts in the alerts UI to properly display metrics in the correct units while also allowing fallbacks to the old way if the response doesn't have data. The response will take precedence.

This follows a similar pattern we're applying for dashboards at the moment. Essentially we construct timeseriesResultsUnits and timeseriesResultsTypes which are used in conjunction to propagate the types and units from the metadata of the response. Then we update the areas that deal with this kind of data for formatted to prioritize the object if it exists.

Resolves LOGS-585

We need to do this because the old alerts UI uses this EventsRequest component.
For metrics, we're starting to surface the units properly from the backend which
means that the old ways of inferring it from the aggregate do not work anymore.
This allows the charts in the alerts UI to properly display metrics in the
correct units while also allowing fallbacks to the old way if the response
doesn't have data. The response will take precedence.
@narsaynorath narsaynorath requested review from a team as code owners February 27, 2026 20:27
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 27, 2026
@narsaynorath narsaynorath changed the title fix(tracemetrics): Parse units off response in events request fix(tracemetrics): Parse units off response in events request for alerts Mar 3, 2026
@linear
Copy link

linear bot commented Mar 3, 2026

Comment on lines +602 to +603
(timeseriesData.meta?.units?.[yAxisAlias] ??
timeseriesData.meta?.units?.[yAxisKey]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to check for both here because the backend no longer requires us to send the aggregate alias, so this would allow both the alias and the raw series name to match.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Multi-series units lookup missing raw key fallback
    • Added fallback to check raw key when alias lookup fails, matching the pattern used in single-series path and transformTimeseriesData function.

Create PR

Or push these changes by commenting:

@cursor push c9e50b7bdc
Preview (c9e50b7bdc)
diff --git a/static/app/components/charts/eventsRequest.tsx b/static/app/components/charts/eventsRequest.tsx
--- a/static/app/components/charts/eventsRequest.tsx
+++ b/static/app/components/charts/eventsRequest.tsx
@@ -556,7 +556,9 @@
         if (fieldsMeta) {
           timeseriesResultsTypes[key] = fieldsMeta;
         }
-        const unitsMeta = timeseriesData[key]!.meta?.units?.[alias];
+        const unitsMeta =
+          timeseriesData[key]!.meta?.units?.[alias] ??
+          timeseriesData[key]!.meta?.units?.[key];
         if (unitsMeta) {
           timeseriesResultsUnits[key] = unitsMeta as DataUnit;
         }
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

true,
durationUnit,
rateUnit
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Axis label formatter missing sizeUnit parameter for size metrics

Medium Severity

The call to axisLabelFormatterUsingAggregateOutputType passes durationUnit and rateUnit but omits the sizeUnit parameter (7th argument). For size-type aggregates like p95(measurements.custom) with unit kibibyte, the formatter defaults to SizeUnit.BYTE, producing incorrect axis labels. The unit info is available in timeseriesResultsUnits but isn't extracted and forwarded like rateUnit and durationUnit are.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is okay. I agree this is weird but in the existing code we already normalized to bytes, so passing in the unit here would have doubled the normalization. I suppose we could get rid of the normalization but I wanted to avoid touching any of the existing behaviour to ensure this only applied for when unit was supplied which is only applicable to tracemetricnar/fix/tracemetrics-parse-units-off-response-in-events-request. Removing the normalization mean ensuring all of the existing code paths for other parts of the app reaching here needed to be checked properly too.

@narsaynorath narsaynorath merged commit fe1a95e into master Mar 4, 2026
60 checks passed
@narsaynorath narsaynorath deleted the nar/fix/tracemetrics-parse-units-off-response-in-events-request branch March 4, 2026 16:05
narsaynorath added a commit that referenced this pull request Mar 10, 2026
`tracemetrics` reports its units through the API response instead of
inferring it on the frontend from the aggregate name. This is because
the metrics themselves can be saved under different units (e.g.
`millisecond`, `minute`, `day`)

To do this we need to read the type and unit from the API response and
plumb them through to the relevant tooltip formatters

This PR is similar to #109608

Resolves LOGS-582
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants