Compare commits

...

1 Commits

Author SHA1 Message Date
Abhi Kumar
0fa2a11262 fix(query-range): request time_series for V1 histogram panels
They bin a time series in the browser; distribution now returns a different shape.
2026-11-12 11:19:22 +05:30
5 changed files with 10 additions and 38 deletions

View File

@@ -4,7 +4,6 @@ import { SuccessResponse, Warning } from 'types/api';
import { MetricRangePayloadV3 } from 'types/api/metrics/getQueryRange';
import {
BuilderQuery,
DistributionData,
MetricRangePayloadV5,
QueryEnvelope,
QueryRangeRequestV5,
@@ -314,20 +313,6 @@ function convertRawData(
};
}
/**
* Converts V5 DistributionData to legacy format
*/
function convertDistributionData(
distributionData: DistributionData,
legendMap: Record<string, string>,
): any {
// Convert V5 distribution format to legacy histogram format
return {
...distributionData,
legendMap,
};
}
/**
* Helper function to convert V5 data based on type
*/
@@ -375,15 +360,6 @@ function convertV5DataByType(
result: traceData.map((trace) => convertRawData(trace, legendMap)),
};
}
case 'distribution': {
const distributionData = v5Data.data.results as DistributionData[];
return {
resultType: 'distribution',
result: distributionData.map((distribution) =>
convertDistributionData(distribution, legendMap),
),
};
}
default:
return {
resultType: '',

View File

@@ -906,6 +906,10 @@ describe('prepareQueryRangePayloadV5', () => {
});
describe('mapPanelTypeToRequestType', () => {
it('sends a histogram as time_series, which it bins in the browser', () => {
expect(mapPanelTypeToRequestType(PANEL_TYPES.HISTOGRAM)).toBe('time_series');
});
it('sends a scatter plot as scalar, like a table', () => {
expect(mapPanelTypeToRequestType(PANEL_TYPES.SCATTER)).toBe('scalar');
});

View File

@@ -47,8 +47,11 @@ type PrepareQueryRangePayloadV5Result = {
*/
export function mapPanelTypeToRequestType(panelType: PANEL_TYPES): RequestType {
switch (panelType) {
// Histogram bins a time series in the browser; `distribution` is the
// Distribution panel's request type.
case PANEL_TYPES.TIME_SERIES:
case PANEL_TYPES.BAR:
case PANEL_TYPES.HISTOGRAM:
return 'time_series';
case PANEL_TYPES.TABLE:
case PANEL_TYPES.SCATTER:
@@ -59,8 +62,6 @@ export function mapPanelTypeToRequestType(panelType: PANEL_TYPES): RequestType {
return 'trace';
case PANEL_TYPES.LIST:
return 'raw';
case PANEL_TYPES.HISTOGRAM:
return 'distribution';
default:
return '';
}

View File

@@ -13,6 +13,7 @@ import type { MetricRangePayloadV3 } from 'types/api/metrics/getQueryRange';
import type {
ColumnDescriptor,
MetricRangePayloadV5,
RawRow,
RequestType,
TimeSeries,
TimeSeriesValue,
@@ -131,7 +132,7 @@ export const queryRangeV5EmptyResponse = (
},
});
export const queryRangeV5RawResponse = <T>(
export const queryRangeV5RawResponse = <T extends RawRow['data']>(
rows: Array<{ timestamp: string; data: T }>,
options: ResponseOptions & {
hasMore?: boolean;

View File

@@ -411,11 +411,6 @@ export interface RawData {
rows: RawRow[];
}
export interface DistributionData {
// Structure to be defined based on requirements
[key: string]: any;
}
// Response data structures with results array
export interface TimeSeriesResponseData {
results: TimeSeriesData[];
@@ -429,15 +424,10 @@ export interface RawResponseData {
results: RawData[];
}
export interface DistributionResponseData {
results: DistributionData[];
}
export type QueryRangeDataV5 =
| TimeSeriesResponseData
| ScalarResponseData
| RawResponseData
| DistributionResponseData;
| RawResponseData;
export interface QueryRangeResponseV5 {
type: RequestType;