mirror of
https://github.com/SigNoz/signoz.git
synced 2026-12-02 13:11:24 +00:00
Compare commits
61 Commits
split/4-e2
...
feat/distr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3314c5009 | ||
|
|
f322bf9b6e | ||
|
|
8fa52236ed | ||
|
|
2c1b959b86 | ||
|
|
27077ec0e3 | ||
|
|
e65bbd281f | ||
|
|
19a737ee41 | ||
|
|
c6e9f8d7fa | ||
|
|
2fe90d84c4 | ||
|
|
659d3fc204 | ||
|
|
30f6175903 | ||
|
|
98dee29f1f | ||
|
|
bcb6e708ab | ||
|
|
d09a79a985 | ||
|
|
48659aad9d | ||
|
|
e9dbf177ab | ||
|
|
ad8425980c | ||
|
|
7aa2aefcd6 | ||
|
|
02edef8406 | ||
|
|
398b1222fb | ||
|
|
29fde6be19 | ||
|
|
27e18b7a31 | ||
|
|
701eac5364 | ||
|
|
3eb014ac3f | ||
|
|
74a82a31a1 | ||
|
|
7003813175 | ||
|
|
b60750c393 | ||
|
|
c1b2107b9e | ||
|
|
836f59becc | ||
|
|
4d7af6a20c | ||
|
|
e9177dd8ea | ||
|
|
295b837a78 | ||
|
|
1996cdb1fb | ||
|
|
26a5ac3507 | ||
|
|
0717c0b5ba | ||
|
|
eefb1837fb | ||
|
|
307408634f | ||
|
|
c2983f34d5 | ||
|
|
5d7e250e02 | ||
|
|
a5773dcddc | ||
|
|
b5f5387246 | ||
|
|
49a025243b | ||
|
|
83803e020a | ||
|
|
7d25dc40ad | ||
|
|
c24be2d17c | ||
|
|
d054046688 | ||
|
|
04bdb49abd | ||
|
|
59f8fbecfc | ||
|
|
20dda1d872 | ||
|
|
479238cb40 | ||
|
|
08d7bbc32f | ||
|
|
542fd1432d | ||
|
|
f0b805ce21 | ||
|
|
e802abaf74 | ||
|
|
0cd4b05cc3 | ||
|
|
2733421a05 | ||
|
|
be0baa98fa | ||
|
|
3f4a28f86d | ||
|
|
53887f9788 | ||
|
|
0fef6d1a6f | ||
|
|
5eb5a23269 |
26
.claude/rules/ai-terms.md
Normal file
26
.claude/rules/ai-terms.md
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
paths:
|
||||
- "pkg/types/aiobservabilitytypes/**"
|
||||
- "pkg/telemetryschema/aitelemetryschema/**"
|
||||
- "pkg/statementbuilder/aistatementbuilder/**"
|
||||
- "pkg/types/llmpricingruletypes/**"
|
||||
- "pkg/modules/llmpricingrule/**"
|
||||
- "pkg/modules/spanmapper/**"
|
||||
- "pkg/modules/tracedetail/**"
|
||||
- "pkg/types/spantypes/**"
|
||||
- "frontend/src/container/LLMObservability/**"
|
||||
- "frontend/src/pages/LLMObservability/**"
|
||||
- "frontend/src/pages/TraceDetailsV3/**"
|
||||
- "tests/integration/tests/querierai/**"
|
||||
- "tests/integration/tests/tracedetail/**"
|
||||
- "tests/e2e/tests/llm-o11y/**"
|
||||
---
|
||||
|
||||
# AI observability glossary
|
||||
|
||||
The names for AI observability concepts, so code and instructions use them without redefining them: in field names, descriptions, column aliases, UI text and tests. They match the AI explorer's per-trace fields, `TraceAggregateFields` in `pkg/telemetryschema/aitelemetryschema/const.go`.
|
||||
|
||||
- **LLM call**: a span with `gen_ai.request.model`. Its count is `llm_call_count`, or `llmCallCount` in a camelCase response.
|
||||
- **Tool call**: a span with `gen_ai.tool.name`. Its count is `tool_call_count`, or `toolCallCount`.
|
||||
- **gen_ai span**: a span with any of `GenAISpanGateKeys`: an LLM call, a tool call or an agent span.
|
||||
- **Review check.** "model call", `modelCall` or `model_call` in a name, a description or UI text is a finding: it is an LLM call.
|
||||
1063
docs/api/openapi.yml
1063
docs/api/openapi.yml
File diff suppressed because it is too large
Load Diff
@@ -89,6 +89,15 @@ func (ah *APIHandler) getFeatureFlags(w http.ResponseWriter, r *http.Request) {
|
||||
Route: "",
|
||||
})
|
||||
|
||||
useNotificationTemplate := ah.Signoz.Flagger.BooleanOrEmpty(ctx, flagger.FeatureUseNotificationTemplate, evalCtx)
|
||||
featureSet = append(featureSet, &licensetypes.Feature{
|
||||
Name: valuer.NewString(flagger.FeatureUseNotificationTemplate.String()),
|
||||
Active: useNotificationTemplate,
|
||||
Usage: 0,
|
||||
UsageLimit: -1,
|
||||
Route: "",
|
||||
})
|
||||
|
||||
ah.Respond(w, featureSet)
|
||||
}
|
||||
|
||||
|
||||
@@ -298,6 +298,8 @@
|
||||
// Steers call sites to the src/lib/router facade (allowlisted in overrides below)
|
||||
"signoz/no-builder-ai-query-access": "error",
|
||||
// Steers AI slot access to lib/query/builderSlot (allowlisted in overrides below)
|
||||
"signoz/no-monaco-stripped-features": "error",
|
||||
// Bans Monaco features the production build strips, and monaco-editor value imports outside src/lib/monaco/setup.ts (allowlisted in overrides below)
|
||||
"no-restricted-globals": [
|
||||
"error",
|
||||
{
|
||||
@@ -644,6 +646,13 @@
|
||||
"rules": {
|
||||
"signoz/no-builder-ai-query-access": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
// setup.ts owns the monaco-editor imports that pick the languages and workers
|
||||
"files": ["src/lib/monaco/setup.ts"],
|
||||
"rules": {
|
||||
"signoz/no-monaco-stripped-features": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
132
frontend/plugins/__tests__/no-monaco-stripped-features.test.mjs
Normal file
132
frontend/plugins/__tests__/no-monaco-stripped-features.test.mjs
Normal file
@@ -0,0 +1,132 @@
|
||||
import { ruleTester } from './rule-tester.mjs';
|
||||
|
||||
const IMPORT = 'Import Monaco from lib/monaco/setup';
|
||||
const STRIPPED = 'which the production build strips';
|
||||
|
||||
await ruleTester({
|
||||
rule: 'no-monaco-stripped-features',
|
||||
valid: [
|
||||
{
|
||||
name: 'setup import',
|
||||
code: "import { monaco } from 'lib/monaco/setup';",
|
||||
},
|
||||
{
|
||||
name: 'type-only import',
|
||||
code: "import type { editor } from 'monaco-editor';",
|
||||
},
|
||||
{
|
||||
name: 'inline type specifiers only',
|
||||
code: "import { type editor, type languages } from 'monaco-editor';",
|
||||
},
|
||||
{
|
||||
name: 'type-only re-export',
|
||||
code: "export type { editor } from 'monaco-editor';",
|
||||
},
|
||||
{
|
||||
name: 'inline type re-export specifiers only',
|
||||
code: "export { type editor, type languages } from 'monaco-editor';",
|
||||
},
|
||||
{
|
||||
name: 'react wrapper',
|
||||
code: "import Editor from '@monaco-editor/react';",
|
||||
},
|
||||
{
|
||||
name: 'kept provider',
|
||||
code: "monaco.languages.registerCompletionItemProvider('json', {});",
|
||||
},
|
||||
{
|
||||
name: 'stripped option turned off',
|
||||
code:
|
||||
"const o = { experimentalGpuAcceleration: 'off', minimap: { showMarkSectionHeaders: false } };",
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
name: 'package entry import',
|
||||
code: "import * as monaco from 'monaco-editor';",
|
||||
errors: [{ message: IMPORT, line: 1, column: 25 }],
|
||||
},
|
||||
{
|
||||
name: 'deep import',
|
||||
code:
|
||||
"import 'monaco-editor/esm/vs/basic-languages/python/python.contribution.js';",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'mixed value and type specifiers',
|
||||
code: "import { editor, type languages } from 'monaco-editor';",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'dynamic import',
|
||||
code: "const m = await import('monaco-editor');",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'require',
|
||||
code: "const m = require('monaco-editor');",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 're-export',
|
||||
code: "export { editor } from 'monaco-editor';",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'mixed value and type re-export specifiers',
|
||||
code: "export { editor, type languages } from 'monaco-editor';",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'export all',
|
||||
code: "export * from 'monaco-editor';",
|
||||
errors: [{ message: IMPORT }],
|
||||
},
|
||||
{
|
||||
name: 'stripped provider on monaco.languages',
|
||||
code: "monaco.languages.registerInlayHintsProvider('sql', {});",
|
||||
errors: [
|
||||
{
|
||||
message: 'needs the Monaco `inlayHints` contribution',
|
||||
line: 1,
|
||||
column: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'stripped provider on a destructured languages',
|
||||
code: "languages.registerSignatureHelpProvider('sql', {});",
|
||||
errors: [{ message: '`parameterHints`' }],
|
||||
},
|
||||
{
|
||||
name: 'stripped provider called bare',
|
||||
code: "registerRenameProvider('json', {});",
|
||||
errors: [{ message: '`rename`' }],
|
||||
},
|
||||
{
|
||||
name: 'stripped provider through a string key',
|
||||
code: "monaco.languages['registerRenameProvider']('json', {});",
|
||||
errors: [{ message: '`rename`' }],
|
||||
},
|
||||
{
|
||||
name: 'semantic tokens provider',
|
||||
code: "monaco.languages.registerDocumentSemanticTokensProvider('json', {});",
|
||||
errors: [{ message: '`semanticTokens`' }],
|
||||
},
|
||||
{
|
||||
name: 'stripped option turned on',
|
||||
code: "const o = { experimentalGpuAcceleration: 'on' };",
|
||||
errors: [{ message: '`gpu`', line: 1, column: 13 }],
|
||||
},
|
||||
{
|
||||
name: 'stripped option with a variable value',
|
||||
code: 'const o = { minimap: { showRegionSectionHeaders: enabled } };',
|
||||
errors: [{ message: STRIPPED }],
|
||||
},
|
||||
{
|
||||
name: 'quoted option key',
|
||||
code: "const o = { 'showMarkSectionHeaders': true };",
|
||||
errors: [{ message: '`sectionHeaders`' }],
|
||||
},
|
||||
],
|
||||
});
|
||||
147
frontend/plugins/rules/no-monaco-stripped-features.mjs
Normal file
147
frontend/plugins/rules/no-monaco-stripped-features.mjs
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* Rule: no-monaco-stripped-features
|
||||
*
|
||||
* The production build drops the Monaco contributions listed in
|
||||
* plugins/rules/shared/monaco-stripped-features.mjs. Dev and Storybook still carry them,
|
||||
* so a provider or option for one of them works there and silently does nothing
|
||||
* in production. This rule reports them, plus value imports of `monaco-editor`
|
||||
* outside src/lib/monaco/setup.ts: the package entry registers every language and
|
||||
* worker.
|
||||
*
|
||||
* src/lib/monaco/setup.ts is allowlisted via overrides in .oxlintrc.json.
|
||||
*/
|
||||
|
||||
import { MONACO_STRIPPED_FEATURES } from './shared/monaco-stripped-features.mjs';
|
||||
|
||||
const featureByProvider = new Map();
|
||||
const featureByOption = new Map();
|
||||
for (const [feature, { providers = [], options = [] }] of Object.entries(
|
||||
MONACO_STRIPPED_FEATURES,
|
||||
)) {
|
||||
providers.forEach((name) => featureByProvider.set(name, feature));
|
||||
options.forEach((name) => featureByOption.set(name, feature));
|
||||
}
|
||||
|
||||
function isMonacoSource(value) {
|
||||
return value === 'monaco-editor' || value.startsWith('monaco-editor/');
|
||||
}
|
||||
|
||||
function isTypeOnlyImport(node) {
|
||||
return (
|
||||
node.importKind === 'type' ||
|
||||
(node.specifiers.length > 0 &&
|
||||
node.specifiers.every((s) => s.importKind === 'type'))
|
||||
);
|
||||
}
|
||||
|
||||
function isTypeOnlyExport(node) {
|
||||
return (
|
||||
node.exportKind === 'type' ||
|
||||
(node.specifiers.length > 0 &&
|
||||
node.specifiers.every((s) => s.exportKind === 'type'))
|
||||
);
|
||||
}
|
||||
|
||||
function propertyName(node) {
|
||||
if (node.type === 'Identifier') {
|
||||
return node.name;
|
||||
}
|
||||
if (node.type === 'Literal' && typeof node.value === 'string') {
|
||||
return node.value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function isDisabledValue(node) {
|
||||
return (
|
||||
node.type === 'Literal' && (node.value === false || node.value === 'off')
|
||||
);
|
||||
}
|
||||
|
||||
export default {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description:
|
||||
'Disallow Monaco features the production build strips, and value imports of monaco-editor outside src/lib/monaco/setup.ts',
|
||||
category: 'Monaco',
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
provider:
|
||||
'{{name}} needs the Monaco `{{feature}}` contribution, which the production build strips, so it works in dev and does nothing in production. Remove `{{feature}}` from plugins/rules/shared/monaco-stripped-features.mjs to use it.',
|
||||
option:
|
||||
'`{{name}}` needs the Monaco `{{feature}}` contribution, which the production build strips, so it works in dev and does nothing in production. Remove `{{feature}}` from plugins/rules/shared/monaco-stripped-features.mjs to use it.',
|
||||
import:
|
||||
'Import Monaco from lib/monaco/setup, not monaco-editor: the package entry registers every language and worker. Type-only imports are fine.',
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const reportSource = (source) => {
|
||||
if (
|
||||
source?.type === 'Literal' &&
|
||||
typeof source.value === 'string' &&
|
||||
isMonacoSource(source.value)
|
||||
) {
|
||||
context.report({ node: source, messageId: 'import' });
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
if (!isTypeOnlyImport(node)) {
|
||||
reportSource(node.source);
|
||||
}
|
||||
},
|
||||
ImportExpression: (node) => reportSource(node.source),
|
||||
ExportAllDeclaration(node) {
|
||||
if (node.exportKind !== 'type') {
|
||||
reportSource(node.source);
|
||||
}
|
||||
},
|
||||
ExportNamedDeclaration(node) {
|
||||
if (!isTypeOnlyExport(node)) {
|
||||
reportSource(node.source);
|
||||
}
|
||||
},
|
||||
CallExpression(node) {
|
||||
const { callee } = node;
|
||||
if (callee.type === 'Identifier' && callee.name === 'require') {
|
||||
reportSource(node.arguments[0]);
|
||||
return;
|
||||
}
|
||||
const name =
|
||||
callee.type === 'MemberExpression'
|
||||
? propertyName(callee.property)
|
||||
: callee.type === 'Identifier'
|
||||
? callee.name
|
||||
: null;
|
||||
if (name !== null && featureByProvider.has(name)) {
|
||||
context.report({
|
||||
node: callee,
|
||||
messageId: 'provider',
|
||||
data: { name, feature: featureByProvider.get(name) },
|
||||
});
|
||||
}
|
||||
},
|
||||
Property(node) {
|
||||
if (node.computed) {
|
||||
return;
|
||||
}
|
||||
const name = propertyName(node.key);
|
||||
if (
|
||||
name !== null &&
|
||||
featureByOption.has(name) &&
|
||||
!isDisabledValue(node.value)
|
||||
) {
|
||||
context.report({
|
||||
node: node.key,
|
||||
messageId: 'option',
|
||||
data: { name, feature: featureByOption.get(name) },
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
29
frontend/plugins/rules/shared/monaco-stripped-features.mjs
Normal file
29
frontend/plugins/rules/shared/monaco-stripped-features.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Monaco editor contributions the production build drops (vite.config.ts marks
|
||||
* them side-effect free), with the API that would need them at runtime.
|
||||
* `signoz/no-monaco-stripped-features` reports those APIs, since the build
|
||||
* leaves them without an error and without an effect.
|
||||
*
|
||||
* To use one, delete its entry here.
|
||||
*/
|
||||
export const MONACO_STRIPPED_FEATURES = {
|
||||
codelens: { providers: ['registerCodeLensProvider'] },
|
||||
dropOrPasteInto: {},
|
||||
gpu: { options: ['experimentalGpuAcceleration'] },
|
||||
inlayHints: { providers: ['registerInlayHintsProvider'] },
|
||||
inlineCompletions: { providers: ['registerInlineCompletionsProvider'] },
|
||||
linkedEditing: { providers: ['registerLinkedEditingRangeProvider'] },
|
||||
parameterHints: { providers: ['registerSignatureHelpProvider'] },
|
||||
rename: {
|
||||
providers: ['registerRenameProvider', 'registerNewSymbolNameProvider'],
|
||||
},
|
||||
sectionHeaders: {
|
||||
options: ['showRegionSectionHeaders', 'showMarkSectionHeaders'],
|
||||
},
|
||||
semanticTokens: {
|
||||
providers: [
|
||||
'registerDocumentSemanticTokensProvider',
|
||||
'registerDocumentRangeSemanticTokensProvider',
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -21,6 +21,7 @@ import noTextCss from './rules/no-text-css.mjs';
|
||||
import requireDisableReason from './rules/require-disable-reason.mjs';
|
||||
import noDomNodeAccess from './rules/no-dom-node-access.mjs';
|
||||
import noBuilderAiQueryAccess from './rules/no-builder-ai-query-access.mjs';
|
||||
import noMonacoStrippedFeatures from './rules/no-monaco-stripped-features.mjs';
|
||||
|
||||
export default {
|
||||
meta: {
|
||||
@@ -43,5 +44,6 @@ export default {
|
||||
'require-disable-reason': requireDisableReason,
|
||||
'no-dom-node-access': noDomNodeAccess,
|
||||
'no-builder-ai-query-access': noBuilderAiQueryAccess,
|
||||
'no-monaco-stripped-features': noMonacoStrippedFeatures,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7248,6 +7248,123 @@ export interface DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDa
|
||||
spec: DashboardtypesTopListPanelSpecDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* The panel kind.
|
||||
*/
|
||||
export enum DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTOKind {
|
||||
'signoz/DistributionPanel' = 'signoz/DistributionPanel',
|
||||
}
|
||||
export interface DashboardtypesDistributionXAxisDTO {
|
||||
/**
|
||||
* @type number,null
|
||||
* @description Buckets wholly above this value are hidden. Null shows them all.
|
||||
*/
|
||||
max?: number | null;
|
||||
/**
|
||||
* @type number,null
|
||||
* @description Buckets wholly below this value are hidden. Null shows them all.
|
||||
*/
|
||||
min?: number | null;
|
||||
}
|
||||
|
||||
export enum DashboardtypesDistributionYScaleDTO {
|
||||
linear = 'linear',
|
||||
log = 'log',
|
||||
}
|
||||
export interface DashboardtypesDistributionYAxisDTO {
|
||||
/**
|
||||
* @description How counts are spaced: linear (default) or log.
|
||||
*/
|
||||
scale: DashboardtypesDistributionYScaleDTO;
|
||||
}
|
||||
|
||||
export interface DashboardtypesDistributionAxesDTO {
|
||||
/**
|
||||
* @description The bucket axis.
|
||||
*/
|
||||
x?: DashboardtypesDistributionXAxisDTO;
|
||||
/**
|
||||
* @description The count axis.
|
||||
*/
|
||||
y?: DashboardtypesDistributionYAxisDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @maxItems 5
|
||||
*/
|
||||
export type DashboardtypesDistributionPercentileValuesDTO = number[];
|
||||
|
||||
export interface DashboardtypesDistributionPercentilesDTO {
|
||||
/**
|
||||
* @type boolean,null
|
||||
* @description Whether percentile markers are drawn. Null draws them.
|
||||
*/
|
||||
enabled?: boolean | null;
|
||||
/**
|
||||
* @description The percentiles to mark, each greater than 0 and less than 100, at most 5, no repeats. Null or omitted marks 50, 90 and 99; [] marks none.
|
||||
*/
|
||||
values: DashboardtypesDistributionPercentileValuesDTO;
|
||||
}
|
||||
|
||||
export interface DashboardtypesDistributionChartAppearanceDTO {
|
||||
/**
|
||||
* @description Percentile markers drawn across the bucket axis.
|
||||
*/
|
||||
percentiles?: DashboardtypesDistributionPercentilesDTO;
|
||||
}
|
||||
|
||||
export enum DashboardtypesDistributionStackModeDTO {
|
||||
normal = 'normal',
|
||||
none = 'none',
|
||||
percent = 'percent',
|
||||
}
|
||||
export interface DashboardtypesDistributionVisualizationDTO {
|
||||
/**
|
||||
* @description How groups combine in a bucket: normal (default) stacks them, none draws them side by side, percent stacks them as shares of the bucket.
|
||||
*/
|
||||
stack: DashboardtypesDistributionStackModeDTO;
|
||||
/**
|
||||
* @description The time range the panel queries: global_time (default) follows the dashboard range; last_5_min, last_15_min, last_30_min, last_1_hr, last_6_hr, last_1_day, last_3_days, last_1_week or last_1_month pin a fixed window.
|
||||
*/
|
||||
timePreference?: DashboardtypesTimePreferenceDTO;
|
||||
}
|
||||
|
||||
export interface DashboardtypesDistributionPanelSpecDTO {
|
||||
/**
|
||||
* @description The X (bucket) axis range and Y (count) axis scale.
|
||||
*/
|
||||
axes?: DashboardtypesDistributionAxesDTO;
|
||||
/**
|
||||
* @description Percentile markers.
|
||||
*/
|
||||
chartAppearance?: DashboardtypesDistributionChartAppearanceDTO;
|
||||
/**
|
||||
* @description Unit and decimal precision of the bucket bounds; counts take no unit.
|
||||
*/
|
||||
formatting?: DashboardtypesPanelFormattingDTO;
|
||||
/**
|
||||
* @description Legend placement and series colors.
|
||||
*/
|
||||
legend?: DashboardtypesLegendDTO;
|
||||
/**
|
||||
* @description The time range the bucket counts are summed over, and how groups stack.
|
||||
*/
|
||||
visualization?: DashboardtypesDistributionVisualizationDTO;
|
||||
}
|
||||
|
||||
export interface DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTO {
|
||||
/**
|
||||
* @enum signoz/DistributionPanel
|
||||
* @type string
|
||||
* @description The panel kind.
|
||||
*/
|
||||
kind: DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTOKind;
|
||||
/**
|
||||
* @description The options for this panel kind. {} accepts every default.
|
||||
*/
|
||||
spec: DashboardtypesDistributionPanelSpecDTO;
|
||||
}
|
||||
|
||||
export type DashboardtypesPanelPluginDTO =
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesTimeSeriesPanelSpecDTO
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesBarChartPanelSpecDTO
|
||||
@@ -7261,7 +7378,8 @@ export type DashboardtypesPanelPluginDTO =
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesHeatmapPanelSpecDTO
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesScatterPlotPanelSpecDTO
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesGeoMapPanelSpecDTO
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesTopListPanelSpecDTO;
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesTopListPanelSpecDTO
|
||||
| DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTO;
|
||||
|
||||
export enum Querybuildertypesv5RequestTypeDTO {
|
||||
scalar = 'scalar',
|
||||
@@ -7750,14 +7868,14 @@ export interface DashboardtypesQuerySpecDTO {
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* @description The query: kind is one of signoz/BuilderQuery, signoz/AIBuilderQuery (builder query over AI observability traces), signoz/CompositeQuery (several named queries and formulas), signoz/Formula, signoz/PromQLQuery, signoz/ClickHouseSQL or signoz/TraceOperator, and spec holds that kind's query. Pie and table panels reject signoz/PromQLQuery; heatmap panels reject signoz/AIBuilderQuery and signoz/TraceOperator; list panels accept only signoz/BuilderQuery and signoz/AIBuilderQuery.
|
||||
* @description The query: kind is one of signoz/BuilderQuery, signoz/AIBuilderQuery (builder query over AI observability traces), signoz/CompositeQuery (several named queries and formulas), signoz/Formula, signoz/PromQLQuery, signoz/ClickHouseSQL or signoz/TraceOperator, and spec holds that kind's query. Pie and table panels reject signoz/PromQLQuery; heatmap and distribution panels reject signoz/AIBuilderQuery and signoz/TraceOperator; list panels accept only signoz/BuilderQuery and signoz/AIBuilderQuery.
|
||||
*/
|
||||
plugin: DashboardtypesQueryPluginDTO;
|
||||
}
|
||||
|
||||
export interface DashboardtypesQueryDTO {
|
||||
/**
|
||||
* @description The result shape the panel requests: time_series for time series, bar, area and histogram panels, scalar for number, table and pie panels, raw for list panels, heatmap for heatmap panels, trace for trace panels.
|
||||
* @description The result shape the panel requests: time_series for time series, bar, area and histogram panels, scalar for number, table and pie panels, raw for list panels, heatmap for heatmap panels, distribution for distribution panels, trace for trace panels.
|
||||
*/
|
||||
kind: Querybuildertypesv5RequestTypeDTO;
|
||||
/**
|
||||
@@ -7777,7 +7895,7 @@ export interface DashboardtypesPanelSpecDTO {
|
||||
*/
|
||||
links?: DashboardtypesLinkDTO[] | null;
|
||||
/**
|
||||
* @description The visualization: kind is one of signoz/TimeSeriesPanel, signoz/BarChartPanel, signoz/AreaChartPanel, signoz/NumberPanel, signoz/PieChartPanel, signoz/TablePanel, signoz/HistogramPanel, signoz/ListPanel, signoz/TextPanel or signoz/HeatmapPanel, and spec holds that kind's options ({} accepts every default).
|
||||
* @description The visualization: kind is one of signoz/TimeSeriesPanel, signoz/BarChartPanel, signoz/AreaChartPanel, signoz/NumberPanel, signoz/PieChartPanel, signoz/TablePanel, signoz/HistogramPanel, signoz/ListPanel, signoz/TextPanel, signoz/HeatmapPanel or signoz/DistributionPanel, and spec holds that kind's options ({} accepts every default).
|
||||
*/
|
||||
plugin: DashboardtypesPanelPluginDTO;
|
||||
/**
|
||||
@@ -8550,6 +8668,7 @@ export enum DashboardtypesPanelPluginKindDTO {
|
||||
'signoz/ScatterPlotPanel' = 'signoz/ScatterPlotPanel',
|
||||
'signoz/GeoMapPanel' = 'signoz/GeoMapPanel',
|
||||
'signoz/TopListPanel' = 'signoz/TopListPanel',
|
||||
'signoz/DistributionPanel' = 'signoz/DistributionPanel',
|
||||
}
|
||||
/**
|
||||
* The RFC 6902 operations, applied in order against the dashboard's postable shape.
|
||||
@@ -14206,7 +14325,19 @@ export interface SpantypesTraceAITokensDTO {
|
||||
}
|
||||
|
||||
export interface SpantypesTraceAISummaryDTO {
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Spans with gen_ai.request.model.
|
||||
*/
|
||||
llmCallCount: number;
|
||||
tokens: SpantypesTraceAITokensDTO;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Spans with gen_ai.tool.name.
|
||||
*/
|
||||
toolCallCount: number;
|
||||
/**
|
||||
* @type number
|
||||
*/
|
||||
@@ -14634,6 +14765,254 @@ export interface SpantypesPostableWaterfallDTO {
|
||||
uncollapsedSpans?: string[] | null;
|
||||
}
|
||||
|
||||
export interface SpantypesSameNameSiblingStatsDTO {
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
errorSpanCount: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
ownTimeNano: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description This span included.
|
||||
*/
|
||||
spanCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* All of them for a span read by ID; the selected ones in a list.
|
||||
*/
|
||||
export type SpantypesSpanDTOAttributes = { [key: string]: unknown };
|
||||
|
||||
/**
|
||||
* Always has service.name. All of them for a span read by ID; the selected ones in a list.
|
||||
*/
|
||||
export type SpantypesSpanDTOResource = { [key: string]: string };
|
||||
|
||||
export interface SpantypesSpanDTO {
|
||||
/**
|
||||
* @type object
|
||||
* @description All of them for a span read by ID; the selected ones in a list.
|
||||
*/
|
||||
attributes: SpantypesSpanDTOAttributes;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
duration_nano: number;
|
||||
/**
|
||||
* @type array
|
||||
* @description All of them for a span read by ID; none in a list.
|
||||
*/
|
||||
events: SpantypesEventDTO[];
|
||||
/**
|
||||
* @type boolean
|
||||
*/
|
||||
has_error: boolean;
|
||||
/**
|
||||
* @type string
|
||||
* @description For example Server, Client or Internal.
|
||||
*/
|
||||
kind_string: string;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* @type string
|
||||
* @description Empty for a root.
|
||||
*/
|
||||
parent_span_id: string;
|
||||
/**
|
||||
* @type array
|
||||
* @description The parent as CHILD_OF, and each span link as FOLLOWS_FROM.
|
||||
*/
|
||||
references: SpantypesOtelSpanRefDTO[];
|
||||
/**
|
||||
* @type object
|
||||
* @description Always has service.name. All of them for a span read by ID; the selected ones in a list.
|
||||
*/
|
||||
resource: SpantypesSpanDTOResource;
|
||||
/**
|
||||
* @type string
|
||||
* @description HTTP or gRPC status code, for example 404.
|
||||
*/
|
||||
response_status_code: string;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
span_id: string;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status_code_string: string;
|
||||
/**
|
||||
* @type string
|
||||
* @description Usually the error text.
|
||||
*/
|
||||
status_message: string;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Start time, in Unix milliseconds.
|
||||
*/
|
||||
time_unix: number;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
trace_id: string;
|
||||
}
|
||||
|
||||
export interface SpantypesSpanTextMatchDTO {
|
||||
/**
|
||||
* @type string
|
||||
* @description name, status_message, attributes.<name>, resource.<name> or events[<index>].
|
||||
*/
|
||||
field: string;
|
||||
/**
|
||||
* @type string
|
||||
* @description About 40 characters on each side of the word.
|
||||
*/
|
||||
snippet: string;
|
||||
}
|
||||
|
||||
export interface SpantypesSpanTreeStatsDTO {
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
childCount: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Ancestors marked as errors in an unbroken run up from the parent: how far an error spread.
|
||||
*/
|
||||
errorAncestorCount: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description 0 for a root.
|
||||
*/
|
||||
level: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Duration minus the time its children cover.
|
||||
*/
|
||||
ownTimeNano: number;
|
||||
/**
|
||||
* @description Totals for the spans with this span's name and parent. Omitted when it has none.
|
||||
*/
|
||||
sameNameSiblings?: SpantypesSameNameSiblingStatsDTO;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Spans below this one, at any depth.
|
||||
*/
|
||||
subtreeSpanCount: number;
|
||||
}
|
||||
|
||||
export enum SpantypesUnmarkedFailureKindDTO {
|
||||
http_4xx = 'http_4xx',
|
||||
http_5xx = 'http_5xx',
|
||||
grpc_status = 'grpc_status',
|
||||
exception_event = 'exception_event',
|
||||
}
|
||||
export interface SpantypesSpanItemDTO {
|
||||
/**
|
||||
* @type array
|
||||
* @description Where the query's words were found, up to three places. Omitted when the query has no words.
|
||||
*/
|
||||
matches?: SpantypesSpanTextMatchDTO[];
|
||||
span: SpantypesSpanDTO;
|
||||
treeStats: SpantypesSpanTreeStatsDTO;
|
||||
/**
|
||||
* @description Why the span is an unmarked failure. Omitted for other spans.
|
||||
*/
|
||||
unmarkedFailureKind?: SpantypesUnmarkedFailureKindDTO;
|
||||
}
|
||||
|
||||
export interface SpantypesSpanListDTO {
|
||||
/**
|
||||
* @type array
|
||||
*/
|
||||
items: SpantypesSpanItemDTO[];
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Matching spans across all pages.
|
||||
*/
|
||||
total: number;
|
||||
/**
|
||||
* @type array
|
||||
* @description Why the result may be incomplete, for example an unknown query key or a selected field no returned span has.
|
||||
*/
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
export enum SpantypesSpanListViewDTO {
|
||||
error_origins = 'error_origins',
|
||||
unmarked_failures = 'unmarked_failures',
|
||||
time_spent = 'time_spent',
|
||||
ai_usage = 'ai_usage',
|
||||
links = 'links',
|
||||
}
|
||||
export interface SpantypesTraceServiceStatsDTO {
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
errorSpanCount: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
* @description Sum of the own time of the service's spans.
|
||||
*/
|
||||
ownTimeNano: number;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
serviceName: string;
|
||||
/**
|
||||
* @type integer
|
||||
* @minimum 0
|
||||
*/
|
||||
spanCount: number;
|
||||
}
|
||||
|
||||
export interface SpantypesTraceHighlightsDTO {
|
||||
/**
|
||||
* @description First page of the ai_usage view.
|
||||
*/
|
||||
aiUsage?: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @description First page of the error_origins view.
|
||||
*/
|
||||
errorOrigins?: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @description First page of the links view.
|
||||
*/
|
||||
links?: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @type array
|
||||
* @description Highest own time first.
|
||||
*/
|
||||
services: SpantypesTraceServiceStatsDTO[];
|
||||
/**
|
||||
* @description First page of the time_spent view.
|
||||
*/
|
||||
timeSpent?: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @description First page of the unmarked_failures view.
|
||||
*/
|
||||
unmarkedFailures?: SpantypesSpanListDTO;
|
||||
}
|
||||
|
||||
export interface SpantypesUpdatableSpanMapperDTO {
|
||||
config?: SpantypesSpanMapperConfigDTO;
|
||||
/**
|
||||
@@ -16099,6 +16478,197 @@ export type GetTraceAggregations200 = {
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type GetTraceHighlightsPathParameters = {
|
||||
traceID: string;
|
||||
};
|
||||
export type GetTraceHighlightsParams = {
|
||||
/**
|
||||
* @type array
|
||||
* @description The lists to return. Default: all.
|
||||
*/
|
||||
views?: SpantypesSpanListViewDTO[];
|
||||
/**
|
||||
* @type integer
|
||||
* @description Spans in each list. Default: 10. Maximum: 1000.
|
||||
*/
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type GetTraceHighlights200 = {
|
||||
data: SpantypesTraceHighlightsDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type ListTraceSpansPathParameters = {
|
||||
traceID: string;
|
||||
};
|
||||
export type ListTraceSpansParams = {
|
||||
/**
|
||||
* @description Keeps only the spans of one kind, judged on the whole trace, by start time unless stated. error_origins: error spans with no failing child. unmarked_failures: spans not marked as errors with a 4xx or 5xx response, a non-OK gRPC status or an exception event. time_spent: one span per same-name sibling group, by the group's own time. ai_usage: spans with gen_ai token or cost usage, with those attributes, by cost, else tokens. links: spans that link to other spans.
|
||||
*/
|
||||
view?: SpantypesSpanListViewDTO;
|
||||
/**
|
||||
* @type string
|
||||
* @description Words, a filter expression, or both, for example: worldpay AND has_error = true. Words match the name, status message, attributes, resource attributes and events, ignoring case. Applied before view.
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* @type array
|
||||
* @description Attributes or resource attributes to add to each span, for example http.route or resource.k8s.pod.name. Default: service.name only.
|
||||
*/
|
||||
selectFields?: string[];
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to skip. Default: 0.
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to return. Default: 50. Maximum: 1000.
|
||||
*/
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type ListTraceSpans200 = {
|
||||
data: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type GetTraceSpanPathParameters = {
|
||||
traceID: string;
|
||||
spanID: string;
|
||||
};
|
||||
export type GetTraceSpan200 = {
|
||||
data: SpantypesSpanDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type ListTraceSpanAncestorsPathParameters = {
|
||||
traceID: string;
|
||||
spanID: string;
|
||||
};
|
||||
export type ListTraceSpanAncestorsParams = {
|
||||
/**
|
||||
* @description Keeps only the spans of one kind, judged on the whole trace, by start time unless stated. error_origins: error spans with no failing child. unmarked_failures: spans not marked as errors with a 4xx or 5xx response, a non-OK gRPC status or an exception event. time_spent: one span per same-name sibling group, by the group's own time. ai_usage: spans with gen_ai token or cost usage, with those attributes, by cost, else tokens. links: spans that link to other spans.
|
||||
*/
|
||||
view?: SpantypesSpanListViewDTO;
|
||||
/**
|
||||
* @type string
|
||||
* @description Words, a filter expression, or both, for example: worldpay AND has_error = true. Words match the name, status message, attributes, resource attributes and events, ignoring case. Applied before view.
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* @type array
|
||||
* @description Attributes or resource attributes to add to each span, for example http.route or resource.k8s.pod.name. Default: service.name only.
|
||||
*/
|
||||
selectFields?: string[];
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to skip. Default: 0.
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to return. Default: 50. Maximum: 1000.
|
||||
*/
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type ListTraceSpanAncestors200 = {
|
||||
data: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type ListTraceSpanChildrenPathParameters = {
|
||||
traceID: string;
|
||||
spanID: string;
|
||||
};
|
||||
export type ListTraceSpanChildrenParams = {
|
||||
/**
|
||||
* @description Keeps only the spans of one kind, judged on the whole trace, by start time unless stated. error_origins: error spans with no failing child. unmarked_failures: spans not marked as errors with a 4xx or 5xx response, a non-OK gRPC status or an exception event. time_spent: one span per same-name sibling group, by the group's own time. ai_usage: spans with gen_ai token or cost usage, with those attributes, by cost, else tokens. links: spans that link to other spans.
|
||||
*/
|
||||
view?: SpantypesSpanListViewDTO;
|
||||
/**
|
||||
* @type string
|
||||
* @description Words, a filter expression, or both, for example: worldpay AND has_error = true. Words match the name, status message, attributes, resource attributes and events, ignoring case. Applied before view.
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* @type array
|
||||
* @description Attributes or resource attributes to add to each span, for example http.route or resource.k8s.pod.name. Default: service.name only.
|
||||
*/
|
||||
selectFields?: string[];
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to skip. Default: 0.
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to return. Default: 50. Maximum: 1000.
|
||||
*/
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type ListTraceSpanChildren200 = {
|
||||
data: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type ListTraceSpanDescendantsPathParameters = {
|
||||
traceID: string;
|
||||
spanID: string;
|
||||
};
|
||||
export type ListTraceSpanDescendantsParams = {
|
||||
/**
|
||||
* @description Keeps only the spans of one kind, judged on the whole trace, by start time unless stated. error_origins: error spans with no failing child. unmarked_failures: spans not marked as errors with a 4xx or 5xx response, a non-OK gRPC status or an exception event. time_spent: one span per same-name sibling group, by the group's own time. ai_usage: spans with gen_ai token or cost usage, with those attributes, by cost, else tokens. links: spans that link to other spans.
|
||||
*/
|
||||
view?: SpantypesSpanListViewDTO;
|
||||
/**
|
||||
* @type string
|
||||
* @description Words, a filter expression, or both, for example: worldpay AND has_error = true. Words match the name, status message, attributes, resource attributes and events, ignoring case. Applied before view.
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* @type array
|
||||
* @description Attributes or resource attributes to add to each span, for example http.route or resource.k8s.pod.name. Default: service.name only.
|
||||
*/
|
||||
selectFields?: string[];
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to skip. Default: 0.
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @description Number of spans to return. Default: 50. Maximum: 1000.
|
||||
*/
|
||||
limit?: number;
|
||||
};
|
||||
|
||||
export type ListTraceSpanDescendants200 = {
|
||||
data: SpantypesSpanListDTO;
|
||||
/**
|
||||
* @type string
|
||||
*/
|
||||
status: string;
|
||||
};
|
||||
|
||||
export type GetTraceSummaryPathParameters = {
|
||||
traceID: string;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,11 @@ import type {
|
||||
GetFlamegraphPathParameters,
|
||||
GetTraceAggregations200,
|
||||
GetTraceAggregationsPathParameters,
|
||||
GetTraceHighlights200,
|
||||
GetTraceHighlightsParams,
|
||||
GetTraceHighlightsPathParameters,
|
||||
GetTraceSpan200,
|
||||
GetTraceSpanPathParameters,
|
||||
GetTraceSummary200,
|
||||
GetTraceSummaryPathParameters,
|
||||
GetTraceThread200,
|
||||
@@ -29,6 +34,18 @@ import type {
|
||||
GetTraceThreadPathParameters,
|
||||
GetWaterfallV4200,
|
||||
GetWaterfallV4PathParameters,
|
||||
ListTraceSpanAncestors200,
|
||||
ListTraceSpanAncestorsParams,
|
||||
ListTraceSpanAncestorsPathParameters,
|
||||
ListTraceSpanChildren200,
|
||||
ListTraceSpanChildrenParams,
|
||||
ListTraceSpanChildrenPathParameters,
|
||||
ListTraceSpanDescendants200,
|
||||
ListTraceSpanDescendantsParams,
|
||||
ListTraceSpanDescendantsPathParameters,
|
||||
ListTraceSpans200,
|
||||
ListTraceSpansParams,
|
||||
ListTraceSpansPathParameters,
|
||||
RenderErrorResponseDTO,
|
||||
SpantypesPostableFlamegraphDTO,
|
||||
SpantypesPostableTraceAggregationsDTO,
|
||||
@@ -159,7 +176,710 @@ export const useGetTraceAggregations = <
|
||||
return useMutation(getGetTraceAggregationsMutationOptions(options));
|
||||
};
|
||||
/**
|
||||
* Returns the trace's time range, root span, span and error counts, and whether any spans are missing. AI traces also include token and cost totals.
|
||||
* Returns the spans to look at, for a trace of any size: per-service totals and the first spans of each view of the span list. views names the lists to return; without it all of them are returned. Read more of a list from the span list with the view of the same name. The totals of the trace come from the trace summary.
|
||||
* @summary Get highlights of a trace
|
||||
*/
|
||||
export const getTraceHighlights = (
|
||||
{ traceID }: GetTraceHighlightsPathParameters,
|
||||
params?: GetTraceHighlightsParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<GetTraceHighlights200>({
|
||||
url: `/api/v1/traces/${traceID}/highlights`,
|
||||
method: 'GET',
|
||||
params,
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getGetTraceHighlightsQueryKey = (
|
||||
{ traceID }: GetTraceHighlightsPathParameters,
|
||||
params?: GetTraceHighlightsParams,
|
||||
) => {
|
||||
return [
|
||||
`/api/v1/traces/${traceID}/highlights`,
|
||||
...(params ? [params] : []),
|
||||
] as const;
|
||||
};
|
||||
|
||||
export const getGetTraceHighlightsQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof getTraceHighlights>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID }: GetTraceHighlightsPathParameters,
|
||||
params?: GetTraceHighlightsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceHighlights>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getGetTraceHighlightsQueryKey({ traceID }, params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof getTraceHighlights>>
|
||||
> = ({ signal }) => getTraceHighlights({ traceID }, params, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: traceID !== null && traceID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceHighlights>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type GetTraceHighlightsQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof getTraceHighlights>>
|
||||
>;
|
||||
export type GetTraceHighlightsQueryError = ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary Get highlights of a trace
|
||||
*/
|
||||
|
||||
export function useGetTraceHighlights<
|
||||
TData = Awaited<ReturnType<typeof getTraceHighlights>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID }: GetTraceHighlightsPathParameters,
|
||||
params?: GetTraceHighlightsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceHighlights>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getGetTraceHighlightsQueryOptions(
|
||||
{ traceID },
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Get highlights of a trace
|
||||
*/
|
||||
export const invalidateGetTraceHighlights = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID }: GetTraceHighlightsPathParameters,
|
||||
params?: GetTraceHighlightsParams,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{ queryKey: getGetTraceHighlightsQueryKey({ traceID }, params) },
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a page of the spans of a trace, in tree order from the top: a span is followed by the spans below it. view keeps only the spans of one kind, query narrows them, and selectFields names the attributes to fill. Values are returned whole.
|
||||
* @summary List spans of a trace
|
||||
*/
|
||||
export const listTraceSpans = (
|
||||
{ traceID }: ListTraceSpansPathParameters,
|
||||
params?: ListTraceSpansParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<ListTraceSpans200>({
|
||||
url: `/api/v1/traces/${traceID}/spans`,
|
||||
method: 'GET',
|
||||
params,
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getListTraceSpansQueryKey = (
|
||||
{ traceID }: ListTraceSpansPathParameters,
|
||||
params?: ListTraceSpansParams,
|
||||
) => {
|
||||
return [
|
||||
`/api/v1/traces/${traceID}/spans`,
|
||||
...(params ? [params] : []),
|
||||
] as const;
|
||||
};
|
||||
|
||||
export const getListTraceSpansQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof listTraceSpans>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID }: ListTraceSpansPathParameters,
|
||||
params?: ListTraceSpansParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpans>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getListTraceSpansQueryKey({ traceID }, params);
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof listTraceSpans>>> = ({
|
||||
signal,
|
||||
}) => listTraceSpans({ traceID }, params, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled: traceID !== null && traceID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpans>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type ListTraceSpansQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof listTraceSpans>>
|
||||
>;
|
||||
export type ListTraceSpansQueryError = ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary List spans of a trace
|
||||
*/
|
||||
|
||||
export function useListTraceSpans<
|
||||
TData = Awaited<ReturnType<typeof listTraceSpans>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID }: ListTraceSpansPathParameters,
|
||||
params?: ListTraceSpansParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpans>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getListTraceSpansQueryOptions(
|
||||
{ traceID },
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary List spans of a trace
|
||||
*/
|
||||
export const invalidateListTraceSpans = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID }: ListTraceSpansPathParameters,
|
||||
params?: ListTraceSpansParams,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{ queryKey: getListTraceSpansQueryKey({ traceID }, params) },
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns one span with every attribute, resource attribute and event. Values are returned whole. It returns only the stored span: its tree stats come with it in any span list, and the spans around it come from the children, descendants and ancestors routes.
|
||||
* @summary Get span of a trace
|
||||
*/
|
||||
export const getTraceSpan = (
|
||||
{ traceID, spanID }: GetTraceSpanPathParameters,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<GetTraceSpan200>({
|
||||
url: `/api/v1/traces/${traceID}/spans/${spanID}`,
|
||||
method: 'GET',
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getGetTraceSpanQueryKey = ({
|
||||
traceID,
|
||||
spanID,
|
||||
}: GetTraceSpanPathParameters) => {
|
||||
return [`/api/v1/traces/${traceID}/spans/${spanID}`] as const;
|
||||
};
|
||||
|
||||
export const getGetTraceSpanQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof getTraceSpan>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: GetTraceSpanPathParameters,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceSpan>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ?? getGetTraceSpanQueryKey({ traceID, spanID });
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getTraceSpan>>> = ({
|
||||
signal,
|
||||
}) => getTraceSpan({ traceID, spanID }, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled:
|
||||
traceID !== null &&
|
||||
traceID !== undefined &&
|
||||
spanID !== null &&
|
||||
spanID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceSpan>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type GetTraceSpanQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof getTraceSpan>>
|
||||
>;
|
||||
export type GetTraceSpanQueryError = ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary Get span of a trace
|
||||
*/
|
||||
|
||||
export function useGetTraceSpan<
|
||||
TData = Awaited<ReturnType<typeof getTraceSpan>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: GetTraceSpanPathParameters,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof getTraceSpan>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getGetTraceSpanQueryOptions({ traceID, spanID }, options);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Get span of a trace
|
||||
*/
|
||||
export const invalidateGetTraceSpan = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID, spanID }: GetTraceSpanPathParameters,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{ queryKey: getGetTraceSpanQueryKey({ traceID, spanID }) },
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a page of the spans above a span: the chain of parents from the span up to its root, the parent first, and nothing from other branches. The span itself is not included. It takes the same parameters as the span list. The list is empty for a root, and stops where a parent was never received.
|
||||
* @summary List ancestors of a span
|
||||
*/
|
||||
export const listTraceSpanAncestors = (
|
||||
{ traceID, spanID }: ListTraceSpanAncestorsPathParameters,
|
||||
params?: ListTraceSpanAncestorsParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<ListTraceSpanAncestors200>({
|
||||
url: `/api/v1/traces/${traceID}/spans/${spanID}/ancestors`,
|
||||
method: 'GET',
|
||||
params,
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getListTraceSpanAncestorsQueryKey = (
|
||||
{ traceID, spanID }: ListTraceSpanAncestorsPathParameters,
|
||||
params?: ListTraceSpanAncestorsParams,
|
||||
) => {
|
||||
return [
|
||||
`/api/v1/traces/${traceID}/spans/${spanID}/ancestors`,
|
||||
...(params ? [params] : []),
|
||||
] as const;
|
||||
};
|
||||
|
||||
export const getListTraceSpanAncestorsQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanAncestors>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanAncestorsPathParameters,
|
||||
params?: ListTraceSpanAncestorsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanAncestors>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getListTraceSpanAncestorsQueryKey({ traceID, spanID }, params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof listTraceSpanAncestors>>
|
||||
> = ({ signal }) =>
|
||||
listTraceSpanAncestors({ traceID, spanID }, params, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled:
|
||||
traceID !== null &&
|
||||
traceID !== undefined &&
|
||||
spanID !== null &&
|
||||
spanID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanAncestors>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type ListTraceSpanAncestorsQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof listTraceSpanAncestors>>
|
||||
>;
|
||||
export type ListTraceSpanAncestorsQueryError =
|
||||
ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary List ancestors of a span
|
||||
*/
|
||||
|
||||
export function useListTraceSpanAncestors<
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanAncestors>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanAncestorsPathParameters,
|
||||
params?: ListTraceSpanAncestorsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanAncestors>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getListTraceSpanAncestorsQueryOptions(
|
||||
{ traceID, spanID },
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary List ancestors of a span
|
||||
*/
|
||||
export const invalidateListTraceSpanAncestors = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID, spanID }: ListTraceSpanAncestorsPathParameters,
|
||||
params?: ListTraceSpanAncestorsParams,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{ queryKey: getListTraceSpanAncestorsQueryKey({ traceID, spanID }, params) },
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a page of the direct children of a span, one level below it and nothing deeper, in start order. It takes the same parameters as the span list. The list is empty for a span without children.
|
||||
* @summary List children of a span
|
||||
*/
|
||||
export const listTraceSpanChildren = (
|
||||
{ traceID, spanID }: ListTraceSpanChildrenPathParameters,
|
||||
params?: ListTraceSpanChildrenParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<ListTraceSpanChildren200>({
|
||||
url: `/api/v1/traces/${traceID}/spans/${spanID}/children`,
|
||||
method: 'GET',
|
||||
params,
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getListTraceSpanChildrenQueryKey = (
|
||||
{ traceID, spanID }: ListTraceSpanChildrenPathParameters,
|
||||
params?: ListTraceSpanChildrenParams,
|
||||
) => {
|
||||
return [
|
||||
`/api/v1/traces/${traceID}/spans/${spanID}/children`,
|
||||
...(params ? [params] : []),
|
||||
] as const;
|
||||
};
|
||||
|
||||
export const getListTraceSpanChildrenQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanChildren>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanChildrenPathParameters,
|
||||
params?: ListTraceSpanChildrenParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanChildren>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getListTraceSpanChildrenQueryKey({ traceID, spanID }, params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof listTraceSpanChildren>>
|
||||
> = ({ signal }) => listTraceSpanChildren({ traceID, spanID }, params, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled:
|
||||
traceID !== null &&
|
||||
traceID !== undefined &&
|
||||
spanID !== null &&
|
||||
spanID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanChildren>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type ListTraceSpanChildrenQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof listTraceSpanChildren>>
|
||||
>;
|
||||
export type ListTraceSpanChildrenQueryError = ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary List children of a span
|
||||
*/
|
||||
|
||||
export function useListTraceSpanChildren<
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanChildren>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanChildrenPathParameters,
|
||||
params?: ListTraceSpanChildrenParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanChildren>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getListTraceSpanChildrenQueryOptions(
|
||||
{ traceID, spanID },
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary List children of a span
|
||||
*/
|
||||
export const invalidateListTraceSpanChildren = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID, spanID }: ListTraceSpanChildrenPathParameters,
|
||||
params?: ListTraceSpanChildrenParams,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{ queryKey: getListTraceSpanChildrenQueryKey({ traceID, spanID }, params) },
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a page of the spans below a span, at any depth, in tree order. It takes the same parameters as the span list, so view=error_origins returns the errors that started below the span.
|
||||
* @summary List descendants of a span
|
||||
*/
|
||||
export const listTraceSpanDescendants = (
|
||||
{ traceID, spanID }: ListTraceSpanDescendantsPathParameters,
|
||||
params?: ListTraceSpanDescendantsParams,
|
||||
signal?: AbortSignal,
|
||||
) => {
|
||||
return GeneratedAPIInstance<ListTraceSpanDescendants200>({
|
||||
url: `/api/v1/traces/${traceID}/spans/${spanID}/descendants`,
|
||||
method: 'GET',
|
||||
params,
|
||||
signal,
|
||||
});
|
||||
};
|
||||
|
||||
export const getListTraceSpanDescendantsQueryKey = (
|
||||
{ traceID, spanID }: ListTraceSpanDescendantsPathParameters,
|
||||
params?: ListTraceSpanDescendantsParams,
|
||||
) => {
|
||||
return [
|
||||
`/api/v1/traces/${traceID}/spans/${spanID}/descendants`,
|
||||
...(params ? [params] : []),
|
||||
] as const;
|
||||
};
|
||||
|
||||
export const getListTraceSpanDescendantsQueryOptions = <
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanDescendants>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanDescendantsPathParameters,
|
||||
params?: ListTraceSpanDescendantsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanDescendants>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
) => {
|
||||
const { query: queryOptions } = options ?? {};
|
||||
|
||||
const queryKey =
|
||||
queryOptions?.queryKey ??
|
||||
getListTraceSpanDescendantsQueryKey({ traceID, spanID }, params);
|
||||
|
||||
const queryFn: QueryFunction<
|
||||
Awaited<ReturnType<typeof listTraceSpanDescendants>>
|
||||
> = ({ signal }) =>
|
||||
listTraceSpanDescendants({ traceID, spanID }, params, signal);
|
||||
|
||||
return {
|
||||
queryKey,
|
||||
queryFn,
|
||||
enabled:
|
||||
traceID !== null &&
|
||||
traceID !== undefined &&
|
||||
spanID !== null &&
|
||||
spanID !== undefined,
|
||||
...queryOptions,
|
||||
} as UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanDescendants>>,
|
||||
TError,
|
||||
TData
|
||||
> & { queryKey: QueryKey };
|
||||
};
|
||||
|
||||
export type ListTraceSpanDescendantsQueryResult = NonNullable<
|
||||
Awaited<ReturnType<typeof listTraceSpanDescendants>>
|
||||
>;
|
||||
export type ListTraceSpanDescendantsQueryError =
|
||||
ErrorType<RenderErrorResponseDTO>;
|
||||
|
||||
/**
|
||||
* @summary List descendants of a span
|
||||
*/
|
||||
|
||||
export function useListTraceSpanDescendants<
|
||||
TData = Awaited<ReturnType<typeof listTraceSpanDescendants>>,
|
||||
TError = ErrorType<RenderErrorResponseDTO>,
|
||||
>(
|
||||
{ traceID, spanID }: ListTraceSpanDescendantsPathParameters,
|
||||
params?: ListTraceSpanDescendantsParams,
|
||||
options?: {
|
||||
query?: UseQueryOptions<
|
||||
Awaited<ReturnType<typeof listTraceSpanDescendants>>,
|
||||
TError,
|
||||
TData
|
||||
>;
|
||||
},
|
||||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } {
|
||||
const queryOptions = getListTraceSpanDescendantsQueryOptions(
|
||||
{ traceID, spanID },
|
||||
params,
|
||||
options,
|
||||
);
|
||||
|
||||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & {
|
||||
queryKey: QueryKey;
|
||||
};
|
||||
|
||||
return withQueryKey(query, queryOptions.queryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary List descendants of a span
|
||||
*/
|
||||
export const invalidateListTraceSpanDescendants = async (
|
||||
queryClient: QueryClient,
|
||||
{ traceID, spanID }: ListTraceSpanDescendantsPathParameters,
|
||||
params?: ListTraceSpanDescendantsParams,
|
||||
options?: InvalidateOptions,
|
||||
): Promise<QueryClient> => {
|
||||
await queryClient.invalidateQueries(
|
||||
{
|
||||
queryKey: getListTraceSpanDescendantsQueryKey({ traceID, spanID }, params),
|
||||
},
|
||||
options,
|
||||
);
|
||||
|
||||
return queryClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the totals of a trace and no spans: its time range, root span, span and error counts, and whether any spans are missing. AI traces also include model and tool call counts, and token and cost totals. For the spans to look at, use the trace highlights.
|
||||
* @summary Get summary for a trace
|
||||
*/
|
||||
export const getTraceSummary = (
|
||||
@@ -261,7 +981,7 @@ export const invalidateGetTraceSummary = async (
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the gen_ai spans of a trace, model calls, tool calls and agent spans, in timestamp order. The messages a span carries are decoded into formattedInput and formattedOutput, with formatterWarnings holding what the converter could not resolve; a span without messages has both empty. Pass nextCursor as after or prevCursor as before to page, or spanId to open the page around a span.
|
||||
* Returns the gen_ai spans of a trace, LLM calls, tool calls and agent spans, in timestamp order. The messages a span carries are decoded into formattedInput and formattedOutput, with formatterWarnings holding what the converter could not resolve; a span without messages has both empty. Pass nextCursor as after or prevCursor as before to page, or spanId to open the page around a span.
|
||||
* @summary Get thread view for a trace
|
||||
*/
|
||||
export const getTraceThread = (
|
||||
|
||||
@@ -286,7 +286,7 @@ export function createAggregation(
|
||||
];
|
||||
}
|
||||
|
||||
// A heatmap buckets the field the user names; count() would be rejected as one.
|
||||
// A heatmap or distribution buckets the field the user names; count() would be rejected as one.
|
||||
// Elsewhere a field is not an aggregation, so it falls back to count().
|
||||
const isDistributionField = aggregatesDistributionField(
|
||||
panelType,
|
||||
|
||||
@@ -292,6 +292,11 @@
|
||||
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
|
||||
&.full-row {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.cm-placeholder {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ToggleGroup } from '@signozhq/ui/toggle-group';
|
||||
import { Tooltip, TooltipProvider } from '@signozhq/ui/tooltip';
|
||||
import InputWithLabel from 'components/InputWithLabel/InputWithLabel';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { isBucketPanelType } from 'lib/query/bucketPanelTypes';
|
||||
import { GroupByFilter } from 'container/QueryBuilder/filters/GroupByFilter/GroupByFilter';
|
||||
import { OrderByFilter } from 'container/QueryBuilder/filters/OrderByFilter/OrderByFilter';
|
||||
import { ReduceToFilter } from 'container/QueryBuilder/filters/ReduceToFilter/ReduceToFilter';
|
||||
@@ -102,7 +103,7 @@ function QueryAddOns({
|
||||
}
|
||||
|
||||
if (
|
||||
panelType === PANEL_TYPES.HEATMAP &&
|
||||
isBucketPanelType(panelType) &&
|
||||
!(
|
||||
query.dataSource === DataSource.METRICS &&
|
||||
HISTOGRAM_ATTRIBUTE_TYPES.has(query.aggregateAttribute?.type ?? '')
|
||||
@@ -201,13 +202,16 @@ function QueryAddOns({
|
||||
initializedRef.current = true;
|
||||
|
||||
// Initial seeding from query values on mount. A disabled field never opens.
|
||||
// Bucket options open even when empty: they are what makes a bucket panel.
|
||||
setSelectedViews(
|
||||
offeredAddOns.filter((addOn) => {
|
||||
const resolved = resolvedFields.get(addOn.key);
|
||||
|
||||
return (
|
||||
resolved?.pinned ||
|
||||
(hasValue(get(query, addOn.queryPath)) && !resolved?.disabled)
|
||||
((hasValue(get(query, addOn.queryPath)) ||
|
||||
addOn.key === QueryBuilderField.BucketOptions) &&
|
||||
!resolved?.disabled)
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -497,7 +501,10 @@ function QueryAddOns({
|
||||
{selectedViews.find(
|
||||
(view) => view.key === QueryBuilderField.BucketOptions,
|
||||
) && (
|
||||
<div className="add-on-content" data-testid="bucket-options-content">
|
||||
<div
|
||||
className="add-on-content full-row"
|
||||
data-testid="bucket-options-content"
|
||||
>
|
||||
<BucketOptions
|
||||
bucketOptions={query.bucketOptions}
|
||||
unit={currentQuery.unit}
|
||||
|
||||
@@ -107,8 +107,8 @@ export const BASE_ADD_ONS = (
|
||||
|
||||
export const REDUCE_TO = toAddOn(QueryBuilderField.ReduceTo);
|
||||
|
||||
// Offered only by a heatmap: the bucket axis is what a heatmap plots against, and no
|
||||
// other panel type sends one. A histogram metric brings its own buckets.
|
||||
// Offered only by a heatmap or distribution: the bucket axis is what they plot against,
|
||||
// and no other panel type sends one. A histogram metric brings its own buckets.
|
||||
export const HISTOGRAM_ATTRIBUTE_TYPES = new Set<string>([
|
||||
ATTRIBUTE_TYPES.HISTOGRAM,
|
||||
ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { toDistributionFieldOptions } from './distributionFieldOptions';
|
||||
|
||||
import Styles from './DistributionFieldSelect.module.scss';
|
||||
|
||||
/** A logs or traces heatmap's aggregation: the one numeric field it buckets. */
|
||||
/** A logs or traces heatmap or distribution's aggregation: the one numeric field it buckets. */
|
||||
export default function DistributionFieldSelect({
|
||||
queryData,
|
||||
onChange,
|
||||
@@ -54,6 +54,8 @@ export default function DistributionFieldSelect({
|
||||
value={selectedField || undefined}
|
||||
onChange={(field): void => onChange?.(field ?? '')}
|
||||
allowClear
|
||||
// Log keys are discovered from ingested data, so a field may not be listed yet.
|
||||
allowCreate={(field): string => `Use "${field}"`}
|
||||
placeholder={getDistributionFieldPlaceholder(queryData.dataSource)}
|
||||
searchInputProps={{
|
||||
placeholder: 'Search numeric fields',
|
||||
|
||||
@@ -125,10 +125,11 @@ describe('DistributionFieldSelect', () => {
|
||||
expect(onChange).toHaveBeenCalledWith('attribute.quantity');
|
||||
});
|
||||
|
||||
it('only offers listed fields: typed text is a filter, not a value', async () => {
|
||||
it('accepts a typed field the keys do not list', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onChange = jest.fn() as jest.MockedFunction<(field: string) => void>;
|
||||
render(
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={jest.fn()} />,
|
||||
<DistributionFieldSelect queryData={tracesQuery('')} onChange={onChange} />,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('distribution-field-select'));
|
||||
@@ -137,13 +138,12 @@ describe('DistributionFieldSelect', () => {
|
||||
);
|
||||
await user.type(
|
||||
screen.getByTestId('distribution-field-select-search'),
|
||||
'no_such_field',
|
||||
'attribute.bytes',
|
||||
);
|
||||
await screen.findByTestId('distribution-field-select-create');
|
||||
await user.keyboard('{Enter}');
|
||||
|
||||
await screen.findByText('No numeric fields');
|
||||
expect(
|
||||
screen.queryByTestId('distribution-field-select-item-no_such_field'),
|
||||
).not.toBeInTheDocument();
|
||||
expect(onChange).toHaveBeenCalledWith('attribute.bytes');
|
||||
});
|
||||
|
||||
it('searches the server for typed text, past the listed fields', async () => {
|
||||
|
||||
@@ -38,7 +38,7 @@ export function toDistributionFieldText(key: TelemetryFieldKey): string {
|
||||
|
||||
/**
|
||||
* Numeric keys grouped by context, each one once. `trace.*` keys are per-trace
|
||||
* aggregates, which a heatmap cannot bucket. A saved field the keys do not carry
|
||||
* aggregates, which a heatmap or distribution cannot bucket. A saved field the keys do not carry
|
||||
* leads as its own item, so the combobox can still show it.
|
||||
*/
|
||||
export function toDistributionFieldOptions(
|
||||
|
||||
@@ -499,6 +499,23 @@ describe('QueryAddOns', () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('is offered on a metrics distribution too', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
query={baseQuery({ dataSource: DataSource.METRICS })}
|
||||
isRawQuery={false}
|
||||
showReduceTo={false}
|
||||
panelType={PANEL_TYPES.DISTRIBUTION}
|
||||
index={0}
|
||||
isForTraceOperator={false}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByTestId('query-add-on-bucket_options'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('is not offered on other panel types', () => {
|
||||
render(
|
||||
<QueryAddOns
|
||||
@@ -554,12 +571,10 @@ describe('QueryAddOns', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('shows the server default, log at scale 4, without sending it', async () => {
|
||||
const user = userEvent.setup();
|
||||
it('opens empty on the server default, log at scale 4, without sending it', () => {
|
||||
renderHeatmap();
|
||||
|
||||
await user.click(screen.getByTestId('query-add-on-bucket_options'));
|
||||
|
||||
expect(screen.getByTestId('bucket-options-content')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Log' })).toHaveAttribute(
|
||||
'aria-pressed',
|
||||
'true',
|
||||
|
||||
@@ -74,6 +74,8 @@ describe('QueryAggregationOptions on a heatmap', () => {
|
||||
it.each([
|
||||
[PANEL_TYPES.HEATMAP, DataSource.TRACES, true],
|
||||
[PANEL_TYPES.HEATMAP, DataSource.METRICS, false],
|
||||
[PANEL_TYPES.DISTRIBUTION, DataSource.LOGS, true],
|
||||
[PANEL_TYPES.DISTRIBUTION, DataSource.METRICS, false],
|
||||
[PANEL_TYPES.TIME_SERIES, DataSource.TRACES, false],
|
||||
])(
|
||||
'%s over %s renders the field picker: %s',
|
||||
|
||||
@@ -9,4 +9,5 @@ export enum FeatureKeys {
|
||||
ANOMALY_DETECTION = 'anomaly_detection',
|
||||
USE_JSON_BODY = 'use_json_body',
|
||||
ENABLE_METRICS_REDUCTION = 'enable_metrics_reduction',
|
||||
USE_NOTIFICATION_TEMPLATE = 'use_notification_template',
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ export const getComponentForPanelType = (
|
||||
[PANEL_TYPES.HISTOGRAM]: Uplot,
|
||||
// V2-only kind; it renders through the V2 panel registry.
|
||||
[PANEL_TYPES.HEATMAP]: null,
|
||||
[PANEL_TYPES.DISTRIBUTION]: null,
|
||||
[PANEL_TYPES.GEO_MAP]: null,
|
||||
[PANEL_TYPES.TOP_LIST]: null,
|
||||
// Dashboards v2 renders this kind; nothing reaches the V1 chart map for it.
|
||||
|
||||
@@ -313,6 +313,7 @@ export enum PANEL_TYPES {
|
||||
PIE = 'pie',
|
||||
HISTOGRAM = 'histogram',
|
||||
HEATMAP = 'heatmap',
|
||||
DISTRIBUTION = 'distribution',
|
||||
GEO_MAP = 'geo_map',
|
||||
TOP_LIST = 'top_list',
|
||||
TEXT = 'text',
|
||||
|
||||
@@ -528,11 +528,12 @@ export const metricsHistogramSpaceAggregateOperatorOptions: SelectOption<
|
||||
];
|
||||
|
||||
/**
|
||||
* A heatmap's Y axis is the `le` labels themselves, so every percentile draws the grid a
|
||||
* count already draws. Sum is also what the statement builder forces on a histogram
|
||||
* heatmap whatever is asked for, so it is the only honest option to offer.
|
||||
* A bucket panel's (heatmap, distribution) axis is the `le` labels themselves, so every
|
||||
* percentile draws what a count already draws. Sum is also what the statement builder
|
||||
* forces on a histogram bucket panel whatever is asked for, so it is the only honest
|
||||
* option to offer.
|
||||
*/
|
||||
export const metricsHeatmapHistogramSpaceAggregateOperatorOptions: SelectOption<
|
||||
export const metricsBucketHistogramSpaceAggregateOperatorOptions: SelectOption<
|
||||
string,
|
||||
string
|
||||
>[] = [
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -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 },
|
||||
};
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
@@ -31,7 +31,6 @@ function ApDexMetricsApplication({
|
||||
<ApDexMetrics
|
||||
topLevelOperationsRoute={topLevelOperationsRoute}
|
||||
handleGraphClick={handleGraphClick}
|
||||
delta={data?.data.delta}
|
||||
metricsBuckets={data?.data.le || []}
|
||||
onDragSelect={onDragSelect}
|
||||
tagFilterItems={tagFilterItems}
|
||||
|
||||
@@ -13,6 +13,5 @@ export interface ApDexDataSwitcherProps extends ApDexApplicationProps {
|
||||
}
|
||||
|
||||
export interface ApDexMetricsProps extends ApDexDataSwitcherProps {
|
||||
delta?: boolean;
|
||||
metricsBuckets?: number[];
|
||||
metricsBuckets: number[];
|
||||
}
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -6,7 +6,7 @@ import InputWithLabel from 'components/InputWithLabel/InputWithLabel';
|
||||
import BucketOptions from 'components/QueryBuilderV2/QueryV2/QueryAddOns/BucketOptions/BucketOptions';
|
||||
import { parseLimit, sanitizeLimit } from 'components/QueryBuilderV2/utils';
|
||||
import { LEGEND } from 'constants/global';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { isBucketPanelType } from 'lib/query/bucketPanelTypes';
|
||||
// ** Hooks
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { useQueryOperations } from 'hooks/queryBuilder/useQueryBuilderOperations';
|
||||
@@ -185,9 +185,9 @@ export function Formula({
|
||||
</div>
|
||||
</Col>
|
||||
)}
|
||||
{/* A heatmap draws its one enabled query, which is the formula when its
|
||||
inputs are disabled — so the formula states its own bucket axis. */}
|
||||
{isQBV2 && panelType === PANEL_TYPES.HEATMAP && (
|
||||
{/* A heatmap or distribution draws its one enabled query, which is the formula
|
||||
when its inputs are disabled — so the formula states its own bucket axis. */}
|
||||
{isQBV2 && isBucketPanelType(panelType) && (
|
||||
<Col span={24} className="formula-item">
|
||||
<BucketOptions
|
||||
bucketOptions={formula.bucketOptions}
|
||||
|
||||
@@ -10,7 +10,7 @@ export type OrderByFilterProps = {
|
||||
isRawQuery?: boolean;
|
||||
isNewQueryV2?: boolean;
|
||||
placeholder?: string;
|
||||
/** A logs or traces heatmap aggregates a field, which Order by then offers. */
|
||||
/** A logs or traces heatmap or distribution aggregates a field, which Order by then offers. */
|
||||
panelType?: PANEL_TYPES;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,8 +3,3 @@
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-3);
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: var(--label-small-400-font-size);
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
@@ -32,8 +32,3 @@
|
||||
gap: var(--spacing-6);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
.titleText {
|
||||
color: inherit;
|
||||
font-size: var(--label-base-400-font-size);
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -13,6 +13,7 @@ export const PANEL_TYPES_VS_FULL_VIEW_TABLE: PanelTypeAndGraphManagerVisibilityP
|
||||
PIE: false,
|
||||
HISTOGRAM: false,
|
||||
HEATMAP: false,
|
||||
DISTRIBUTION: false,
|
||||
GEO_MAP: false,
|
||||
TOP_LIST: false,
|
||||
TEXT: false,
|
||||
|
||||
@@ -24,6 +24,7 @@ export const PanelTypeVsPanelWrapper = {
|
||||
[PANEL_TYPES.HISTOGRAM]: HistogramPanel,
|
||||
// V2-only kind; it renders through the V2 panel registry.
|
||||
[PANEL_TYPES.HEATMAP]: null,
|
||||
[PANEL_TYPES.DISTRIBUTION]: null,
|
||||
[PANEL_TYPES.GEO_MAP]: null,
|
||||
[PANEL_TYPES.TOP_LIST]: null,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
} from 'constants/queryBuilder';
|
||||
import {
|
||||
metricsGaugeSpaceAggregateOperatorOptions,
|
||||
metricsHeatmapHistogramSpaceAggregateOperatorOptions,
|
||||
metricsBucketHistogramSpaceAggregateOperatorOptions,
|
||||
metricsHistogramSpaceAggregateOperatorOptions,
|
||||
metricsSumSpaceAggregateOperatorOptions,
|
||||
metricsUnknownSpaceAggregateOperatorOptions,
|
||||
@@ -59,6 +59,7 @@ import {
|
||||
} from 'types/common/queryBuilder';
|
||||
import { SelectOption } from 'types/common/select';
|
||||
import { getFormatedLegend } from 'utils/getFormatedLegend';
|
||||
import { isBucketPanelType } from 'lib/query/bucketPanelTypes';
|
||||
|
||||
export const useQueryOperations: UseQueryOperations = ({
|
||||
query,
|
||||
@@ -181,10 +182,9 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
(aggregateAttribute?.type as ATTRIBUTE_TYPES) || ATTRIBUTE_TYPES.GAUGE,
|
||||
});
|
||||
|
||||
const histogramSpaceAggregationOptions =
|
||||
panelType === PANEL_TYPES.HEATMAP
|
||||
? metricsHeatmapHistogramSpaceAggregateOperatorOptions
|
||||
: metricsHistogramSpaceAggregateOperatorOptions;
|
||||
const histogramSpaceAggregationOptions = isBucketPanelType(panelType)
|
||||
? metricsBucketHistogramSpaceAggregateOperatorOptions
|
||||
: metricsHistogramSpaceAggregateOperatorOptions;
|
||||
|
||||
switch (aggregateAttribute?.type) {
|
||||
case ATTRIBUTE_TYPES.SUM:
|
||||
@@ -267,13 +267,12 @@ export const useQueryOperations: UseQueryOperations = ({
|
||||
timeAggregation: '',
|
||||
metricName: newQuery.aggregateAttribute?.key || '',
|
||||
temporality: '',
|
||||
// A heatmap cell holds a count of observations per `le` band, which is
|
||||
// the one option the kind offers — a percentile default would sit in the
|
||||
// Heatmap and distribution count observations per `le` band, the one
|
||||
// option those kinds offer — a percentile default would sit in the
|
||||
// selector with nothing behind it.
|
||||
spaceAggregation:
|
||||
panelType === PANEL_TYPES.HEATMAP
|
||||
? MetricAggregateOperator.COUNT
|
||||
: MetricAggregateOperator.P90,
|
||||
spaceAggregation: isBucketPanelType(panelType)
|
||||
? MetricAggregateOperator.COUNT
|
||||
: MetricAggregateOperator.P90,
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import * as monaco from 'monaco-editor';
|
||||
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api.js';
|
||||
import * as jsonContribution from 'monaco-editor/esm/vs/language/json/monaco.contribution.js';
|
||||
import 'monaco-editor/esm/vs/basic-languages/sql/sql.contribution.js';
|
||||
import 'monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution.js';
|
||||
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
|
||||
@@ -11,10 +14,13 @@ self.MonacoEnvironment = {
|
||||
if (label === 'json') {
|
||||
return new JsonWorker(); // JSON language service
|
||||
}
|
||||
// SigNoz editors use JSON + a hand-registered ClickHouse tokenizer (no worker),
|
||||
// so the base editor worker covers everything else.
|
||||
return new EditorWorker(); // base worker — sql, yaml, plaintext etc.
|
||||
// SigNoz editors use JSON, SQL and YAML. Their tokenizers run on the main thread,
|
||||
// so the base editor worker covers the rest (word suggestions, links).
|
||||
return new EditorWorker(); // base worker: sql, yaml, plaintext etc.
|
||||
},
|
||||
};
|
||||
|
||||
// The `monaco-editor` entry exposes JSON this way; the role editor reads `languages.json`.
|
||||
Object.assign(monaco.languages, { json: jsonContribution });
|
||||
|
||||
export { monaco };
|
||||
|
||||
13
frontend/src/lib/query/__tests__/bucketPanelTypes.test.ts
Normal file
13
frontend/src/lib/query/__tests__/bucketPanelTypes.test.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
|
||||
import { isBucketPanelType } from '../bucketPanelTypes';
|
||||
|
||||
describe('isBucketPanelType', () => {
|
||||
it('is true for heatmap and distribution only', () => {
|
||||
expect(isBucketPanelType(PANEL_TYPES.HEATMAP)).toBe(true);
|
||||
expect(isBucketPanelType(PANEL_TYPES.DISTRIBUTION)).toBe(true);
|
||||
expect(isBucketPanelType(PANEL_TYPES.HISTOGRAM)).toBe(false);
|
||||
expect(isBucketPanelType(PANEL_TYPES.TIME_SERIES)).toBe(false);
|
||||
expect(isBucketPanelType(null)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,9 @@
|
||||
import { initialQueriesMap } from 'constants/queryBuilder';
|
||||
import { initialQueriesMap, PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
aggregatesDistributionField,
|
||||
getDistributionFieldPlaceholder,
|
||||
setDistributionField,
|
||||
toDistributionAggregation,
|
||||
@@ -17,6 +18,17 @@ const queryOf = (
|
||||
aggregations: expressions.map((expression) => ({ expression })),
|
||||
});
|
||||
|
||||
describe('aggregatesDistributionField', () => {
|
||||
it.each([
|
||||
[PANEL_TYPES.HEATMAP, DataSource.TRACES, true],
|
||||
[PANEL_TYPES.DISTRIBUTION, DataSource.LOGS, true],
|
||||
[PANEL_TYPES.DISTRIBUTION, DataSource.METRICS, false],
|
||||
[PANEL_TYPES.HISTOGRAM, DataSource.TRACES, false],
|
||||
])('%s over %s → %s', (panelType, dataSource, expected) => {
|
||||
expect(aggregatesDistributionField(panelType, dataSource)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getDistributionFieldPlaceholder', () => {
|
||||
it.each([
|
||||
[DataSource.TRACES, 'Numeric field to bucket, e.g. duration_nano'],
|
||||
|
||||
@@ -49,8 +49,23 @@ describe('handleQueryChange bucket options', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// The request rejects an axis on any type but heatmap, so a switch has to shed it
|
||||
// from the query (via the field allowlist) and from the formula (by hand).
|
||||
it('keeps both axes when a heatmap switches to a distribution', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.DISTRIBUTION,
|
||||
queryWithFormulaAxis(),
|
||||
PANEL_TYPES.HEATMAP,
|
||||
);
|
||||
|
||||
expect(result.builder.queryData[0].bucketOptions).toStrictEqual(
|
||||
bucketOptions,
|
||||
);
|
||||
expect(result.builder.queryFormulas[0].bucketOptions).toStrictEqual(
|
||||
bucketOptions,
|
||||
);
|
||||
});
|
||||
|
||||
// The request rejects an axis on any type but heatmap and distribution, so a switch
|
||||
// has to shed it from the query (via the field allowlist) and from the formula (by hand).
|
||||
it('drops both axes when switching to another panel type', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
@@ -124,16 +139,19 @@ describe('handleQueryChange trace operator', () => {
|
||||
expect(result.builder.queryTraceOperator).toStrictEqual([]);
|
||||
});
|
||||
|
||||
// A heatmap request takes one builder query and rejects a trace operator.
|
||||
it('drops the trace operator when switching to a heatmap', () => {
|
||||
const result = handleQueryChange(
|
||||
PANEL_TYPES.HEATMAP,
|
||||
queryWithTraceOperator(),
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
// A heatmap or distribution request takes one builder query and rejects a trace operator.
|
||||
it.each([PANEL_TYPES.HEATMAP, PANEL_TYPES.DISTRIBUTION] as const)(
|
||||
'drops the trace operator when switching to a %s',
|
||||
(panelType) => {
|
||||
const result = handleQueryChange(
|
||||
panelType,
|
||||
queryWithTraceOperator(),
|
||||
PANEL_TYPES.TIME_SERIES,
|
||||
);
|
||||
|
||||
expect(result.builder.queryTraceOperator).toStrictEqual([]);
|
||||
});
|
||||
expect(result.builder.queryTraceOperator).toStrictEqual([]);
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps the trace operator when switching to a table', () => {
|
||||
const result = handleQueryChange(
|
||||
|
||||
@@ -5,7 +5,7 @@ export const unquoteAlias = (alias: string): string =>
|
||||
alias.replace(/^['"]|['"]$/g, '');
|
||||
|
||||
/**
|
||||
* A logs or traces heatmap's aggregation: one field with an optional alias.
|
||||
* A logs or traces heatmap or distribution's aggregation: one field with an optional alias.
|
||||
* The field mirrors the querier's HeatmapAggregationField: no call, no whitespace.
|
||||
*/
|
||||
export const DISTRIBUTION_FIELD = new RegExp(
|
||||
@@ -26,7 +26,7 @@ export function parseAggregations(
|
||||
'g',
|
||||
);
|
||||
// With no call at all, the whole expression may be the field a logs/traces
|
||||
// heatmap buckets, e.g. "duration_nano"
|
||||
// heatmap or distribution buckets, e.g. "duration_nano"
|
||||
let match =
|
||||
regex.exec(expression) ??
|
||||
(allowDistributionField ? DISTRIBUTION_FIELD.exec(expression) : null);
|
||||
|
||||
14
frontend/src/lib/query/bucketPanelTypes.ts
Normal file
14
frontend/src/lib/query/bucketPanelTypes.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
|
||||
/**
|
||||
* Panel types whose request counts observations into buckets (`heatmap`,
|
||||
* `distribution`): they share the bucket axis, its query-builder options and the
|
||||
* count aggregation a histogram metric gets.
|
||||
*/
|
||||
export function isBucketPanelType(
|
||||
panelType: string | null | undefined,
|
||||
): boolean {
|
||||
return (
|
||||
panelType === PANEL_TYPES.HEATMAP || panelType === PANEL_TYPES.DISTRIBUTION
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import type {
|
||||
IBuilderQuery,
|
||||
OrderByPayload,
|
||||
@@ -6,6 +5,8 @@ import type {
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import type { LogAggregation, TraceAggregation } from 'types/api/v5/queryRange';
|
||||
|
||||
import { isBucketPanelType } from './bucketPanelTypes';
|
||||
|
||||
import {
|
||||
ALIAS,
|
||||
DISTRIBUTION_FIELD,
|
||||
@@ -20,7 +21,7 @@ const NUMERIC_FIELD_CALL = new RegExp(
|
||||
`^\\s*(?:avg|sum|min|max|p\\d{2})\\(\\s*([^\\s(),]+)\\s*\\)(?:\\s+as\\s+(${ALIAS}))?\\s*$`,
|
||||
);
|
||||
|
||||
/** The percentile a field or histogram metric gets when it leaves a heatmap. */
|
||||
/** The percentile a field or histogram metric gets when it leaves a heatmap or distribution. */
|
||||
export const DEFAULT_PERCENTILE = 'p90';
|
||||
|
||||
type FieldAggregation = TraceAggregation | LogAggregation;
|
||||
@@ -41,7 +42,7 @@ export function aggregatesDistributionField(
|
||||
panelType: string | null | undefined,
|
||||
dataSource: DataSource,
|
||||
): boolean {
|
||||
return panelType === PANEL_TYPES.HEATMAP && isLogsOrTraces(dataSource);
|
||||
return isBucketPanelType(panelType) && isLogsOrTraces(dataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ export function getDistributionFieldPlaceholder(
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs and traces heatmaps bucket a field; any function aggregation is
|
||||
* Logs and traces heatmaps and distributions bucket a field; any function aggregation is
|
||||
* rejected, so a numeric `fn(field)` keeps its field and anything else leaves
|
||||
* the field for the user to pick.
|
||||
*/
|
||||
@@ -109,7 +110,7 @@ export function toDistributionAggregation(query: IBuilderQuery): IBuilderQuery {
|
||||
);
|
||||
}
|
||||
|
||||
/** Picks `field` as the heatmap's aggregation; a sort on the old field follows it. */
|
||||
/** Picks `field` as the aggregation; a sort on the old field follows it. */
|
||||
export function setDistributionField(
|
||||
query: IBuilderQuery,
|
||||
field: string,
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
PANEL_TYPES,
|
||||
} from 'constants/queryBuilder';
|
||||
import { cloneDeep, isEqual, set, unset } from 'lodash-es';
|
||||
import { isBucketPanelType } from 'lib/query/bucketPanelTypes';
|
||||
import {
|
||||
IBuilderFormula,
|
||||
IBuilderQuery,
|
||||
@@ -99,13 +100,13 @@ export const getIsQueryModified = (
|
||||
/**
|
||||
* Formulas are carried across a panel-type switch whole, not rebuilt from
|
||||
* `panelTypeDataSourceFormValuesMap` the way `queryData` is, so a bucket axis has to be
|
||||
* dropped by hand. The request rejects one on any type but heatmap.
|
||||
* dropped by hand. The request rejects one on any type that does not count buckets.
|
||||
*/
|
||||
const withHeatmapBucketOptions = (
|
||||
const withBucketOptions = (
|
||||
formulas: IBuilderFormula[],
|
||||
newPanelType: keyof PartialPanelTypes,
|
||||
): IBuilderFormula[] => {
|
||||
if (newPanelType === PANEL_TYPES.HEATMAP) {
|
||||
if (isBucketPanelType(newPanelType)) {
|
||||
return formulas;
|
||||
}
|
||||
|
||||
@@ -170,11 +171,11 @@ export function rebuildBuilderForPanelType(
|
||||
|
||||
return tempQuery;
|
||||
}),
|
||||
queryFormulas: withHeatmapBucketOptions(builder.queryFormulas, newPanelType),
|
||||
queryFormulas: withBucketOptions(builder.queryFormulas, newPanelType),
|
||||
queryTraceOperator:
|
||||
newPanelType === PANEL_TYPES.LIST ||
|
||||
newPanelType === PANEL_TYPES.SCATTER ||
|
||||
newPanelType === PANEL_TYPES.HEATMAP
|
||||
isBucketPanelType(newPanelType)
|
||||
? []
|
||||
: builder.queryTraceOperator,
|
||||
};
|
||||
|
||||
@@ -17,6 +17,7 @@ export type PartialPanelTypes = {
|
||||
[PANEL_TYPES.SCATTER]: 'scatter';
|
||||
[PANEL_TYPES.HISTOGRAM]: 'histogram';
|
||||
[PANEL_TYPES.HEATMAP]: 'heatmap';
|
||||
[PANEL_TYPES.DISTRIBUTION]: 'distribution';
|
||||
[PANEL_TYPES.GEO_MAP]: 'geo_map';
|
||||
[PANEL_TYPES.TOP_LIST]: 'top_list';
|
||||
};
|
||||
@@ -149,6 +150,7 @@ export const panelTypeDataSourceFormValuesMap: Record<
|
||||
[PANEL_TYPES.BAR]: bySource(SERIES, SERIES_METRICS),
|
||||
[PANEL_TYPES.HISTOGRAM]: bySource(SERIES, SERIES_METRICS),
|
||||
[PANEL_TYPES.HEATMAP]: bySource(HEATMAP, HEATMAP),
|
||||
[PANEL_TYPES.DISTRIBUTION]: bySource(HEATMAP, HEATMAP),
|
||||
[PANEL_TYPES.TABLE]: bySource(SERIES, SCALAR_METRICS),
|
||||
[PANEL_TYPES.PIE]: bySource(SERIES, SCALAR_METRICS),
|
||||
[PANEL_TYPES.SCATTER]: bySource(SERIES, SCALAR_METRICS),
|
||||
|
||||
@@ -11,8 +11,9 @@ const MARKER_IDLE_ALPHA = 0.55;
|
||||
/** Cap height as a share of the font size. */
|
||||
const CAP_HEIGHT_RATIO = 0.7;
|
||||
const MARKER_FONT_SIZE_PX = 9;
|
||||
/** Space between a badge's name and its diamond's edges. */
|
||||
const MARKER_BADGE_PADDING_PX = 2;
|
||||
const MARKER_BADGE_PADDING_X_PX = 5;
|
||||
const MARKER_BADGE_PADDING_Y_PX = 4;
|
||||
const MARKER_BADGE_RADIUS_PX = 3;
|
||||
const MARKER_BADGE_GAP_PX = 2;
|
||||
const MARKER_VALUE_FONT_SIZE_PX = 11;
|
||||
/** How far from a marker line the cursor still hovers it, in CSS pixels. */
|
||||
@@ -81,21 +82,24 @@ export function layoutMarkerLabels(
|
||||
return rows;
|
||||
}
|
||||
|
||||
/** A square diamond centred on `(x, y)` with half-diagonal `radius`, filled then outlined. */
|
||||
function drawDiamond(
|
||||
/** A rounded rectangle centred on `(x, y)`, filled then outlined. */
|
||||
function drawBadge(
|
||||
ctx: CanvasRenderingContext2D,
|
||||
x: number,
|
||||
y: number,
|
||||
radius: number,
|
||||
halfWidth: number,
|
||||
halfHeight: number,
|
||||
fill: string,
|
||||
stroke: string,
|
||||
): void {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x, y - radius);
|
||||
ctx.lineTo(x + radius, y);
|
||||
ctx.lineTo(x, y + radius);
|
||||
ctx.lineTo(x - radius, y);
|
||||
ctx.closePath();
|
||||
ctx.roundRect(
|
||||
x - halfWidth,
|
||||
y - halfHeight,
|
||||
2 * halfWidth,
|
||||
2 * halfHeight,
|
||||
MARKER_BADGE_RADIUS_PX * uPlot.pxRatio,
|
||||
);
|
||||
ctx.fillStyle = fill;
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = stroke;
|
||||
@@ -103,7 +107,7 @@ function drawDiamond(
|
||||
}
|
||||
|
||||
/**
|
||||
* Dashed lines across the plot with a diamond badge at each end naming the
|
||||
* Dashed lines across the plot with a badge at each end naming the
|
||||
* percentile, one per group on the same spot; badges stack into rows so none overlap. The hovered marker is
|
||||
* emphasised and shows its value on the x axis. Returns each marker's hover targets.
|
||||
*/
|
||||
@@ -128,33 +132,34 @@ export function drawPercentileMarkers(
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'middle';
|
||||
|
||||
const badgeLabels = markers.map((group) => {
|
||||
// Cap height stands in for the text's height.
|
||||
const halfHeight =
|
||||
(MARKER_FONT_SIZE_PX * pxRatio * CAP_HEIGHT_RATIO) / 2 +
|
||||
MARKER_BADGE_PADDING_Y_PX * pxRatio;
|
||||
const badges = markers.map((group) => {
|
||||
const text = formatPercentileBadge(group);
|
||||
return { text, width: ctx.measureText(text).width };
|
||||
return {
|
||||
text,
|
||||
x: uPlotInstance.valToPos(group[0].axisValue, 'x', true),
|
||||
halfWidth:
|
||||
ctx.measureText(text).width / 2 + MARKER_BADGE_PADDING_X_PX * pxRatio,
|
||||
};
|
||||
});
|
||||
// One square diamond for all, fitting the widest name's box: |dx| + |dy| ≤ radius at
|
||||
// its corners. Cap height stands in for the text's height.
|
||||
const radius =
|
||||
(Math.max(...badgeLabels.map(({ width }) => width)) +
|
||||
MARKER_FONT_SIZE_PX * pxRatio * CAP_HEIGHT_RATIO) /
|
||||
2 +
|
||||
MARKER_BADGE_PADDING_PX * pxRatio;
|
||||
const badges = markers.map((group, index) => ({
|
||||
text: badgeLabels[index].text,
|
||||
x: uPlotInstance.valToPos(group[0].axisValue, 'x', true),
|
||||
}));
|
||||
const rows = layoutMarkerLabels(
|
||||
badges.map(({ x }) => ({ x: x - radius, width: 2 * radius })),
|
||||
badges.map(({ x, halfWidth }) => ({
|
||||
x: x - halfWidth,
|
||||
width: 2 * halfWidth,
|
||||
})),
|
||||
MARKER_BADGE_GAP_PX * pxRatio,
|
||||
);
|
||||
const rowStep = 2 * radius + MARKER_BADGE_GAP_PX * pxRatio;
|
||||
const rowStep = 2 * halfHeight + MARKER_BADGE_GAP_PX * pxRatio;
|
||||
const badgeCentres = (index: number): [number, number] => {
|
||||
const offset = radius + rows[index] * rowStep;
|
||||
const offset = halfHeight + rows[index] * rowStep;
|
||||
return [bbox.top + offset, bottom - offset];
|
||||
};
|
||||
|
||||
const drawMarker = (index: number): void => {
|
||||
const { text, x } = badges[index];
|
||||
const { text, x, halfWidth } = badges[index];
|
||||
const isHovered = index === hovered;
|
||||
|
||||
ctx.globalAlpha = isHovered ? 1 : MARKER_IDLE_ALPHA;
|
||||
@@ -169,7 +174,15 @@ export function drawPercentileMarkers(
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.setLineDash([]);
|
||||
badgeCentres(index).forEach((y) => {
|
||||
drawDiamond(ctx, x, y, radius, isHovered ? color : background, color);
|
||||
drawBadge(
|
||||
ctx,
|
||||
x,
|
||||
y,
|
||||
halfWidth,
|
||||
halfHeight,
|
||||
isHovered ? color : background,
|
||||
color,
|
||||
);
|
||||
ctx.fillStyle = isHovered ? background : color;
|
||||
ctx.fillText(text, x, y);
|
||||
});
|
||||
@@ -179,7 +192,7 @@ export function drawPercentileMarkers(
|
||||
}
|
||||
// The value sits on the x axis under the line, over the tick labels, in a pill
|
||||
// whose notch points up at the line.
|
||||
ctx.font = `500 ${MARKER_VALUE_FONT_SIZE_PX * pxRatio}px Inter, sans-serif`;
|
||||
ctx.font = `600 ${MARKER_VALUE_FONT_SIZE_PX * pxRatio}px Inter, sans-serif`;
|
||||
const value = formatPercentileValue(markers[index], formatBound);
|
||||
const pillPaddingX = MARKER_PILL_PADDING_X_PX * pxRatio;
|
||||
const pillPaddingY = MARKER_PILL_PADDING_Y_PX * pxRatio;
|
||||
@@ -200,7 +213,8 @@ export function drawPercentileMarkers(
|
||||
width + 2 * pillPaddingX,
|
||||
height + 2 * pillPaddingY,
|
||||
);
|
||||
ctx.fillStyle = isDarkMode ? Color.BG_SLATE_400 : Color.BG_INK_400;
|
||||
// The hovered badge's colours, so the value reads as part of the same marker.
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.roundRect(left, top, width, height, MARKER_PILL_RADIUS_PX * pxRatio);
|
||||
ctx.moveTo(notchX - pointer, top);
|
||||
@@ -208,7 +222,7 @@ export function drawPercentileMarkers(
|
||||
ctx.lineTo(notchX + pointer, top);
|
||||
ctx.closePath();
|
||||
ctx.fill();
|
||||
ctx.fillStyle = Color.BG_VANILLA_100;
|
||||
ctx.fillStyle = background;
|
||||
ctx.fillText(value, left + width / 2, top + height / 2);
|
||||
};
|
||||
|
||||
@@ -219,16 +233,16 @@ export function drawPercentileMarkers(
|
||||
}
|
||||
ctx.restore();
|
||||
|
||||
return badges.map(({ x }, index) => {
|
||||
return badges.map(({ x, halfWidth }, index) => {
|
||||
const toPlot = (value: number, origin: number): number =>
|
||||
(value - origin) / pxRatio;
|
||||
return {
|
||||
x: toPlot(x, bbox.left),
|
||||
badges: badgeCentres(index).map((y) => ({
|
||||
left: toPlot(x - radius, bbox.left),
|
||||
right: toPlot(x + radius, bbox.left),
|
||||
top: toPlot(y - radius, bbox.top),
|
||||
bottom: toPlot(y + radius, bbox.top),
|
||||
left: toPlot(x - halfWidth, bbox.left),
|
||||
right: toPlot(x + halfWidth, bbox.left),
|
||||
top: toPlot(y - halfHeight, bbox.top),
|
||||
bottom: toPlot(y + halfHeight, bbox.top),
|
||||
})),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -12,7 +12,7 @@ const OPTIONS = [
|
||||
{ kind: 'signoz/BarChartPanel', displayName: 'Bar Chart' },
|
||||
{ kind: 'signoz/AreaChartPanel', displayName: 'Area' },
|
||||
{ kind: 'signoz/PieChartPanel', displayName: 'Pie Chart' },
|
||||
{ kind: 'signoz/HistogramPanel', displayName: 'Histogram' },
|
||||
{ kind: 'signoz/HistogramPanel', displayName: 'Histogram', isRetired: true },
|
||||
{ kind: 'signoz/ListPanel', displayName: 'List' },
|
||||
{ kind: 'signoz/TextPanel', displayName: 'Text' },
|
||||
].map((option) => ({ ...option, icon: (): null => null }));
|
||||
@@ -110,6 +110,22 @@ describe('PanelTypeSwitcher', () => {
|
||||
expect(onChange).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not offer a retired type to a panel of another type', async () => {
|
||||
await renderSwitcher();
|
||||
|
||||
expect(
|
||||
screen.queryByTestId('panel-type-signoz/HistogramPanel'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps a retired type on offer to a panel already of it', async () => {
|
||||
await renderSwitcher({ panelKind: 'signoz/HistogramPanel' });
|
||||
|
||||
expect(
|
||||
screen.getByTestId('panel-type-signoz/HistogramPanel'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('disables types whose supported signals exclude the current signal', async () => {
|
||||
const { onChange, user } = await renderSwitcher({
|
||||
signal: TelemetrytypesSignalDTO.metrics,
|
||||
|
||||
@@ -4,11 +4,14 @@ import type { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
import { PANEL_OPTIONS } from '../../../Panels/registry';
|
||||
import type { PanelKind } from '../../../Panels/types/panelKind';
|
||||
import { isPanelOptionOffered } from '../../../Panels/utils/isPanelOptionOffered';
|
||||
import type { ConfigSelectItem } from '../controls/ConfigSelect/ConfigSelect';
|
||||
|
||||
import { getPanelTypeDisabledReason } from './utils';
|
||||
|
||||
interface UsePanelTypeSelectItemsArgs {
|
||||
/** The panel's kind — the only one a retired kind is still offered to. */
|
||||
panelKind: PanelKind;
|
||||
/** Active query type — a kind that can't be authored in it is disabled. */
|
||||
queryType: EQueryType;
|
||||
/** Current datasource — also gates the disabled rule (List needs logs/traces, not metrics). */
|
||||
@@ -21,12 +24,15 @@ interface UsePanelTypeSelectItemsArgs {
|
||||
* the capabilities guard, the same rule the editor's `PanelTypeSwitcher` applies.
|
||||
*/
|
||||
export function usePanelTypeSelectItems({
|
||||
panelKind,
|
||||
queryType,
|
||||
signal,
|
||||
}: UsePanelTypeSelectItemsArgs): ConfigSelectItem<PanelKind>[] {
|
||||
return useMemo(
|
||||
() =>
|
||||
PANEL_OPTIONS.map(({ kind, displayName, icon: Icon }) => {
|
||||
PANEL_OPTIONS.filter((option) =>
|
||||
isPanelOptionOffered(option, panelKind),
|
||||
).map(({ kind, displayName, icon: Icon }) => {
|
||||
// One reason drives both the disabled flag and the tooltip, so they can't disagree.
|
||||
const disabledReason = getPanelTypeDisabledReason({
|
||||
kind,
|
||||
@@ -42,6 +48,6 @@ export function usePanelTypeSelectItems({
|
||||
tooltip: disabledReason,
|
||||
};
|
||||
}),
|
||||
[queryType, signal],
|
||||
[panelKind, queryType, signal],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,13 @@ export const SWITCH_SKETCHES = {
|
||||
))}
|
||||
</SketchSvg>
|
||||
),
|
||||
percentiles: (
|
||||
<SketchSvg>
|
||||
<path d="M3 19 L9 13 L15 7 L21 9 L27 14 L33 17 L37 19" />
|
||||
<path d="M15 3 V20" strokeDasharray="2 2" />
|
||||
<path d="M29 3 V20" strokeDasharray="2 2" />
|
||||
</SketchSvg>
|
||||
),
|
||||
rank: (
|
||||
<SketchSvg>
|
||||
{[5, 11, 17].map((y, index) => (
|
||||
|
||||
@@ -180,6 +180,22 @@ export const TILE_DRAWINGS = {
|
||||
<rect x={38} y={8} width={11} height={6} {...FILLED} />
|
||||
</TileSvg>
|
||||
),
|
||||
barsSideBySide: (
|
||||
<TileSvg>
|
||||
<rect x={10} y={8} width={7} height={14} {...FILLED} opacity={0.5} />
|
||||
<rect x={18} y={12} width={7} height={10} {...FILLED} />
|
||||
<rect x={36} y={11} width={7} height={11} {...FILLED} opacity={0.5} />
|
||||
<rect x={44} y={6} width={7} height={16} {...FILLED} />
|
||||
</TileSvg>
|
||||
),
|
||||
barsPercent: (
|
||||
<TileSvg>
|
||||
<rect x={14} y={12} width={11} height={10} {...FILLED} opacity={0.5} />
|
||||
<rect x={14} y={2} width={11} height={9} {...FILLED} />
|
||||
<rect x={38} y={8} width={11} height={14} {...FILLED} opacity={0.5} />
|
||||
<rect x={38} y={2} width={11} height={5} {...FILLED} />
|
||||
</TileSvg>
|
||||
),
|
||||
areaOverlap: (
|
||||
<TileSvg>
|
||||
<path d="M4 15 L18 9 L32 13 L46 6 L60 9" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { ComponentType } from 'react';
|
||||
import {
|
||||
type DashboardtypesDistributionAxesDTO,
|
||||
type DashboardtypesGeoMapChartAppearanceDTO,
|
||||
DashboardtypesGeoMapLayerDTO,
|
||||
type DashboardtypesGeoMapLocationDTO,
|
||||
@@ -32,6 +33,7 @@ import BucketsSection from './sections/BucketsSection/BucketsSection';
|
||||
import ChartAppearanceSection from './sections/ChartAppearanceSection/ChartAppearanceSection';
|
||||
import ContextLinksSection from './sections/ContextLinksSection/ContextLinksSection';
|
||||
import DimensionsSection from './sections/DimensionsSection/DimensionsSection';
|
||||
import DistributionAxesSection from './sections/DistributionAxesSection/DistributionAxesSection';
|
||||
import FormattingSection from './sections/FormattingSection/FormattingSection';
|
||||
import LegendSection from './sections/LegendSection/LegendSection';
|
||||
import LocationSection from './sections/LocationSection/LocationSection';
|
||||
@@ -105,6 +107,13 @@ export const SECTION_REGISTRY: {
|
||||
getPluginSlice<DashboardtypesScatterPlotAxesDTO>(spec, 'axes'),
|
||||
update: (spec, axes): PanelSpec => updatePluginSlice(spec, 'axes', axes),
|
||||
},
|
||||
// Same `axes` key again, in Distribution's bucket-range/count-scale shape.
|
||||
[SectionKind.DistributionAxes]: {
|
||||
Component: DistributionAxesSection,
|
||||
get: (spec): DashboardtypesDistributionAxesDTO | undefined =>
|
||||
getPluginSlice<DashboardtypesDistributionAxesDTO>(spec, 'axes'),
|
||||
update: (spec, axes): PanelSpec => updatePluginSlice(spec, 'axes', axes),
|
||||
},
|
||||
[SectionKind.Dimensions]: {
|
||||
Component: DimensionsSection,
|
||||
get: (spec): DashboardtypesScatterPlotDimensionsDTO | undefined =>
|
||||
|
||||
@@ -16,6 +16,7 @@ import { resolveBubbleRadius } from 'pages/DashboardPage/DashboardContainer/Pane
|
||||
|
||||
import ConfigRangeSlider from '../../controls/ConfigRangeSlider/ConfigRangeSlider';
|
||||
import DisconnectValuesField from './DisconnectValuesField';
|
||||
import DistributionPercentilesField from './DistributionPercentilesField';
|
||||
import GeoMapColorsField from './GeoMapColorsField';
|
||||
import HeatmapColorsField from './HeatmapColorsField';
|
||||
import PointsFields from './PointsFields';
|
||||
@@ -43,6 +44,7 @@ const BUBBLE_RADIUS_BOUNDS = { min: 1, max: 64 };
|
||||
*/
|
||||
function ChartAppearanceSection({
|
||||
value,
|
||||
defaultValue,
|
||||
savedValue,
|
||||
controls,
|
||||
onChange,
|
||||
@@ -59,6 +61,15 @@ function ChartAppearanceSection({
|
||||
|
||||
return (
|
||||
<>
|
||||
{controls.percentiles && (
|
||||
<DistributionPercentilesField
|
||||
value={value?.percentiles}
|
||||
defaultValue={defaultValue?.percentiles}
|
||||
savedValue={savedValue?.percentiles}
|
||||
onChange={(percentiles): void => onChange({ ...value, percentiles })}
|
||||
/>
|
||||
)}
|
||||
|
||||
{controls.lineStyle && (
|
||||
<ConfigField label="Line" {...reset('lineStyle')}>
|
||||
<ConfigTiles
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import type { DashboardtypesDistributionPercentilesDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import ConfigField from '../../controls/ConfigField/ConfigField';
|
||||
import ConfigMultiSelect from '../../controls/ConfigMultiSelect/ConfigMultiSelect';
|
||||
import ConfigSwitch from '../../controls/ConfigSwitch/ConfigSwitch';
|
||||
import { SWITCH_SKETCHES } from '../../controls/drawings/switchSketches';
|
||||
import { createFieldResetter } from '../../utils/changes';
|
||||
import {
|
||||
MAX_PERCENTILE_MARKERS,
|
||||
resolvePercentileItems,
|
||||
} from './percentileOptions';
|
||||
|
||||
interface DistributionPercentilesFieldProps {
|
||||
value: DashboardtypesDistributionPercentilesDTO | undefined;
|
||||
/** The new panel's seed: what the server writes for unset percentiles. */
|
||||
defaultValue?: DashboardtypesDistributionPercentilesDTO;
|
||||
savedValue?: DashboardtypesDistributionPercentilesDTO;
|
||||
onChange: (next: DashboardtypesDistributionPercentilesDTO) => void;
|
||||
}
|
||||
|
||||
/** Edits `chartAppearance.percentiles`. */
|
||||
function DistributionPercentilesField({
|
||||
value,
|
||||
defaultValue,
|
||||
savedValue,
|
||||
onChange,
|
||||
}: DistributionPercentilesFieldProps): JSX.Element {
|
||||
const reset = createFieldResetter(value, savedValue, onChange);
|
||||
const enabled = value?.enabled ?? defaultValue?.enabled ?? false;
|
||||
const values = value?.values ?? defaultValue?.values ?? [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<ConfigSwitch
|
||||
testId="panel-editor-v2-percentile-markers"
|
||||
title="Percentile markers"
|
||||
description="Dashed lines at percentiles estimated from the bucket counts."
|
||||
sketch={SWITCH_SKETCHES.percentiles}
|
||||
changed={reset('enabled').changed}
|
||||
value={enabled}
|
||||
onChange={(next): void => onChange({ enabled: next, values })}
|
||||
/>
|
||||
|
||||
{enabled && (
|
||||
<ConfigField
|
||||
label="Percentiles"
|
||||
help={
|
||||
<span data-testid="panel-editor-v2-percentile-limit">
|
||||
{values.length >= MAX_PERCENTILE_MARKERS
|
||||
? `Limit of ${MAX_PERCENTILE_MARKERS} reached; remove one to pick another.`
|
||||
: `Up to ${MAX_PERCENTILE_MARKERS}.`}
|
||||
</span>
|
||||
}
|
||||
{...reset('values')}
|
||||
>
|
||||
<ConfigMultiSelect
|
||||
testId="panel-editor-v2-percentile-values"
|
||||
placeholder="Pick percentiles"
|
||||
value={values.map(String)}
|
||||
items={resolvePercentileItems(values)}
|
||||
onChange={(picked): void => {
|
||||
if (picked.length <= MAX_PERCENTILE_MARKERS) {
|
||||
onChange({ enabled, values: picked.map(Number) });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</ConfigField>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default DistributionPercentilesField;
|
||||
@@ -0,0 +1,122 @@
|
||||
import type { ComponentProps } from 'react';
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
|
||||
import DistributionPercentilesField from '../DistributionPercentilesField';
|
||||
import { resolvePercentileItems } from '../percentileOptions';
|
||||
|
||||
describe('DistributionPercentilesField', () => {
|
||||
it("opens on the new panel's seed, with the values picker shown", () => {
|
||||
render(
|
||||
<DistributionPercentilesField
|
||||
value={undefined}
|
||||
defaultValue={{ enabled: true, values: [50, 90, 99] }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByTestId('panel-editor-v2-percentile-values'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('turns markers off, keeping the values for when they come back', async () => {
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
ComponentProps<typeof DistributionPercentilesField>['onChange']
|
||||
>;
|
||||
render(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: true, values: [75] }}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
await userEvent
|
||||
.setup()
|
||||
.click(screen.getByTestId('panel-editor-v2-percentile-markers'));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({ enabled: false, values: [75] });
|
||||
});
|
||||
|
||||
it('hides the values picker while markers are off', () => {
|
||||
render(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: false, values: [75] }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.queryByTestId('panel-editor-v2-percentile-values'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('DistributionPercentilesField limit', () => {
|
||||
it('says when the limit is reached', () => {
|
||||
const { rerender } = render(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: true, values: [50, 90, 99] }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId('panel-editor-v2-percentile-limit'),
|
||||
).toHaveTextContent('Up to 5.');
|
||||
|
||||
rerender(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: true, values: [50, 75, 90, 95, 99] }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
expect(
|
||||
screen.getByTestId('panel-editor-v2-percentile-limit'),
|
||||
).toHaveTextContent('Limit of 5 reached; remove one to pick another.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolvePercentileItems', () => {
|
||||
it('adds a saved value missing from the presets, in order', () => {
|
||||
expect(resolvePercentileItems([97]).map(({ label }) => label)).toStrictEqual([
|
||||
'p50',
|
||||
'p75',
|
||||
'p90',
|
||||
'p95',
|
||||
'p97',
|
||||
'p99',
|
||||
'p99.9',
|
||||
]);
|
||||
});
|
||||
|
||||
it('resets cleared percentiles to the saved ones', async () => {
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
ComponentProps<typeof DistributionPercentilesField>['onChange']
|
||||
>;
|
||||
render(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: true, values: [] }}
|
||||
savedValue={{ enabled: true, values: [50, 90, 99] }}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
await userEvent.setup().click(screen.getByTestId('config-field-reset'));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({
|
||||
enabled: true,
|
||||
values: [50, 90, 99],
|
||||
});
|
||||
});
|
||||
|
||||
it('offers no Reset when the values match the saved ones', () => {
|
||||
render(
|
||||
<DistributionPercentilesField
|
||||
value={{ enabled: true, values: [50, 90, 99] }}
|
||||
savedValue={{ enabled: true, values: [50, 90, 99] }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.queryByTestId('config-field-reset')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { ConfigMultiSelectItem } from '../../controls/ConfigMultiSelect/ConfigMultiSelect';
|
||||
|
||||
/** The save API rejects more. */
|
||||
export const MAX_PERCENTILE_MARKERS = 5;
|
||||
|
||||
const PRESET_PERCENTILES = [50, 75, 90, 95, 99, 99.9];
|
||||
|
||||
/** The presets plus any saved value outside them, ascending, so nothing saved is hidden. */
|
||||
export function resolvePercentileItems(
|
||||
values: number[],
|
||||
): ConfigMultiSelectItem[] {
|
||||
return [...new Set([...PRESET_PERCENTILES, ...values])]
|
||||
.sort((a, b) => a - b)
|
||||
.map((percentile) => ({
|
||||
value: String(percentile),
|
||||
label: `p${percentile}`,
|
||||
}));
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
.axes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.axis + .axis {
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--l1-border);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { SolidAlertCircle } from '@signozhq/icons';
|
||||
import { Callout } from '@signozhq/ui/callout';
|
||||
import type {
|
||||
SectionEditorProps,
|
||||
SectionKind,
|
||||
} from 'pages/DashboardPage/DashboardContainer/Panels/types/sections';
|
||||
import { DashboardtypesDistributionYScaleDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import ConfigField from '../../controls/ConfigField/ConfigField';
|
||||
import ConfigRangeInput from '../../controls/ConfigRangeInput/ConfigRangeInput';
|
||||
import { isRangeInverted } from '../../controls/ConfigRangeInput/utils';
|
||||
import ConfigTiles from '../../controls/ConfigTiles/ConfigTiles';
|
||||
import { createFieldResetter } from '../../utils/changes';
|
||||
import { Y_SCALE_HELP, Y_SCALE_OPTIONS } from './options';
|
||||
|
||||
import styles from './DistributionAxesSection.module.scss';
|
||||
|
||||
function DistributionAxesSection({
|
||||
value,
|
||||
savedValue,
|
||||
onChange,
|
||||
}: SectionEditorProps<SectionKind.DistributionAxes>): JSX.Element {
|
||||
const reset = createFieldResetter(value, savedValue, onChange);
|
||||
const xMin = value?.x?.min;
|
||||
const xMax = value?.x?.max;
|
||||
const yScale = value?.y?.scale ?? DashboardtypesDistributionYScaleDTO.linear;
|
||||
|
||||
return (
|
||||
<div className={styles.axes}>
|
||||
<div className={styles.axis}>
|
||||
<ConfigField
|
||||
label="X-axis range"
|
||||
help={
|
||||
isRangeInverted(xMin, xMax) ? (
|
||||
<Callout color="danger" size="sm" icon={<SolidAlertCircle />}>
|
||||
Min can't be greater than max.
|
||||
</Callout>
|
||||
) : (
|
||||
'Hides buckets outside the range. Leave empty to show them all.'
|
||||
)
|
||||
}
|
||||
{...reset('x')}
|
||||
>
|
||||
<ConfigRangeInput
|
||||
minTestId="panel-editor-v2-distribution-x-min"
|
||||
maxTestId="panel-editor-v2-distribution-x-max"
|
||||
min={xMin}
|
||||
max={xMax}
|
||||
onChangeMin={(min): void =>
|
||||
onChange({ ...value, x: { ...value?.x, min } })
|
||||
}
|
||||
onChangeMax={(max): void =>
|
||||
onChange({ ...value, x: { ...value?.x, max } })
|
||||
}
|
||||
/>
|
||||
</ConfigField>
|
||||
</div>
|
||||
<div className={styles.axis}>
|
||||
<ConfigField
|
||||
label="Y-axis scale"
|
||||
help={Y_SCALE_HELP[yScale]}
|
||||
{...reset('y')}
|
||||
>
|
||||
<ConfigTiles
|
||||
testId="panel-editor-v2-distribution-y-scale"
|
||||
aria-label="Y-axis scale"
|
||||
value={yScale}
|
||||
items={Y_SCALE_OPTIONS}
|
||||
onChange={(scale): void => onChange({ ...value, y: { scale } })}
|
||||
/>
|
||||
</ConfigField>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DistributionAxesSection;
|
||||
@@ -0,0 +1,71 @@
|
||||
import type { ComponentProps } from 'react';
|
||||
import { DashboardtypesDistributionYScaleDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { render, screen, userEvent } from 'tests/test-utils';
|
||||
|
||||
import DistributionAxesSection from '../DistributionAxesSection';
|
||||
|
||||
describe('DistributionAxesSection', () => {
|
||||
it('opens on the defaults the chart draws: every bucket, linear counts', () => {
|
||||
render(<DistributionAxesSection value={undefined} onChange={jest.fn()} />);
|
||||
|
||||
expect(
|
||||
screen.getByText(
|
||||
'Hides buckets outside the range. Leave empty to show them all.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByText('Bar heights proportional to counts.'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('writes the x min without dropping the max or the y scale', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
ComponentProps<typeof DistributionAxesSection>['onChange']
|
||||
>;
|
||||
render(
|
||||
<DistributionAxesSection
|
||||
value={{
|
||||
x: { max: 100 },
|
||||
y: { scale: DashboardtypesDistributionYScaleDTO.log },
|
||||
}}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('panel-editor-v2-distribution-x-min'));
|
||||
await user.paste('10');
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({
|
||||
x: { min: 10, max: 100 },
|
||||
y: { scale: DashboardtypesDistributionYScaleDTO.log },
|
||||
});
|
||||
});
|
||||
|
||||
it('flags a min above the max', () => {
|
||||
render(
|
||||
<DistributionAxesSection
|
||||
value={{ x: { min: 100, max: 10 } }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByText("Min can't be greater than max."),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('writes the y scale', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
ComponentProps<typeof DistributionAxesSection>['onChange']
|
||||
>;
|
||||
render(<DistributionAxesSection value={undefined} onChange={onChange} />);
|
||||
|
||||
await user.click(screen.getByText('Logarithmic'));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({
|
||||
y: { scale: DashboardtypesDistributionYScaleDTO.log },
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
import { DashboardtypesDistributionYScaleDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import { pickScaleOptions } from '../AxesSection/options';
|
||||
|
||||
export const Y_SCALE_OPTIONS = pickScaleOptions([
|
||||
DashboardtypesDistributionYScaleDTO.linear,
|
||||
DashboardtypesDistributionYScaleDTO.log,
|
||||
] as const);
|
||||
|
||||
export const Y_SCALE_HELP: Record<DashboardtypesDistributionYScaleDTO, string> =
|
||||
{
|
||||
linear: 'Bar heights proportional to counts.',
|
||||
log: 'Keeps small tail buckets visible next to the bulk.',
|
||||
};
|
||||
@@ -17,6 +17,8 @@ import {
|
||||
BAR_LAYOUT_HELP,
|
||||
BAR_LAYOUT_OPTIONS,
|
||||
BarLayout,
|
||||
BUCKET_STACK_HELP,
|
||||
BUCKET_STACK_OPTIONS,
|
||||
STACK_MODE_HELP,
|
||||
STACK_MODE_OPTIONS,
|
||||
} from './options';
|
||||
@@ -35,7 +37,8 @@ type VisualizationSectionProps = SectionEditorProps<SectionKind.Visualization> &
|
||||
/**
|
||||
* Edits the `visualization` slice: the panel-type switcher (`switchPanelKind`, every
|
||||
* kind), the per-panel time preference, bar stacking (`stackedBarChart`, Bar only),
|
||||
* area stacking (`stack`, Area only) and gap filling (`fillSpans`). Each control is
|
||||
* area stacking (`stack`, Area only), bucket stacking (`stack`, Distribution only)
|
||||
* and gap filling (`fillSpans`). Each control is
|
||||
* gated by its `controls` flag, so a kind only renders — and only writes — the fields
|
||||
* its spec supports.
|
||||
*/
|
||||
@@ -137,6 +140,22 @@ function VisualizationSection({
|
||||
/>
|
||||
</ConfigField>
|
||||
)}
|
||||
|
||||
{controls.bucketStack && (
|
||||
<ConfigField
|
||||
label="Groups in a bucket"
|
||||
help={stack && BUCKET_STACK_HELP[stack]}
|
||||
{...reset('stack')}
|
||||
>
|
||||
<ConfigTiles
|
||||
testId="panel-editor-v2-bucket-stack"
|
||||
aria-label="Groups in a bucket"
|
||||
value={stack}
|
||||
items={BUCKET_STACK_OPTIONS}
|
||||
onChange={(next): void => onChange({ ...value, stack: next })}
|
||||
/>
|
||||
</ConfigField>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { ComponentProps } from 'react';
|
||||
import { render, screen, userEvent, within } from 'tests/test-utils';
|
||||
import {
|
||||
DashboardtypesStackModeDTO,
|
||||
@@ -162,6 +163,43 @@ describe('VisualizationSection', () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("opens the bucket stack on the kind's seeded default", () => {
|
||||
render(
|
||||
<VisualizationSection
|
||||
value={undefined}
|
||||
defaultValue={{ stack: DashboardtypesStackModeDTO.normal }}
|
||||
controls={{ switchPanelKind: false, bucketStack: true }}
|
||||
onChange={jest.fn()}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByText(
|
||||
'Groups sit on top of each other, so the height shows the bucket total.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('writes the chosen bucket stack', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onChange = jest.fn() as jest.MockedFunction<
|
||||
ComponentProps<typeof VisualizationSection>['onChange']
|
||||
>;
|
||||
render(
|
||||
<VisualizationSection
|
||||
value={undefined}
|
||||
controls={{ switchPanelKind: false, bucketStack: true }}
|
||||
onChange={onChange}
|
||||
/>,
|
||||
);
|
||||
|
||||
await user.click(screen.getByTestId('panel-editor-v2-bucket-stack-none'));
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({
|
||||
stack: DashboardtypesStackModeDTO.none,
|
||||
});
|
||||
});
|
||||
|
||||
it('toggles fill spans through onChange', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onChange = jest.fn();
|
||||
|
||||
@@ -55,3 +55,32 @@ export const STACK_MODE_HELP: Record<DashboardtypesStackModeDTO, string> = {
|
||||
[DashboardtypesStackModeDTO.percent]:
|
||||
'Each series shows its share of the total at every point in time.',
|
||||
};
|
||||
|
||||
/** Distribution's layout of groups within a bucket. */
|
||||
export const BUCKET_STACK_OPTIONS: ConfigTileItem<DashboardtypesStackModeDTO>[] =
|
||||
[
|
||||
{
|
||||
value: DashboardtypesStackModeDTO.normal,
|
||||
label: 'Stacked',
|
||||
drawing: TILE_DRAWINGS.barsStacked,
|
||||
},
|
||||
{
|
||||
value: DashboardtypesStackModeDTO.none,
|
||||
label: 'Side by side',
|
||||
drawing: TILE_DRAWINGS.barsSideBySide,
|
||||
},
|
||||
{
|
||||
value: DashboardtypesStackModeDTO.percent,
|
||||
label: '100%',
|
||||
drawing: TILE_DRAWINGS.barsPercent,
|
||||
},
|
||||
];
|
||||
|
||||
export const BUCKET_STACK_HELP: Record<DashboardtypesStackModeDTO, string> = {
|
||||
[DashboardtypesStackModeDTO.normal]:
|
||||
'Groups sit on top of each other, so the height shows the bucket total.',
|
||||
[DashboardtypesStackModeDTO.none]:
|
||||
'Groups share each bucket side by side; hard to read past a few groups.',
|
||||
[DashboardtypesStackModeDTO.percent]:
|
||||
"Each group's share of the bucket; the y axis becomes a percentage.",
|
||||
};
|
||||
|
||||
@@ -21,9 +21,10 @@ import RunQueryBtn from 'container/QueryBuilder/components/RunQueryBtn/RunQueryB
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { useSyncQueryBuilderFields } from 'components/QueryBuilderV2/useSyncQueryBuilderFields';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { DATA_SOURCE_TO_SIGNAL, DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
getQueryBuilderFields,
|
||||
getQueryTypeSignals,
|
||||
isRawRequest,
|
||||
} from '../../Panels/types/panelCapabilities';
|
||||
@@ -44,6 +45,8 @@ interface PanelEditorQueryBuilderProps {
|
||||
onStageRunQuery: () => void;
|
||||
/** Abort the in-flight preview fetch (the button's cancel action). */
|
||||
onCancelQuery: () => void;
|
||||
/** Optional content above the tabs (e.g. Histogram's pointer to Distribution). */
|
||||
banner?: ReactNode;
|
||||
/** Optional content pinned below the builder (e.g. the List columns editor). */
|
||||
footer?: ReactNode;
|
||||
/** Pin the tabs + Run Query row to the top of the scroll area. Off in the View modal, which shares a scroll area with its own header. */
|
||||
@@ -60,6 +63,7 @@ function PanelEditorQueryBuilder({
|
||||
isLoadingQueries,
|
||||
onStageRunQuery,
|
||||
onCancelQuery,
|
||||
banner,
|
||||
footer,
|
||||
stickyHeader = true,
|
||||
}: PanelEditorQueryBuilderProps): JSX.Element {
|
||||
@@ -74,6 +78,16 @@ function PanelEditorQueryBuilder({
|
||||
// operator that combines aggregated trace queries (V1 parity).
|
||||
const isRawQuery = isRawRequest(panelDefinition.queryCapabilities);
|
||||
const { currentQuery } = useQueryBuilder();
|
||||
// Every query of a panel shares a signal, so the first one speaks for all.
|
||||
const signal = currentQuery.builder.queryData[0]?.dataSource;
|
||||
const queryBuilderFields = useMemo(
|
||||
() =>
|
||||
getQueryBuilderFields(
|
||||
panelDefinition,
|
||||
signal ? DATA_SOURCE_TO_SIGNAL[signal] : undefined,
|
||||
),
|
||||
[panelDefinition, signal],
|
||||
);
|
||||
const isDarkMode = useIsDarkMode();
|
||||
useSyncQueryBuilderFields(panelDefinition.syncedQueryBuilderFields);
|
||||
|
||||
@@ -111,7 +125,7 @@ function PanelEditorQueryBuilder({
|
||||
<div className="query-builder-v2-container">
|
||||
<QueryBuilderV2
|
||||
panelType={panelType}
|
||||
fieldsConfig={panelDefinition.queryBuilderFields}
|
||||
fieldsConfig={queryBuilderFields}
|
||||
allowedDataSources={getQueryTypeSignals(
|
||||
panelDefinition.supportedQueryTypesKindMap,
|
||||
EQueryType.QUERY_BUILDER,
|
||||
@@ -187,7 +201,7 @@ function PanelEditorQueryBuilder({
|
||||
// QB wants a null data source and AI pins traces: both mounted, they overwrite each other's provider config in a loop.
|
||||
destroyInactiveTabPane: isBuilderQueryType(queryType),
|
||||
}));
|
||||
}, [panelDefinition, panelType, isDarkMode, isRawQuery]);
|
||||
}, [panelDefinition, queryBuilderFields, panelType, isDarkMode, isRawQuery]);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -197,6 +211,7 @@ function PanelEditorQueryBuilder({
|
||||
role="presentation"
|
||||
>
|
||||
<div className={styles.scrollArea}>
|
||||
{banner}
|
||||
<Tabs
|
||||
type="card"
|
||||
className={cx(styles.tabsContainer, {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import type { DashboardtypesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import {
|
||||
initialClickHouseData,
|
||||
initialFormulaBuilderFormValues,
|
||||
initialQueriesMap,
|
||||
initialQueryAIWithType,
|
||||
initialQueryPromQLData,
|
||||
PANEL_TYPES,
|
||||
} from 'constants/queryBuilder';
|
||||
import { getActiveBuilder } from 'lib/query/builderSlot';
|
||||
@@ -11,6 +13,7 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import type { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { act, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { resolveQueryType } from 'pages/DashboardPage/DashboardContainer/Panels/capabilities';
|
||||
import { getBuilderQueries } from '../../../Panels/utils/getBuilderQueries';
|
||||
@@ -79,6 +82,21 @@ const tracesBuilder = (expression: string): Query['builder'] => ({
|
||||
queryFormulas: [],
|
||||
});
|
||||
|
||||
const builderWithQueries = (
|
||||
queries: { queryName: string; disabled: boolean }[],
|
||||
formulas: { queryName: string; disabled: boolean }[] = [],
|
||||
): Query['builder'] => ({
|
||||
...initialQueriesMap.metrics.builder,
|
||||
queryData: queries.map((query) => ({
|
||||
...initialQueriesMap.metrics.builder.queryData[0],
|
||||
...query,
|
||||
})),
|
||||
queryFormulas: formulas.map((formula) => ({
|
||||
...initialFormulaBuilderFormValues,
|
||||
...formula,
|
||||
})),
|
||||
});
|
||||
|
||||
function makeSpec(
|
||||
kind: string,
|
||||
pluginSpec: unknown,
|
||||
@@ -103,7 +121,13 @@ function fakeQuery(
|
||||
queryType: string,
|
||||
queryData: Record<string, unknown>[] = [],
|
||||
): Query {
|
||||
return { id, queryType, builder: { queryData } } as unknown as Query;
|
||||
return {
|
||||
id,
|
||||
queryType,
|
||||
builder: { queryData },
|
||||
promql: [],
|
||||
clickhouse_sql: [],
|
||||
} as unknown as Query;
|
||||
}
|
||||
|
||||
function builderState(currentQuery: Query): {
|
||||
@@ -301,12 +325,117 @@ describe('usePanelKindChange', () => {
|
||||
expect(persisted.builder.queryFormulas).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('keeps the field of a traces function aggregation when switching to a Heatmap panel', () => {
|
||||
it.each(['signoz/HeatmapPanel', 'signoz/DistributionPanel'] as const)(
|
||||
'keeps the first enabled query, enabled, when switching to %s',
|
||||
(kind) => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState(fakeQuery('ts-current', 'builder')),
|
||||
);
|
||||
mockRebuildBuilder.mockReturnValue(
|
||||
builderWithQueries(
|
||||
[
|
||||
{ queryName: 'A', disabled: true },
|
||||
{ queryName: 'B', disabled: true },
|
||||
],
|
||||
[{ queryName: 'F1', disabled: false }],
|
||||
),
|
||||
);
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
setSpec,
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind(kind));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(
|
||||
persisted.builder.queryData.map(({ queryName, disabled }) => ({
|
||||
queryName,
|
||||
disabled,
|
||||
})),
|
||||
).toStrictEqual([{ queryName: 'A', disabled: false }]);
|
||||
},
|
||||
);
|
||||
|
||||
it.each(['signoz/HeatmapPanel', 'signoz/DistributionPanel'] as const)(
|
||||
'keeps one enabled PromQL and ClickHouse query when switching to %s',
|
||||
(kind) => {
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState({
|
||||
...initialQueriesMap.metrics,
|
||||
promql: ['A', 'B', 'C'].map((name) => ({
|
||||
...initialQueryPromQLData,
|
||||
name,
|
||||
disabled: name === 'A',
|
||||
})),
|
||||
clickhouse_sql: ['A', 'B'].map((name) => ({
|
||||
...initialClickHouseData,
|
||||
name,
|
||||
disabled: true,
|
||||
})),
|
||||
}),
|
||||
);
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
setSpec: jest.fn(),
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind(kind));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
const summarize = (
|
||||
queries: { name: string; disabled: boolean }[],
|
||||
): { name: string; disabled: boolean }[] =>
|
||||
queries.map(({ name, disabled }) => ({ name, disabled }));
|
||||
expect(summarize(persisted.promql)).toStrictEqual([
|
||||
{ name: 'B', disabled: false },
|
||||
]);
|
||||
expect(summarize(persisted.clickhouse_sql)).toStrictEqual([
|
||||
{ name: 'A', disabled: false },
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it('leaves PromQL queries alone when switching to a non-bucket kind', () => {
|
||||
const promql = ['A', 'B'].map((name) => ({
|
||||
...initialQueryPromQLData,
|
||||
name,
|
||||
}));
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState({ ...initialQueriesMap.metrics, promql }),
|
||||
);
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
setSpec: jest.fn(),
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind('signoz/BarChartPanel'));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(persisted.promql).toStrictEqual(promql);
|
||||
});
|
||||
|
||||
it('prefers an enabled query over a disabled one ahead of it', () => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState(fakeQuery('ts-current', 'builder')),
|
||||
);
|
||||
mockRebuildBuilder.mockReturnValue(tracesBuilder('p99(duration_nano)'));
|
||||
mockRebuildBuilder.mockReturnValue(
|
||||
builderWithQueries([
|
||||
{ queryName: 'A', disabled: true },
|
||||
{ queryName: 'B', disabled: false },
|
||||
]),
|
||||
);
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
@@ -315,14 +444,39 @@ describe('usePanelKindChange', () => {
|
||||
setSpec,
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind('signoz/HeatmapPanel'));
|
||||
act(() => result.current.onChangePanelKind('signoz/DistributionPanel'));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(persisted.builder.queryData[0].aggregations).toMatchObject([
|
||||
{ expression: 'duration_nano' },
|
||||
expect(persisted.builder.queryData.map((qd) => qd.queryName)).toStrictEqual([
|
||||
'B',
|
||||
]);
|
||||
});
|
||||
|
||||
it.each(['signoz/HeatmapPanel', 'signoz/DistributionPanel'] as const)(
|
||||
'keeps the field of a traces function aggregation when switching to %s',
|
||||
(kind) => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
builderState(fakeQuery('ts-current', 'builder')),
|
||||
);
|
||||
mockRebuildBuilder.mockReturnValue(tracesBuilder('p99(duration_nano)'));
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
usePanelKindChange({
|
||||
spec: makeSpec('signoz/TimeSeriesPanel', {}, TABLE_QUERIES),
|
||||
panelType: PANEL_TYPES.TIME_SERIES,
|
||||
setSpec,
|
||||
}),
|
||||
);
|
||||
act(() => result.current.onChangePanelKind(kind));
|
||||
|
||||
const [persisted] = mockToPerses.mock.calls[0] as [Query];
|
||||
expect(persisted.builder.queryData[0].aggregations).toMatchObject([
|
||||
{ expression: 'duration_nano' },
|
||||
]);
|
||||
},
|
||||
);
|
||||
|
||||
it('wraps a traces heatmap field in a function when switching to a TimeSeries panel', () => {
|
||||
const setSpec = jest.fn();
|
||||
mockUseQueryBuilder.mockReturnValue(
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
toDistributionAggregation,
|
||||
} from 'lib/query/distributionField';
|
||||
import { rebuildBuilderForPanelType } from 'lib/query/panelQuery';
|
||||
import { isBucketPanelType } from 'lib/query/bucketPanelTypes';
|
||||
import type { PartialPanelTypes } from 'lib/query/panelTypeDataSourceFormValuesMap';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { DashboardDetailEvents } from 'pages/DashboardPage/constants/events';
|
||||
@@ -37,8 +38,9 @@ import {
|
||||
} from '../getSwitchedPluginSpec';
|
||||
import {
|
||||
withPercentileHistogramAggregation,
|
||||
withSingleHeatmapQuery,
|
||||
} from '../utils/heatmapQuery';
|
||||
withSingleBucketQuery,
|
||||
withSingleEnabledQuery,
|
||||
} from '../utils/bucketQuery';
|
||||
|
||||
// V1's panel-type rebuild clears orderBy for lists; re-seed the fresh-list default (timestamp desc).
|
||||
const DEFAULT_LIST_ORDER_BY: OrderByPayload[] = [
|
||||
@@ -186,15 +188,15 @@ export function usePanelKindChange({
|
||||
: transformed,
|
||||
newKind,
|
||||
);
|
||||
const isHeatmap = newKind === 'signoz/HeatmapPanel';
|
||||
const isBucketPanel = isBucketPanelType(newPanelType);
|
||||
const converted = {
|
||||
...ordered,
|
||||
queryData: ordered.queryData.map(
|
||||
isHeatmap ? toDistributionAggregation : fromDistributionAggregation,
|
||||
isBucketPanel ? toDistributionAggregation : fromDistributionAggregation,
|
||||
),
|
||||
};
|
||||
return isHeatmap
|
||||
? withSingleHeatmapQuery(converted)
|
||||
return isBucketPanel
|
||||
? withSingleBucketQuery(converted)
|
||||
: withPercentileHistogramAggregation(converted);
|
||||
};
|
||||
|
||||
@@ -257,6 +259,10 @@ export function usePanelKindChange({
|
||||
...(query.builder_ai_query && {
|
||||
builder_ai_query: rebuildForNewKind(query.builder_ai_query),
|
||||
}),
|
||||
...(isBucketPanelType(newPanelType) && {
|
||||
promql: withSingleEnabledQuery(query.promql),
|
||||
clickhouse_sql: withSingleEnabledQuery(query.clickhouse_sql),
|
||||
}),
|
||||
};
|
||||
const signal = getBuilderQueries(currentSpec.queries)[0]
|
||||
?.signal as TelemetrytypesSignalDTO;
|
||||
|
||||
@@ -22,23 +22,25 @@ const HISTOGRAM_ATTRIBUTE_TYPES = new Set<string>([
|
||||
ATTRIBUTE_TYPES.EXPONENTIAL_HISTOGRAM,
|
||||
]);
|
||||
|
||||
/** What a heatmap cell holds, and the one space aggregation the kind offers. */
|
||||
const HEATMAP_HISTOGRAM_SPACE_AGGREGATION = 'count';
|
||||
/** What a bucket panel's cell or bar holds, and the one space aggregation it offers. */
|
||||
const BUCKET_HISTOGRAM_SPACE_AGGREGATION = 'count';
|
||||
|
||||
/**
|
||||
* A heatmap draws against one bucket axis, so the request takes exactly one enabled
|
||||
* query and refuses a formula over the cells. The per-kind cache restores whatever is
|
||||
* dropped here if the panel switches back.
|
||||
* A bucket panel (heatmap, distribution) draws against one bucket axis, so the request
|
||||
* takes exactly one enabled query and refuses a formula over the buckets. It keeps the
|
||||
* first enabled query (the first when none is) and enables it, since a dropped formula
|
||||
* may have been the only output. The per-kind cache restores whatever is dropped here
|
||||
* if the panel switches back.
|
||||
*
|
||||
* Percentiles go the same way: a histogram heatmap takes its axis from the `le` labels,
|
||||
* so a percentile draws the grid a count already draws, and the statement builder sums
|
||||
* the `le` counts either way.
|
||||
* Percentiles go the same way: a histogram bucket panel takes its axis from the `le`
|
||||
* labels, so a percentile draws what a count already draws, and the statement builder
|
||||
* sums the `le` counts either way.
|
||||
*/
|
||||
export function withSingleHeatmapQuery(
|
||||
export function withSingleBucketQuery(
|
||||
builder: Query['builder'],
|
||||
): Query['builder'] {
|
||||
const [first] = builder.queryData;
|
||||
if (!first) {
|
||||
const [kept] = withSingleEnabledQuery(builder.queryData);
|
||||
if (!kept) {
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -46,9 +48,9 @@ export function withSingleHeatmapQuery(
|
||||
...builder,
|
||||
queryData: [
|
||||
{
|
||||
...first,
|
||||
spaceAggregation: withoutPercentile(first.spaceAggregation),
|
||||
aggregations: first.aggregations?.map((aggregation) => ({
|
||||
...kept,
|
||||
spaceAggregation: withoutPercentile(kept.spaceAggregation),
|
||||
aggregations: kept.aggregations?.map((aggregation) => ({
|
||||
...aggregation,
|
||||
spaceAggregation: withoutPercentile(
|
||||
(aggregation as MetricAggregation).spaceAggregation,
|
||||
@@ -60,21 +62,33 @@ export function withSingleHeatmapQuery(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A bucket panel takes one enabled query on every tab: the first enabled one (the first
|
||||
* when none is), enabled. The per-kind cache restores the rest.
|
||||
*/
|
||||
export function withSingleEnabledQuery<T extends { disabled: boolean }>(
|
||||
queries: T[],
|
||||
): T[] {
|
||||
const kept = queries.find((query) => !query.disabled) ?? queries[0];
|
||||
return kept ? [{ ...kept, disabled: false }] : queries;
|
||||
}
|
||||
|
||||
/** Cast because the substitute is a `SpaceAggregation` whichever of its callers `T` came from. */
|
||||
function withoutPercentile<T extends string | undefined>(
|
||||
spaceAggregation: T,
|
||||
): T {
|
||||
return (
|
||||
PERCENTILE_SPACE_AGGREGATIONS.has(spaceAggregation as SpaceAggregation)
|
||||
? HEATMAP_HISTOGRAM_SPACE_AGGREGATION
|
||||
? BUCKET_HISTOGRAM_SPACE_AGGREGATION
|
||||
: spaceAggregation
|
||||
) as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undoes the count above: every other kind offers a histogram metric percentiles alone,
|
||||
* so a count carried out of a heatmap would sit in the selector with no option behind
|
||||
* it. Other metric types are left alone — count is a real choice for a sum or a gauge.
|
||||
* so a count carried out of a bucket panel would sit in the selector with no option
|
||||
* behind it. Other metric types are left alone — count is a real choice for a sum or a
|
||||
* gauge.
|
||||
*/
|
||||
export function withPercentileHistogramAggregation(
|
||||
builder: Query['builder'],
|
||||
@@ -104,7 +118,7 @@ export function withPercentileHistogramAggregation(
|
||||
|
||||
function withoutCount<T extends string | undefined>(spaceAggregation: T): T {
|
||||
return (
|
||||
spaceAggregation === HEATMAP_HISTOGRAM_SPACE_AGGREGATION
|
||||
spaceAggregation === BUCKET_HISTOGRAM_SPACE_AGGREGATION
|
||||
? DEFAULT_PERCENTILE
|
||||
: spaceAggregation
|
||||
) as T;
|
||||
@@ -8,7 +8,10 @@ import { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
import { UNSUPPORTED_PANEL } from '../kinds/UnsupportedPanel/definition';
|
||||
import { getPanelDefinition, isPanelKindSupported } from '../registry';
|
||||
import type { PanelQueryCapabilities } from '../types/panelCapabilities';
|
||||
import {
|
||||
getQueryBuilderFields,
|
||||
type PanelQueryCapabilities,
|
||||
} from '../types/panelCapabilities';
|
||||
import { NO_PANEL_ACTIONS } from '../types/panelDefinition';
|
||||
import {
|
||||
getQueryPanelDefinition,
|
||||
@@ -24,7 +27,8 @@ import type { PanelKind } from '../types/panelKind';
|
||||
|
||||
const { QUERY_BUILDER, CLICKHOUSE, PROM } = EQueryType;
|
||||
const { logs, traces, metrics } = TelemetrytypesSignalDTO;
|
||||
const { time_series, scalar, raw, heatmap } = Querybuildertypesv5RequestTypeDTO;
|
||||
const { time_series, scalar, raw, heatmap, distribution } =
|
||||
Querybuildertypesv5RequestTypeDTO;
|
||||
|
||||
const EXPECTED_QUERY_TYPES: Record<PanelKind, EQueryType[]> = {
|
||||
'signoz/TimeSeriesPanel': [
|
||||
@@ -58,6 +62,7 @@ const EXPECTED_QUERY_TYPES: Record<PanelKind, EQueryType[]> = {
|
||||
EQueryType.AI_QUERY_BUILDER,
|
||||
],
|
||||
'signoz/HeatmapPanel': [QUERY_BUILDER, CLICKHOUSE, PROM],
|
||||
'signoz/DistributionPanel': [QUERY_BUILDER, CLICKHOUSE, PROM],
|
||||
'signoz/PieChartPanel': [
|
||||
QUERY_BUILDER,
|
||||
CLICKHOUSE,
|
||||
@@ -78,6 +83,7 @@ const EXPECTED_SIGNALS: Record<PanelKind, TelemetrytypesSignalDTO[]> = {
|
||||
'signoz/NumberPanel': [metrics, logs, traces],
|
||||
'signoz/HistogramPanel': [metrics, logs, traces],
|
||||
'signoz/HeatmapPanel': [metrics, logs, traces],
|
||||
'signoz/DistributionPanel': [metrics, logs, traces],
|
||||
'signoz/PieChartPanel': [metrics, logs, traces],
|
||||
'signoz/GeoMapPanel': [metrics, logs, traces],
|
||||
'signoz/TopListPanel': [metrics, logs, traces],
|
||||
@@ -133,6 +139,13 @@ const EXPECTED_QUERY_CAPABILITIES: Partial<
|
||||
orderTiebreaker: false,
|
||||
serverPaginated: false,
|
||||
},
|
||||
'signoz/DistributionPanel': {
|
||||
requestType: distribution,
|
||||
formatTableResultForUI: false,
|
||||
bucketedStepInterval: false,
|
||||
orderTiebreaker: false,
|
||||
serverPaginated: false,
|
||||
},
|
||||
'signoz/NumberPanel': {
|
||||
requestType: scalar,
|
||||
formatTableResultForUI: false,
|
||||
@@ -196,6 +209,7 @@ const HIDES_TRACE_OPERATOR: PanelKind[] = [
|
||||
'signoz/ScatterPlotPanel',
|
||||
'signoz/GeoMapPanel',
|
||||
'signoz/HeatmapPanel',
|
||||
'signoz/DistributionPanel',
|
||||
];
|
||||
|
||||
describe('panel capabilities guard', () => {
|
||||
@@ -218,6 +232,24 @@ describe('panel capabilities guard', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('formula', () => {
|
||||
it.each([
|
||||
[TelemetrytypesSignalDTO.metrics, false],
|
||||
[TelemetrytypesSignalDTO.logs, true],
|
||||
[TelemetrytypesSignalDTO.traces, true],
|
||||
])('a %s distribution hides it: %s', (signal, hidden) => {
|
||||
expect(
|
||||
resolveQueryBuilderField(
|
||||
QueryBuilderField.Formula,
|
||||
getQueryBuilderFields(
|
||||
requireQueryPanelDefinition('signoz/DistributionPanel'),
|
||||
signal,
|
||||
),
|
||||
).hidden,
|
||||
).toBe(hidden);
|
||||
});
|
||||
});
|
||||
|
||||
// A dashboard spec written by a newer SigNoz can name a kind this build has no
|
||||
// definition for. The registry answers with UNSUPPORTED_PANEL rather than nothing, so
|
||||
// every guard below reads it without first proving a definition exists.
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import { useCallback, useMemo, useRef } from 'react';
|
||||
import type { DashboardtypesDistributionPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import Distribution from 'lib/visualization/charts/Distribution/Distribution';
|
||||
import type { DistributionBarClick } from 'lib/visualization/charts/Distribution/types';
|
||||
import { IRenderTooltipFooterArgs } from 'lib/uPlotV2/components/types';
|
||||
import TooltipFooter from 'lib/visualization/panels/components/TooltipFooter';
|
||||
import { useIsDarkMode } from 'hooks/useDarkMode';
|
||||
import { useResizeObserver } from 'hooks/useDimensions';
|
||||
import { getDistributionResults } from 'pages/DashboardPage/DashboardContainer/queryV5/v5ResponseData';
|
||||
|
||||
import NoData from '../../components/NoData/NoData';
|
||||
import PanelStyles from '../../panel.module.scss';
|
||||
import { PanelRendererProps } from '../../types/rendererProps';
|
||||
import {
|
||||
resolveDecimalPrecision,
|
||||
resolveDistributionPercentiles,
|
||||
resolveDistributionYScale,
|
||||
resolveLegendPosition,
|
||||
resolveStackMode,
|
||||
} from '../../utils/chartAppearance/resolvers';
|
||||
import { prepareDistributionClickData } from '../../utils/drilldown/prepareDistributionClickData';
|
||||
import { getBuilderQueries } from '../../utils/getBuilderQueries';
|
||||
import { getPanelTimeRange } from '../../utils/getPanelTimeRange';
|
||||
|
||||
import { prepareDistributionData } from './prepareData';
|
||||
|
||||
function DistributionPanelRenderer({
|
||||
panelId,
|
||||
panel,
|
||||
data,
|
||||
isFetching,
|
||||
refetch,
|
||||
onClick,
|
||||
enableDrillDown,
|
||||
}: PanelRendererProps<'signoz/DistributionPanel'>): JSX.Element {
|
||||
const graphRef = useRef<HTMLDivElement>(null);
|
||||
const containerDimensions = useResizeObserver(graphRef);
|
||||
const isDarkMode = useIsDarkMode();
|
||||
|
||||
const spec = useMemo<DashboardtypesDistributionPanelSpecDTO>(
|
||||
() => panel.spec.plugin.spec,
|
||||
[panel.spec.plugin.spec],
|
||||
);
|
||||
|
||||
const { buckets, series, queryName } = useMemo(
|
||||
() =>
|
||||
prepareDistributionData({
|
||||
results: getDistributionResults(data.response),
|
||||
legendMap: data.legendMap ?? {},
|
||||
}),
|
||||
[data.response, data.legendMap],
|
||||
);
|
||||
|
||||
const percentiles = useMemo(
|
||||
() => resolveDistributionPercentiles(spec.chartAppearance?.percentiles),
|
||||
[spec.chartAppearance?.percentiles],
|
||||
);
|
||||
|
||||
const decimalPrecision = useMemo(
|
||||
() => resolveDecimalPrecision(spec.formatting?.decimalPrecision),
|
||||
[spec.formatting?.decimalPrecision],
|
||||
);
|
||||
|
||||
const builderQueries = useMemo(
|
||||
() => getBuilderQueries(panel.spec.queries),
|
||||
[panel.spec.queries],
|
||||
);
|
||||
|
||||
const handleBarClick = useCallback(
|
||||
(click: DistributionBarClick): void => {
|
||||
const payload = prepareDistributionClickData({
|
||||
click,
|
||||
queryName,
|
||||
builderQueries,
|
||||
timeRange: getPanelTimeRange(data.requestPayload),
|
||||
});
|
||||
if (payload) {
|
||||
onClick?.(payload);
|
||||
}
|
||||
},
|
||||
[onClick, queryName, builderQueries, data.requestPayload],
|
||||
);
|
||||
|
||||
const renderTooltipFooter = useCallback(
|
||||
({ isPinned, dismiss }: IRenderTooltipFooterArgs) => (
|
||||
<TooltipFooter
|
||||
id={panelId}
|
||||
isPinned={isPinned}
|
||||
canDrilldown={!!enableDrillDown}
|
||||
dismiss={dismiss}
|
||||
/>
|
||||
),
|
||||
[panelId, enableDrillDown],
|
||||
);
|
||||
|
||||
const hasBars = buckets.length > 0 && series.length > 0;
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={graphRef}
|
||||
data-testid="distribution-panel-renderer"
|
||||
className={PanelStyles.panelContainer}
|
||||
>
|
||||
{!hasBars && (
|
||||
<NoData isFetching={isFetching} onRetry={refetch} panel={panel} />
|
||||
)}
|
||||
{hasBars &&
|
||||
containerDimensions.width > 0 &&
|
||||
containerDimensions.height > 0 && (
|
||||
<Distribution
|
||||
key={panelId}
|
||||
id={panelId}
|
||||
buckets={buckets}
|
||||
series={series}
|
||||
xMin={spec.axes?.x?.min ?? undefined}
|
||||
xMax={spec.axes?.x?.max ?? undefined}
|
||||
yScale={resolveDistributionYScale(spec.axes?.y?.scale)}
|
||||
stack={resolveStackMode(spec.visualization?.stack)}
|
||||
xAxisUnit={spec.formatting?.unit}
|
||||
decimalPrecision={decimalPrecision}
|
||||
customColors={spec.legend?.customColors ?? undefined}
|
||||
percentiles={percentiles}
|
||||
canPinTooltip
|
||||
renderTooltipFooter={renderTooltipFooter}
|
||||
onBarClick={enableDrillDown && onClick ? handleBarClick : undefined}
|
||||
legendPosition={resolveLegendPosition(spec.legend?.position)}
|
||||
isDarkMode={isDarkMode}
|
||||
width={containerDimensions.width}
|
||||
height={containerDimensions.height}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DistributionPanelRenderer;
|
||||
@@ -0,0 +1,152 @@
|
||||
import type {
|
||||
Querybuildertypesv5DistributionDataDTO,
|
||||
Querybuildertypesv5DistributionDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import { prepareDistributionData } from '../prepareData';
|
||||
|
||||
function result({
|
||||
queryName = 'A',
|
||||
buckets = [1, 2, 4],
|
||||
distributions = [],
|
||||
}: {
|
||||
queryName?: string;
|
||||
buckets?: number[];
|
||||
distributions?: Querybuildertypesv5DistributionDTO[];
|
||||
} = {}): Querybuildertypesv5DistributionDataDTO {
|
||||
return {
|
||||
queryName,
|
||||
aggregations: [
|
||||
{ alias: '__result_0', index: 0, meta: { buckets }, distributions },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
describe('prepareDistributionData', () => {
|
||||
it('reads the bucket bounds and one count array per group', () => {
|
||||
const { buckets, series, queryName } = prepareDistributionData({
|
||||
results: [
|
||||
result({
|
||||
distributions: [
|
||||
{
|
||||
labels: [{ key: { name: 'service' }, value: 'redis' }],
|
||||
counts: [5, 12, 3, 1],
|
||||
},
|
||||
{
|
||||
labels: [{ key: { name: 'service' }, value: 'cart' }],
|
||||
counts: [0, 4, 8, 0],
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
legendMap: {},
|
||||
});
|
||||
|
||||
expect(buckets).toStrictEqual([1, 2, 4]);
|
||||
expect(queryName).toBe('A');
|
||||
expect(series).toStrictEqual([
|
||||
{
|
||||
label: '{service="redis"}',
|
||||
groupLabels: { service: 'redis' },
|
||||
counts: [5, 12, 3, 1],
|
||||
},
|
||||
{
|
||||
label: '{service="cart"}',
|
||||
groupLabels: { service: 'cart' },
|
||||
counts: [0, 4, 8, 0],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('names an ungrouped distribution after its query', () => {
|
||||
const { series } = prepareDistributionData({
|
||||
results: [result({ distributions: [{ counts: [1, 0, 0, 0] }] })],
|
||||
legendMap: { A: '' },
|
||||
});
|
||||
|
||||
expect(series).toHaveLength(1);
|
||||
expect(series[0].label).toBe('A');
|
||||
});
|
||||
|
||||
it('applies the query legend as the group label template', () => {
|
||||
const { series } = prepareDistributionData({
|
||||
results: [
|
||||
result({
|
||||
distributions: [
|
||||
{
|
||||
labels: [{ key: { name: 'service' }, value: 'redis' }],
|
||||
counts: [1, 0, 0, 0],
|
||||
},
|
||||
],
|
||||
}),
|
||||
],
|
||||
legendMap: { A: '{{service}} latency' },
|
||||
});
|
||||
|
||||
expect(series[0].label).toBe('redis latency');
|
||||
});
|
||||
|
||||
it('pads missing counts with zero and trims extras, keeping the overflow slot', () => {
|
||||
const { series } = prepareDistributionData({
|
||||
results: [
|
||||
result({
|
||||
distributions: [
|
||||
{ counts: [1, 2] },
|
||||
{ counts: [1, 2, 3, 4, 5] },
|
||||
{ counts: null },
|
||||
],
|
||||
}),
|
||||
],
|
||||
legendMap: {},
|
||||
});
|
||||
|
||||
expect(series.map(({ counts }) => counts)).toStrictEqual([
|
||||
[1, 2, 0, 0],
|
||||
[1, 2, 3, 4],
|
||||
[0, 0, 0, 0],
|
||||
]);
|
||||
});
|
||||
|
||||
it('skips aggregations without bounds and reads the first that has them', () => {
|
||||
const { buckets } = prepareDistributionData({
|
||||
results: [
|
||||
{
|
||||
queryName: 'A',
|
||||
aggregations: [
|
||||
{
|
||||
alias: '__result_0',
|
||||
index: 0,
|
||||
meta: {},
|
||||
distributions: [{ counts: [1] }],
|
||||
},
|
||||
{
|
||||
alias: '__result_1',
|
||||
index: 1,
|
||||
meta: { buckets: [10, 20] },
|
||||
distributions: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
legendMap: {},
|
||||
});
|
||||
|
||||
expect(buckets).toStrictEqual([10, 20]);
|
||||
});
|
||||
|
||||
it('returns no buckets when nothing carries bounds', () => {
|
||||
expect(
|
||||
prepareDistributionData({
|
||||
results: [result({ buckets: [] })],
|
||||
legendMap: {},
|
||||
}),
|
||||
).toStrictEqual({ buckets: [], series: [], queryName: '' });
|
||||
expect(prepareDistributionData({ results: [], legendMap: {} })).toStrictEqual(
|
||||
{
|
||||
buckets: [],
|
||||
series: [],
|
||||
queryName: '',
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
import {
|
||||
DashboardtypesPanelKindDTO,
|
||||
DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTOKind as DistributionKind,
|
||||
type DashboardtypesDistributionPanelSpecDTO,
|
||||
type Querybuildertypesv5DistributionDataDTO,
|
||||
Querybuildertypesv5RequestTypeDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import type { PanelQueryData } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
|
||||
|
||||
import type { PanelOfKind } from '../../../types/rendererProps';
|
||||
import { getDistributionDataWarning } from '../warning';
|
||||
|
||||
function dataWith(buckets: number[], counts: number[][]): PanelQueryData {
|
||||
const result: Querybuildertypesv5DistributionDataDTO = {
|
||||
queryName: 'A',
|
||||
aggregations: [
|
||||
{
|
||||
alias: '__result_0',
|
||||
index: 0,
|
||||
meta: { buckets },
|
||||
distributions: counts.map((entry) => ({ counts: entry })),
|
||||
},
|
||||
],
|
||||
};
|
||||
return {
|
||||
response: {
|
||||
status: 'success',
|
||||
data: {
|
||||
type: Querybuildertypesv5RequestTypeDTO.distribution,
|
||||
data: { results: [result] },
|
||||
},
|
||||
},
|
||||
requestPayload: undefined,
|
||||
legendMap: {},
|
||||
};
|
||||
}
|
||||
|
||||
function panelWith(
|
||||
spec: Partial<DashboardtypesDistributionPanelSpecDTO> = {},
|
||||
): PanelOfKind<'signoz/DistributionPanel'> {
|
||||
return {
|
||||
kind: DashboardtypesPanelKindDTO.Panel,
|
||||
spec: {
|
||||
display: { name: '' },
|
||||
plugin: { kind: DistributionKind['signoz/DistributionPanel'], spec },
|
||||
queries: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
describe('getDistributionDataWarning', () => {
|
||||
it('warns when more than 10% of observations overflow', () => {
|
||||
const warning = getDistributionDataWarning(
|
||||
panelWith({ formatting: { unit: 's' } }),
|
||||
dataWith([1, 10], [[10, 50, 40]]),
|
||||
);
|
||||
|
||||
expect(warning?.message).toMatch(/^40% of observations are above 10/);
|
||||
});
|
||||
|
||||
it('says nothing at or under 10%', () => {
|
||||
expect(
|
||||
getDistributionDataWarning(panelWith(), dataWith([1, 10], [[40, 50, 10]])),
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it('says nothing without bounds', () => {
|
||||
expect(getDistributionDataWarning(panelWith(), dataWith([], []))).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
import { ChartColumnBig } from '@signozhq/icons';
|
||||
|
||||
import { QueryBuilderField } from 'components/QueryBuilderV2/queryBuilderFields.types';
|
||||
|
||||
import type { PanelDefinition } from '../../types/panelDefinition';
|
||||
import { QueryTypeKind } from '../../types/panelCapabilities';
|
||||
import QueryBuilderEditorPane from 'pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/QueryBuilderEditorPane';
|
||||
import Renderer from './Renderer';
|
||||
import { sections } from './sections';
|
||||
import { getDistributionDataWarning } from './warning';
|
||||
import {
|
||||
Querybuildertypesv5RequestTypeDTO,
|
||||
TelemetrytypesSignalDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
export const definition: PanelDefinition<'signoz/DistributionPanel'> = {
|
||||
kind: 'signoz/DistributionPanel',
|
||||
displayName: 'Distribution',
|
||||
mode: 'query',
|
||||
icon: ChartColumnBig,
|
||||
Renderer,
|
||||
EditorPane: QueryBuilderEditorPane,
|
||||
sections,
|
||||
supportedQueryTypesKindMap: {
|
||||
// Logs and traces bucket the field named as the aggregation.
|
||||
[EQueryType.QUERY_BUILDER]: {
|
||||
kind: QueryTypeKind.SIGNAL,
|
||||
signals: [
|
||||
TelemetrytypesSignalDTO.metrics,
|
||||
TelemetrytypesSignalDTO.logs,
|
||||
TelemetrytypesSignalDTO.traces,
|
||||
],
|
||||
},
|
||||
[EQueryType.CLICKHOUSE]: { kind: QueryTypeKind.SIGNAL_LESS },
|
||||
[EQueryType.PROM]: { kind: QueryTypeKind.SIGNAL_LESS },
|
||||
},
|
||||
// The request rejects both, as for heatmap: a point is a count per bucket.
|
||||
queryBuilderFields: {
|
||||
[QueryBuilderField.Functions]: { state: 'hidden' },
|
||||
[QueryBuilderField.Having]: { state: 'hidden' },
|
||||
// The request takes one builder query and has no case for a trace operator.
|
||||
[QueryBuilderField.TraceOperator]: { state: 'hidden' },
|
||||
},
|
||||
// Logs and traces bucket the one field the query names; a formula has none.
|
||||
queryBuilderFieldsBySignal: {
|
||||
[TelemetrytypesSignalDTO.logs]: {
|
||||
[QueryBuilderField.Formula]: { state: 'hidden' },
|
||||
[QueryBuilderField.AdditionalQueries]: { state: 'hidden' },
|
||||
},
|
||||
[TelemetrytypesSignalDTO.traces]: {
|
||||
[QueryBuilderField.Formula]: { state: 'hidden' },
|
||||
[QueryBuilderField.AdditionalQueries]: { state: 'hidden' },
|
||||
[QueryBuilderField.TraceOperator]: { state: 'hidden' },
|
||||
},
|
||||
},
|
||||
// No width-derived step: there is no time axis, and a histogram's counts do not
|
||||
// depend on the step.
|
||||
queryCapabilities: {
|
||||
requestType: Querybuildertypesv5RequestTypeDTO.distribution,
|
||||
formatTableResultForUI: false,
|
||||
bucketedStepInterval: false,
|
||||
orderTiebreaker: false,
|
||||
serverPaginated: false,
|
||||
},
|
||||
getDataWarning: getDistributionDataWarning,
|
||||
actions: {
|
||||
view: true,
|
||||
edit: true,
|
||||
clone: true,
|
||||
download: { csv: false, png: true, svg: true },
|
||||
createAlert: false,
|
||||
search: false,
|
||||
drilldown: true,
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
import type {
|
||||
Querybuildertypesv5DistributionDataDTO,
|
||||
Querybuildertypesv5DistributionDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import getLabelName from 'lib/getLabelName';
|
||||
import type { DistributionSeries } from 'lib/visualization/charts/Distribution/types';
|
||||
|
||||
export interface DistributionPanelData {
|
||||
/** Ascending bucket upper bounds shared by every group; empty means no chart. */
|
||||
buckets: number[];
|
||||
series: DistributionSeries[];
|
||||
/** The query the series came from, for drilldown. */
|
||||
queryName: string;
|
||||
}
|
||||
|
||||
const EMPTY_DATA: DistributionPanelData = {
|
||||
buckets: [],
|
||||
series: [],
|
||||
queryName: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* V5 distribution results → the chart's `buckets` + `series`. Only the first
|
||||
* aggregation carrying bounds is read: each has its own bucket axis, and the chart
|
||||
* has one.
|
||||
*/
|
||||
export function prepareDistributionData({
|
||||
results,
|
||||
legendMap,
|
||||
}: {
|
||||
results: Querybuildertypesv5DistributionDataDTO[];
|
||||
legendMap: Record<string, string>;
|
||||
}): DistributionPanelData {
|
||||
for (const result of results) {
|
||||
const { queryName } = result;
|
||||
for (const aggregation of result.aggregations ?? []) {
|
||||
const buckets = aggregation.meta?.buckets;
|
||||
if (!buckets?.length) {
|
||||
continue;
|
||||
}
|
||||
return {
|
||||
buckets,
|
||||
queryName,
|
||||
series: (aggregation.distributions ?? []).map((distribution) =>
|
||||
toDistributionSeries(
|
||||
distribution,
|
||||
buckets.length + 1,
|
||||
queryName,
|
||||
legendMap[queryName] ?? '',
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return EMPTY_DATA;
|
||||
}
|
||||
|
||||
/** Pads or trims to `length` so every series lines up with the bucket axis. */
|
||||
function toDistributionSeries(
|
||||
distribution: Querybuildertypesv5DistributionDTO,
|
||||
length: number,
|
||||
queryName: string,
|
||||
legend: string,
|
||||
): DistributionSeries {
|
||||
const record: Record<string, string> = {};
|
||||
(distribution.labels ?? []).forEach((label) => {
|
||||
if (label.key?.name) {
|
||||
record[label.key.name] = String(label.value);
|
||||
}
|
||||
});
|
||||
|
||||
const counts = distribution.counts ?? [];
|
||||
return {
|
||||
label: getLabelName(record, queryName, legend),
|
||||
groupLabels: record,
|
||||
counts: Array.from({ length }, (_, index) => {
|
||||
const count = counts[index];
|
||||
return Number.isFinite(count) ? count : 0;
|
||||
}),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { SectionKind, type SectionConfig } from '../../types/sections';
|
||||
import { resolveDistributionLegendSeries } from '../../utils/legendSeries';
|
||||
|
||||
export const sections: SectionConfig[] = [
|
||||
{
|
||||
kind: SectionKind.Visualization,
|
||||
controls: { switchPanelKind: true, timePreference: true, bucketStack: true },
|
||||
},
|
||||
{
|
||||
kind: SectionKind.ChartAppearance,
|
||||
controls: { percentiles: true },
|
||||
},
|
||||
// Formats the bucket bounds; counts are plain integers and take no unit.
|
||||
{ kind: SectionKind.Formatting, controls: { unit: true, decimals: true } },
|
||||
{ kind: SectionKind.DistributionAxes },
|
||||
{
|
||||
kind: SectionKind.Legend,
|
||||
controls: { position: true, colors: resolveDistributionLegendSeries },
|
||||
},
|
||||
{ kind: SectionKind.ContextLinks },
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
import { getToolTipValue } from 'components/Graph/yAxisConfig';
|
||||
import type { PanelStatusDetail } from 'pages/DashboardPage/DashboardContainer/PanelsAndSectionsLayout/Panel/PanelStatus/types';
|
||||
import type { PanelQueryData } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
|
||||
import { getDistributionResults } from 'pages/DashboardPage/DashboardContainer/queryV5/v5ResponseData';
|
||||
|
||||
import type { PanelOfKind } from '../../types/rendererProps';
|
||||
import { prepareDistributionData } from './prepareData';
|
||||
|
||||
/** Above this share in overflow, the bucket bounds probably stop short. */
|
||||
export const OVERFLOW_WARNING_SHARE = 0.1;
|
||||
|
||||
/**
|
||||
* Bounds that stop short, over every group regardless of the legend: too much
|
||||
* landing in overflow.
|
||||
*/
|
||||
export function getDistributionDataWarning(
|
||||
panel: PanelOfKind<'signoz/DistributionPanel'>,
|
||||
data: PanelQueryData,
|
||||
): PanelStatusDetail | null {
|
||||
const { buckets, series } = prepareDistributionData({
|
||||
results: getDistributionResults(data.response),
|
||||
legendMap: data.legendMap ?? {},
|
||||
});
|
||||
if (buckets.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const spec = panel.spec.plugin.spec;
|
||||
const lastBound = buckets[buckets.length - 1];
|
||||
let total = 0;
|
||||
let overflow = 0;
|
||||
series.forEach(({ counts }) => {
|
||||
counts.forEach((count) => {
|
||||
total += count;
|
||||
});
|
||||
overflow += counts[buckets.length] ?? 0;
|
||||
});
|
||||
|
||||
const overflowShare = total > 0 ? overflow / total : 0;
|
||||
if (overflowShare <= OVERFLOW_WARNING_SHARE) {
|
||||
return null;
|
||||
}
|
||||
const bound = getToolTipValue(String(lastBound), spec.formatting?.unit);
|
||||
return {
|
||||
message: `${Math.round(overflowShare * 100)}% of observations are above ${bound}. The bucket bounds may be too low.`,
|
||||
messages: [],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.banner {
|
||||
margin: var(--spacing-4) var(--spacing-6) 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { SolidInfoCircle } from '@signozhq/icons';
|
||||
import { Callout } from '@signozhq/ui/callout';
|
||||
|
||||
import type { QueryEditorPaneProps } from '../../types/panelDefinition';
|
||||
import PanelEditorQueryBuilder from '../../../PanelEditor/PanelEditorQueryBuilder/PanelEditorQueryBuilder';
|
||||
|
||||
import styles from './HistogramEditorPane.module.scss';
|
||||
|
||||
/**
|
||||
* Histogram bins the query's values in the browser: percentiles or rates of a
|
||||
* histogram metric, or per-interval aggregates of logs and traces, not the bucket
|
||||
* counts Distribution reads.
|
||||
*/
|
||||
function HistogramEditorPane({
|
||||
panelDefinition,
|
||||
isLoadingQueries,
|
||||
onStageRunQuery,
|
||||
onCancelQuery,
|
||||
stickyHeader,
|
||||
}: QueryEditorPaneProps): JSX.Element {
|
||||
return (
|
||||
<PanelEditorQueryBuilder
|
||||
panelDefinition={panelDefinition}
|
||||
isLoadingQueries={isLoadingQueries}
|
||||
onStageRunQuery={onStageRunQuery}
|
||||
onCancelQuery={onCancelQuery}
|
||||
stickyHeader={stickyHeader}
|
||||
banner={
|
||||
<div className={styles.banner}>
|
||||
<Callout
|
||||
color="primary"
|
||||
size="sm"
|
||||
icon={<SolidInfoCircle />}
|
||||
testId="histogram-distribution-banner"
|
||||
>
|
||||
For bucket counts over the time range, use the Distribution panel.
|
||||
</Callout>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default HistogramEditorPane;
|
||||
@@ -3,7 +3,7 @@ import { BarChart } from '@signozhq/icons';
|
||||
|
||||
import type { PanelDefinition } from '../../types/panelDefinition';
|
||||
import { QueryTypeKind } from '../../types/panelCapabilities';
|
||||
import QueryBuilderEditorPane from 'pages/DashboardPage/DashboardContainer/PanelEditor/PanelEditorQueryBuilder/QueryBuilderEditorPane';
|
||||
import HistogramEditorPane from './HistogramEditorPane';
|
||||
import Renderer from './Renderer';
|
||||
import { sections } from './sections';
|
||||
import {
|
||||
@@ -16,8 +16,9 @@ export const definition: PanelDefinition<'signoz/HistogramPanel'> = {
|
||||
displayName: 'Histogram',
|
||||
mode: 'query',
|
||||
icon: BarChart,
|
||||
isRetired: true,
|
||||
Renderer,
|
||||
EditorPane: QueryBuilderEditorPane,
|
||||
EditorPane: HistogramEditorPane,
|
||||
sections,
|
||||
supportedQueryTypesKindMap: {
|
||||
[EQueryType.QUERY_BUILDER]: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { definition as AreaChart } from './kinds/AreaChartPanel/definition';
|
||||
import { definition as BarChart } from './kinds/BarChartPanel/definition';
|
||||
import { definition as Distribution } from './kinds/DistributionPanel/definition';
|
||||
import { definition as Heatmap } from './kinds/HeatmapPanel/definition';
|
||||
import { definition as Histogram } from './kinds/HistogramPanel/definition';
|
||||
import { definition as NumberValue } from './kinds/NumberPanel/definition';
|
||||
@@ -33,13 +34,14 @@ export const PANELS: PanelRegistry = {
|
||||
[TopList.kind]: TopList,
|
||||
[Histogram.kind]: Histogram,
|
||||
[Heatmap.kind]: Heatmap,
|
||||
[Distribution.kind]: Distribution,
|
||||
[List.kind]: List,
|
||||
[Text.kind]: Text,
|
||||
};
|
||||
|
||||
export type PanelOption = Pick<
|
||||
PanelDefinition,
|
||||
'kind' | 'displayName' | 'icon'
|
||||
'kind' | 'displayName' | 'icon' | 'isRetired'
|
||||
>;
|
||||
|
||||
// Backs both the new-panel picker and the editor's kind switcher; derived from PANELS
|
||||
|
||||
@@ -37,6 +37,9 @@ export type PanelInteractionMap = Record<PanelKind, object> & {
|
||||
'signoz/HeatmapPanel': { onDragSelect?: DragSelect };
|
||||
'signoz/TablePanel': { onClick?: (event: DrilldownClickPayload) => void };
|
||||
'signoz/PieChartPanel': { onClick?: (event: DrilldownClickPayload) => void };
|
||||
'signoz/DistributionPanel': {
|
||||
onClick?: (event: DrilldownClickPayload) => void;
|
||||
};
|
||||
'signoz/TopListPanel': { onClick?: (event: DrilldownClickPayload) => void };
|
||||
'signoz/NumberPanel': { onClick?: (event: DrilldownClickPayload) => void };
|
||||
'signoz/ScatterPlotPanel': {
|
||||
|
||||
@@ -4,7 +4,32 @@ import {
|
||||
type TelemetrytypesSignalDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
export type { QueryBuilderFieldsConfig } from 'components/QueryBuilderV2/queryBuilderFields.types';
|
||||
import type { QueryBuilderFieldsConfig } from 'components/QueryBuilderV2/queryBuilderFields.types';
|
||||
import { mergeQueryBuilderFieldsConfig } from 'components/QueryBuilderV2/queryBuilderFields.utils';
|
||||
|
||||
export type { QueryBuilderFieldsConfig };
|
||||
|
||||
/** Narrowing applied over a kind's `queryBuilderFields` while the builder points at that signal. */
|
||||
export type QueryBuilderFieldsBySignal = Partial<
|
||||
Record<TelemetrytypesSignalDTO, QueryBuilderFieldsConfig>
|
||||
>;
|
||||
|
||||
/** A kind's builder narrowing with its `signal` overrides on top. */
|
||||
export function getQueryBuilderFields(
|
||||
{
|
||||
queryBuilderFields,
|
||||
queryBuilderFieldsBySignal,
|
||||
}: {
|
||||
queryBuilderFields: QueryBuilderFieldsConfig;
|
||||
queryBuilderFieldsBySignal?: QueryBuilderFieldsBySignal;
|
||||
},
|
||||
signal?: TelemetrytypesSignalDTO,
|
||||
): QueryBuilderFieldsConfig | undefined {
|
||||
return mergeQueryBuilderFieldsConfig(
|
||||
queryBuilderFields,
|
||||
signal ? queryBuilderFieldsBySignal?.[signal] : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* How a kind's query-range request is shaped. Declared per-kind in
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { PanelKind } from './panelKind';
|
||||
import type { SyncedQueryBuilderField } from 'components/QueryBuilderV2/queryBuilderFields.types';
|
||||
import type {
|
||||
PanelQueryCapabilities,
|
||||
QueryBuilderFieldsBySignal,
|
||||
QueryBuilderFieldsConfig,
|
||||
SupportedQueryTypesKindMap,
|
||||
} from './panelCapabilities';
|
||||
@@ -80,6 +81,8 @@ export interface PanelDefinitionBase<K extends PanelKind = PanelKind> {
|
||||
kind: K;
|
||||
displayName: string;
|
||||
icon: PanelIcon;
|
||||
/** Still renders saved panels, but is offered only to a panel already of this kind. */
|
||||
isRetired?: boolean;
|
||||
sections: SectionConfig[];
|
||||
actions: PanelActionCapabilities;
|
||||
}
|
||||
@@ -128,6 +131,7 @@ export interface QueryPanelDefinition<
|
||||
/** Authoring modes (Query Builder / ClickHouse / PromQL / AI) and the signals each accepts. */
|
||||
supportedQueryTypesKindMap: SupportedQueryTypesKindMap;
|
||||
queryBuilderFields: QueryBuilderFieldsConfig;
|
||||
queryBuilderFieldsBySignal?: QueryBuilderFieldsBySignal;
|
||||
/** How this kind's query-range request is shaped (request type, paging, result formatting). */
|
||||
queryCapabilities: PanelQueryCapabilities;
|
||||
/** Builder fields kept equal across queries: an edit to one query copies to the rest. */
|
||||
|
||||
@@ -29,6 +29,7 @@ export const PANEL_KIND_TO_PANEL_TYPE: Record<PanelKind, PANEL_TYPES> = {
|
||||
'signoz/TopListPanel': PANEL_TYPES.TOP_LIST,
|
||||
'signoz/TextPanel': PANEL_TYPES.TEXT,
|
||||
'signoz/ScatterPlotPanel': PANEL_TYPES.SCATTER,
|
||||
'signoz/DistributionPanel': PANEL_TYPES.DISTRIBUTION,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,8 @@ import type {
|
||||
DashboardtypesLinkDTO,
|
||||
DashboardtypesAxesDTO,
|
||||
DashboardtypesComparisonThresholdDTO,
|
||||
DashboardtypesDistributionAxesDTO,
|
||||
DashboardtypesDistributionPercentilesDTO,
|
||||
DashboardtypesFillModeDTO,
|
||||
DashboardtypesFillOpacityDTO,
|
||||
DashboardtypesGeoMapBubblesDTO,
|
||||
@@ -78,6 +80,8 @@ export enum SectionKind {
|
||||
Dimensions = 'dimensions',
|
||||
/** Scatter Plot's per-axis `axes` shape; `Axes` is the single y-axis shape. */
|
||||
ScatterAxes = 'scatterAxes',
|
||||
/** Distribution's `axes` shape: the bucket-axis range and count-axis scale. */
|
||||
DistributionAxes = 'distributionAxes',
|
||||
/** Geo Map's placement: what a row is, its columns, the area, the layer and the value columns. */
|
||||
Location = 'location',
|
||||
/** Top List's row display, for a kind with no chart to style. */
|
||||
@@ -129,6 +133,8 @@ export interface PanelChartAppearanceSlice {
|
||||
colors?: DashboardtypesHeatmapColorsDTO & DashboardtypesGeoMapColorsDTO;
|
||||
/** Scatter Plot's dot size and opacity. */
|
||||
points?: DashboardtypesScatterPlotPointsDTO;
|
||||
/** Distribution's percentile markers. */
|
||||
percentiles?: DashboardtypesDistributionPercentilesDTO;
|
||||
/** Geo Map's circle radius range. */
|
||||
bubbles?: DashboardtypesGeoMapBubblesDTO;
|
||||
/** Geo Map's shape names; unset shows them. */
|
||||
@@ -146,7 +152,7 @@ export interface PanelVisualizationSlice {
|
||||
timePreference?: DashboardtypesTimePreferenceDTO;
|
||||
/** Bar stacking; a kind declares this or `stack`, never both. */
|
||||
stackedBarChart?: boolean;
|
||||
/** Area stacking. */
|
||||
/** Area or Distribution stacking; Distribution's wire enum is nominally distinct with the same members. */
|
||||
stack?: DashboardtypesStackModeDTO;
|
||||
fillSpans?: boolean;
|
||||
}
|
||||
@@ -171,6 +177,7 @@ export interface SectionSpecMap {
|
||||
[SectionKind.PanelHeader]: DashboardtypesHeaderOptionsDTO; // spec.plugin.spec.headerOptions (Text)
|
||||
[SectionKind.Dimensions]: DashboardtypesScatterPlotDimensionsDTO; // spec.plugin.spec.dimensions (Scatter Plot)
|
||||
[SectionKind.ScatterAxes]: DashboardtypesScatterPlotAxesDTO; // spec.plugin.spec.axes (Scatter Plot)
|
||||
[SectionKind.DistributionAxes]: DashboardtypesDistributionAxesDTO; // spec.plugin.spec.axes (Distribution)
|
||||
[SectionKind.Location]: GeoMapPlacementSlice; // spec.plugin.spec.location + .map (Geo Map)
|
||||
[SectionKind.Appearance]: DashboardtypesTopListAppearanceDTO; // spec.plugin.spec.appearance (Top List)
|
||||
}
|
||||
@@ -213,6 +220,8 @@ export interface SectionControls {
|
||||
colors?: boolean;
|
||||
/** Scatter Plot's dots: one size, or a min/max range when a size column is bound. */
|
||||
points?: boolean;
|
||||
/** Distribution's percentile markers: on/off and which ones. */
|
||||
percentiles?: boolean;
|
||||
/** Geo Map's value ramp: palette, scale, steps and a value range. */
|
||||
mapColors?: boolean;
|
||||
/** Geo Map's circle radius range. */
|
||||
@@ -227,12 +236,14 @@ export interface SectionControls {
|
||||
};
|
||||
// switchPanelKind → the visualization-type switcher (every kind, so you can switch
|
||||
// away from any panel); stacking → stackedBarChart (Bar); stackMode → stack
|
||||
// (Area); fillSpans → fill gaps with 0 (TimeSeries / Area).
|
||||
// (Area); bucketStack → stack (Distribution); fillSpans → fill gaps with 0
|
||||
// (TimeSeries / Area).
|
||||
[SectionKind.Visualization]: {
|
||||
switchPanelKind: boolean;
|
||||
timePreference?: boolean;
|
||||
stacking?: boolean;
|
||||
stackMode?: boolean;
|
||||
bucketStack?: boolean;
|
||||
fillSpans?: boolean;
|
||||
};
|
||||
// Editor discriminator (not a spec field): which threshold variant a kind edits.
|
||||
@@ -255,6 +266,7 @@ export type AtomicSectionKind =
|
||||
| SectionKind.PanelHeader
|
||||
| SectionKind.Dimensions
|
||||
| SectionKind.ScatterAxes
|
||||
| SectionKind.DistributionAxes
|
||||
| SectionKind.Location;
|
||||
|
||||
/** Predicate to hide a section from the current spec; returning true removes it. */
|
||||
@@ -292,6 +304,7 @@ export const SECTION_METADATA = {
|
||||
[SectionKind.PanelHeader]: { title: 'Panel header', icon: PanelTop },
|
||||
[SectionKind.Dimensions]: { title: 'Dimensions', icon: Crosshair },
|
||||
[SectionKind.ScatterAxes]: { title: 'Axes', icon: Scale3D },
|
||||
[SectionKind.DistributionAxes]: { title: 'Axes', icon: Scale3D },
|
||||
[SectionKind.Location]: { title: 'Location', icon: MapPin },
|
||||
[SectionKind.Appearance]: { title: 'Appearance', icon: Palette },
|
||||
} as const satisfies Record<SectionKind, SectionMetadata>;
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
import { DEFAULT_BAR_COLOR } from '../../../PanelEditor/ConfigPane/sections/AppearanceSection/barColorOptions';
|
||||
import { defaultColumnsForSignal } from '../../../PanelEditor/ListColumnsEditor/selectFields';
|
||||
import { sections as areaSections } from '../../kinds/AreaChartPanel/sections';
|
||||
import { sections as distributionSections } from '../../kinds/DistributionPanel/sections';
|
||||
import { sections as geoMapSections } from '../../kinds/GeoMapPanel/sections';
|
||||
import { sections as heatmapSections } from '../../kinds/HeatmapPanel/sections';
|
||||
import { sections as listSections } from '../../kinds/ListPanel/sections';
|
||||
@@ -371,6 +372,25 @@ describe('buildPluginSpec', () => {
|
||||
});
|
||||
|
||||
describe('chartAppearance seed', () => {
|
||||
it('seeds a new distribution with the stack and percentiles the server writes', () => {
|
||||
const spec = buildPluginSpec(distributionSections);
|
||||
|
||||
expect(spec.visualization?.stack).toBe(DashboardtypesStackModeDTO.normal);
|
||||
expect(spec.chartAppearance?.percentiles).toStrictEqual({
|
||||
enabled: true,
|
||||
values: [50, 90, 99],
|
||||
});
|
||||
});
|
||||
|
||||
it("carries a distribution's percentiles across a switch", () => {
|
||||
const percentiles = { enabled: false, values: [75] };
|
||||
const spec = buildPluginSpec(distributionSections, {
|
||||
oldSpec: oldSpecWith({ chartAppearance: { percentiles } }),
|
||||
});
|
||||
|
||||
expect(spec.chartAppearance?.percentiles).toStrictEqual(percentiles);
|
||||
});
|
||||
|
||||
it('seeds only the declared defaulting controls', () => {
|
||||
const sections: SectionConfig[] = [
|
||||
{
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import {
|
||||
DashboardtypesPanelPluginVariantGithubComSigNozSignozPkgTypesDashboardtypesDistributionPanelSpecDTOKind as DistributionKind,
|
||||
type DashboardtypesPanelSpecDTO,
|
||||
type Querybuildertypesv5DistributionDataDTO,
|
||||
Querybuildertypesv5RequestTypeDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { resolveSeriesColor } from 'lib/visualization/charts/Distribution/colors';
|
||||
import type { PanelQueryData } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
|
||||
|
||||
import { resolveDistributionLegendSeries } from '../legendSeries';
|
||||
|
||||
describe('resolveDistributionLegendSeries', () => {
|
||||
it('keys each group by the label and default colour the chart draws it with', () => {
|
||||
const result: Querybuildertypesv5DistributionDataDTO = {
|
||||
queryName: 'A',
|
||||
aggregations: [
|
||||
{
|
||||
alias: '__result_0',
|
||||
index: 0,
|
||||
meta: { buckets: [1] },
|
||||
distributions: [
|
||||
{
|
||||
labels: [{ key: { name: 'service' }, value: 'cart' }],
|
||||
counts: [1, 2],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const data: PanelQueryData = {
|
||||
response: {
|
||||
status: 'success',
|
||||
data: {
|
||||
type: Querybuildertypesv5RequestTypeDTO.distribution,
|
||||
data: { results: [result] },
|
||||
},
|
||||
},
|
||||
requestPayload: undefined,
|
||||
legendMap: { A: '{{service}}' },
|
||||
};
|
||||
const spec: DashboardtypesPanelSpecDTO = {
|
||||
display: { name: '' },
|
||||
plugin: { kind: DistributionKind['signoz/DistributionPanel'], spec: {} },
|
||||
queries: [],
|
||||
};
|
||||
|
||||
expect(
|
||||
resolveDistributionLegendSeries({
|
||||
spec,
|
||||
queries: [],
|
||||
data,
|
||||
isDarkMode: true,
|
||||
}),
|
||||
).toStrictEqual([
|
||||
{ label: 'cart', defaultColor: resolveSeriesColor('cart', true) },
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -32,6 +32,9 @@ import {
|
||||
import { DEFAULT_BAR_COLOR } from '../../PanelEditor/ConfigPane/sections/AppearanceSection/barColorOptions';
|
||||
import { getTableColumnKeys } from './getTableColumnKeys';
|
||||
|
||||
/** Matches what the server writes for unset `chartAppearance.percentiles.values`. */
|
||||
const DEFAULT_DISTRIBUTION_PERCENTILES = [50, 90, 99];
|
||||
|
||||
/** Cross-section of the per-kind spec union; assigned to `plugin.spec` (unknown) at the boundary. */
|
||||
export interface SeededPluginSpec {
|
||||
visualization?: SectionSpecMap[SectionKind.Visualization];
|
||||
@@ -157,7 +160,7 @@ function translateStackingForKind(
|
||||
}
|
||||
return {};
|
||||
}
|
||||
if (controls.stackMode) {
|
||||
if (controls.stackMode || controls.bucketStack) {
|
||||
if (old?.stack !== undefined) {
|
||||
return { stack: old.stack };
|
||||
}
|
||||
@@ -326,6 +329,7 @@ const SECTION_SEEDS: SectionSeeds = {
|
||||
colors,
|
||||
bubbles,
|
||||
labels,
|
||||
percentiles,
|
||||
} = oldPluginSpec?.chartAppearance ?? {};
|
||||
const appearance: SectionSpecMap[SectionKind.ChartAppearance] = {};
|
||||
if (controls.lineStyle) {
|
||||
@@ -352,6 +356,13 @@ const SECTION_SEEDS: SectionSeeds = {
|
||||
if (controls.spanGaps && spanGaps !== undefined) {
|
||||
appearance.spanGaps = spanGaps;
|
||||
}
|
||||
// The server's default for unset percentiles, so a new panel previews the same.
|
||||
if (controls.percentiles) {
|
||||
appearance.percentiles = percentiles ?? {
|
||||
enabled: true,
|
||||
values: DEFAULT_DISTRIBUTION_PERCENTILES,
|
||||
};
|
||||
}
|
||||
// Seeded so the controls open on the ramp the grid is drawn with; the
|
||||
// count bounds and step count stay unset, which reads as derived.
|
||||
const seededColors = seedColors(controls, colors);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
DashboardtypesAreaFillModeDTO,
|
||||
DashboardtypesDistributionYScaleDTO,
|
||||
DashboardtypesHeatmapColorModeDTO,
|
||||
DashboardtypesHeatmapColorScaleDTO,
|
||||
DashboardtypesHeatmapPaletteDTO,
|
||||
@@ -15,9 +16,12 @@ import {
|
||||
ColorRampPalette,
|
||||
ColorRampScale,
|
||||
} from 'lib/visualization/colorRamp/types';
|
||||
import { DistributionYScale } from 'lib/visualization/charts/Distribution/types';
|
||||
|
||||
import {
|
||||
resolveAreaFillMode,
|
||||
resolveDistributionPercentiles,
|
||||
resolveDistributionYScale,
|
||||
resolveHeatmapAxisScale,
|
||||
resolveHeatmapColors,
|
||||
resolveSpanGaps,
|
||||
@@ -190,3 +194,27 @@ describe('resolveHeatmapColors', () => {
|
||||
expect(resolveHeatmapColors({ steps: 0 })).toStrictEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveDistributionYScale', () => {
|
||||
it('defaults to linear', () => {
|
||||
expect(resolveDistributionYScale(undefined)).toBe(DistributionYScale.Linear);
|
||||
expect(
|
||||
resolveDistributionYScale(DashboardtypesDistributionYScaleDTO.log),
|
||||
).toBe(DistributionYScale.Log);
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveDistributionPercentiles', () => {
|
||||
it('marks nothing without percentiles; the server always writes them', () => {
|
||||
expect(resolveDistributionPercentiles(undefined)).toStrictEqual([]);
|
||||
});
|
||||
|
||||
it('marks the configured percentiles, or none when turned off', () => {
|
||||
expect(
|
||||
resolveDistributionPercentiles({ enabled: true, values: [75, 99.9] }),
|
||||
).toStrictEqual([75, 99.9]);
|
||||
expect(
|
||||
resolveDistributionPercentiles({ enabled: false, values: [75] }),
|
||||
).toStrictEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
DashboardtypesAreaFillModeDTO,
|
||||
DashboardtypesDistributionYScaleDTO,
|
||||
DashboardtypesFillModeDTO,
|
||||
DashboardtypesHeatmapColorModeDTO,
|
||||
DashboardtypesHeatmapColorScaleDTO,
|
||||
@@ -24,6 +25,7 @@ import {
|
||||
ColorRampPalette,
|
||||
ColorRampScale,
|
||||
} from 'lib/visualization/colorRamp/types';
|
||||
import { DistributionYScale } from 'lib/visualization/charts/Distribution/types';
|
||||
|
||||
/**
|
||||
* Bridges the V2 wire-format enums to the uPlotV2 chart enums. String values
|
||||
@@ -58,7 +60,11 @@ export const AREA_FILL_MODE_MAP: Record<
|
||||
FillMode
|
||||
> = omit(FILL_MODE_MAP, DashboardtypesFillModeDTO.none);
|
||||
|
||||
export const STACK_MODE_MAP: Record<DashboardtypesStackModeDTO, StackMode> = {
|
||||
// Keyed by the wire strings, so Distribution's same-valued enum resolves through it too.
|
||||
export const STACK_MODE_MAP: Record<
|
||||
`${DashboardtypesStackModeDTO}`,
|
||||
StackMode
|
||||
> = {
|
||||
[DashboardtypesStackModeDTO.none]: StackMode.None,
|
||||
[DashboardtypesStackModeDTO.normal]: StackMode.Normal,
|
||||
[DashboardtypesStackModeDTO.percent]: StackMode.Percent,
|
||||
@@ -114,3 +120,11 @@ export const HEATMAP_Y_SCALE_MAP: Record<
|
||||
[DashboardtypesHeatmapYScaleDTO.log]: HeatmapAxisScale.Log,
|
||||
[DashboardtypesHeatmapYScaleDTO.symlog]: HeatmapAxisScale.Symlog,
|
||||
};
|
||||
|
||||
export const DISTRIBUTION_Y_SCALE_MAP: Record<
|
||||
DashboardtypesDistributionYScaleDTO,
|
||||
DistributionYScale
|
||||
> = {
|
||||
[DashboardtypesDistributionYScaleDTO.linear]: DistributionYScale.Linear,
|
||||
[DashboardtypesDistributionYScaleDTO.log]: DistributionYScale.Log,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { rangeUtil } from '@grafana/data';
|
||||
import {
|
||||
type DashboardtypesAreaFillModeDTO,
|
||||
type DashboardtypesDistributionPercentilesDTO,
|
||||
type DashboardtypesDistributionStackModeDTO,
|
||||
type DashboardtypesDistributionYScaleDTO,
|
||||
DashboardtypesHeatmapYScaleDTO,
|
||||
DashboardtypesLegendPositionDTO,
|
||||
DashboardtypesPrecisionOptionDTO,
|
||||
@@ -16,9 +19,11 @@ import { FillMode, StackMode } from 'lib/uPlotV2/config/types';
|
||||
import { clampColorSteps } from 'lib/visualization/colorRamp/colorScale';
|
||||
import { HeatmapAxisScale } from 'lib/uPlotV2/plugins/HeatmapPlugin/types';
|
||||
import type { ColorRampOptions } from 'lib/visualization/colorRamp/types';
|
||||
import { DistributionYScale } from 'lib/visualization/charts/Distribution/types';
|
||||
|
||||
import {
|
||||
AREA_FILL_MODE_MAP,
|
||||
DISTRIBUTION_Y_SCALE_MAP,
|
||||
HEATMAP_COLOR_MODE_MAP,
|
||||
HEATMAP_COLOR_SCALE_MAP,
|
||||
HEATMAP_PALETTE_MAP,
|
||||
@@ -96,7 +101,10 @@ export function resolveAreaFillMode(
|
||||
|
||||
/** Missing/unknown falls back to `None` — series drawn independently. */
|
||||
export function resolveStackMode(
|
||||
stack: DashboardtypesStackModeDTO | undefined,
|
||||
stack:
|
||||
| DashboardtypesStackModeDTO
|
||||
| DashboardtypesDistributionStackModeDTO
|
||||
| undefined,
|
||||
): StackMode {
|
||||
if (stack && stack in STACK_MODE_MAP) {
|
||||
return STACK_MODE_MAP[stack];
|
||||
@@ -104,6 +112,23 @@ export function resolveStackMode(
|
||||
return StackMode.None;
|
||||
}
|
||||
|
||||
export function resolveDistributionPercentiles(
|
||||
percentiles: DashboardtypesDistributionPercentilesDTO | undefined,
|
||||
): number[] {
|
||||
if (percentiles?.enabled === false) {
|
||||
return [];
|
||||
}
|
||||
return percentiles?.values ?? [];
|
||||
}
|
||||
|
||||
export function resolveDistributionYScale(
|
||||
scale: DashboardtypesDistributionYScaleDTO | undefined,
|
||||
): DistributionYScale {
|
||||
return scale && scale in DISTRIBUTION_Y_SCALE_MAP
|
||||
? DISTRIBUTION_Y_SCALE_MAP[scale]
|
||||
: DistributionYScale.Linear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Row-height distribution of a heatmap's bucket axis. Missing/unknown resolves to
|
||||
* `auto`, the one option that reads the bucket bounds rather than overriding them.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user