Compare commits

...

3 Commits

Author SHA1 Message Date
Aditya Singh
30f6175903 refactor(service-details): remove unsafe casts and dead code from the v5 queries (#13780)
Some checks are pending
build-staging / prepare (push) Waiting to run
build-staging / js-build (push) Blocked by required conditions
build-staging / go-build (push) Blocked by required conditions
build-staging / staging (push) Blocked by required conditions
cacheci / tests (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
#### Description

- #13617 moved the service details page to v5. It merged with review
comments still open, and this PR addresses them.
- The query builders take the v5 aggregation types instead of
`MetricAggregateOperator`, so the unsafe `as` casts are gone. The values
are the same strings, so every payload stays the same.
- It removes dead code: the `stepInterval` prop, the unused widget keys,
and the `delta` argument to the ApDex query. The three ApDex formulas
were the same string, so one `FORMULA.APDEX` replaces them.
- The ApDex bucket lookup moves to `MetricsPageQueries/utils.ts`. It
returns the bucket number instead of a string. It also sorts a copy now,
because it sorted the cached bucket array in place.

#### Issues closed by this PR

Part of https://github.com/SigNoz/events-pod/issues/150

#### Additional Information

- No screen renders differently, so no story changes.
2026-12-01 11:43:05 +00:00
Manika Malhotra
98dee29f1f chore(frontend): remove dead code from saved views and the bottom strip (#13801)
#### Description

- Removes the unused `.label` and `.titleText` classes from the saved
views CSS modules. Part of #13738, split by code owner into
#13797–#13802 so each needs one reviewer; this one merges on its own. No
change in behavior or visuals is intended.

#### Additional Information

**Verification**

| Check | Result |
|---|---|
| `tsgo`, `oxlint`, `stylelint` | Run on every commit by the pre-commit
hooks; 0 errors on the head |
| `vite build` | Passes |
| jest, every test that imports a changed file | 5 test files, 17 tests,
0 failed |
| **All six PRs merged on `main`:** | |
| full jest, 10 shards | 1,171 test files, 10,950 tests, 0 failed, 15
skipped |
| Storybook interaction runner | 137 story files, 1,428 tests pass |
| Playwright e2e, Chromium, CI settings, one backend built from `main` |
768 passed, 1 failed (it fails on `main` too), 6 passed on retry. The 8
spec files behind every failure in either run, rerun back to back on an
idle machine: 44 of 44 pass on this build, and on `main` (3 there on
retry) |
| CSS a direct visit loads, per lazily loaded page (384) | Same global
rules as `main` wherever one can apply |
2026-12-01 11:27:52 +00:00
ashu8912
bcb6e708ab fix(alerts): return to the list when a details page's active tab is clicked (#13769)
#### Description

- On a rule details page, Alert Rules is already the active top tab, so
clicking it did nothing: antd `Tabs.onChange` only fires for a new key.
The same happened with Configuration on the new/edit channel pages.
- The top tabs now use `onTabClick`: on a details page, clicking its own
tab goes back to that list. On a list page, clicking the active tab
still does nothing, so the list keeps its filters.
- No visual change, so no story update.
2026-12-01 07:41:15 +00:00
19 changed files with 241 additions and 241 deletions

View File

@@ -1,14 +1,14 @@
import {
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import {
BaseAutocompleteData,
DataTypes,
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import {
DataSource,
MetricAggregateOperator,
QueryBuilderData,
} from 'types/common/queryBuilder';
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
import { FORMULA, MetricsType, WidgetKeys } from '../constant';
import { DatabaseCallProps, DatabaseCallsRPSProps } from '../types';
@@ -55,8 +55,8 @@ export const databaseCallsRPS = ({
const legends = [legend];
const dataSource = DataSource.METRICS;
const timeAggregateOperators = [MetricAggregateOperator.RATE];
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
const timeAggregateOperators = [MetrictypesTimeAggregationDTO.rate];
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
return getQueryBuilderQueries({
autocompleteData,
@@ -113,12 +113,12 @@ export const databaseCallsAvgDuration = ({
const legendFormulas = ['Average Duration'];
const expressions = [FORMULA.DATABASE_CALLS_AVG_DURATION];
const timeAggregateOperators = [
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const dataSource = DataSource.METRICS;

View File

@@ -1,14 +1,14 @@
import {
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import {
BaseAutocompleteData,
DataTypes,
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import {
DataSource,
MetricAggregateOperator,
QueryBuilderData,
} from 'types/common/queryBuilder';
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
import { FORMULA, MetricsType, WidgetKeys } from '../constant';
import {
@@ -88,12 +88,12 @@ export const externalCallErrorPercent = ({
const additionalItems = [additionalItemsA, additionalItemsB];
const timeAggregateOperators = [
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const legends = [legend, legend];
const dataSource = DataSource.METRICS;
@@ -149,12 +149,12 @@ export const externalCallDuration = ({
const additionalItems = [additionalItemsA, additionalItemsA];
const legends = [legend, legend];
const timeAggregateOperators = [
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const dataSource = DataSource.METRICS;
@@ -202,8 +202,8 @@ export const externalCallRpsByAddress = ({
const legends = [legend];
const dataSource = DataSource.METRICS;
const timeAggregateOperators = [MetricAggregateOperator.RATE];
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
const timeAggregateOperators = [MetrictypesTimeAggregationDTO.rate];
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
return getQueryBuilderQueries({
autocompleteData,
@@ -252,12 +252,12 @@ export const externalCallDurationByAddress = ({
const additionalItems = [additionalItemsA, additionalItemsA];
const legends = [legend, legend];
const timeAggregateOperators = [
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const dataSource = DataSource.METRICS;

View File

@@ -1,4 +1,8 @@
import { MetrictypesComparisonSpaceAggregationParamDTO } from 'api/generated/services/sigNoz.schemas';
import {
MetrictypesComparisonSpaceAggregationParamDTO,
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import {
alphabet,
initialFormulaBuilderFormValues,
@@ -7,7 +11,6 @@ import {
import getStep from 'lib/getStep';
import store from 'store';
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
import { SpaceAggregation, TimeAggregation } from 'types/api/v5/queryRange';
import {
DataSource,
MetricAggregateOperator,
@@ -34,8 +37,8 @@ const getAggregations = ({
dataSource: DataSource;
key: string;
aggregateOperator: string;
timeAggregation: MetricAggregateOperator;
spaceAggregation: MetricAggregateOperator;
timeAggregation: MetrictypesTimeAggregationDTO;
spaceAggregation: MetrictypesSpaceAggregationDTO;
comparisonSpaceAggregationParam?: MetrictypesComparisonSpaceAggregationParamDTO;
}): IBuilderQuery['aggregations'] =>
dataSource === DataSource.TRACES
@@ -44,8 +47,8 @@ const getAggregations = ({
{
metricName: key,
temporality: '',
timeAggregation: timeAggregation as TimeAggregation,
spaceAggregation: spaceAggregation as SpaceAggregation,
timeAggregation,
spaceAggregation,
reduceTo: ReduceOperators.AVG,
...(comparisonSpaceAggregationParam && {
comparisonSpaceAggregationParam,
@@ -124,7 +127,6 @@ export const getQueryBuilderQuerieswithFormula = ({
timeAggregateOperators,
spaceAggregateOperators,
comparisonSpaceAggregationParams = [],
stepInterval,
dataSource,
}: BuilderQuerieswithFormulaProps): QueryBuilderData => ({
queryFormulas: expressions.map((expression, index) => ({
@@ -156,7 +158,7 @@ export const getQueryBuilderQuerieswithFormula = ({
items: additionalItems[index],
op: 'AND',
},
stepInterval: stepInterval ?? null,
stepInterval: null,
dataSource,
})),
queryTraceOperator: [],

View File

@@ -1,15 +1,14 @@
import { MetrictypesComparisonSpaceAggregationParamDTO } from 'api/generated/services/sigNoz.schemas';
import {
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import {
BaseAutocompleteData,
DataTypes,
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import {
DataSource,
MetricAggregateOperator,
QueryBuilderData,
} from 'types/common/queryBuilder';
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
import {
FORMULA,
@@ -26,11 +25,11 @@ import {
LatencyProps,
OperationPerSecProps,
} from '../Tabs/types';
import { getNearestHighestBucketValue } from '../utils';
import {
getQueryBuilderQueries,
getQueryBuilderQuerieswithFormula,
} from './MetricsPageQueriesFactory';
import { getLatencyAtOrBelowAggregation } from './utils';
export const latency = ({
servicename,
@@ -43,7 +42,7 @@ export const latency = ({
const newAutoCompleteData: BaseAutocompleteData = {
key: isSpanMetricEnable
? signozLatencyBucketMetrics
: WidgetKeys.SpanDurationNano,
: WidgetKeys.DurationNano,
dataType: DataTypes.Float64,
type: isSpanMetricEnable ? '' : MetricsType.Tag,
};
@@ -83,14 +82,14 @@ export const latency = ({
const queryNameAndExpression = QUERYNAME_AND_EXPRESSION;
const timeAggregateOperators = [
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.EMPTY,
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO[''],
];
const spaceAggregateOperators = [
MetricAggregateOperator.P50,
MetricAggregateOperator.P90,
MetricAggregateOperator.P99,
MetrictypesSpaceAggregationDTO.p50,
MetrictypesSpaceAggregationDTO.p90,
MetrictypesSpaceAggregationDTO.p99,
];
return getQueryBuilderQueries({
@@ -109,33 +108,17 @@ export const apDexMetricsQueryBuilderQueries = ({
servicename,
tagFilterItems,
topLevelOperationsRoute,
threashold,
delta,
threshold,
metricsBuckets,
}: ApDexMetricsQueryBuilderQueriesProps): QueryBuilderData => {
// the comparison count stops at the largest finite bucket, so a threshold past it
// reads the count metric, which is the +Inf bucket
const countAtOrBelow = (
ms: number,
): {
key: string;
spaceAggregation: MetricAggregateOperator;
param?: MetrictypesComparisonSpaceAggregationParamDTO;
} => {
const bucket = getNearestHighestBucketValue(ms, metricsBuckets);
return bucket === '+Inf'
? {
key: WidgetKeys.SignozLatencyCount,
spaceAggregation: MetricAggregateOperator.SUM,
}
: {
key: WidgetKeys.SignozLatencyBucket,
spaceAggregation: MetricAggregateOperator.COUNT,
param: { operator: '<=', threshold: Number(bucket) },
};
};
const satisfied = countAtOrBelow(threashold * 1000);
const tolerating = countAtOrBelow(threashold * 1000 * 4);
const satisfied = getLatencyAtOrBelowAggregation(
threshold * 1000,
metricsBuckets,
);
const tolerating = getLatencyAtOrBelowAggregation(
threshold * 1000 * 4,
metricsBuckets,
);
const autoCompleteDataA: BaseAutocompleteData = {
key: WidgetKeys.SignozLatencyCount,
@@ -213,63 +196,27 @@ export const apDexMetricsQueryBuilderQueries = ({
...tagFilterItems,
];
const filterItemC: TagFilterItem[] = [
{
id: '',
key: {
key: WidgetKeys.StatusCode,
dataType: DataTypes.String,
type: MetricsType.Tag,
},
op: OPERATORS['!='],
value: 'STATUS_CODE_ERROR',
},
{
id: '',
key: {
key: WidgetKeys.OTelServiceName,
dataType: DataTypes.String,
type: MetricsType.Tag,
},
op: OPERATORS['='],
value: servicename,
},
{
id: '',
key: {
key: WidgetKeys.Operation,
dataType: DataTypes.String,
type: MetricsType.Tag,
},
op: OPERATORS.IN,
value: [...topLevelOperationsRoute],
},
...tagFilterItems,
];
const autocompleteData = [
autoCompleteDataA,
autoCompleteDataB,
autoCompleteDataC,
];
const additionalItems = [filterItemA, filterItemB, filterItemC];
const additionalItems = [filterItemA, filterItemB, filterItemB];
const legends = [GraphTitle.APDEX];
const disabled = Array(3).fill(true);
const expressions = delta
? [FORMULA.APDEX_DELTA_SPAN_METRICS]
: [FORMULA.APDEX_CUMULATIVE_SPAN_METRICS];
const expressions = [FORMULA.APDEX];
const legendFormulas = [GraphTitle.APDEX];
// v5 forces increase on histograms, so the total matches it
const timeAggregateOperators = [
MetricAggregateOperator.INCREASE,
MetricAggregateOperator.INCREASE,
MetricAggregateOperator.INCREASE,
MetrictypesTimeAggregationDTO.increase,
MetrictypesTimeAggregationDTO.increase,
MetrictypesTimeAggregationDTO.increase,
];
// a plain sum keeps the le label on B and C, and the formula then cannot join them
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
satisfied.spaceAggregation,
tolerating.spaceAggregation,
];
@@ -336,8 +283,8 @@ export const operationPerSec = ({
const legends = OPERATION_LEGENDS;
const dataSource = DataSource.METRICS;
const timeAggregateOperators = [MetricAggregateOperator.RATE];
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
const timeAggregateOperators = [MetrictypesTimeAggregationDTO.rate];
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
return getQueryBuilderQueries({
autocompleteData,
@@ -431,12 +378,12 @@ export const errorPercentage = ({
const expressions = [FORMULA.ERROR_PERCENTAGE];
const legendFormulas = [GraphTitle.ERROR_PERCENTAGE];
const timeAggregateOperators = [
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const dataSource = DataSource.METRICS;

View File

@@ -1,14 +1,14 @@
import {
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { OPERATORS } from 'constants/queryBuilder';
import {
BaseAutocompleteData,
DataTypes,
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import {
DataSource,
MetricAggregateOperator,
QueryBuilderData,
} from 'types/common/queryBuilder';
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
import {
GraphTitle,
@@ -112,20 +112,20 @@ export const topOperationQueries = ({
KeyOperationTableHeader.NUM_OF_CALLS,
];
const timeAggregateOperators = [
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.P50,
MetricAggregateOperator.P90,
MetricAggregateOperator.P99,
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.p50,
MetrictypesSpaceAggregationDTO.p90,
MetrictypesSpaceAggregationDTO.p99,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const expressions = ['D*100/E'];
const legendFormulas = [GraphTitle.ERROR_PERCENTAGE];

View File

@@ -1,7 +1,7 @@
import { prepareQueryRangePayloadV5 } from 'api/v5/queryRange/prepareQueryRangePayloadV5';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { QueryBuilderData } from 'types/common/queryBuilder';
import { QueryEnvelope } from 'types/api/v5/queryRange';
import { QueryBuilderFormula, QueryEnvelope } from 'types/api/v5/queryRange';
import { EQueryType } from 'types/common/dashboard';
import {
@@ -102,8 +102,7 @@ describe('service details queries on v5', () => {
servicename: 'frontend',
tagFilterItems: [],
topLevelOperationsRoute: ['GET /'],
threashold: 0.5,
delta: true,
threshold: 0.5,
metricsBuckets: [100, 250, 500, 1000, 2000, 5000],
}),
);
@@ -139,6 +138,11 @@ describe('service details queries on v5', () => {
"status.code != 'STATUS_CODE_ERROR' AND service.name = 'frontend' AND operation in ['GET /']",
},
]);
expect(
queries
.filter((query) => query.type === 'builder_formula')
.map((query) => (query.spec as QueryBuilderFormula).expression),
).toStrictEqual(['((B + C)/2)/A']);
});
it('reads the count metric when the apdex threshold is past the largest bucket', () => {
@@ -147,8 +151,7 @@ describe('service details queries on v5', () => {
servicename: 'frontend',
tagFilterItems: [],
topLevelOperationsRoute: ['GET /'],
threashold: 0.5,
delta: true,
threshold: 0.5,
metricsBuckets: [100, 250, 500, 1000],
}),
);

View File

@@ -0,0 +1,23 @@
import { MetrictypesSpaceAggregationDTO } from 'api/generated/services/sigNoz.schemas';
import { WidgetKeys } from '../constant';
import { LatencyAtOrBelowAggregation } from '../Tabs/types';
import { getNearestHighestBucketValue } from '../utils';
// the comparison count stops at the largest finite bucket, so a threshold past it
// reads the count metric, which is the +Inf bucket
export const getLatencyAtOrBelowAggregation = (
thresholdMs: number,
buckets: number[],
): LatencyAtOrBelowAggregation => {
const bucket = getNearestHighestBucketValue(thresholdMs, buckets);
return bucket === undefined
? {
key: WidgetKeys.SignozLatencyCount,
spaceAggregation: MetrictypesSpaceAggregationDTO.sum,
}
: {
key: WidgetKeys.SignozLatencyBucket,
spaceAggregation: MetrictypesSpaceAggregationDTO.count,
param: { operator: '<=', threshold: bucket },
};
};

View File

@@ -24,7 +24,6 @@ import { v4 as uuid } from 'uuid';
import { ApDexMetricsProps } from './types';
function ApDexMetrics({
delta,
metricsBuckets,
thresholdValue,
onDragSelect,
@@ -44,9 +43,8 @@ function ApDexMetrics({
servicename,
tagFilterItems,
topLevelOperationsRoute,
threashold: thresholdValue || 0,
delta: delta || false,
metricsBuckets: metricsBuckets || [],
threshold: thresholdValue || 0,
metricsBuckets,
}),
clickhouse_sql: [],
id: uuid(),
@@ -75,7 +73,6 @@ function ApDexMetrics({
id: SERVICE_CHART_ID.apdex,
}),
[
delta,
metricsBuckets,
servicename,
tagFilterItems,
@@ -92,10 +89,7 @@ function ApDexMetrics({
}, [thresholdValue]);
const isQueryEnabled =
topLevelOperationsRoute.length > 0 &&
!!metricsBuckets &&
metricsBuckets?.length > 0 &&
delta !== undefined;
topLevelOperationsRoute.length > 0 && metricsBuckets.length > 0;
return (
<Graph
@@ -110,9 +104,4 @@ function ApDexMetrics({
);
}
ApDexMetrics.defaultProps = {
delta: undefined,
le: undefined,
};
export default ApDexMetrics;

View File

@@ -31,7 +31,6 @@ function ApDexMetricsApplication({
<ApDexMetrics
topLevelOperationsRoute={topLevelOperationsRoute}
handleGraphClick={handleGraphClick}
delta={data?.data.delta}
metricsBuckets={data?.data.le || []}
onDragSelect={onDragSelect}
tagFilterItems={tagFilterItems}

View File

@@ -13,6 +13,5 @@ export interface ApDexDataSwitcherProps extends ApDexApplicationProps {
}
export interface ApDexMetricsProps extends ApDexDataSwitcherProps {
delta?: boolean;
metricsBuckets?: number[];
metricsBuckets: number[];
}

View File

@@ -1,9 +1,15 @@
import { ReactNode } from 'react';
import { MetrictypesComparisonSpaceAggregationParamDTO } from 'api/generated/services/sigNoz.schemas';
import {
MetrictypesComparisonSpaceAggregationParamDTO,
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { RowData } from 'lib/query/createTableColumnsFromQuery';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import { DataSource, MetricAggregateOperator } from 'types/common/queryBuilder';
import { DataSource } from 'types/common/queryBuilder';
import type { WidgetKeys } from '../constant';
export interface IServiceName {
servicename: string;
@@ -30,8 +36,8 @@ export interface BuilderQueriesProps {
aggregateOperator?: string[];
dataSource: DataSource;
queryNameAndExpression?: string[];
timeAggregateOperators: MetricAggregateOperator[];
spaceAggregateOperators: MetricAggregateOperator[];
timeAggregateOperators: MetrictypesTimeAggregationDTO[];
spaceAggregateOperators: MetrictypesSpaceAggregationDTO[];
}
export interface BuilderQuerieswithFormulaProps {
@@ -42,14 +48,12 @@ export interface BuilderQuerieswithFormulaProps {
expressions: string[];
legendFormulas: string[];
additionalItems: TagFilterItem[][];
timeAggregateOperators: MetricAggregateOperator[];
spaceAggregateOperators: MetricAggregateOperator[];
timeAggregateOperators: MetrictypesTimeAggregationDTO[];
spaceAggregateOperators: MetrictypesSpaceAggregationDTO[];
comparisonSpaceAggregationParams?: (
| MetrictypesComparisonSpaceAggregationParamDTO
| undefined
)[];
// v5 picks its own step when none is sent; v4 needs one
stepInterval?: number;
dataSource: DataSource;
}
@@ -70,7 +74,7 @@ export interface ApDexProps {
servicename: IServiceName['servicename'];
tagFilterItems: TagFilterItem[];
topLevelOperationsRoute: string[];
threashold: number;
threshold: number;
}
export interface TableRendererProps {
@@ -78,7 +82,12 @@ export interface TableRendererProps {
renderFunction: (record: RowData) => ReactNode;
}
export interface LatencyAtOrBelowAggregation {
key: WidgetKeys;
spaceAggregation: MetrictypesSpaceAggregationDTO;
param?: MetrictypesComparisonSpaceAggregationParamDTO;
}
export interface ApDexMetricsQueryBuilderQueriesProps extends ApDexProps {
delta: boolean;
metricsBuckets: number[];
}

View File

@@ -30,23 +30,10 @@ export const SERVICE_DETAIL_DRILLDOWN_ENABLED = true;
export enum FORMULA {
ERROR_PERCENTAGE = 'A*100/B',
DATABASE_CALLS_AVG_DURATION = 'A/B',
// The apdex formula is (satisfied_count + 0.5 * tolerating_count + 0 * frustating_count) / total_count
// The satisfied_count is B, tolerating_count is C, total_count is A
// But why do we have (B+C)/2 instead of B + C/2?
// The way we issue the query is latency <= threshold, which means we over count i.e
// query B => durationNano <= 500ms
// query C => durationNano <= 2000ms
// Since <= 2000ms includes <= 500ms, we over count, to correct we subtract B/2
// so the full expression would be (B + C/2) - B/2 = (B+C)/2
// However, if you add a filter on durationNano > 500ms, (filterItemC in overviewQueries) the query would be
// B + C/2
APDEX_TRACES = '((B + C)/2)/A',
// The delta span metrics store delta compared to previous reporting interval
// but not the counts for the current interval. The bucket counts are cumulative
APDEX_DELTA_SPAN_METRICS = '((B + C)/2)/A',
// Cumulative span metrics store the counts for all buckets
// so we need to subtract B/2 to correct the over counting
APDEX_CUMULATIVE_SPAN_METRICS = '((B + C)/2)/A',
// Apdex is (satisfied + tolerating / 2) / total, with satisfied B, tolerating C and total A.
// C counts requests up to the bucket covering 4x the threshold, so it includes B:
// B + (C - B) / 2 = (B + C) / 2
APDEX = '((B + C)/2)/A',
}
export const TOP_LEVEL_OPERATIONS = ['{{.top_level_operations}}'];
@@ -80,17 +67,13 @@ export enum MetricsType {
}
export enum WidgetKeys {
Le = 'le',
Name = 'name',
HasError = 'hasError',
Address = 'address',
DurationNano = 'durationNano',
SpanDurationNano = 'duration_nano',
DurationNano = 'duration_nano',
StatusCode = 'status.code',
Operation = 'operation',
OperationName = 'operationName',
OTelServiceName = 'service.name',
ServiceName = 'serviceName',
SignozLatencyCount = 'signoz_latency.count',
SignozDBLatencyCount = 'signoz_db_latency_count',
DatabaseCallCount = 'signoz_database_call_count',

View File

@@ -29,17 +29,24 @@ describe('Error Rate', () => {
describe('getNearestHighestBucketValue', () => {
it('should return nearest higher bucket value', () => {
expect(getNearestHighestBucketValue(50, [10, 20, 30, 40, 60, 70])).toBe('60');
expect(getNearestHighestBucketValue(50, [10, 20, 30, 40, 60, 70])).toBe(60);
});
it('should return +Inf for value higher than any bucket', () => {
expect(getNearestHighestBucketValue(80, [10, 20, 30, 40, 60, 70])).toBe(
'+Inf',
);
it('should return undefined for value higher than any bucket', () => {
expect(
getNearestHighestBucketValue(80, [10, 20, 30, 40, 60, 70]),
).toBeUndefined();
});
it('should return the first bucket for value lower than all buckets', () => {
expect(getNearestHighestBucketValue(5, [10, 20, 30, 40, 60, 70])).toBe('10');
expect(getNearestHighestBucketValue(5, [10, 20, 30, 40, 60, 70])).toBe(10);
});
it('should not reorder the buckets it is given', () => {
const buckets = [60, 10, 30];
expect(getNearestHighestBucketValue(20, buckets)).toBe(30);
expect(buckets).toStrictEqual([60, 10, 30]);
});
});

View File

@@ -47,11 +47,9 @@ export const navigateToTrace = ({
export const getNearestHighestBucketValue = (
value: number,
buckets: number[],
): string => {
// sort the buckets
buckets.sort((a, b) => a - b);
const nearestBucket = buckets.find((bucket) => bucket >= value);
return nearestBucket?.toString() || '+Inf';
): number | undefined => {
// buckets are cached query data; never mutate
return [...buckets].sort((a, b) => a - b).find((bucket) => bucket >= value);
};
export const convertedTracesToDownloadData = (

View File

@@ -3,8 +3,3 @@
flex-direction: column;
gap: var(--spacing-3);
}
.label {
font-size: var(--label-small-400-font-size);
color: var(--l1-foreground);
}

View File

@@ -32,8 +32,3 @@
gap: var(--spacing-6);
color: var(--l2-foreground);
}
.titleText {
color: inherit;
font-size: var(--label-base-400-font-size);
}

View File

@@ -1,3 +1,7 @@
import {
MetrictypesSpaceAggregationDTO,
MetrictypesTimeAggregationDTO,
} from 'api/generated/services/sigNoz.schemas';
import { ServiceDataProps } from 'api/metrics/getTopLevelOperations';
import { OPERATORS } from 'constants/queryBuilder';
import {
@@ -11,11 +15,7 @@ import {
DataTypes,
} from 'types/api/queryBuilder/queryAutocompleteResponse';
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
import {
DataSource,
MetricAggregateOperator,
QueryBuilderData,
} from 'types/common/queryBuilder';
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
export const serviceMetricsQuery = (
topLevelOperation: [keyof ServiceDataProps, string[]],
@@ -155,16 +155,16 @@ export const serviceMetricsQuery = (
];
const timeAggregateOperators = [
MetricAggregateOperator.EMPTY,
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetricAggregateOperator.RATE,
MetrictypesTimeAggregationDTO[''],
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
MetrictypesTimeAggregationDTO.rate,
];
const spaceAggregateOperators = [
MetricAggregateOperator.P99,
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetricAggregateOperator.SUM,
MetrictypesSpaceAggregationDTO.p99,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
MetrictypesSpaceAggregationDTO.sum,
];
const disabled = [false, true, true, false];

View File

@@ -41,6 +41,12 @@ jest.mock('pages/AlertDetails', () => ({
return <div>Alert Details Component</div>;
},
}));
jest.mock('pages/ChannelsNew', () => ({
__esModule: true,
default: function MockChannelsNew(): JSX.Element {
return <div>Channels New Component</div>;
},
}));
jest.mock('../NotificationChannels/NotificationChannels', () => ({
__esModule: true,
default: function MockNotificationChannels(): JSX.Element {
@@ -167,6 +173,41 @@ describe('AlertList', () => {
`/alerts?tab=Configuration&subTab=${CHANNELS_SUB_TAB}`,
);
});
it('navigates to the alert rules list when Alert Rules is clicked on a rule details page', async () => {
mockQueryParams({ ruleId: 'rule-1' });
mockLocation('/alerts/overview');
render(<AlertList />);
await clickTab(ALERT_RULES_TEXT);
expect(mockSafeNavigate).toHaveBeenCalledWith('/alerts?tab=AlertRules');
});
it('navigates to the channels list when Configuration is clicked on a channel page', async () => {
mockQueryParams({});
mockLocation('/alerts/channels/new');
render(<AlertList />);
await clickTab(CONFIGURATION_TEXT);
expect(mockSafeNavigate).toHaveBeenCalledWith(
`/alerts?tab=Configuration&subTab=${CHANNELS_SUB_TAB}`,
);
});
it('does not navigate when the active list tab is clicked again', async () => {
mockQueryParams({ tab: 'AlertRules' });
mockLocation(ALERTS_PATH);
render(<AlertList />);
await clickTab(ALERT_RULES_TEXT);
expect(mockSafeNavigate).not.toHaveBeenCalled();
});
});
describe('Configuration Tab with Secondary Sidebar', () => {

View File

@@ -53,14 +53,16 @@ function AllAlertList(): JSX.Element {
const tab = urlQuery.get('tab');
const subTab = urlQuery.get('subTab');
const isAlertHistory = location.pathname === ROUTES.ALERT_HISTORY;
const isAlertOverview = location.pathname === ROUTES.ALERT_OVERVIEW;
const isRuleDetails =
location.pathname === ROUTES.ALERT_HISTORY ||
location.pathname === ROUTES.ALERT_OVERVIEW;
const isChannelsNew = location.pathname === ROUTES.CHANNELS_NEW;
const isChannelsEdit = location.pathname.startsWith('/alerts/channels/edit/');
const isChannelDetails = isChannelsNew || isChannelsEdit;
const isDetailsView = isRuleDetails || isChannelDetails;
const getActiveTab = useCallback((): string => {
if (isAlertHistory || isAlertOverview) {
if (isRuleDetails) {
return AlertListTabs.ALERT_RULES;
}
if (isChannelDetails) {
@@ -74,7 +76,7 @@ function AllAlertList(): JSX.Element {
return AlertListTabs.CONFIGURATION;
}
return tab || AlertListTabs.ALERT_RULES;
}, [isAlertHistory, isAlertOverview, isChannelDetails, tab]);
}, [isRuleDetails, isChannelDetails, tab]);
const getActiveSubTab = useCallback((): AlertListSubTabs => {
if (isChannelDetails) {
@@ -114,6 +116,18 @@ function AllAlertList(): JSX.Element {
[getActiveSubTab, safeNavigate],
);
// A details page shows its parent tab as active, so a click on that tab must
// still navigate back to the list; antd only fires onChange for a new key.
const handleTopTabClick = useCallback(
(clickedTab: string): void => {
if (clickedTab === getActiveTab() && !isDetailsView) {
return;
}
handleTopTabChange(clickedTab);
},
[getActiveTab, handleTopTabChange, isDetailsView],
);
const handleSubTabChange = useCallback(
(newSubTab: AlertListSubTabs): void => {
const queryParams = new URLSearchParams();
@@ -201,7 +215,7 @@ function AllAlertList(): JSX.Element {
key: AlertListTabs.ALERT_RULES,
children: (
<div className="alert-rules-container">
{isAlertHistory || isAlertOverview ? <AlertDetails /> : <AllAlertRules />}
{isRuleDetails ? <AlertDetails /> : <AllAlertRules />}
</div>
),
},
@@ -222,12 +236,8 @@ function AllAlertList(): JSX.Element {
destroyInactiveTabPane
items={items}
activeKey={getActiveTab()}
onChange={handleTopTabChange}
className={`alerts-container ${
isAlertHistory || isAlertOverview || isChannelDetails
? 'alert-details-tabs'
: ''
}`}
onTabClick={handleTopTabClick}
className={`alerts-container ${isDetailsView ? 'alert-details-tabs' : ''}`}
tabBarExtraContent={
<HeaderRightSection
enableAnnouncements={false}