Skip to content

Conversation

gggritso
Copy link
Member

@gggritso gggritso commented Sep 29, 2025

Explore makes requests to /events-stats/ but immediately converts that response to an array of TimeSeries objects, which are passed to charts and so on. The way it's done right now is a slight hack, which I'm fixing. If the request is a "top events" grouped by environment, we end up with TimeSeries objects that look like this:

{
  yAxis: "prod",
  values: [...
  meta: {
     ...

This works fine because TimeSeriesWidgetVisualization parses the yAxis value and formats it correctly. A better approach is to actually parse the response properly, and create a full TimeSeries object that looks like this:

{
  yAxis: "count(span.duration)",
  groupBy: [{key: "environment": value: "prod"}],
  meta: {
    isOther: false,
    ...

If we correctly populate yAxis, groupBy, and isOther, that allows TimeSeriesVisualization to correctly label everything by default. This removes the need for setting aliases, and improves compatibility. Incidentally, it also fixes DAIN-119! With a proper groupBy, we don't need to try and parse everything as a version, and cause false positives.

Other than the fix for that small bug, this doesn't create any visible changes in the UI. This also helps me prepare for replacing /events-stats/ with /events-timeseries/ on this page.

NOTE: This change creates a bit of duplication when parsing groupBy, but don't worry, it's temporary, since all this code will go away once we use /events-timeseries/ here.


Note

Refactors timeseries transformation to populate yAxis/groupBy/isOther and ordering, updates chart/formatter to use meta.isOther, adds parseGroupBy, and removes legacy isTimeSeriesOther.

  • Explore timeseries transformation:
    • Refactor transformToSeriesMap and convertEventsStatsToTimeSeriesData to set yAxis, groupBy (via parseGroupBy), meta.isOther, and meta.order; support grouped multi-series; return series grouped by yAxis and sorted by order.
  • Formatting and visualization:
    • formatTimeSeriesName returns "Other" when meta.isOther and continues existing measurement/version/equation formatting.
    • chartVisualization colors series using s.meta.isOther and removes alias-based legend formatting.
  • Types:
    • Export TimeSeriesGroupBy from widgets/common/types.
  • Utilities/Tests:
    • Add parseGroupBy with tests; remove isTimeSeriesOther and its tests; add tests for Other handling in formatter.

Written by Cursor Bugbot for commit ea8e062. This will update automatically on new commits. Configure here.

Copy link

linear bot commented Sep 29, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Sep 29, 2025
Copy link

codecov bot commented Sep 29, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
11684 1 11683 10
View the top 1 failed test(s) by shortest run time
parseGroupBy handles complex mismatch scenarios
Stack Traces | 0.016s run time
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 0
+ Received  + 8

@@ -5,6 +5,14 @@
    },
    Object {
      "key": "field2",
      "value": "val2",
    },
+   Object {
+     "key": "",
+     "value": "val3",
+   },
+   Object {
+     "key": "",
+     "value": "val4",
+   },
  ]
    at Object.toEqual (.../utils/timeSeries/parseGroupBy.spec.tsx:56:21)
    at Promise.finally.completed (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:1559:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:1499:10)
    at _callCircusTest (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:1009:40)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at _runTest (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:949:3)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:839:13)
    at _runTestsForDescribeBlock (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:829:11)
    at run (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:757:3)
    at runAndTransformResultsToJestFormat (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/jestAdapterInit.js:1920:21)
    at jestAdapter (.../sentry/node_modules/.pnpm/jest-circus@30.0.4_babel-plugin-macros@3.1..../jest-circus/build/runner.js:101:19)
    at runTestInternal (.../sentry/node_modules/.pnpm/jest-runner@30.0..../jest-runner/build/testWorker.js:272:16)
    at runTest (.../sentry/node_modules/.pnpm/jest-runner@30.0..../jest-runner/build/testWorker.js:340:7)
    at Object.worker (.../sentry/node_modules/.pnpm/jest-runner@30.0..../jest-runner/build/testWorker.js:494:12)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

cursor[bot]

This comment was marked as outdated.

}

const groupKeys = fields;
const groupValues = groupName.split(',');
Copy link
Member

Choose a reason for hiding this comment

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

This makes the assumption that each group value won't have any commas.

Copy link
Member Author

Choose a reason for hiding this comment

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

🤔 it does make that assumption, yes. I don't think there's actually any way for me to figure out which commas are the delimiters, even knowing how many fields there were originally ... but this problem will go away when we use /events-timeseries/ which separates each field completely

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up making this more permissive, and creating empty keys/values when necessary. The values end up getting concatenated with commas later anyway and the keys are not readily visible to anyone, so we should be good. Good catch, thanks!

Comment on lines +202 to +204
if (groupName === 'Other') {
timeSeries.meta.isOther = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

Feels like the backend should mark some meta to indicate this instead of continuing to relying on the fact that the series name is Other but for now, this is fine.

Copy link
Member Author

@gggritso gggritso Oct 1, 2025

Choose a reason for hiding this comment

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

That is exactly the case for the /events-timeseries/ endpoint! Once we switch over, we won't have to mark it manually 👍🏻

cursor[bot]

This comment was marked as outdated.

@gggritso gggritso merged commit ae6ec7c into master Oct 2, 2025
46 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-119-legend-name-formatter-incorrectly-treats-cache-keys-as branch October 2, 2025 14:01
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