Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions static/app/utils/timeSeries/parseGroupBy.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {parseGroupBy} from './parseGroupBy';

describe('parseGroupBy', () => {
it('returns undefined for "Other" group name', () => {
it('returns null for "Other" group name', () => {
const result = parseGroupBy('Other', ['field1', 'field2']);
expect(result).toBeUndefined();
expect(result).toBeNull();
});

it('parses single field and value correctly', () => {
Expand Down Expand Up @@ -47,6 +47,6 @@ describe('parseGroupBy', () => {

it('handles empty fields array', () => {
const result = parseGroupBy('', []);
expect(result).toBeUndefined();
expect(result).toBeNull();
});
});
6 changes: 3 additions & 3 deletions static/app/utils/timeSeries/parseGroupBy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type {TimeSeriesGroupBy} from 'sentry/views/dashboards/widgets/common/typ
export function parseGroupBy(
groupName: string,
fields: string[]
): TimeSeriesGroupBy[] | undefined {
): TimeSeriesGroupBy[] | null {
if (groupName === 'Other') {
return undefined;
return null;
}

const groupKeys = fields;
Expand All @@ -22,5 +22,5 @@ export function parseGroupBy(
return groupBy.key || groupBy.value;
});

return groupBys.length > 0 ? groupBys : undefined;
return groupBys.length > 0 ? groupBys : null;
}
4 changes: 2 additions & 2 deletions static/app/views/dashboards/widgets/common/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export type TimeSeries = {
* Represents the grouping information for the time series, if applicable.
* e.g., if the initial request supplied a `groupBy` query param of `"span.op"`, the
* `groupBy` of the `TimeSeries` could be `[{key: 'span.op': value: 'db' }]`
* If the `excludeOther` query param is `true`, an "other" time series will be part of the response. `TimeSeries.meta.isOther` specifies the "other" time series.
* If the `excludeOther` query param is `true`, an "other" time series will be part of the response. `TimeSeries.meta.isOther` specifies the "other" time series, and `groupBy` is `null` in that case
*/
groupBy?: TimeSeriesGroupBy[];
groupBy?: TimeSeriesGroupBy[] | null;
};

export type TabularValueType = AttributeValueType | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {decodeSorts} from 'sentry/utils/queryString';
import {getTimeSeriesInterval} from 'sentry/utils/timeSeries/getTimeSeriesInterval';
import {markDelayedData} from 'sentry/utils/timeSeries/markDelayedData';
import {parseGroupBy} from 'sentry/utils/timeSeries/parseGroupBy';
import {useFetchSpanTimeSeries} from 'sentry/utils/timeSeries/useFetchEventsTimeSeries';
import {useFetchEventsTimeSeries} from 'sentry/utils/timeSeries/useFetchEventsTimeSeries';
import type {MutableSearch} from 'sentry/utils/tokenizeSearch';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
Expand Down Expand Up @@ -121,7 +121,8 @@ export const useSortedTimeSeries = <
useIsSampled(0.1, key) &&
organization.features.includes('explore-events-time-series-spot-check');

const timeSeriesResult = useFetchSpanTimeSeries(
const timeSeriesResult = useFetchEventsTimeSeries(
dataset ?? DiscoverDatasets.SPANS,
Comment on lines +124 to +125
Copy link
Contributor

Choose a reason for hiding this comment

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

I kinda liked how we used to have a hook for each dataset. We could alternatively do useFetchSpanTImeSeries, and useFetchLogTimeSeries. I like the little abstraction, imo in code your likely thinking "i wanna fetch a span time series", not "I wanna fetch an events timeseries", although usability wise its pretty much the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

We still have the hook for each dataset! useSortedTimeSeries uses the type-less one though, because it's used for both logs and traces

{
yAxis: yAxis as unknown as any,
query: search,
Expand Down Expand Up @@ -360,16 +361,32 @@ export function convertEventsStatsToTimeSeriesData(
return [delayedTimeSeries.meta.order ?? 0, delayedTimeSeries];
}

const NUMERIC_KEYS: Array<symbol | string | number> = [
'value',
'sampleCount',
'sampleRate',
];

function comparator(
valueA: unknown,
valueB: unknown,
key: symbol | string | number | undefined
) {
// Compare numbers by near equality, which makes the comparison less sensitive to small natural variations in value caused by request sequencing
if (key === 'value' && typeof valueA === 'number' && typeof valueB === 'number') {
if (
key &&
NUMERIC_KEYS.includes(key) &&
typeof valueA === 'number' &&
typeof valueB === 'number'
) {
return areNumbersAlmostEqual(valueA, valueB, 5);
}

// This can be removed when ENG-5677 is resolved. There's a known bug here.
if (key === 'dataScanned') {
return true;
}

// Otherwise use default deep comparison
return undefined;
}
Expand Down
Loading