mirror of
https://github.com/SigNoz/signoz.git
synced 2026-12-02 13:11:24 +00:00
Compare commits
47 Commits
fix/ai-agg
...
split/4-e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
189ebaad72 | ||
|
|
62201a6289 | ||
|
|
7700246e4a | ||
|
|
11df5721c9 | ||
|
|
7b92439d93 | ||
|
|
565440ed21 | ||
|
|
60b35b8222 | ||
|
|
b910ccc618 | ||
|
|
a1e8febab5 | ||
|
|
0eda2c3080 | ||
|
|
62099763dc | ||
|
|
0a15b0f9be | ||
|
|
ca6045a462 | ||
|
|
f80c6be217 | ||
|
|
d0ee0d913b | ||
|
|
f057d5894e | ||
|
|
c6b1e8ea0e | ||
|
|
c31870110a | ||
|
|
8f201eeb76 | ||
|
|
b1261610b0 | ||
|
|
ac1a12c390 | ||
|
|
f7ad5f2f47 | ||
|
|
1ecb2ea954 | ||
|
|
e75768f981 | ||
|
|
e10731fb7c | ||
|
|
d28421004e | ||
|
|
136d98311e | ||
|
|
083f70c70f | ||
|
|
1cdf7e82ee | ||
|
|
79f49f56fc | ||
|
|
e395459783 | ||
|
|
59a23fbc2d | ||
|
|
8f5450df7c | ||
|
|
d7ecc1034d | ||
|
|
245cca1cb5 | ||
|
|
4f4a793558 | ||
|
|
7413f3f427 | ||
|
|
89f1c7cc72 | ||
|
|
8b068c827f | ||
|
|
cc389a3d73 | ||
|
|
322b288daf | ||
|
|
c017fc7436 | ||
|
|
18aab1a293 | ||
|
|
01790cd6dc | ||
|
|
4f20848baa | ||
|
|
bd8000d0c5 | ||
|
|
a1662e453e |
@@ -1,26 +0,0 @@
|
||||
---
|
||||
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.
|
||||
1042
docs/api/openapi.yml
1042
docs/api/openapi.yml
File diff suppressed because it is too large
Load Diff
@@ -89,15 +89,6 @@ 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,8 +298,6 @@
|
||||
// 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",
|
||||
{
|
||||
@@ -646,13 +644,6 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -190,6 +190,7 @@ const preview: Preview = {
|
||||
['Overview', 'Kafka', 'Kafka Detail', 'Celery'],
|
||||
'Onboarding',
|
||||
['Questionnaire', 'Add Data Source'],
|
||||
'Audit Logs',
|
||||
'Settings',
|
||||
[
|
||||
'Workspace',
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
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`' }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
* 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) },
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* 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,7 +21,6 @@ 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: {
|
||||
@@ -44,6 +43,5 @@ export default {
|
||||
'require-disable-reason': requireDisableReason,
|
||||
'no-dom-node-access': noDomNodeAccess,
|
||||
'no-builder-ai-query-access': noBuilderAiQueryAccess,
|
||||
'no-monaco-stripped-features': noMonacoStrippedFeatures,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -61,5 +61,6 @@
|
||||
"AI_OBSERVABILITY_OVERVIEW": "SigNoz | AI Observability Overview",
|
||||
"AI_OBSERVABILITY_EXPLORER": "SigNoz | AI Observability Explorer",
|
||||
"AI_OBSERVABILITY_CONFIGURATION": "SigNoz | AI Observability Configuration",
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping"
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping",
|
||||
"AUDIT_LOGS": "SigNoz | Audit Logs"
|
||||
}
|
||||
@@ -82,5 +82,6 @@
|
||||
"AI_OBSERVABILITY_OVERVIEW": "SigNoz | AI Observability Overview",
|
||||
"AI_OBSERVABILITY_EXPLORER": "SigNoz | AI Observability Explorer",
|
||||
"AI_OBSERVABILITY_CONFIGURATION": "SigNoz | AI Observability Configuration",
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping"
|
||||
"AI_OBSERVABILITY_ATTRIBUTE_MAPPING": "SigNoz | AI Observability Attribute Mapping",
|
||||
"AUDIT_LOGS": "SigNoz | Audit Logs"
|
||||
}
|
||||
@@ -292,3 +292,10 @@ export const LLMObservabilityPage = Loadable(
|
||||
/* webpackChunkName: "LLM Observability Page" */ 'pages/LLMObservability'
|
||||
),
|
||||
);
|
||||
|
||||
export const AuditLogsPage = Loadable(
|
||||
() =>
|
||||
import(
|
||||
/* webpackChunkName: "Audit Logs Page" */ 'pages/AuditLogsModule/AuditLogsModule'
|
||||
),
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
AlertOverview,
|
||||
AllErrors,
|
||||
ApiMonitoring,
|
||||
AuditLogsPage,
|
||||
ChannelsEdit,
|
||||
ChannelsNew,
|
||||
CreateNewAlerts,
|
||||
@@ -408,6 +409,12 @@ const routes: AppRoutes[] = [
|
||||
key: 'AI_OBSERVABILITY_CONFIGURATION',
|
||||
isPrivate: true,
|
||||
},
|
||||
{
|
||||
path: ROUTES.AUDIT_LOGS,
|
||||
component: AuditLogsPage,
|
||||
key: 'AUDIT_LOGS',
|
||||
isPrivate: true,
|
||||
},
|
||||
];
|
||||
|
||||
export const SUPPORT_ROUTE: AppRoutes = {
|
||||
|
||||
@@ -14206,19 +14206,7 @@ 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
|
||||
*/
|
||||
@@ -14646,254 +14634,6 @@ 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;
|
||||
/**
|
||||
@@ -15777,7 +15517,7 @@ export type GetFieldsKeysParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -15788,13 +15528,13 @@ export type GetFieldsKeysParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -15836,7 +15576,7 @@ export type GetFieldsValuesParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -15847,13 +15587,13 @@ export type GetFieldsValuesParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -16359,197 +16099,6 @@ 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;
|
||||
};
|
||||
@@ -17582,7 +17131,7 @@ export type GetRuleHistoryFilterKeysParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -17593,13 +17142,13 @@ export type GetRuleHistoryFilterKeysParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
@@ -17644,7 +17193,7 @@ export type GetRuleHistoryFilterValuesParams = {
|
||||
*/
|
||||
signal?: TelemetrytypesSignalDTO;
|
||||
/**
|
||||
* @description The data source within the signal. Use meter for Cost Meter metrics; empty means the default source.
|
||||
* @description The data source within the signal. Use audit for audit logs or meter for Cost Meter metrics; empty means the default source.
|
||||
*/
|
||||
source?: TelemetrytypesSourceDTO;
|
||||
/**
|
||||
@@ -17655,13 +17204,13 @@ export type GetRuleHistoryFilterValuesParams = {
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
* @description Start of the lookup window in Unix milliseconds, rounded down to a 6 hour boundary. Ignored for key lookups, audit lookups (fixed 30 day lookback) and meter lookups; trace and log values apply it at calendar-day granularity; metric attribute values and relatedValues apply it. Omit for no lower bound.
|
||||
*/
|
||||
startUnixMilli?: number;
|
||||
/**
|
||||
* @type integer
|
||||
* @format int64
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
* @description End of the lookup window in Unix milliseconds. Ignored for key lookups, trace and log value lookups, audit lookups (fixed 30 day lookback) and meter lookups; applied to metric attribute values and relatedValues. Omit for no upper bound.
|
||||
*/
|
||||
endUnixMilli?: number;
|
||||
/**
|
||||
|
||||
@@ -22,11 +22,6 @@ import type {
|
||||
GetFlamegraphPathParameters,
|
||||
GetTraceAggregations200,
|
||||
GetTraceAggregationsPathParameters,
|
||||
GetTraceHighlights200,
|
||||
GetTraceHighlightsParams,
|
||||
GetTraceHighlightsPathParameters,
|
||||
GetTraceSpan200,
|
||||
GetTraceSpanPathParameters,
|
||||
GetTraceSummary200,
|
||||
GetTraceSummaryPathParameters,
|
||||
GetTraceThread200,
|
||||
@@ -34,18 +29,6 @@ import type {
|
||||
GetTraceThreadPathParameters,
|
||||
GetWaterfallV4200,
|
||||
GetWaterfallV4PathParameters,
|
||||
ListTraceSpanAncestors200,
|
||||
ListTraceSpanAncestorsParams,
|
||||
ListTraceSpanAncestorsPathParameters,
|
||||
ListTraceSpanChildren200,
|
||||
ListTraceSpanChildrenParams,
|
||||
ListTraceSpanChildrenPathParameters,
|
||||
ListTraceSpanDescendants200,
|
||||
ListTraceSpanDescendantsParams,
|
||||
ListTraceSpanDescendantsPathParameters,
|
||||
ListTraceSpans200,
|
||||
ListTraceSpansParams,
|
||||
ListTraceSpansPathParameters,
|
||||
RenderErrorResponseDTO,
|
||||
SpantypesPostableFlamegraphDTO,
|
||||
SpantypesPostableTraceAggregationsDTO,
|
||||
@@ -176,710 +159,7 @@ export const useGetTraceAggregations = <
|
||||
return useMutation(getGetTraceAggregationsMutationOptions(options));
|
||||
};
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* @summary Get summary for a trace
|
||||
*/
|
||||
export const getTraceSummary = (
|
||||
@@ -981,7 +261,7 @@ export const invalidateGetTraceSummary = async (
|
||||
};
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* @summary Get thread view for a trace
|
||||
*/
|
||||
export const getTraceThread = (
|
||||
|
||||
@@ -396,16 +396,20 @@ describe('convertV5ResponseToLegacy', () => {
|
||||
meta: { rowsScanned: 0, bytesScanned: 0, durationMs: 0, stepIntervals: {} },
|
||||
} as unknown as QueryRangeResponseV5;
|
||||
|
||||
const baseSpec = {
|
||||
name: 'A',
|
||||
stepInterval: 60,
|
||||
disabled: false,
|
||||
aggregations: [],
|
||||
};
|
||||
|
||||
const params = makeBaseParams(type as RequestType, [
|
||||
{
|
||||
type: 'builder_query',
|
||||
spec: {
|
||||
name: 'A',
|
||||
signal: type === 'trace' ? 'traces' : 'logs',
|
||||
stepInterval: 60,
|
||||
disabled: false,
|
||||
aggregations: [],
|
||||
},
|
||||
spec:
|
||||
type === 'trace'
|
||||
? { ...baseSpec, signal: 'traces' }
|
||||
: { ...baseSpec, signal: 'logs' },
|
||||
},
|
||||
]);
|
||||
|
||||
|
||||
@@ -643,6 +643,28 @@ describe('prepareQueryRangePayloadV5', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('sends source audit on a logs query that targets audit', () => {
|
||||
const [envelope] = convertBuilderQueriesToV5(
|
||||
{
|
||||
A: baseBuilderQuery({ dataSource: DataSource.LOGS, source: 'audit' }),
|
||||
},
|
||||
'raw',
|
||||
);
|
||||
|
||||
expect(envelope.spec).toMatchObject({ signal: 'logs', source: 'audit' });
|
||||
});
|
||||
|
||||
it('sends no source on a plain logs query', () => {
|
||||
const [envelope] = convertBuilderQueriesToV5(
|
||||
{
|
||||
A: baseBuilderQuery({ dataSource: DataSource.LOGS, source: '' }),
|
||||
},
|
||||
'raw',
|
||||
);
|
||||
|
||||
expect(envelope.spec).not.toHaveProperty('source');
|
||||
});
|
||||
|
||||
it('builds payload for builder queries with filters array but no filter expression', () => {
|
||||
const props: GetQueryResultsProps = {
|
||||
query: {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* eslint-disable sonarjs/cognitive-complexity */
|
||||
/* eslint-disable sonarjs/no-identical-functions */
|
||||
import { TelemetrytypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { convertFiltersToExpression } from 'components/QueryBuilderV2/utils';
|
||||
import { PANEL_TYPES } from 'constants/queryBuilder';
|
||||
import { GetQueryResultsProps } from 'lib/dashboard/getQueryResults';
|
||||
@@ -341,6 +342,9 @@ export function convertBuilderQueriesToV5(
|
||||
spec = {
|
||||
name: queryName,
|
||||
signal: 'logs' as const,
|
||||
...(queryData.source === TelemetrytypesSourceDTO.audit && {
|
||||
source: TelemetrytypesSourceDTO.audit,
|
||||
}),
|
||||
...baseSpec,
|
||||
aggregations: aggregations as LogAggregation[],
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { ToggleGroup } from '@signozhq/ui/toggle-group';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import { Tooltip } from 'antd';
|
||||
import { SavedviewtypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import LogStateIndicator from 'components/Logs/LogStateIndicator/LogStateIndicator';
|
||||
@@ -20,22 +19,17 @@ import useInitialQuery from 'container/LogsExplorerContext/useInitialQuery';
|
||||
import { useOptionsMenu } from 'container/OptionsMenu';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { useArrowKeyNavigation } from 'container/TracesExplorer/SpanDrawer/useArrowKeyNavigation';
|
||||
import { useCloseOnOutsideClick } from 'hooks/logs/useCloseOnOutsideClick';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { getBodyMessage } from 'lib/logs/logBody';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import {
|
||||
ArrowDown,
|
||||
ArrowUp,
|
||||
Filter,
|
||||
Histogram,
|
||||
Table,
|
||||
TextSelect,
|
||||
} from '@signozhq/icons';
|
||||
import { Filter, Histogram, Table, TextSelect } from '@signozhq/icons';
|
||||
import { Query, TagFilter } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, StringOperators } from 'types/common/queryBuilder';
|
||||
|
||||
import { RESOURCE_KEYS, VIEW_TYPES, VIEWS } from './constants';
|
||||
import { LogDetailBodyProps } from './LogDetail.interfaces';
|
||||
import { LogNavigationHint } from './LogNavigationHint/LogNavigationHint';
|
||||
import LogHighlights from './LogHighlights/LogHighlights';
|
||||
|
||||
/* eslint-disable-next-line sonarjs/cognitive-complexity */
|
||||
@@ -61,33 +55,7 @@ function LogDetailBody({
|
||||
const [isEdit, setIsEdit] = useState<boolean>(false);
|
||||
const { stagedQuery } = useQueryBuilder();
|
||||
|
||||
// Handle clicks outside to close drawer, except on explicitly ignored regions
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (e: MouseEvent): void => {
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
// Don't close if clicking on drawer content, overlays, or portal elements
|
||||
if (
|
||||
target.closest('[data-log-detail-ignore="true"]') ||
|
||||
target.closest('.cm-tooltip-autocomplete') ||
|
||||
target.closest('.drawer-popover') ||
|
||||
target.closest('.query-status-popover') ||
|
||||
target.closest('[data-radix-popper-content-wrapper]') ||
|
||||
target.closest('[data-base-ui-portal]')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Close the drawer for any other outside click
|
||||
onClose();
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', handleClickOutside);
|
||||
|
||||
return (): void => {
|
||||
document.removeEventListener('mousedown', handleClickOutside);
|
||||
};
|
||||
}, [onClose]);
|
||||
useCloseOnOutsideClick(true, onClose);
|
||||
|
||||
// Only listen in the OVERVIEW tab so we don't hijack arrow keys from the
|
||||
// JSON editor / context view.
|
||||
@@ -329,31 +297,7 @@ function LogDetailBody({
|
||||
|
||||
{selectedView === VIEW_TYPES.OVERVIEW && (
|
||||
<div className="log-detail-drawer__footer-hint">
|
||||
<div className="log-detail-drawer__footer-hint-content">
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Use
|
||||
</Typography>
|
||||
<ArrowUp size={14} className="log-detail-drawer__footer-hint-icon" />
|
||||
<span>/</span>
|
||||
<ArrowDown size={14} className="log-detail-drawer__footer-hint-icon" />
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
to view previous/next log
|
||||
</Typography>
|
||||
</div>
|
||||
<LogNavigationHint />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -110,17 +110,5 @@
|
||||
color: var(--l3-foreground);
|
||||
background: var(--drawer-background);
|
||||
z-index: 10;
|
||||
|
||||
.log-detail-drawer__footer-hint-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.log-detail-drawer__footer-hint-icon {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
color: var(--l3-foreground);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
import { act, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useLogNavigation } from '../useLogNavigation';
|
||||
|
||||
interface TestLog {
|
||||
id: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const logs: TestLog[] = [
|
||||
{ id: 'a', label: 'first' },
|
||||
{ id: 'b', label: 'second' },
|
||||
{ id: 'c', label: 'third' },
|
||||
];
|
||||
|
||||
const onNavigateLog = jest.fn();
|
||||
const onScrollToLog = jest.fn();
|
||||
|
||||
function renderNavigation(
|
||||
activeLogId: string,
|
||||
list: TestLog[] | undefined = logs,
|
||||
) {
|
||||
return renderHook(() =>
|
||||
useLogNavigation<TestLog>({
|
||||
logs: list,
|
||||
activeLogId,
|
||||
onNavigateLog,
|
||||
onScrollToLog,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('useLogNavigation', () => {
|
||||
it('disables previous on the first log', () => {
|
||||
const { result } = renderNavigation('a');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(false);
|
||||
});
|
||||
|
||||
it('disables next on the last log', () => {
|
||||
const { result } = renderNavigation('c');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(false);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
|
||||
it('enables both in the middle', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(false);
|
||||
expect(result.current.isNextDisabled).toBe(false);
|
||||
});
|
||||
|
||||
it('moves to the next log and scrolls to it', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
act(() => result.current.goToNext());
|
||||
|
||||
expect(onNavigateLog).toHaveBeenCalledWith(logs[2]);
|
||||
expect(onScrollToLog).toHaveBeenCalledWith('c');
|
||||
});
|
||||
|
||||
it('moves to the previous log and scrolls to it', () => {
|
||||
const { result } = renderNavigation('b');
|
||||
|
||||
act(() => result.current.goToPrev());
|
||||
|
||||
expect(onNavigateLog).toHaveBeenCalledWith(logs[0]);
|
||||
expect(onScrollToLog).toHaveBeenCalledWith('a');
|
||||
});
|
||||
|
||||
it('does nothing past the ends', () => {
|
||||
const { result } = renderNavigation('a');
|
||||
|
||||
act(() => result.current.goToPrev());
|
||||
|
||||
expect(onNavigateLog).not.toHaveBeenCalled();
|
||||
expect(onScrollToLog).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('disables both when the active log is not in the list', () => {
|
||||
const { result } = renderNavigation('missing');
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
|
||||
it('disables both without logs', () => {
|
||||
const { result } = renderNavigation('a', []);
|
||||
|
||||
expect(result.current.isPrevDisabled).toBe(true);
|
||||
expect(result.current.isNextDisabled).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { LogWithId } from 'hooks/logs/types';
|
||||
|
||||
interface UseLogNavigationParams {
|
||||
logs?: ILog[];
|
||||
interface UseLogNavigationParams<T extends LogWithId> {
|
||||
logs?: T[];
|
||||
activeLogId: string;
|
||||
onNavigateLog?: (log: ILog) => void;
|
||||
onNavigateLog?: (log: T) => void;
|
||||
onScrollToLog?: (id: string) => void;
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ interface UseLogNavigationReturn {
|
||||
isNextDisabled: boolean;
|
||||
}
|
||||
|
||||
export function useLogNavigation({
|
||||
export function useLogNavigation<T extends LogWithId>({
|
||||
logs,
|
||||
activeLogId,
|
||||
onNavigateLog,
|
||||
onScrollToLog,
|
||||
}: UseLogNavigationParams): UseLogNavigationReturn {
|
||||
}: UseLogNavigationParams<T>): UseLogNavigationReturn {
|
||||
const currentIndex = useMemo(
|
||||
() => logs?.findIndex((l) => l.id === activeLogId) ?? -1,
|
||||
[logs, activeLogId],
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
color: var(--l3-foreground);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { ArrowDown, ArrowUp } from '@signozhq/icons';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
|
||||
import styles from './LogNavigationHint.module.scss';
|
||||
|
||||
export function LogNavigationHint(): JSX.Element {
|
||||
return (
|
||||
<div className={styles.content}>
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Use
|
||||
</Typography>
|
||||
<ArrowUp size={14} className={styles.icon} />
|
||||
<span>/</span>
|
||||
<ArrowDown size={14} className={styles.icon} />
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
to view previous/next log
|
||||
</Typography>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import ROUTES from 'constants/routes';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import {
|
||||
NO_DELAY_USER_EVENT,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
} from 'tests/test-utils';
|
||||
import { IField } from 'types/api/logs/fields';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
|
||||
import { buildLog } from '../../__tests__/buildLog';
|
||||
import ListLogView from '..';
|
||||
|
||||
jest.mock('react-use', () => ({
|
||||
...jest.requireActual('react-use'),
|
||||
useCopyToClipboard: (): [unknown, jest.Mock] => [null, jest.fn()],
|
||||
}));
|
||||
|
||||
const field = (name: string): IField => ({ name, type: '', dataType: '' });
|
||||
|
||||
function renderRow(
|
||||
props: Partial<React.ComponentProps<typeof ListLogView<ILog>>> = {},
|
||||
route: string = ROUTES.LOGS_EXPLORER,
|
||||
): void {
|
||||
render(
|
||||
<ListLogView
|
||||
logData={buildLog()}
|
||||
linesPerRow={1}
|
||||
fontSize={FontSize.SMALL}
|
||||
selectedFields={[field('body')]}
|
||||
onSetActiveLog={jest.fn()}
|
||||
onAddToQuery={jest.fn()}
|
||||
{...props}
|
||||
/>,
|
||||
undefined,
|
||||
{ initialRoute: route },
|
||||
);
|
||||
}
|
||||
|
||||
describe('ListLogView action buttons', () => {
|
||||
it('shows copy link and context on the Logs Explorer route', () => {
|
||||
renderRow();
|
||||
|
||||
expect(screen.getByTestId('log-line-copy-link')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('log-line-show-context')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the buttons off the Logs Explorer route', () => {
|
||||
renderRow({}, ROUTES.AUDIT_LOGS);
|
||||
|
||||
expect(screen.queryByTestId('log-line-copy-link')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('log-line-show-context')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ListLogView content', () => {
|
||||
it('renders the body', () => {
|
||||
renderRow({ logData: buildLog({ body: 'created dashboard' }) });
|
||||
|
||||
expect(screen.getByTestId('logs-list-row-log-1')).toHaveTextContent(
|
||||
'created dashboard',
|
||||
);
|
||||
});
|
||||
|
||||
it('reads selected fields from the log by default', () => {
|
||||
renderRow({
|
||||
logData: buildLog({ severity_text: 'NOTICE' }),
|
||||
selectedFields: [field('severity_text')],
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-list-row-log-1')).toHaveTextContent('NOTICE');
|
||||
});
|
||||
|
||||
it('reads selected fields through getFieldValue when it is given', () => {
|
||||
renderRow({
|
||||
selectedFields: [field('custom.field')],
|
||||
getFieldValue: (_, fieldName) => `resolved:${fieldName}`,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-list-row-log-1')).toHaveTextContent(
|
||||
'resolved:custom.field',
|
||||
);
|
||||
});
|
||||
|
||||
it('skips a field the resolver returns nothing for', () => {
|
||||
renderRow({
|
||||
selectedFields: [field('missing')],
|
||||
getFieldValue: () => undefined,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-list-row-log-1')).not.toHaveTextContent(
|
||||
'missing',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ListLogView row click', () => {
|
||||
it('opens the log on click', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onSetActiveLog = jest.fn();
|
||||
const logData = buildLog();
|
||||
renderRow({ logData, onSetActiveLog });
|
||||
|
||||
await user.click(screen.getByTestId('logs-list-row-log-1'));
|
||||
|
||||
expect(onSetActiveLog).toHaveBeenCalledWith(logData);
|
||||
});
|
||||
|
||||
it('clears the active log when the active row is clicked', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClearActiveLog = jest.fn();
|
||||
const onSetActiveLog = jest.fn();
|
||||
renderRow({ isActiveLog: true, onClearActiveLog, onSetActiveLog });
|
||||
|
||||
await user.click(screen.getByTestId('logs-list-row-log-1'));
|
||||
|
||||
expect(onClearActiveLog).toHaveBeenCalledTimes(1);
|
||||
expect(onSetActiveLog).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -16,12 +16,12 @@ import { getBodyDisplay } from 'lib/logs/logBody';
|
||||
import { useTimezone } from 'providers/Timezone';
|
||||
// interfaces
|
||||
import { IField } from 'types/api/logs/fields';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { coerceToString, isScalarFieldValue } from 'utils/stringUtils';
|
||||
|
||||
// components
|
||||
import AddToQueryHOC, { AddToQueryHOCProps } from '../AddToQueryHOC';
|
||||
import LogLinesActionButtons from '../LogLinesActionButtons/LogLinesActionButtons';
|
||||
import { LogRowData } from '../RawLogView/types';
|
||||
import LogStateIndicator from '../LogStateIndicator/LogStateIndicator';
|
||||
import { getLogIndicatorType } from '../LogStateIndicator/utils';
|
||||
// styles
|
||||
@@ -127,40 +127,42 @@ function LogSelectedField({
|
||||
);
|
||||
}
|
||||
|
||||
type ListLogViewProps = {
|
||||
logData: ILog;
|
||||
type ListLogViewProps<T extends LogRowData> = {
|
||||
logData: T;
|
||||
selectedFields: IField[];
|
||||
onSetActiveLog: (
|
||||
log: ILog,
|
||||
log: T,
|
||||
selectedTab?: (typeof VIEW_TYPES)[keyof typeof VIEW_TYPES],
|
||||
) => void;
|
||||
onAddToQuery: AddToQueryHOCProps['onAddToQuery'];
|
||||
activeLog?: ILog | null;
|
||||
activeLog?: T | null;
|
||||
linesPerRow: number;
|
||||
fontSize: FontSize;
|
||||
handleChangeSelectedView?: ChangeViewFunctionType;
|
||||
isActiveLog?: boolean;
|
||||
onClearActiveLog?: () => void;
|
||||
getFieldValue?: (log: T, fieldName: string) => unknown;
|
||||
};
|
||||
|
||||
function ListLogView({
|
||||
function ListLogView<T extends LogRowData>({
|
||||
logData,
|
||||
selectedFields,
|
||||
onSetActiveLog,
|
||||
onAddToQuery,
|
||||
activeLog,
|
||||
activeLog = null,
|
||||
linesPerRow,
|
||||
fontSize,
|
||||
isActiveLog,
|
||||
onClearActiveLog,
|
||||
}: ListLogViewProps): JSX.Element {
|
||||
getFieldValue,
|
||||
}: ListLogViewProps<T>): JSX.Element {
|
||||
const flattenLogData = useMemo(() => FlatLogData(logData), [logData]);
|
||||
const isBodyJsonEnabled = useIsBodyJsonEnabled();
|
||||
|
||||
const { isHighlighted, isLogsExplorerPage, onLogCopy } = useCopyLogLink(
|
||||
logData.id,
|
||||
);
|
||||
const isReadOnlyLog = !isLogsExplorerPage;
|
||||
const shouldShowActions = isLogsExplorerPage;
|
||||
|
||||
const isDarkMode = useIsDarkMode();
|
||||
|
||||
@@ -249,7 +251,9 @@ function ListLogView({
|
||||
{updatedSelecedFields
|
||||
.filter((field) => !['timestamp', 'body'].includes(field.name))
|
||||
.map((field) => {
|
||||
const value = getLogFieldValue(logData, field.name, isBodyJsonEnabled);
|
||||
const value = getFieldValue
|
||||
? getFieldValue(logData, field.name)
|
||||
: getLogFieldValue(logData, field.name, isBodyJsonEnabled);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -268,9 +272,9 @@ function ListLogView({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!isReadOnlyLog && (
|
||||
{shouldShowActions && (
|
||||
<LogLinesActionButtons
|
||||
handleShowContext={handleShowContext}
|
||||
handleShowContext={isLogsExplorerPage ? handleShowContext : undefined}
|
||||
onLogCopy={onLogCopy}
|
||||
/>
|
||||
)}
|
||||
@@ -279,13 +283,8 @@ function ListLogView({
|
||||
);
|
||||
}
|
||||
|
||||
ListLogView.defaultProps = {
|
||||
activeLog: null,
|
||||
handleChangeSelectedView: undefined,
|
||||
};
|
||||
|
||||
LogGeneralField.defaultProps = {
|
||||
linesPerRow: 1,
|
||||
};
|
||||
|
||||
export default memo(ListLogView);
|
||||
export default memo(ListLogView) as typeof ListLogView;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { Button, Tooltip } from 'antd';
|
||||
import './LogLinesActionButtons.styles.scss';
|
||||
|
||||
export interface LogLinesActionButtonsProps {
|
||||
handleShowContext: MouseEventHandler<HTMLElement>;
|
||||
handleShowContext?: MouseEventHandler<HTMLElement>;
|
||||
onLogCopy: MouseEventHandler<HTMLElement>;
|
||||
customClassName?: string;
|
||||
}
|
||||
@@ -17,15 +17,17 @@ function LogLinesActionButtons({
|
||||
}: LogLinesActionButtonsProps): JSX.Element {
|
||||
return (
|
||||
<div className={`log-line-action-buttons ${customClassName}`}>
|
||||
<Tooltip title="Show in Context">
|
||||
<Button
|
||||
size="small"
|
||||
icon={<TextSelect size={14} />}
|
||||
className="show-context-btn"
|
||||
onClick={handleShowContext}
|
||||
data-testid="log-line-show-context"
|
||||
/>
|
||||
</Tooltip>
|
||||
{handleShowContext && (
|
||||
<Tooltip title="Show in Context">
|
||||
<Button
|
||||
size="small"
|
||||
icon={<TextSelect size={14} />}
|
||||
className="show-context-btn"
|
||||
onClick={handleShowContext}
|
||||
data-testid="log-line-show-context"
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip title="Copy Link">
|
||||
<Button
|
||||
size="small"
|
||||
|
||||
@@ -90,7 +90,10 @@ const getLogType = (
|
||||
return defaultType;
|
||||
};
|
||||
|
||||
export const getLogIndicatorType = (logData: ILog): string => {
|
||||
export type LogIndicatorData = Pick<ILog, 'severity_text' | 'severity_number'> &
|
||||
Partial<Pick<ILog, 'attributes_string'>>;
|
||||
|
||||
export const getLogIndicatorType = (logData: LogIndicatorData): string => {
|
||||
const defaultType = logData.attributes_string?.log_level || LogType.INFO;
|
||||
// convert the severity_text to upper case for the comparison to support case insensitive values
|
||||
return getLogType(
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import Spinner from 'components/Spinner';
|
||||
|
||||
export function LogsLoadingFooter(): JSX.Element {
|
||||
return <Spinner height={20} tip="Getting Logs" testId="logs-loading-footer" />;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import ROUTES from 'constants/routes';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import {
|
||||
NO_DELAY_USER_EVENT,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
} from 'tests/test-utils';
|
||||
import { IField } from 'types/api/logs/fields';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
|
||||
import { buildLog } from '../../__tests__/buildLog';
|
||||
import RawLogView from '..';
|
||||
|
||||
jest.mock('react-use', () => ({
|
||||
...jest.requireActual('react-use'),
|
||||
useCopyToClipboard: (): [unknown, jest.Mock] => [null, jest.fn()],
|
||||
}));
|
||||
|
||||
const field = (name: string): IField => ({ name, type: '', dataType: '' });
|
||||
const bodyField = [field('body')];
|
||||
|
||||
function renderRow(
|
||||
props: Partial<React.ComponentProps<typeof RawLogView<ILog>>> = {},
|
||||
route: string = ROUTES.LOGS_EXPLORER,
|
||||
): void {
|
||||
render(
|
||||
<RawLogView
|
||||
data={buildLog()}
|
||||
linesPerRow={1}
|
||||
fontSize={FontSize.SMALL}
|
||||
selectedFields={bodyField}
|
||||
{...props}
|
||||
/>,
|
||||
undefined,
|
||||
{ initialRoute: route },
|
||||
);
|
||||
}
|
||||
|
||||
describe('RawLogView action buttons', () => {
|
||||
it('shows copy link and context on the Logs Explorer route', () => {
|
||||
renderRow();
|
||||
|
||||
expect(screen.getByTestId('log-line-copy-link')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('log-line-show-context')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the buttons off the Logs Explorer route', () => {
|
||||
renderRow({}, ROUTES.AUDIT_LOGS);
|
||||
|
||||
expect(screen.queryByTestId('log-line-copy-link')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('log-line-show-context')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides the buttons for a read-only row on the Logs Explorer route', () => {
|
||||
renderRow({ isReadOnly: true });
|
||||
|
||||
expect(screen.queryByTestId('log-line-copy-link')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('log-line-show-context')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('RawLogView content', () => {
|
||||
it('renders the body', () => {
|
||||
renderRow({ data: buildLog({ body: 'created dashboard' }) });
|
||||
|
||||
expect(screen.getByTestId('logs-raw-row-log-1')).toHaveTextContent(
|
||||
'created dashboard',
|
||||
);
|
||||
});
|
||||
|
||||
it('reads selected fields from the log by default', () => {
|
||||
renderRow({
|
||||
data: buildLog({ severity_text: 'NOTICE' }),
|
||||
selectedFields: [field('severity_text'), field('body')],
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-raw-row-log-1')).toHaveTextContent('NOTICE');
|
||||
});
|
||||
|
||||
it('reads selected fields through getFieldValue when it is given', () => {
|
||||
renderRow({
|
||||
selectedFields: [field('custom.field'), field('body')],
|
||||
getFieldValue: (_, fieldName) => `resolved:${fieldName}`,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-raw-row-log-1')).toHaveTextContent(
|
||||
'resolved:custom.field',
|
||||
);
|
||||
});
|
||||
|
||||
it('skips a field the resolver returns nothing for', () => {
|
||||
renderRow({
|
||||
selectedFields: [field('missing'), field('body')],
|
||||
getFieldValue: () => undefined,
|
||||
});
|
||||
|
||||
expect(screen.getByTestId('logs-raw-row-log-1')).toHaveTextContent(
|
||||
/^a log body$/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('RawLogView row click', () => {
|
||||
it('opens the log on click', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onSetActiveLog = jest.fn();
|
||||
const data = buildLog();
|
||||
renderRow({ data, onSetActiveLog });
|
||||
|
||||
await user.click(screen.getByTestId('logs-raw-row-log-1'));
|
||||
|
||||
expect(onSetActiveLog).toHaveBeenCalledWith(data);
|
||||
});
|
||||
|
||||
it('clears the active log when the active row is clicked', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClearActiveLog = jest.fn();
|
||||
const onSetActiveLog = jest.fn();
|
||||
renderRow({ isActiveLog: true, onClearActiveLog, onSetActiveLog });
|
||||
|
||||
await user.click(screen.getByTestId('logs-raw-row-log-1'));
|
||||
|
||||
expect(onClearActiveLog).toHaveBeenCalledTimes(1);
|
||||
expect(onSetActiveLog).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -25,22 +25,23 @@ import LogStateIndicator from '../LogStateIndicator/LogStateIndicator';
|
||||
import { getLogIndicatorType } from '../LogStateIndicator/utils';
|
||||
// styles
|
||||
import { InfoIconWrapper, RawLogContent, RawLogViewContainer } from './styles';
|
||||
import { RawLogViewProps } from './types';
|
||||
import { LogRowData, RawLogViewProps } from './types';
|
||||
|
||||
function RawLogView({
|
||||
isActiveLog,
|
||||
isReadOnly,
|
||||
function RawLogView<T extends LogRowData>({
|
||||
isActiveLog = false,
|
||||
isReadOnly = false,
|
||||
data,
|
||||
linesPerRow,
|
||||
isTextOverflowEllipsisDisabled,
|
||||
isHighlighted,
|
||||
isTextOverflowEllipsisDisabled = false,
|
||||
isHighlighted = false,
|
||||
helpTooltip,
|
||||
selectedFields = [],
|
||||
getFieldValue,
|
||||
fontSize,
|
||||
onLogClick,
|
||||
onSetActiveLog,
|
||||
onClearActiveLog,
|
||||
}: RawLogViewProps): JSX.Element {
|
||||
}: RawLogViewProps<T>): JSX.Element {
|
||||
const {
|
||||
isHighlighted: isUrlHighlighted,
|
||||
isLogsExplorerPage,
|
||||
@@ -49,7 +50,7 @@ function RawLogView({
|
||||
const isBodyJsonEnabled = useIsBodyJsonEnabled();
|
||||
|
||||
const isDarkMode = useIsDarkMode();
|
||||
const isReadOnlyLog = !isLogsExplorerPage || isReadOnly;
|
||||
const shouldShowActions = !isReadOnly && isLogsExplorerPage;
|
||||
|
||||
const logType = getLogIndicatorType(data);
|
||||
|
||||
@@ -60,7 +61,11 @@ function RawLogView({
|
||||
|
||||
const attributesValues = updatedSelecedFields
|
||||
.filter((field) => !['timestamp', 'body'].includes(field.name))
|
||||
.map((field) => getLogFieldValue(data, field.name, isBodyJsonEnabled))
|
||||
.map((field) =>
|
||||
getFieldValue
|
||||
? getFieldValue(data, field.name)
|
||||
: getLogFieldValue(data, field.name, isBodyJsonEnabled),
|
||||
)
|
||||
.filter((attribute) => {
|
||||
// loadash isEmpty doesnot work with numbers
|
||||
if (isNumber(attribute) || isBoolean(attribute)) {
|
||||
@@ -196,20 +201,13 @@ function RawLogView({
|
||||
dangerouslySetInnerHTML={html}
|
||||
/>
|
||||
|
||||
{!isReadOnlyLog && (
|
||||
{shouldShowActions && (
|
||||
<LogLinesActionButtons
|
||||
handleShowContext={handleShowContext}
|
||||
handleShowContext={isLogsExplorerPage ? handleShowContext : undefined}
|
||||
onLogCopy={onLogCopy}
|
||||
/>
|
||||
)}
|
||||
</RawLogViewContainer>
|
||||
);
|
||||
}
|
||||
RawLogView.defaultProps = {
|
||||
isActiveLog: false,
|
||||
isReadOnly: false,
|
||||
isTextOverflowEllipsisDisabled: false,
|
||||
isHighlighted: false,
|
||||
};
|
||||
|
||||
export default memo(RawLogView);
|
||||
export default memo(RawLogView) as typeof RawLogView;
|
||||
|
||||
@@ -4,21 +4,26 @@ import { ChangeViewFunctionType } from 'hooks/useHandleExplorerTabChange';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { IField } from 'types/api/logs/fields';
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
import { LogIndicatorData } from '../LogStateIndicator/utils';
|
||||
|
||||
export interface RawLogViewProps {
|
||||
export type LogRowData = Pick<ILog, 'id' | 'timestamp' | 'body'> &
|
||||
LogIndicatorData;
|
||||
|
||||
export interface RawLogViewProps<T extends LogRowData = ILog> {
|
||||
isActiveLog?: boolean;
|
||||
isReadOnly?: boolean;
|
||||
isTextOverflowEllipsisDisabled?: boolean;
|
||||
isHighlighted?: boolean;
|
||||
helpTooltip?: string;
|
||||
data: ILog;
|
||||
data: T;
|
||||
linesPerRow: number;
|
||||
fontSize: FontSize;
|
||||
selectedFields?: IField[];
|
||||
onLogClick?: (log: ILog, event: MouseEvent) => void;
|
||||
getFieldValue?: (log: T, fieldName: string) => unknown;
|
||||
onLogClick?: (log: T, event: MouseEvent) => void;
|
||||
handleChangeSelectedView?: ChangeViewFunctionType;
|
||||
onSetActiveLog?: (
|
||||
log: ILog,
|
||||
log: T,
|
||||
selectedTab?: (typeof VIEW_TYPES)[keyof typeof VIEW_TYPES],
|
||||
) => void;
|
||||
onClearActiveLog?: () => void;
|
||||
|
||||
24
frontend/src/components/Logs/__tests__/buildLog.ts
Normal file
24
frontend/src/components/Logs/__tests__/buildLog.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ILog } from 'types/api/logs/log';
|
||||
|
||||
export function buildLog(overrides: Partial<ILog> = {}): ILog {
|
||||
return {
|
||||
id: 'log-1',
|
||||
timestamp: '2024-01-01T10:00:00.000Z',
|
||||
date: '2024-01-01T10:00:00.000Z',
|
||||
body: 'a log body',
|
||||
severityText: 'INFO',
|
||||
severityNumber: 9,
|
||||
severity_text: 'INFO',
|
||||
severity_number: 9,
|
||||
traceFlags: 0,
|
||||
traceId: '',
|
||||
spanID: '',
|
||||
attributesString: {},
|
||||
attributesInt: {},
|
||||
attributesFloat: {},
|
||||
attributes_string: {},
|
||||
resources_string: {},
|
||||
scope_string: {},
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
@@ -191,6 +191,7 @@ function OptionsMenu({
|
||||
type="button"
|
||||
className="periscope-btn"
|
||||
aria-label="Fewer lines per row"
|
||||
data-testid="max-lines-fewer"
|
||||
onClick={(): void => handleLinesPerRowChange(maxLinesPerRow - 1)}
|
||||
>
|
||||
<Minus size={12} />
|
||||
@@ -211,6 +212,7 @@ function OptionsMenu({
|
||||
type="button"
|
||||
className="periscope-btn"
|
||||
aria-label="More lines per row"
|
||||
data-testid="max-lines-more"
|
||||
onClick={(): void => handleLinesPerRowChange(maxLinesPerRow + 1)}
|
||||
>
|
||||
<Plus size={12} />
|
||||
|
||||
@@ -238,7 +238,7 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
queryVariant={config?.queryVariant || 'dropdown'}
|
||||
showOnlyWhereClause={showOnlyWhereClause}
|
||||
isRawQuery={isRawQuery}
|
||||
signalSource={activeBuilder.queryData[0].source as 'meter' | ''}
|
||||
signalSource={activeBuilder.queryData[0].source}
|
||||
onSignalSourceChange={onSignalSourceChange || ((): void => {})}
|
||||
signalSourceChangeEnabled={signalSourceChangeEnabled}
|
||||
queriesCount={1}
|
||||
@@ -260,7 +260,7 @@ export const QueryBuilderV2 = memo(function QueryBuilderV2({
|
||||
queryVariant={config?.queryVariant || 'dropdown'}
|
||||
showOnlyWhereClause={showOnlyWhereClause}
|
||||
isRawQuery={isRawQuery}
|
||||
signalSource={query.source as 'meter' | ''}
|
||||
signalSource={query.source}
|
||||
onSignalSourceChange={onSignalSourceChange || ((): void => {})}
|
||||
signalSourceChangeEnabled={signalSourceChangeEnabled}
|
||||
queriesCount={activeBuilder.queryData.length}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
import { TelemetrytypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { FieldValuesConfig } from 'api/querySuggestions/types';
|
||||
import { QUICK_FILTER_SOURCE_TO_SIGNAL } from 'components/QuickFilters/constants';
|
||||
import {
|
||||
QUICK_FILTER_SOURCE_TO_SIGNAL,
|
||||
QUICK_FILTER_SOURCE_TO_SOURCE,
|
||||
} from 'components/QuickFilters/constants';
|
||||
import {
|
||||
IQuickFiltersConfig,
|
||||
QuickFiltersSource,
|
||||
@@ -27,12 +29,6 @@ interface UseFieldValuesReturn {
|
||||
isFetching: boolean;
|
||||
}
|
||||
|
||||
const QUICK_FILTERS_SOURCE_TO_SOURCE: Partial<
|
||||
Record<QuickFiltersSource, TelemetrytypesSourceDTO>
|
||||
> = {
|
||||
[QuickFiltersSource.METER_EXPLORER]: TelemetrytypesSourceDTO.meter,
|
||||
};
|
||||
|
||||
export function useFieldValues({
|
||||
filter,
|
||||
searchText,
|
||||
@@ -65,7 +61,7 @@ export function useFieldValues({
|
||||
searchText,
|
||||
existingQuery,
|
||||
metricNamespace,
|
||||
source: QUICK_FILTERS_SOURCE_TO_SOURCE[quickFilterSource],
|
||||
source: QUICK_FILTER_SOURCE_TO_SOURCE[quickFilterSource],
|
||||
startUnixMilli,
|
||||
// This field does not affect the backend but I wanted to keep it here
|
||||
// in case we add the support in the future
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useMemo } from 'react';
|
||||
import { Button, Skeleton } from 'antd';
|
||||
import {
|
||||
QuickfiltertypesSourceDTO,
|
||||
TelemetrytypesSourceDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { QuickfiltertypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import { FieldKeysConfig } from 'api/querySuggestions/types';
|
||||
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
|
||||
import { QUICK_FILTER_SOURCE_TO_SIGNAL } from 'components/QuickFilters/constants';
|
||||
import {
|
||||
QUICK_FILTER_SOURCE_TO_SIGNAL,
|
||||
QUICK_FILTER_SOURCE_TO_SOURCE,
|
||||
} from 'components/QuickFilters/constants';
|
||||
import { buildCompositeKey } from 'container/OptionsMenu/utils';
|
||||
import { useFieldKeysSuggestion } from 'hooks/querySuggestions/useFieldKeysSuggestion';
|
||||
import {
|
||||
@@ -43,8 +43,6 @@ function OtherFilters({
|
||||
addedFilters: TelemetryFieldKey[];
|
||||
setAddedFilters: React.Dispatch<React.SetStateAction<TelemetryFieldKey[]>>;
|
||||
}): JSX.Element {
|
||||
const isMeterDataSource =
|
||||
savedFiltersSource === QuickfiltertypesSourceDTO.meter;
|
||||
const isAIObservability =
|
||||
savedFiltersSource === QuickfiltertypesSourceDTO.ai_observability;
|
||||
|
||||
@@ -57,7 +55,7 @@ function OtherFilters({
|
||||
: {
|
||||
searchText: inputValue,
|
||||
signal: QUICK_FILTER_SOURCE_TO_SIGNAL[savedFiltersSource],
|
||||
source: isMeterDataSource ? TelemetrytypesSourceDTO.meter : undefined,
|
||||
source: QUICK_FILTER_SOURCE_TO_SOURCE[savedFiltersSource],
|
||||
};
|
||||
|
||||
const { data: fetchedKeys, isFetching } = useFieldKeysSuggestion(
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { TelemetrytypesSignalDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import {
|
||||
TelemetrytypesSignalDTO,
|
||||
TelemetrytypesSourceDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
|
||||
import { QuickFiltersSource } from './types';
|
||||
|
||||
@@ -15,3 +18,17 @@ export const QUICK_FILTER_SOURCE_TO_SIGNAL: Record<
|
||||
[QuickFiltersSource.INFRA_MONITORING]: TelemetrytypesSignalDTO.metrics,
|
||||
[QuickFiltersSource.AUDIT_LOGS]: TelemetrytypesSignalDTO.logs,
|
||||
};
|
||||
|
||||
export const QUICK_FILTER_SOURCE_TO_SOURCE: Record<
|
||||
QuickFiltersSource,
|
||||
TelemetrytypesSourceDTO | undefined
|
||||
> = {
|
||||
[QuickFiltersSource.LOGS_EXPLORER]: undefined,
|
||||
[QuickFiltersSource.TRACES_EXPLORER]: undefined,
|
||||
[QuickFiltersSource.EXCEPTIONS]: undefined,
|
||||
[QuickFiltersSource.API_MONITORING]: undefined,
|
||||
[QuickFiltersSource.AI_OBSERVABILITY]: undefined,
|
||||
[QuickFiltersSource.METER_EXPLORER]: TelemetrytypesSourceDTO.meter,
|
||||
[QuickFiltersSource.INFRA_MONITORING]: undefined,
|
||||
[QuickFiltersSource.AUDIT_LOGS]: TelemetrytypesSourceDTO.audit,
|
||||
};
|
||||
|
||||
@@ -9,5 +9,4 @@ 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',
|
||||
}
|
||||
|
||||
@@ -48,4 +48,5 @@ export enum LOCALSTORAGE {
|
||||
ALERT_RULES_LIST_VIEWS = 'ALERT_RULES_LIST_VIEWS',
|
||||
DASHBOARD_V2_PANEL_COLUMN_WIDTHS = 'DASHBOARD_V2_PANEL_COLUMN_WIDTHS',
|
||||
LLM_ATTRIBUTE_MAPPING_TEST_SPAN = 'LLM_ATTRIBUTE_MAPPING_TEST_SPAN',
|
||||
AUDIT_LOGS_OPTIONS = 'AUDIT_LOGS_OPTIONS',
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export const REACT_QUERY_KEY = {
|
||||
GET_PUBLIC_DASHBOARD_WIDGET_DATA: 'GET_PUBLIC_DASHBOARD_WIDGET_DATA',
|
||||
GET_ALL_LICENCES: 'GET_ALL_LICENCES',
|
||||
GET_QUERY_RANGE: 'GET_QUERY_RANGE',
|
||||
GET_AUDIT_LOGS: 'GET_AUDIT_LOGS',
|
||||
GET_ALL_DASHBOARDS: 'GET_ALL_DASHBOARDS',
|
||||
GET_TRIGGERED_ALERTS: 'GET_TRIGGERED_ALERTS',
|
||||
DASHBOARD_BY_ID: 'DASHBOARD_BY_ID',
|
||||
|
||||
@@ -41,6 +41,7 @@ const ROUTES = {
|
||||
LOGS_PIPELINES: '/logs/pipelines',
|
||||
PASSWORD_RESET: '/password-reset',
|
||||
LIST_LICENSES: '/licenses',
|
||||
AUDIT_LOGS: '/audit-logs',
|
||||
LOGS_INDEX_FIELDS: '/logs-explorer/index-fields',
|
||||
TRACE_EXPLORER: '/trace-explorer',
|
||||
BILLING: '/settings/billing',
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-3) var(--spacing-4);
|
||||
margin-top: -28px;
|
||||
padding: 0 calc(var(--spacing-8) + 28px) var(--spacing-2) var(--spacing-8);
|
||||
padding: 0 calc(var(--spacing-8) + 28px) var(--spacing-4) var(--spacing-8);
|
||||
|
||||
&.compact {
|
||||
padding: 0 calc(var(--spacing-3) + 28px) var(--spacing-2) var(--spacing-3);
|
||||
padding: 0 calc(var(--spacing-3) + 28px) var(--spacing-3) var(--spacing-3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
.message {
|
||||
display: flex;
|
||||
// Each message ends in its 28px hover row; the 4px under it makes 32px between messages.
|
||||
padding: 0 var(--spacing-8) var(--spacing-2);
|
||||
padding: 8px 16px;
|
||||
// CSS variable consumed by MessageFeedback to fade in on hover.
|
||||
--feedback-opacity: 0;
|
||||
|
||||
@@ -10,12 +9,7 @@
|
||||
}
|
||||
|
||||
&.compact {
|
||||
padding: 0 var(--spacing-3) var(--spacing-2);
|
||||
}
|
||||
|
||||
// An error reply has no hover row, so it holds the 32px itself.
|
||||
&.noActions {
|
||||
padding-bottom: var(--spacing-16);
|
||||
padding: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,10 +74,6 @@
|
||||
border-bottom-left-radius: var(--radius-2);
|
||||
}
|
||||
|
||||
.assistant &:not(.error) {
|
||||
padding-block: 0;
|
||||
}
|
||||
|
||||
// The full page sets replies flush on the pane; errors keep their callout.
|
||||
.assistant .fullPage &:not(.error) {
|
||||
padding: 0 0 0 var(--spacing-5);
|
||||
@@ -124,7 +114,7 @@
|
||||
}
|
||||
|
||||
.retryButton {
|
||||
margin-top: var(--spacing-2);
|
||||
margin-top: 6px;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ export default function MessageBubble({
|
||||
isUser ? styles.user : styles.assistant,
|
||||
{
|
||||
[styles.compact]: isCompact,
|
||||
[styles.noActions]: isError && !showRetry,
|
||||
},
|
||||
);
|
||||
const bodyClass = cx(styles.body, {
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
|
||||
// Room around the thread lives in its rows: Virtuoso measures only rows, so padding outside them leaves its scrolls short.
|
||||
.row.first {
|
||||
padding-top: var(--spacing-12);
|
||||
padding-top: var(--spacing-8);
|
||||
}
|
||||
|
||||
// Keeps the last bubble off the disclaimer and input bar.
|
||||
.row.last {
|
||||
padding-bottom: var(--spacing-2);
|
||||
padding-bottom: var(--spacing-32);
|
||||
}
|
||||
|
||||
// As wide as the full-page input; the extra 32px is the rows' own gutters.
|
||||
|
||||
@@ -16,7 +16,7 @@ import { getLogIndicatorType } from 'components/Logs/LogStateIndicator/utils';
|
||||
import RawLogView from 'components/Logs/RawLogView';
|
||||
import { useLogsTableColumns } from 'components/Logs/TableView/useLogsTableColumns';
|
||||
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
|
||||
import Spinner from 'components/Spinner';
|
||||
import { LogsLoadingFooter } from 'components/Logs/LogsLoadingFooter/LogsLoadingFooter';
|
||||
import type { TanStackTableHandle } from 'components/TanStackTableView';
|
||||
import TanStackTable from 'components/TanStackTableView';
|
||||
import type { TableColumnDef } from 'components/TanStackTableView/types';
|
||||
@@ -51,9 +51,6 @@ import {
|
||||
import styles from './LogsExplorerList.module.scss';
|
||||
import './LogsExplorerList.style.scss';
|
||||
|
||||
function Footer(): JSX.Element {
|
||||
return <Spinner height={20} tip="Getting Logs" />;
|
||||
}
|
||||
function LogsExplorerList({
|
||||
isLoading,
|
||||
isFetching,
|
||||
@@ -195,7 +192,7 @@ function LogsExplorerList({
|
||||
const renderContent = useMemo(() => {
|
||||
const components = isLoading
|
||||
? {
|
||||
Footer,
|
||||
Footer: LogsLoadingFooter,
|
||||
}
|
||||
: {};
|
||||
|
||||
|
||||
@@ -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, QueryBuilderData } from 'types/common/queryBuilder';
|
||||
import {
|
||||
DataSource,
|
||||
MetricAggregateOperator,
|
||||
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 = [MetrictypesTimeAggregationDTO.rate];
|
||||
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
|
||||
const timeAggregateOperators = [MetricAggregateOperator.RATE];
|
||||
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
|
||||
|
||||
return getQueryBuilderQueries({
|
||||
autocompleteData,
|
||||
@@ -113,12 +113,12 @@ export const databaseCallsAvgDuration = ({
|
||||
const legendFormulas = ['Average Duration'];
|
||||
const expressions = [FORMULA.DATABASE_CALLS_AVG_DURATION];
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.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, QueryBuilderData } from 'types/common/queryBuilder';
|
||||
import {
|
||||
DataSource,
|
||||
MetricAggregateOperator,
|
||||
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 = [
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.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 = [
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.SUM,
|
||||
];
|
||||
const dataSource = DataSource.METRICS;
|
||||
|
||||
@@ -202,8 +202,8 @@ export const externalCallRpsByAddress = ({
|
||||
const legends = [legend];
|
||||
const dataSource = DataSource.METRICS;
|
||||
|
||||
const timeAggregateOperators = [MetrictypesTimeAggregationDTO.rate];
|
||||
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
|
||||
const timeAggregateOperators = [MetricAggregateOperator.RATE];
|
||||
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
|
||||
|
||||
return getQueryBuilderQueries({
|
||||
autocompleteData,
|
||||
@@ -252,12 +252,12 @@ export const externalCallDurationByAddress = ({
|
||||
const additionalItems = [additionalItemsA, additionalItemsA];
|
||||
const legends = [legend, legend];
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.SUM,
|
||||
];
|
||||
const dataSource = DataSource.METRICS;
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
MetrictypesComparisonSpaceAggregationParamDTO,
|
||||
MetrictypesSpaceAggregationDTO,
|
||||
MetrictypesTimeAggregationDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { MetrictypesComparisonSpaceAggregationParamDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import {
|
||||
alphabet,
|
||||
initialFormulaBuilderFormValues,
|
||||
@@ -11,6 +7,7 @@ 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,
|
||||
@@ -37,8 +34,8 @@ const getAggregations = ({
|
||||
dataSource: DataSource;
|
||||
key: string;
|
||||
aggregateOperator: string;
|
||||
timeAggregation: MetrictypesTimeAggregationDTO;
|
||||
spaceAggregation: MetrictypesSpaceAggregationDTO;
|
||||
timeAggregation: MetricAggregateOperator;
|
||||
spaceAggregation: MetricAggregateOperator;
|
||||
comparisonSpaceAggregationParam?: MetrictypesComparisonSpaceAggregationParamDTO;
|
||||
}): IBuilderQuery['aggregations'] =>
|
||||
dataSource === DataSource.TRACES
|
||||
@@ -47,8 +44,8 @@ const getAggregations = ({
|
||||
{
|
||||
metricName: key,
|
||||
temporality: '',
|
||||
timeAggregation,
|
||||
spaceAggregation,
|
||||
timeAggregation: timeAggregation as TimeAggregation,
|
||||
spaceAggregation: spaceAggregation as SpaceAggregation,
|
||||
reduceTo: ReduceOperators.AVG,
|
||||
...(comparisonSpaceAggregationParam && {
|
||||
comparisonSpaceAggregationParam,
|
||||
@@ -127,6 +124,7 @@ export const getQueryBuilderQuerieswithFormula = ({
|
||||
timeAggregateOperators,
|
||||
spaceAggregateOperators,
|
||||
comparisonSpaceAggregationParams = [],
|
||||
stepInterval,
|
||||
dataSource,
|
||||
}: BuilderQuerieswithFormulaProps): QueryBuilderData => ({
|
||||
queryFormulas: expressions.map((expression, index) => ({
|
||||
@@ -158,7 +156,7 @@ export const getQueryBuilderQuerieswithFormula = ({
|
||||
items: additionalItems[index],
|
||||
op: 'AND',
|
||||
},
|
||||
stepInterval: null,
|
||||
stepInterval: stepInterval ?? null,
|
||||
dataSource,
|
||||
})),
|
||||
queryTraceOperator: [],
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import {
|
||||
MetrictypesSpaceAggregationDTO,
|
||||
MetrictypesTimeAggregationDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { MetrictypesComparisonSpaceAggregationParamDTO } 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, QueryBuilderData } from 'types/common/queryBuilder';
|
||||
import {
|
||||
DataSource,
|
||||
MetricAggregateOperator,
|
||||
QueryBuilderData,
|
||||
} from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
FORMULA,
|
||||
@@ -25,11 +26,11 @@ import {
|
||||
LatencyProps,
|
||||
OperationPerSecProps,
|
||||
} from '../Tabs/types';
|
||||
import { getNearestHighestBucketValue } from '../utils';
|
||||
import {
|
||||
getQueryBuilderQueries,
|
||||
getQueryBuilderQuerieswithFormula,
|
||||
} from './MetricsPageQueriesFactory';
|
||||
import { getLatencyAtOrBelowAggregation } from './utils';
|
||||
|
||||
export const latency = ({
|
||||
servicename,
|
||||
@@ -42,7 +43,7 @@ export const latency = ({
|
||||
const newAutoCompleteData: BaseAutocompleteData = {
|
||||
key: isSpanMetricEnable
|
||||
? signozLatencyBucketMetrics
|
||||
: WidgetKeys.DurationNano,
|
||||
: WidgetKeys.SpanDurationNano,
|
||||
dataType: DataTypes.Float64,
|
||||
type: isSpanMetricEnable ? '' : MetricsType.Tag,
|
||||
};
|
||||
@@ -82,14 +83,14 @@ export const latency = ({
|
||||
const queryNameAndExpression = QUERYNAME_AND_EXPRESSION;
|
||||
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.p50,
|
||||
MetrictypesSpaceAggregationDTO.p90,
|
||||
MetrictypesSpaceAggregationDTO.p99,
|
||||
MetricAggregateOperator.P50,
|
||||
MetricAggregateOperator.P90,
|
||||
MetricAggregateOperator.P99,
|
||||
];
|
||||
|
||||
return getQueryBuilderQueries({
|
||||
@@ -108,17 +109,33 @@ export const apDexMetricsQueryBuilderQueries = ({
|
||||
servicename,
|
||||
tagFilterItems,
|
||||
topLevelOperationsRoute,
|
||||
threshold,
|
||||
threashold,
|
||||
delta,
|
||||
metricsBuckets,
|
||||
}: ApDexMetricsQueryBuilderQueriesProps): QueryBuilderData => {
|
||||
const satisfied = getLatencyAtOrBelowAggregation(
|
||||
threshold * 1000,
|
||||
metricsBuckets,
|
||||
);
|
||||
const tolerating = getLatencyAtOrBelowAggregation(
|
||||
threshold * 1000 * 4,
|
||||
metricsBuckets,
|
||||
);
|
||||
// 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 autoCompleteDataA: BaseAutocompleteData = {
|
||||
key: WidgetKeys.SignozLatencyCount,
|
||||
@@ -196,27 +213,63 @@ 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, filterItemB];
|
||||
const additionalItems = [filterItemA, filterItemB, filterItemC];
|
||||
const legends = [GraphTitle.APDEX];
|
||||
const disabled = Array(3).fill(true);
|
||||
const expressions = [FORMULA.APDEX];
|
||||
const expressions = delta
|
||||
? [FORMULA.APDEX_DELTA_SPAN_METRICS]
|
||||
: [FORMULA.APDEX_CUMULATIVE_SPAN_METRICS];
|
||||
const legendFormulas = [GraphTitle.APDEX];
|
||||
// v5 forces increase on histograms, so the total matches it
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO.increase,
|
||||
MetrictypesTimeAggregationDTO.increase,
|
||||
MetrictypesTimeAggregationDTO.increase,
|
||||
MetricAggregateOperator.INCREASE,
|
||||
MetricAggregateOperator.INCREASE,
|
||||
MetricAggregateOperator.INCREASE,
|
||||
];
|
||||
|
||||
// a plain sum keeps the le label on B and C, and the formula then cannot join them
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
satisfied.spaceAggregation,
|
||||
tolerating.spaceAggregation,
|
||||
];
|
||||
@@ -283,8 +336,8 @@ export const operationPerSec = ({
|
||||
const legends = OPERATION_LEGENDS;
|
||||
const dataSource = DataSource.METRICS;
|
||||
|
||||
const timeAggregateOperators = [MetrictypesTimeAggregationDTO.rate];
|
||||
const spaceAggregateOperators = [MetrictypesSpaceAggregationDTO.sum];
|
||||
const timeAggregateOperators = [MetricAggregateOperator.RATE];
|
||||
const spaceAggregateOperators = [MetricAggregateOperator.SUM];
|
||||
|
||||
return getQueryBuilderQueries({
|
||||
autocompleteData,
|
||||
@@ -378,12 +431,12 @@ export const errorPercentage = ({
|
||||
const expressions = [FORMULA.ERROR_PERCENTAGE];
|
||||
const legendFormulas = [GraphTitle.ERROR_PERCENTAGE];
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.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, QueryBuilderData } from 'types/common/queryBuilder';
|
||||
import {
|
||||
DataSource,
|
||||
MetricAggregateOperator,
|
||||
QueryBuilderData,
|
||||
} from 'types/common/queryBuilder';
|
||||
|
||||
import {
|
||||
GraphTitle,
|
||||
@@ -112,20 +112,20 @@ export const topOperationQueries = ({
|
||||
KeyOperationTableHeader.NUM_OF_CALLS,
|
||||
];
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.p50,
|
||||
MetrictypesSpaceAggregationDTO.p90,
|
||||
MetrictypesSpaceAggregationDTO.p99,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.P50,
|
||||
MetricAggregateOperator.P90,
|
||||
MetricAggregateOperator.P99,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.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 { QueryBuilderFormula, QueryEnvelope } from 'types/api/v5/queryRange';
|
||||
import { QueryEnvelope } from 'types/api/v5/queryRange';
|
||||
import { EQueryType } from 'types/common/dashboard';
|
||||
|
||||
import {
|
||||
@@ -102,7 +102,8 @@ describe('service details queries on v5', () => {
|
||||
servicename: 'frontend',
|
||||
tagFilterItems: [],
|
||||
topLevelOperationsRoute: ['GET /'],
|
||||
threshold: 0.5,
|
||||
threashold: 0.5,
|
||||
delta: true,
|
||||
metricsBuckets: [100, 250, 500, 1000, 2000, 5000],
|
||||
}),
|
||||
);
|
||||
@@ -138,11 +139,6 @@ 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', () => {
|
||||
@@ -151,7 +147,8 @@ describe('service details queries on v5', () => {
|
||||
servicename: 'frontend',
|
||||
tagFilterItems: [],
|
||||
topLevelOperationsRoute: ['GET /'],
|
||||
threshold: 0.5,
|
||||
threashold: 0.5,
|
||||
delta: true,
|
||||
metricsBuckets: [100, 250, 500, 1000],
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
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,6 +24,7 @@ import { v4 as uuid } from 'uuid';
|
||||
import { ApDexMetricsProps } from './types';
|
||||
|
||||
function ApDexMetrics({
|
||||
delta,
|
||||
metricsBuckets,
|
||||
thresholdValue,
|
||||
onDragSelect,
|
||||
@@ -43,8 +44,9 @@ function ApDexMetrics({
|
||||
servicename,
|
||||
tagFilterItems,
|
||||
topLevelOperationsRoute,
|
||||
threshold: thresholdValue || 0,
|
||||
metricsBuckets,
|
||||
threashold: thresholdValue || 0,
|
||||
delta: delta || false,
|
||||
metricsBuckets: metricsBuckets || [],
|
||||
}),
|
||||
clickhouse_sql: [],
|
||||
id: uuid(),
|
||||
@@ -73,6 +75,7 @@ function ApDexMetrics({
|
||||
id: SERVICE_CHART_ID.apdex,
|
||||
}),
|
||||
[
|
||||
delta,
|
||||
metricsBuckets,
|
||||
servicename,
|
||||
tagFilterItems,
|
||||
@@ -89,7 +92,10 @@ function ApDexMetrics({
|
||||
}, [thresholdValue]);
|
||||
|
||||
const isQueryEnabled =
|
||||
topLevelOperationsRoute.length > 0 && metricsBuckets.length > 0;
|
||||
topLevelOperationsRoute.length > 0 &&
|
||||
!!metricsBuckets &&
|
||||
metricsBuckets?.length > 0 &&
|
||||
delta !== undefined;
|
||||
|
||||
return (
|
||||
<Graph
|
||||
@@ -104,4 +110,9 @@ function ApDexMetrics({
|
||||
);
|
||||
}
|
||||
|
||||
ApDexMetrics.defaultProps = {
|
||||
delta: undefined,
|
||||
le: undefined,
|
||||
};
|
||||
|
||||
export default ApDexMetrics;
|
||||
|
||||
@@ -31,6 +31,7 @@ function ApDexMetricsApplication({
|
||||
<ApDexMetrics
|
||||
topLevelOperationsRoute={topLevelOperationsRoute}
|
||||
handleGraphClick={handleGraphClick}
|
||||
delta={data?.data.delta}
|
||||
metricsBuckets={data?.data.le || []}
|
||||
onDragSelect={onDragSelect}
|
||||
tagFilterItems={tagFilterItems}
|
||||
|
||||
@@ -13,5 +13,6 @@ export interface ApDexDataSwitcherProps extends ApDexApplicationProps {
|
||||
}
|
||||
|
||||
export interface ApDexMetricsProps extends ApDexDataSwitcherProps {
|
||||
metricsBuckets: number[];
|
||||
delta?: boolean;
|
||||
metricsBuckets?: number[];
|
||||
}
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
import { ReactNode } from 'react';
|
||||
import {
|
||||
MetrictypesComparisonSpaceAggregationParamDTO,
|
||||
MetrictypesSpaceAggregationDTO,
|
||||
MetrictypesTimeAggregationDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { MetrictypesComparisonSpaceAggregationParamDTO } 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 } from 'types/common/queryBuilder';
|
||||
|
||||
import type { WidgetKeys } from '../constant';
|
||||
import { DataSource, MetricAggregateOperator } from 'types/common/queryBuilder';
|
||||
|
||||
export interface IServiceName {
|
||||
servicename: string;
|
||||
@@ -36,8 +30,8 @@ export interface BuilderQueriesProps {
|
||||
aggregateOperator?: string[];
|
||||
dataSource: DataSource;
|
||||
queryNameAndExpression?: string[];
|
||||
timeAggregateOperators: MetrictypesTimeAggregationDTO[];
|
||||
spaceAggregateOperators: MetrictypesSpaceAggregationDTO[];
|
||||
timeAggregateOperators: MetricAggregateOperator[];
|
||||
spaceAggregateOperators: MetricAggregateOperator[];
|
||||
}
|
||||
|
||||
export interface BuilderQuerieswithFormulaProps {
|
||||
@@ -48,12 +42,14 @@ export interface BuilderQuerieswithFormulaProps {
|
||||
expressions: string[];
|
||||
legendFormulas: string[];
|
||||
additionalItems: TagFilterItem[][];
|
||||
timeAggregateOperators: MetrictypesTimeAggregationDTO[];
|
||||
spaceAggregateOperators: MetrictypesSpaceAggregationDTO[];
|
||||
timeAggregateOperators: MetricAggregateOperator[];
|
||||
spaceAggregateOperators: MetricAggregateOperator[];
|
||||
comparisonSpaceAggregationParams?: (
|
||||
| MetrictypesComparisonSpaceAggregationParamDTO
|
||||
| undefined
|
||||
)[];
|
||||
// v5 picks its own step when none is sent; v4 needs one
|
||||
stepInterval?: number;
|
||||
dataSource: DataSource;
|
||||
}
|
||||
|
||||
@@ -74,7 +70,7 @@ export interface ApDexProps {
|
||||
servicename: IServiceName['servicename'];
|
||||
tagFilterItems: TagFilterItem[];
|
||||
topLevelOperationsRoute: string[];
|
||||
threshold: number;
|
||||
threashold: number;
|
||||
}
|
||||
|
||||
export interface TableRendererProps {
|
||||
@@ -82,12 +78,7 @@ 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,10 +30,23 @@ export const SERVICE_DETAIL_DRILLDOWN_ENABLED = true;
|
||||
export enum FORMULA {
|
||||
ERROR_PERCENTAGE = 'A*100/B',
|
||||
DATABASE_CALLS_AVG_DURATION = 'A/B',
|
||||
// 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',
|
||||
// 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',
|
||||
}
|
||||
|
||||
export const TOP_LEVEL_OPERATIONS = ['{{.top_level_operations}}'];
|
||||
@@ -67,13 +80,17 @@ export enum MetricsType {
|
||||
}
|
||||
|
||||
export enum WidgetKeys {
|
||||
Le = 'le',
|
||||
Name = 'name',
|
||||
HasError = 'hasError',
|
||||
Address = 'address',
|
||||
DurationNano = 'duration_nano',
|
||||
DurationNano = 'durationNano',
|
||||
SpanDurationNano = '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,24 +29,17 @@ 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 undefined for value higher than any bucket', () => {
|
||||
expect(
|
||||
getNearestHighestBucketValue(80, [10, 20, 30, 40, 60, 70]),
|
||||
).toBeUndefined();
|
||||
it('should return +Inf for value higher than any bucket', () => {
|
||||
expect(getNearestHighestBucketValue(80, [10, 20, 30, 40, 60, 70])).toBe(
|
||||
'+Inf',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return the first bucket for value lower than all buckets', () => {
|
||||
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]);
|
||||
expect(getNearestHighestBucketValue(5, [10, 20, 30, 40, 60, 70])).toBe('10');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -47,9 +47,11 @@ export const navigateToTrace = ({
|
||||
export const getNearestHighestBucketValue = (
|
||||
value: number,
|
||||
buckets: number[],
|
||||
): number | undefined => {
|
||||
// buckets are cached query data; never mutate
|
||||
return [...buckets].sort((a, b) => a - b).find((bucket) => bucket >= value);
|
||||
): string => {
|
||||
// sort the buckets
|
||||
buckets.sort((a, b) => a - b);
|
||||
const nearestBucket = buckets.find((bucket) => bucket >= value);
|
||||
return nearestBucket?.toString() || '+Inf';
|
||||
};
|
||||
|
||||
export const convertedTracesToDownloadData = (
|
||||
|
||||
@@ -3,3 +3,8 @@
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-3);
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: var(--label-small-400-font-size);
|
||||
color: var(--l1-foreground);
|
||||
}
|
||||
|
||||
@@ -32,3 +32,8 @@
|
||||
gap: var(--spacing-6);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
.titleText {
|
||||
color: inherit;
|
||||
font-size: var(--label-base-400-font-size);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import {
|
||||
MetrictypesSpaceAggregationDTO,
|
||||
MetrictypesTimeAggregationDTO,
|
||||
} from 'api/generated/services/sigNoz.schemas';
|
||||
import { ServiceDataProps } from 'api/metrics/getTopLevelOperations';
|
||||
import { OPERATORS } from 'constants/queryBuilder';
|
||||
import {
|
||||
@@ -15,7 +11,11 @@ import {
|
||||
DataTypes,
|
||||
} from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { TagFilterItem } from 'types/api/queryBuilder/queryBuilderData';
|
||||
import { DataSource, QueryBuilderData } from 'types/common/queryBuilder';
|
||||
import {
|
||||
DataSource,
|
||||
MetricAggregateOperator,
|
||||
QueryBuilderData,
|
||||
} from 'types/common/queryBuilder';
|
||||
|
||||
export const serviceMetricsQuery = (
|
||||
topLevelOperation: [keyof ServiceDataProps, string[]],
|
||||
@@ -155,16 +155,16 @@ export const serviceMetricsQuery = (
|
||||
];
|
||||
|
||||
const timeAggregateOperators = [
|
||||
MetrictypesTimeAggregationDTO[''],
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetrictypesTimeAggregationDTO.rate,
|
||||
MetricAggregateOperator.EMPTY,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
MetricAggregateOperator.RATE,
|
||||
];
|
||||
const spaceAggregateOperators = [
|
||||
MetrictypesSpaceAggregationDTO.p99,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetrictypesSpaceAggregationDTO.sum,
|
||||
MetricAggregateOperator.P99,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.SUM,
|
||||
MetricAggregateOperator.SUM,
|
||||
];
|
||||
|
||||
const disabled = [false, true, true, false];
|
||||
|
||||
@@ -82,6 +82,7 @@ import {
|
||||
aiAssistantMenuItem,
|
||||
USER_SETTINGS_MENU_LABELS,
|
||||
type UserSettingsMenuKey,
|
||||
auditLogsMenuItem,
|
||||
} from './menuItems';
|
||||
import NavItem from './NavItem/NavItem';
|
||||
import {
|
||||
@@ -958,6 +959,9 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
|
||||
onSelect: handleSettingsMenuItemClick,
|
||||
});
|
||||
|
||||
const isAuditLogsEnabled =
|
||||
(isCloudUser || isEnterpriseSelfHostedUser) && isAdmin;
|
||||
|
||||
return (
|
||||
<div className={cx('sidenav-container', isPinned && 'pinned')}>
|
||||
<div
|
||||
@@ -1198,6 +1202,8 @@ function SideNav({ isPinned }: { isPinned: boolean }): JSX.Element {
|
||||
<div className="secondary-nav-items">
|
||||
{isAIAssistantEnabled && renderNavItems([aiAssistantMenuItem], false)}
|
||||
|
||||
{isAuditLogsEnabled && renderNavItems([auditLogsMenuItem], false)}
|
||||
|
||||
<div className="nav-dropdown-item">
|
||||
<Dropdown
|
||||
items={helpSupportItems}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
|
||||
import { render, screen } from 'tests/test-utils';
|
||||
import { USER_ROLES } from 'types/roles';
|
||||
|
||||
import SideNav from '../SideNav';
|
||||
|
||||
jest.mock('hooks/useGetTenantLicense');
|
||||
|
||||
jest.mock('providers/cmdKProvider', () => ({
|
||||
useCmdK: (): { openCmdK: jest.Mock } => ({ openCmdK: jest.fn() }),
|
||||
}));
|
||||
|
||||
jest.mock('hooks/hotkeys/useKeyboardHotkeys', () => ({
|
||||
useKeyboardHotkeys: (): Record<string, jest.Mock> => ({
|
||||
registerShortcut: jest.fn(),
|
||||
deregisterShortcut: jest.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
type TenantLicense = ReturnType<typeof useGetTenantLicense>;
|
||||
|
||||
const NO_LICENSE: TenantLicense = {
|
||||
isCloudUser: false,
|
||||
isEnterpriseSelfHostedUser: false,
|
||||
isCommunityUser: false,
|
||||
isCommunityEnterpriseUser: false,
|
||||
};
|
||||
|
||||
const AUDIT_LOGS_NAV_ITEM = 'nav-item-audit-logs';
|
||||
|
||||
describe('SideNav audit logs entry', () => {
|
||||
it.each([
|
||||
['cloud', { ...NO_LICENSE, isCloudUser: true }],
|
||||
[
|
||||
'enterprise self-hosted',
|
||||
{ ...NO_LICENSE, isEnterpriseSelfHostedUser: true },
|
||||
],
|
||||
])('shows the entry to an admin on %s', (_, license) => {
|
||||
jest.mocked(useGetTenantLicense).mockReturnValue(license);
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role: USER_ROLES.ADMIN });
|
||||
|
||||
expect(screen.getByTestId(AUDIT_LOGS_NAV_ITEM)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it.each([USER_ROLES.EDITOR, USER_ROLES.VIEWER])(
|
||||
'hides the entry from a %s',
|
||||
(role) => {
|
||||
jest
|
||||
.mocked(useGetTenantLicense)
|
||||
.mockReturnValue({ ...NO_LICENSE, isCloudUser: true });
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role });
|
||||
|
||||
expect(screen.queryByTestId(AUDIT_LOGS_NAV_ITEM)).not.toBeInTheDocument();
|
||||
},
|
||||
);
|
||||
|
||||
it('hides the entry from an admin on a community install', () => {
|
||||
jest
|
||||
.mocked(useGetTenantLicense)
|
||||
.mockReturnValue({ ...NO_LICENSE, isCommunityUser: true });
|
||||
|
||||
render(<SideNav isPinned />, undefined, { role: USER_ROLES.ADMIN });
|
||||
|
||||
expect(screen.queryByTestId(AUDIT_LOGS_NAV_ITEM)).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
ChartArea,
|
||||
Cloudy,
|
||||
DraftingCompass,
|
||||
FileClock,
|
||||
FileKey2,
|
||||
Github,
|
||||
HardDrive,
|
||||
@@ -81,6 +82,14 @@ export const helpSupportMenuItem = {
|
||||
icon: <MessageSquareText size={16} />,
|
||||
};
|
||||
|
||||
export const auditLogsMenuItem = {
|
||||
key: ROUTES.AUDIT_LOGS,
|
||||
label: 'Audit Logs',
|
||||
icon: <FileClock size={16} />,
|
||||
isEnabled: true,
|
||||
itemKey: 'audit-logs',
|
||||
};
|
||||
|
||||
// The AI Assistant route is parameterized as `/ai-assistant/:conversationId`.
|
||||
// Sending the user to `/ai-assistant/new` triggers the page's fallback that
|
||||
// spawns a fresh conversation and replaces the URL with the real id, so
|
||||
|
||||
@@ -201,6 +201,7 @@ export const routesToSkip = [
|
||||
ROUTES.AI_OBSERVABILITY_CONFIGURATION,
|
||||
ROUTES.AI_OBSERVABILITY_ATTRIBUTE_MAPPING,
|
||||
ROUTES.AI_OBSERVABILITY_EXPLORER,
|
||||
ROUTES.AUDIT_LOGS,
|
||||
];
|
||||
|
||||
export const routesToDisable = [ROUTES.LOGS_EXPLORER];
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import {
|
||||
NO_DELAY_USER_EVENT,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { useCloseOnOutsideClick } from '../useCloseOnOutsideClick';
|
||||
|
||||
function Harness({
|
||||
enabled,
|
||||
onClose,
|
||||
}: {
|
||||
enabled: boolean;
|
||||
onClose: () => void;
|
||||
}): JSX.Element {
|
||||
useCloseOnOutsideClick(enabled, onClose);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<button type="button" data-testid="outside">
|
||||
outside
|
||||
</button>
|
||||
<div data-log-detail-ignore="true">
|
||||
<button type="button" data-testid="ignored-list">
|
||||
list
|
||||
</button>
|
||||
</div>
|
||||
<div className="drawer-popover">
|
||||
<button type="button" data-testid="ignored-popover">
|
||||
popover
|
||||
</button>
|
||||
</div>
|
||||
<div data-base-ui-portal>
|
||||
<button type="button" data-testid="ignored-portal">
|
||||
portal
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
describe('useCloseOnOutsideClick', () => {
|
||||
it('closes on a click outside', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn();
|
||||
render(<Harness enabled onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it.each(['ignored-list', 'ignored-popover', 'ignored-portal'])(
|
||||
'does not close on a click inside %s',
|
||||
async (testId) => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn();
|
||||
render(<Harness enabled onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId(testId));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
it('does nothing while disabled', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn();
|
||||
render(<Harness enabled={false} onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('stops listening after it is disabled', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
const onClose = jest.fn();
|
||||
const { rerender } = render(<Harness enabled onClose={onClose} />);
|
||||
rerender(<Harness enabled={false} onClose={onClose} />);
|
||||
|
||||
await user.click(screen.getByTestId('outside'));
|
||||
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
75
frontend/src/hooks/logs/__tests__/useCopyLogLink.test.tsx
Normal file
75
frontend/src/hooks/logs/__tests__/useCopyLogLink.test.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
import { ReactNode } from 'react';
|
||||
import ROUTES from 'constants/routes';
|
||||
import { act, AllTheProviders, renderHook } from 'tests/test-utils';
|
||||
|
||||
import { useCopyLogLink } from '../useCopyLogLink';
|
||||
|
||||
const mockCopy = jest.fn();
|
||||
|
||||
jest.mock('react-use', () => ({
|
||||
...jest.requireActual('react-use'),
|
||||
useCopyToClipboard: (): [unknown, jest.Mock] => [null, mockCopy],
|
||||
}));
|
||||
|
||||
function wrapperAt(initialRoute: string) {
|
||||
return function Wrapper({ children }: { children: ReactNode }): JSX.Element {
|
||||
return (
|
||||
<AllTheProviders initialRoute={initialRoute}>{children}</AllTheProviders>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function copiedLink(): URL {
|
||||
return new URL(mockCopy.mock.calls[0][0] as string);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
mockCopy.mockClear();
|
||||
});
|
||||
|
||||
describe('useCopyLogLink', () => {
|
||||
it('copies a link to the current page that carries the log id', () => {
|
||||
const { result } = renderHook(() => useCopyLogLink('log-1'), {
|
||||
wrapper: wrapperAt(ROUTES.AUDIT_LOGS),
|
||||
});
|
||||
|
||||
act(() => result.current.onLogCopy());
|
||||
|
||||
expect(mockCopy).toHaveBeenCalledTimes(1);
|
||||
expect(copiedLink().pathname).toBe(ROUTES.AUDIT_LOGS);
|
||||
expect(copiedLink().searchParams.get('activeLogId')).toBe('"log-1"');
|
||||
});
|
||||
|
||||
it('drops the relative time and pins the time range', () => {
|
||||
const { result } = renderHook(() => useCopyLogLink('log-1'), {
|
||||
wrapper: wrapperAt(`${ROUTES.AUDIT_LOGS}?relativeTime=30m`),
|
||||
});
|
||||
|
||||
act(() => result.current.onLogCopy());
|
||||
|
||||
const { searchParams } = copiedLink();
|
||||
expect(searchParams.has('relativeTime')).toBe(false);
|
||||
expect(searchParams.has('startTime')).toBe(true);
|
||||
expect(searchParams.has('endTime')).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps the other params of the page', () => {
|
||||
const { result } = renderHook(() => useCopyLogLink('log-1'), {
|
||||
wrapper: wrapperAt(`${ROUTES.AUDIT_LOGS}?compositeQuery=abc`),
|
||||
});
|
||||
|
||||
act(() => result.current.onLogCopy());
|
||||
|
||||
expect(copiedLink().searchParams.get('compositeQuery')).toBe('abc');
|
||||
});
|
||||
|
||||
it('copies nothing without a log id', () => {
|
||||
const { result } = renderHook(() => useCopyLogLink(), {
|
||||
wrapper: wrapperAt(ROUTES.AUDIT_LOGS),
|
||||
});
|
||||
|
||||
act(() => result.current.onLogCopy());
|
||||
|
||||
expect(mockCopy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -16,9 +16,11 @@ export type UseCopyLogLink = {
|
||||
onClearActiveLog: () => void;
|
||||
};
|
||||
|
||||
export type UseActiveLog = {
|
||||
activeLog: ILog | null;
|
||||
onSetActiveLog: (log: ILog) => void;
|
||||
export type LogWithId = { id: string };
|
||||
|
||||
export type UseActiveLog<T extends LogWithId = ILog> = {
|
||||
activeLog: T | null;
|
||||
onSetActiveLog: (log: T) => void;
|
||||
onClearActiveLog: () => void;
|
||||
onAddToQuery: (
|
||||
fieldKey: string,
|
||||
|
||||
@@ -8,12 +8,12 @@ import { ILog } from 'types/api/logs/log';
|
||||
import { DataTypes } from 'types/api/queryBuilder/queryAutocompleteResponse';
|
||||
import { Query } from 'types/api/queryBuilder/queryBuilderData';
|
||||
|
||||
import { UseActiveLog } from './types';
|
||||
import { LogWithId, UseActiveLog } from './types';
|
||||
|
||||
export const useActiveLog = (): UseActiveLog => {
|
||||
export const useActiveLog = <T extends LogWithId = ILog>(): UseActiveLog<T> => {
|
||||
const { currentQuery, redirectWithQueryBuilderData } = useQueryBuilder();
|
||||
|
||||
const [activeLog, setActiveLog] = useState<ILog | null>(null);
|
||||
const [activeLog, setActiveLog] = useState<T | null>(null);
|
||||
|
||||
// Close drawer/clear active log when query in URL changes
|
||||
const urlQuery = useUrlQuery();
|
||||
@@ -29,7 +29,7 @@ export const useActiveLog = (): UseActiveLog => {
|
||||
prevQueryRef.current = compositeQuery;
|
||||
}, [compositeQuery]);
|
||||
|
||||
const onSetActiveLog = useCallback((nextActiveLog: ILog): void => {
|
||||
const onSetActiveLog = useCallback((nextActiveLog: T): void => {
|
||||
setActiveLog(nextActiveLog);
|
||||
}, []);
|
||||
|
||||
|
||||
33
frontend/src/hooks/logs/useCloseOnOutsideClick.ts
Normal file
33
frontend/src/hooks/logs/useCloseOnOutsideClick.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const IGNORED_TARGETS = [
|
||||
'[data-log-detail-ignore="true"]',
|
||||
'.cm-tooltip-autocomplete',
|
||||
'.drawer-popover',
|
||||
'.query-status-popover',
|
||||
'[data-radix-popper-content-wrapper]',
|
||||
'[data-base-ui-portal]',
|
||||
].join(',');
|
||||
|
||||
export function useCloseOnOutsideClick(
|
||||
enabled: boolean,
|
||||
onClose: () => void,
|
||||
): void {
|
||||
useEffect(() => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const handleMouseDown = (e: MouseEvent): void => {
|
||||
if (e.target instanceof Element && e.target.closest(IGNORED_TARGETS)) {
|
||||
return;
|
||||
}
|
||||
onClose();
|
||||
};
|
||||
|
||||
document.addEventListener('mousedown', handleMouseDown);
|
||||
return (): void => {
|
||||
document.removeEventListener('mousedown', handleMouseDown);
|
||||
};
|
||||
}, [enabled, onClose]);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { BuilderQuerySource, DataSource } from 'types/common/queryBuilder';
|
||||
|
||||
export type ExplorerQueryRules = {
|
||||
dataSource: DataSource;
|
||||
/** `meter` on the meter explorer, which shares the metrics signal; '' elsewhere. */
|
||||
/** `meter` on the meter explorer, which shares the metrics signal; `audit` on the audit logs page, which shares the logs signal; '' elsewhere. */
|
||||
source: BuilderQuerySource;
|
||||
/** AI_QUERY_BUILDER on the AI explorer, whose queries live in the AI slot. */
|
||||
queryType: EQueryType.QUERY_BUILDER | EQueryType.AI_QUERY_BUILDER;
|
||||
@@ -43,6 +43,12 @@ const EXPLORER_QUERY_RULES: Partial<Record<string, ExplorerQueryRules>> = {
|
||||
queryType: EQueryType.QUERY_BUILDER,
|
||||
allowsTraceOperator: false,
|
||||
},
|
||||
[ROUTES.AUDIT_LOGS]: {
|
||||
dataSource: DataSource.LOGS,
|
||||
source: TelemetrytypesSourceDTO.audit,
|
||||
queryType: EQueryType.QUERY_BUILDER,
|
||||
allowsTraceOperator: false,
|
||||
},
|
||||
};
|
||||
|
||||
export function getExplorerQueryRules(
|
||||
|
||||
@@ -268,6 +268,16 @@ describe('normalizeCompositeQuery', () => {
|
||||
normalizeCompositeQuery(initialQueriesMap.metrics, ROUTES.METER_EXPLORER)
|
||||
.query.builder.queryData[0].source,
|
||||
).toBe(TelemetrytypesSourceDTO.meter);
|
||||
expect(
|
||||
firstBuilderQuery(
|
||||
initialQueriesMap.logs,
|
||||
[{ ...without(logsQuery, 'source'), filter: { expression: "x='y'" } }],
|
||||
ROUTES.AUDIT_LOGS,
|
||||
),
|
||||
).toMatchObject({
|
||||
source: TelemetrytypesSourceDTO.audit,
|
||||
filter: { expression: "x='y'" },
|
||||
});
|
||||
expect(
|
||||
firstBuilderQuery(traces, [{ ...tracesQuery, ...llmFilter }], ai),
|
||||
).toStrictEqual({ ...tracesQuery, ...llmFilter });
|
||||
|
||||
@@ -166,10 +166,11 @@ function fillMissingSignal(
|
||||
builderQuery.dataSource = rules.dataSource;
|
||||
}
|
||||
|
||||
// A missing `source` already means '', so only meter needs it written.
|
||||
// A missing `source` already means '', so only meter and audit need it written.
|
||||
if (
|
||||
builderQuery.source === undefined &&
|
||||
rules.source === TelemetrytypesSourceDTO.meter
|
||||
(rules.source === TelemetrytypesSourceDTO.meter ||
|
||||
rules.source === TelemetrytypesSourceDTO.audit)
|
||||
) {
|
||||
builderQuery.source = rules.source;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { defaultTo } from 'lodash-es';
|
||||
import { ILog, ILogBody } from 'types/api/logs/log';
|
||||
|
||||
export function FlatLogData(log: ILog): Record<string, string> {
|
||||
export function FlatLogData(logData: object): Record<string, string> {
|
||||
const log = logData as Record<string, never>;
|
||||
const flattenLogObject: Record<string, string> = {};
|
||||
|
||||
Object.keys(log).forEach((key: string): void => {
|
||||
if (typeof log[key as never] !== 'object') {
|
||||
flattenLogObject[key] = log[key as never];
|
||||
if (typeof log[key] !== 'object') {
|
||||
flattenLogObject[key] = log[key];
|
||||
} else {
|
||||
Object.keys(defaultTo(log[key as never], {})).forEach((childKey) => {
|
||||
flattenLogObject[childKey] = log[key as never][childKey];
|
||||
Object.keys(defaultTo(log[key], {})).forEach((childKey) => {
|
||||
flattenLogObject[childKey] = log[key][childKey];
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -29,7 +30,7 @@ function getBodyFieldValue(body: ILogBody, key: string): unknown {
|
||||
// only), splitting the key on `.`; otherwise fall back to FlatLogData
|
||||
// (attributes/resources/scope/top-level).
|
||||
export function getLogFieldValue(
|
||||
log: ILog,
|
||||
log: Pick<ILog, 'body'>,
|
||||
fieldName: string,
|
||||
isBodyJsonEnabled: boolean,
|
||||
): unknown {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
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 * as monaco from 'monaco-editor';
|
||||
import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker';
|
||||
import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker';
|
||||
|
||||
@@ -14,13 +11,10 @@ self.MonacoEnvironment = {
|
||||
if (label === 'json') {
|
||||
return new JsonWorker(); // JSON language service
|
||||
}
|
||||
// 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.
|
||||
// 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.
|
||||
},
|
||||
};
|
||||
|
||||
// The `monaco-editor` entry exposes JSON this way; the role editor reads `languages.json`.
|
||||
Object.assign(monaco.languages, { json: jsonContribution });
|
||||
|
||||
export { monaco };
|
||||
|
||||
@@ -41,12 +41,6 @@ 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 {
|
||||
@@ -173,41 +167,6 @@ 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,16 +53,14 @@ function AllAlertList(): JSX.Element {
|
||||
|
||||
const tab = urlQuery.get('tab');
|
||||
const subTab = urlQuery.get('subTab');
|
||||
const isRuleDetails =
|
||||
location.pathname === ROUTES.ALERT_HISTORY ||
|
||||
location.pathname === ROUTES.ALERT_OVERVIEW;
|
||||
const isAlertHistory = location.pathname === ROUTES.ALERT_HISTORY;
|
||||
const isAlertOverview = 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 (isRuleDetails) {
|
||||
if (isAlertHistory || isAlertOverview) {
|
||||
return AlertListTabs.ALERT_RULES;
|
||||
}
|
||||
if (isChannelDetails) {
|
||||
@@ -76,7 +74,7 @@ function AllAlertList(): JSX.Element {
|
||||
return AlertListTabs.CONFIGURATION;
|
||||
}
|
||||
return tab || AlertListTabs.ALERT_RULES;
|
||||
}, [isRuleDetails, isChannelDetails, tab]);
|
||||
}, [isAlertHistory, isAlertOverview, isChannelDetails, tab]);
|
||||
|
||||
const getActiveSubTab = useCallback((): AlertListSubTabs => {
|
||||
if (isChannelDetails) {
|
||||
@@ -116,18 +114,6 @@ 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();
|
||||
@@ -215,7 +201,7 @@ function AllAlertList(): JSX.Element {
|
||||
key: AlertListTabs.ALERT_RULES,
|
||||
children: (
|
||||
<div className="alert-rules-container">
|
||||
{isRuleDetails ? <AlertDetails /> : <AllAlertRules />}
|
||||
{isAlertHistory || isAlertOverview ? <AlertDetails /> : <AllAlertRules />}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
@@ -236,8 +222,12 @@ function AllAlertList(): JSX.Element {
|
||||
destroyInactiveTabPane
|
||||
items={items}
|
||||
activeKey={getActiveTab()}
|
||||
onTabClick={handleTopTabClick}
|
||||
className={`alerts-container ${isDetailsView ? 'alert-details-tabs' : ''}`}
|
||||
onChange={handleTopTabChange}
|
||||
className={`alerts-container ${
|
||||
isAlertHistory || isAlertOverview || isChannelDetails
|
||||
? 'alert-details-tabs'
|
||||
: ''
|
||||
}`}
|
||||
tabBarExtraContent={
|
||||
<HeaderRightSection
|
||||
enableAnnouncements={false}
|
||||
|
||||
40
frontend/src/pages/AuditLogs/AuditLogs.module.scss
Normal file
40
frontend/src/pages/AuditLogs/AuditLogs.module.scss
Normal file
@@ -0,0 +1,40 @@
|
||||
.auditLogsRoot {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.auditLogsRightPane {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.queryToolbar {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.queryToolbarLeft {
|
||||
display: flex;
|
||||
padding-left: var(--spacing-4);
|
||||
}
|
||||
|
||||
.queryToolbarRight {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
.actionsRow {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-4);
|
||||
padding: var(--spacing-4) var(--spacing-8);
|
||||
}
|
||||
11
frontend/src/pages/AuditLogs/README.md
Normal file
11
frontend/src/pages/AuditLogs/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# Audit Logs
|
||||
|
||||
Explorer for audit events at `/audit-logs`, admins only. It queries `signal: logs` with `source: audit` through `/api/v5/query_range`.
|
||||
|
||||
- `index.tsx`: the page (quick filters, query bar, list, details drawer).
|
||||
- `components/`: query bar, order by, options menu, results, details drawer and cells.
|
||||
- `hooks/`: the paged query, columns, and the active-log detail.
|
||||
- `store/`: persisted display options (format, font size, max lines, filters panel).
|
||||
- `types.ts`, `utils.ts`, `constants.ts`: audit log types, field getters, export columns.
|
||||
|
||||
The Raw and Default formats reuse `RawLogView` and `ListLogView`, and the drawer reuses the log detail navigation.
|
||||
140
frontend/src/pages/AuditLogs/__tests__/AuditLogs.test.tsx
Normal file
140
frontend/src/pages/AuditLogs/__tests__/AuditLogs.test.tsx
Normal file
@@ -0,0 +1,140 @@
|
||||
import { useAuditLogsQuery } from '../hooks/useAuditLogsQuery';
|
||||
import {
|
||||
NO_DELAY_USER_EVENT,
|
||||
render,
|
||||
screen,
|
||||
userEvent,
|
||||
} from 'tests/test-utils';
|
||||
|
||||
import { QueryKey } from 'react-query';
|
||||
import { Warning } from 'types/api';
|
||||
|
||||
import AuditLogs from '..';
|
||||
|
||||
jest.mock('../hooks/useAuditLogsQuery');
|
||||
jest.mock('components/QuickFilters/hooks/useSignalFieldApis');
|
||||
|
||||
jest.mock(
|
||||
'components/QuickFilters/QuickFiltersLayout/QuickFiltersLayout',
|
||||
() => ({
|
||||
__esModule: true,
|
||||
default: ({ children }: { children: React.ReactNode }): JSX.Element => (
|
||||
<div>{children}</div>
|
||||
),
|
||||
}),
|
||||
);
|
||||
jest.mock('container/TopNav/DateTimeSelectionV2', () => ({
|
||||
__esModule: true,
|
||||
default: (): null => null,
|
||||
}));
|
||||
jest.mock('components/DownloadOptionsMenu/DownloadOptionsMenu', () => ({
|
||||
__esModule: true,
|
||||
default: (): null => null,
|
||||
}));
|
||||
jest.mock('../components/QueryBar', () => ({ QueryBar: (): null => null }));
|
||||
jest.mock('../components/OrderBy', () => ({ OrderBy: (): null => null }));
|
||||
jest.mock('../components/OptionsMenu', () => ({
|
||||
OptionsMenu: (): null => null,
|
||||
}));
|
||||
jest.mock('components/QueryCancelledPlaceholder', () => ({
|
||||
__esModule: true,
|
||||
default: (): JSX.Element => <div data-testid="query-cancelled" />,
|
||||
}));
|
||||
jest.mock('components/WarningPopover/WarningPopover', () => ({
|
||||
__esModule: true,
|
||||
default: (): JSX.Element => <div data-testid="query-warning" />,
|
||||
}));
|
||||
jest.mock('../components/QueryResults', () => ({
|
||||
QueryResults: (): JSX.Element => <div data-testid="results" />,
|
||||
}));
|
||||
|
||||
const mockCancelQueries = jest.fn();
|
||||
|
||||
jest.mock('react-query', () => ({
|
||||
...jest.requireActual('react-query'),
|
||||
useQueryClient: (): { cancelQueries: jest.Mock } => ({
|
||||
cancelQueries: mockCancelQueries,
|
||||
}),
|
||||
}));
|
||||
|
||||
const KEY = ['audit-key'];
|
||||
|
||||
function mockQuery(
|
||||
isFetching: boolean,
|
||||
warning?: Warning,
|
||||
queryKey: QueryKey = KEY,
|
||||
): void {
|
||||
jest.mocked(useAuditLogsQuery).mockReturnValue({
|
||||
logs: [],
|
||||
isLoading: false,
|
||||
isFetching,
|
||||
isError: false,
|
||||
error: null,
|
||||
warning,
|
||||
queryKey,
|
||||
onEndReached: jest.fn(),
|
||||
});
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('AuditLogs cancelling a query', () => {
|
||||
it('cancels the running request and shows the cancelled placeholder', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
mockQuery(true);
|
||||
render(<AuditLogs />);
|
||||
|
||||
await user.click(screen.getByTestId('audit-logs-run-query-btn-cancel'));
|
||||
|
||||
expect(mockCancelQueries).toHaveBeenCalledWith(KEY);
|
||||
expect(screen.getByTestId('query-cancelled')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('results')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the cancelled placeholder while the query key stays', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
mockQuery(true);
|
||||
const { rerender } = render(<AuditLogs />);
|
||||
await user.click(screen.getByTestId('audit-logs-run-query-btn-cancel'));
|
||||
|
||||
mockQuery(false);
|
||||
rerender(<AuditLogs />);
|
||||
|
||||
expect(screen.getByTestId('query-cancelled')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows the results again when the query key changes', async () => {
|
||||
const user = userEvent.setup(NO_DELAY_USER_EVENT);
|
||||
mockQuery(true);
|
||||
const { rerender } = render(<AuditLogs />);
|
||||
await user.click(screen.getByTestId('audit-logs-run-query-btn-cancel'));
|
||||
|
||||
mockQuery(true, undefined, ['next-audit-key']);
|
||||
rerender(<AuditLogs />);
|
||||
|
||||
expect(screen.getByTestId('results')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('AuditLogs query warning', () => {
|
||||
it('shows the warning the query returned', () => {
|
||||
mockQuery(false, {
|
||||
code: 'W1',
|
||||
message: 'LIKE without a wildcard',
|
||||
url: '',
|
||||
warnings: [],
|
||||
});
|
||||
render(<AuditLogs />);
|
||||
|
||||
expect(screen.getByTestId('query-warning')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows no warning when the query returned none', () => {
|
||||
mockQuery(false);
|
||||
render(<AuditLogs />);
|
||||
|
||||
expect(screen.queryByTestId('query-warning')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
34
frontend/src/pages/AuditLogs/__tests__/auditLogFixture.ts
Normal file
34
frontend/src/pages/AuditLogs/__tests__/auditLogFixture.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { AuditLog, AuditOutcome, AuditPrincipalType } from '../types';
|
||||
|
||||
export function buildAuditLog(overrides: Partial<AuditLog> = {}): AuditLog {
|
||||
return {
|
||||
id: 'log-1',
|
||||
timestamp: 1_700_000_000_000_000_000,
|
||||
date: '2023-11-14T22:13:20Z',
|
||||
body: 'alice@acme.com (user-001) created dashboard (dash-001)',
|
||||
event_name: 'signoz.audit.create',
|
||||
severity_number: 9,
|
||||
severity_text: 'INFO',
|
||||
trace_id: '',
|
||||
span_id: '',
|
||||
trace_flags: 0,
|
||||
attributes: {
|
||||
'signoz.audit.action_category': 'configuration_change',
|
||||
'signoz.audit.outcome': AuditOutcome.SUCCESS,
|
||||
'signoz.audit.verb': 'create',
|
||||
'signoz.organization.id': 'org-001',
|
||||
'signoz.principal.id': 'user-001',
|
||||
'signoz.principal.type': AuditPrincipalType.USER,
|
||||
'signoz.principal.email': 'alice@acme.com',
|
||||
},
|
||||
resource: {
|
||||
attributes: {
|
||||
'service.name': 'signoz',
|
||||
'signoz.resource.kind': 'dashboard',
|
||||
'signoz.resource.id': 'dash-001-abcdef-123456',
|
||||
},
|
||||
},
|
||||
scope: { name: 'signoz.audit', version: '1', attributes: {} },
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
144
frontend/src/pages/AuditLogs/__tests__/utils.test.ts
Normal file
144
frontend/src/pages/AuditLogs/__tests__/utils.test.ts
Normal file
@@ -0,0 +1,144 @@
|
||||
import { Color } from '@signozhq/design-tokens';
|
||||
|
||||
import { AuditOutcome, AuditPrincipalType } from '../types';
|
||||
import {
|
||||
EMPTY_VALUE,
|
||||
getAuditFieldValue,
|
||||
getBody,
|
||||
getEventName,
|
||||
getOutcome,
|
||||
getPrincipalEmail,
|
||||
getResourceId,
|
||||
getResourceName,
|
||||
getRowHoverColor,
|
||||
getVerb,
|
||||
isServiceAccount,
|
||||
truncateId,
|
||||
} from '../utils';
|
||||
import { buildAuditLog } from './auditLogFixture';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('field getters', () => {
|
||||
it('read the values off the log', () => {
|
||||
const log = buildAuditLog();
|
||||
|
||||
expect(getOutcome(log)).toBe(AuditOutcome.SUCCESS);
|
||||
expect(getPrincipalEmail(log)).toBe('alice@acme.com');
|
||||
expect(getEventName(log)).toBe('signoz.audit.create');
|
||||
expect(getResourceName(log)).toBe('dashboard');
|
||||
expect(getResourceId(log)).toBe('dash-001-abcdef-123456');
|
||||
expect(getVerb(log)).toBe('create');
|
||||
expect(getBody(log)).toBe(
|
||||
'alice@acme.com (user-001) created dashboard (dash-001)',
|
||||
);
|
||||
});
|
||||
|
||||
it('fall back to the empty marker when a value is missing', () => {
|
||||
const log = buildAuditLog({
|
||||
event_name: '',
|
||||
body: '',
|
||||
attributes: {
|
||||
...buildAuditLog().attributes,
|
||||
'signoz.principal.email': undefined,
|
||||
'signoz.audit.verb': '',
|
||||
},
|
||||
resource: { attributes: { 'service.name': 'signoz' } },
|
||||
});
|
||||
|
||||
expect(getPrincipalEmail(log)).toBe(EMPTY_VALUE);
|
||||
expect(getEventName(log)).toBe(EMPTY_VALUE);
|
||||
expect(getResourceName(log)).toBe(EMPTY_VALUE);
|
||||
expect(getResourceId(log)).toBe(EMPTY_VALUE);
|
||||
expect(getVerb(log)).toBe(EMPTY_VALUE);
|
||||
expect(getBody(log)).toBe(EMPTY_VALUE);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isServiceAccount', () => {
|
||||
it.each([
|
||||
[AuditPrincipalType.SERVICE_ACCOUNT, true],
|
||||
[AuditPrincipalType.USER, false],
|
||||
[undefined, false],
|
||||
])('principal type %s gives %s', (principalType, expected) => {
|
||||
const log = buildAuditLog({
|
||||
attributes: {
|
||||
...buildAuditLog().attributes,
|
||||
'signoz.principal.type': principalType,
|
||||
},
|
||||
});
|
||||
|
||||
expect(isServiceAccount(log)).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('truncateId', () => {
|
||||
it('keeps the first and last four characters of a long id', () => {
|
||||
expect(truncateId('abcdefghijklmnop')).toBe('abcd…mnop');
|
||||
});
|
||||
|
||||
it('leaves an id of head + tail + 1 characters untouched', () => {
|
||||
expect(truncateId('123456789')).toBe('123456789');
|
||||
});
|
||||
|
||||
it('truncates an id one character past that boundary', () => {
|
||||
expect(truncateId('1234567890')).toBe('1234…7890');
|
||||
});
|
||||
|
||||
it('leaves the empty marker untouched', () => {
|
||||
expect(truncateId(EMPTY_VALUE)).toBe(EMPTY_VALUE);
|
||||
});
|
||||
|
||||
it('honours custom head and tail lengths', () => {
|
||||
expect(truncateId('abcdefghijklmnop', 2, 3)).toBe('ab…nop');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAuditFieldValue', () => {
|
||||
it.each([
|
||||
['signoz.principal.email', 'alice@acme.com'],
|
||||
['event_name', 'signoz.audit.create'],
|
||||
['signoz.resource.kind', 'dashboard'],
|
||||
['signoz.resource.id', 'dash-001-abcdef-123456'],
|
||||
['signoz.audit.outcome', AuditOutcome.SUCCESS],
|
||||
])('resolves %s', (fieldName, expected) => {
|
||||
expect(getAuditFieldValue(buildAuditLog(), fieldName)).toBe(expected);
|
||||
});
|
||||
|
||||
it('returns undefined for a field it does not map', () => {
|
||||
expect(getAuditFieldValue(buildAuditLog(), 'service.name')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('returns undefined when the log does not carry the value', () => {
|
||||
const log = buildAuditLog({
|
||||
resource: { attributes: { 'service.name': 'signoz' } },
|
||||
});
|
||||
|
||||
expect(getAuditFieldValue(log, 'signoz.resource.id')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRowHoverColor', () => {
|
||||
const failure = buildAuditLog({
|
||||
severity_text: 'ERROR',
|
||||
severity_number: 17,
|
||||
});
|
||||
|
||||
it('colors an info row blue in dark mode', () => {
|
||||
expect(getRowHoverColor(true, buildAuditLog())).toBe(
|
||||
`${Color.BG_ROBIN_500}40`,
|
||||
);
|
||||
});
|
||||
|
||||
it('colors an error row red in dark mode', () => {
|
||||
expect(getRowHoverColor(true, failure)).toBe(`${Color.BG_CHERRY_500}40`);
|
||||
});
|
||||
|
||||
it('colors an info row blue in light mode', () => {
|
||||
expect(getRowHoverColor(false, buildAuditLog())).toBe(Color.BG_ROBIN_100);
|
||||
});
|
||||
|
||||
it('colors an error row red in light mode', () => {
|
||||
expect(getRowHoverColor(false, failure)).toBe(Color.BG_CHERRY_100);
|
||||
});
|
||||
});
|
||||
});
|
||||
31
frontend/src/pages/AuditLogs/components/CopyLinkButton.tsx
Normal file
31
frontend/src/pages/AuditLogs/components/CopyLinkButton.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { useCallback } from 'react';
|
||||
import { Link } from '@signozhq/icons';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { Tooltip } from '@signozhq/ui/tooltip';
|
||||
import { useCopyLogLink } from 'hooks/logs/useCopyLogLink';
|
||||
|
||||
interface CopyLinkButtonProps {
|
||||
logId: string;
|
||||
}
|
||||
|
||||
export function CopyLinkButton({ logId }: CopyLinkButtonProps): JSX.Element {
|
||||
const { onLogCopy } = useCopyLogLink(logId);
|
||||
|
||||
const handleClick = useCallback((): void => onLogCopy(), [onLogCopy]);
|
||||
|
||||
return (
|
||||
<Tooltip title="Copy link to log" side="top">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
icon
|
||||
aria-label="Copy link to log"
|
||||
onClick={handleClick}
|
||||
testId="audit-log-detail-copy-link"
|
||||
>
|
||||
<Link size={14} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
[data-testid='audit-log-detail-drawer'] {
|
||||
--drawer-body-padding: 0 var(--spacing-8);
|
||||
}
|
||||
|
||||
.headerActions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
.summary {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: var(--spacing-8) var(--spacing-10);
|
||||
padding: var(--spacing-8) var(--spacing-0) var(--spacing-10);
|
||||
border-bottom: 1px solid var(--l1-border);
|
||||
}
|
||||
|
||||
.logLine {
|
||||
grid-column: 1 / -1;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
gap: var(--spacing-4);
|
||||
min-width: 0;
|
||||
margin-bottom: var(--spacing-2);
|
||||
}
|
||||
|
||||
.logText {
|
||||
min-width: 0;
|
||||
font-family: var(--code-base-400-font-family);
|
||||
font-size: var(--code-base-400-font-size);
|
||||
line-height: 18px;
|
||||
color: var(--l2-foreground);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: var(--code-base-400-font-family);
|
||||
}
|
||||
|
||||
.emphasis {
|
||||
color: var(--l1-foreground);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
.hint {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
padding: var(--spacing-4) 0;
|
||||
color: var(--l3-foreground);
|
||||
background: var(--drawer-background);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.dataViewer {
|
||||
:global(.pretty-view__search-wrapper),
|
||||
:global(.pretty-view__search-input) {
|
||||
background: var(--drawer-background);
|
||||
}
|
||||
}
|
||||
156
frontend/src/pages/AuditLogs/components/DetailsDrawer.tsx
Normal file
156
frontend/src/pages/AuditLogs/components/DetailsDrawer.tsx
Normal file
@@ -0,0 +1,156 @@
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
import { Drawer } from '@signozhq/ui/drawer';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import cx from 'classnames';
|
||||
import LogStateIndicator from 'components/Logs/LogStateIndicator/LogStateIndicator';
|
||||
import { FontSize } from 'container/OptionsMenu/types';
|
||||
import { DataViewer } from 'periscope/components/DataViewer';
|
||||
import { getBodyMessage } from 'lib/logs/logBody';
|
||||
|
||||
import { DATE_TIME_FORMATS } from '@/constants/dateTimeFormats';
|
||||
import { useTimezone } from '@/providers/Timezone';
|
||||
|
||||
import { AuditLog } from '../types';
|
||||
import {
|
||||
getOutcome,
|
||||
getPrincipalEmail,
|
||||
getResourceId,
|
||||
getResourceName,
|
||||
getVerb,
|
||||
isServiceAccount,
|
||||
} from '../utils';
|
||||
|
||||
import { CopyLinkButton } from './CopyLinkButton';
|
||||
import { DetailsField } from './DetailsField';
|
||||
import { OutcomeCell } from './QueryResultCells/OutcomeCell';
|
||||
|
||||
import styles from './DetailsDrawer.module.scss';
|
||||
import { useLogNavigation } from '@/components/LogDetail/LogDetailsHeader/useLogNavigation';
|
||||
import LogNavigation from '@/components/LogDetail/LogDetailsHeader/LogNavigation';
|
||||
import { LogNavigationHint } from '@/components/LogDetail/LogNavigationHint/LogNavigationHint';
|
||||
import { useArrowKeyNavigation } from '@/container/TracesExplorer/SpanDrawer/useArrowKeyNavigation';
|
||||
import { useCloseOnOutsideClick } from '@/hooks/logs/useCloseOnOutsideClick';
|
||||
|
||||
export const DetailsDrawer = ({
|
||||
logs,
|
||||
activeLog,
|
||||
handleCloseLogDetail,
|
||||
handleSetActiveLog,
|
||||
onScrollToLog,
|
||||
}: {
|
||||
logs: AuditLog[];
|
||||
activeLog: AuditLog | null;
|
||||
handleSetActiveLog: (log: AuditLog) => void;
|
||||
handleCloseLogDetail: () => void;
|
||||
onScrollToLog: (logId: string) => void;
|
||||
}): JSX.Element => {
|
||||
const { formatTimezoneAdjustedTimestamp } = useTimezone();
|
||||
|
||||
const { goToPrev, goToNext, isPrevDisabled, isNextDisabled } =
|
||||
useLogNavigation<AuditLog>({
|
||||
logs,
|
||||
activeLogId: activeLog?.id ?? '',
|
||||
onNavigateLog: handleSetActiveLog,
|
||||
onScrollToLog,
|
||||
});
|
||||
|
||||
useCloseOnOutsideClick(activeLog !== null, handleCloseLogDetail);
|
||||
|
||||
useArrowKeyNavigation({
|
||||
enabled: activeLog !== null,
|
||||
onNext: goToNext,
|
||||
onPrev: goToPrev,
|
||||
});
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
type="inspector"
|
||||
stack="overlay"
|
||||
open={activeLog !== null}
|
||||
onClose={handleCloseLogDetail}
|
||||
title={
|
||||
activeLog
|
||||
? formatTimezoneAdjustedTimestamp(
|
||||
activeLog.date,
|
||||
DATE_TIME_FORMATS.ISO_DATETIME_MS,
|
||||
)
|
||||
: ''
|
||||
}
|
||||
headerSuffix={
|
||||
<div className={styles.headerActions}>
|
||||
{activeLog && <CopyLinkButton logId={activeLog.id} />}
|
||||
<LogNavigation
|
||||
onNavigatePrev={goToPrev}
|
||||
onNavigateNext={goToNext}
|
||||
isPrevDisabled={isPrevDisabled}
|
||||
isNextDisabled={isNextDisabled}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
width="extra-wide"
|
||||
testId="audit-log-detail-drawer"
|
||||
closePosition="start"
|
||||
>
|
||||
{activeLog ? (
|
||||
<div className={styles.summary} data-testid="audit-log-detail-summary">
|
||||
<div className={styles.logLine} data-testid="audit-log-detail-body">
|
||||
<LogStateIndicator
|
||||
fontSize={FontSize.MEDIUM}
|
||||
severityText={activeLog.severity_text}
|
||||
severityNumber={activeLog.severity_number}
|
||||
/>
|
||||
<span className={styles.logText}>{getBodyMessage(activeLog.body)}</span>
|
||||
</div>
|
||||
<DetailsField label="Principal" testId="audit-log-detail-principal">
|
||||
<Typography
|
||||
variant="paragraph"
|
||||
size="base"
|
||||
weight="regular"
|
||||
color="primary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
{getPrincipalEmail(activeLog)}
|
||||
</Typography>
|
||||
{isServiceAccount(activeLog) && (
|
||||
<Badge variant="outlined" color="info" textTransform="none">
|
||||
BOT
|
||||
</Badge>
|
||||
)}
|
||||
</DetailsField>
|
||||
<DetailsField label="Outcome" testId="audit-log-detail-outcome">
|
||||
<OutcomeCell outcome={getOutcome(activeLog)} />
|
||||
</DetailsField>
|
||||
<DetailsField label="Event" testId="audit-log-detail-event">
|
||||
<span className={cx(styles.mono, styles.emphasis)}>
|
||||
{getVerb(activeLog)}
|
||||
</span>
|
||||
</DetailsField>
|
||||
<DetailsField label="Resource" testId="audit-log-detail-resource">
|
||||
<span className={cx(styles.mono, styles.emphasis)}>
|
||||
{getResourceName(activeLog)}
|
||||
</span>
|
||||
</DetailsField>
|
||||
<DetailsField label="Resource ID" testId="audit-log-detail-resource-id">
|
||||
<span className={cx(styles.mono, styles.muted)}>
|
||||
{getResourceId(activeLog)}
|
||||
</span>
|
||||
</DetailsField>
|
||||
</div>
|
||||
) : null}
|
||||
<div className={styles.dataViewer}>
|
||||
<DataViewer
|
||||
data={activeLog ? activeLog : {}}
|
||||
drawerKey="audit-log-detail"
|
||||
fontSize={13}
|
||||
jsonString={JSON.stringify(activeLog ?? {}, null, 2)}
|
||||
/>
|
||||
</div>
|
||||
{activeLog ? (
|
||||
<div className={styles.hint} data-testid="audit-log-detail-navigation-hint">
|
||||
<LogNavigationHint />
|
||||
</div>
|
||||
) : null}
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,15 @@
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.value {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--spacing-3);
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
32
frontend/src/pages/AuditLogs/components/DetailsField.tsx
Normal file
32
frontend/src/pages/AuditLogs/components/DetailsField.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
|
||||
import styles from './DetailsField.module.scss';
|
||||
|
||||
interface DetailsFieldProps {
|
||||
label: string;
|
||||
testId: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function DetailsField({
|
||||
label,
|
||||
testId,
|
||||
children,
|
||||
}: DetailsFieldProps): JSX.Element {
|
||||
return (
|
||||
<div className={styles.field} data-testid={testId}>
|
||||
<Typography
|
||||
variant="uppercase"
|
||||
size="small"
|
||||
weight="bold"
|
||||
color="secondary"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
{label}
|
||||
</Typography>
|
||||
<div className={styles.value}>{children}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.expandIcon {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ArrowUpToLine, Filter } from '@signozhq/icons';
|
||||
import { Button } from '@signozhq/ui/button';
|
||||
import { Tooltip } from '@signozhq/ui/tooltip';
|
||||
|
||||
import styles from './FilterExpandButton.module.scss';
|
||||
|
||||
interface FilterExpandButtonProps {
|
||||
onClick: () => void;
|
||||
}
|
||||
|
||||
export function FilterExpandButton({
|
||||
onClick,
|
||||
}: FilterExpandButtonProps): JSX.Element {
|
||||
return (
|
||||
<Tooltip title="Show Filters">
|
||||
<Button
|
||||
variant="outlined"
|
||||
size="md"
|
||||
aria-label="Show filters"
|
||||
color="secondary"
|
||||
onClick={onClick}
|
||||
testId="audit-logs-expand-filters-btn"
|
||||
>
|
||||
<Filter size={12} />
|
||||
<ArrowUpToLine size={12} className={styles.expandIcon} />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
43
frontend/src/pages/AuditLogs/components/OptionsMenu.tsx
Normal file
43
frontend/src/pages/AuditLogs/components/OptionsMenu.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useMemo } from 'react';
|
||||
import LogsFormatOptionsMenu from 'components/LogsFormatOptionsMenu/LogsFormatOptionsMenu';
|
||||
import { OptionsMenuConfig } from 'container/OptionsMenu/types';
|
||||
|
||||
import { useAuditLogsOptionsStore } from '../store/useAuditLogsOptionsStore';
|
||||
|
||||
const FORMAT_ITEMS = [
|
||||
{ key: 'raw', label: 'Raw' },
|
||||
{ key: 'list', label: 'Default' },
|
||||
{ key: 'table', label: 'Column' },
|
||||
];
|
||||
|
||||
export function OptionsMenu(): JSX.Element {
|
||||
const fontSize = useAuditLogsOptionsStore((state) => state.fontSize);
|
||||
const setFontSize = useAuditLogsOptionsStore((state) => state.setFontSize);
|
||||
const format = useAuditLogsOptionsStore((state) => state.format);
|
||||
const setFormat = useAuditLogsOptionsStore((state) => state.setFormat);
|
||||
const maxLines = useAuditLogsOptionsStore((state) => state.maxLines);
|
||||
const setMaxLines = useAuditLogsOptionsStore((state) => state.setMaxLines);
|
||||
|
||||
const config: OptionsMenuConfig = useMemo(
|
||||
() => ({
|
||||
fontSize: { value: fontSize, onChange: setFontSize },
|
||||
format: {
|
||||
value: format,
|
||||
onChange: setFormat,
|
||||
},
|
||||
maxLines: {
|
||||
value: maxLines,
|
||||
onChange: (value): void => setMaxLines(Number(value)),
|
||||
},
|
||||
}),
|
||||
[fontSize, setFontSize, format, setFormat, maxLines, setMaxLines],
|
||||
);
|
||||
|
||||
return (
|
||||
<LogsFormatOptionsMenu
|
||||
items={FORMAT_ITEMS}
|
||||
selectedOptionFormat={format}
|
||||
config={config}
|
||||
/>
|
||||
);
|
||||
}
|
||||
24
frontend/src/pages/AuditLogs/components/OrderBy.module.scss
Normal file
24
frontend/src/pages/AuditLogs/components/OrderBy.module.scss
Normal file
@@ -0,0 +1,24 @@
|
||||
.orderBy {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
color: var(--l2-foreground);
|
||||
}
|
||||
|
||||
.select {
|
||||
:global(.order-by-select) {
|
||||
width: 100px;
|
||||
|
||||
:global(.ant-select-selector) {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
53
frontend/src/pages/AuditLogs/components/OrderBy.tsx
Normal file
53
frontend/src/pages/AuditLogs/components/OrderBy.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { ArrowUp10, Minus } from '@signozhq/icons';
|
||||
import { Typography } from '@signozhq/ui/typography';
|
||||
import { TelemetrytypesSourceDTO } from 'api/generated/services/sigNoz.schemas';
|
||||
import ListViewOrderBy from 'components/OrderBy/ListViewOrderBy';
|
||||
import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
|
||||
import { DataSource } from 'types/common/queryBuilder';
|
||||
import { getListOrderBy, setListOrderBy } from 'utils/explorerUtils';
|
||||
|
||||
import styles from './OrderBy.module.scss';
|
||||
|
||||
const FIELD_KEYS_CONFIG = { source: TelemetrytypesSourceDTO.audit };
|
||||
|
||||
export function OrderBy(): JSX.Element {
|
||||
const { stagedQuery, currentQuery, redirectWithQueryBuilderData } =
|
||||
useQueryBuilder();
|
||||
|
||||
const orderBy = useMemo(() => getListOrderBy(stagedQuery), [stagedQuery]);
|
||||
|
||||
const handleOrderChange = useCallback(
|
||||
(value: string): void => {
|
||||
redirectWithQueryBuilderData(setListOrderBy(currentQuery, value));
|
||||
},
|
||||
[currentQuery, redirectWithQueryBuilderData],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.orderBy} data-testid="audit-logs-order-by">
|
||||
<div className={styles.label}>
|
||||
<Typography
|
||||
variant="label"
|
||||
size="small"
|
||||
weight="regular"
|
||||
color="inherit"
|
||||
as="span"
|
||||
textOverflow="wrap"
|
||||
>
|
||||
Order by
|
||||
</Typography>
|
||||
<Minus size={14} />
|
||||
<ArrowUp10 size={14} />
|
||||
</div>
|
||||
<div className={styles.select}>
|
||||
<ListViewOrderBy
|
||||
value={orderBy}
|
||||
onChange={handleOrderChange}
|
||||
dataSource={DataSource.LOGS}
|
||||
fieldKeysConfig={FIELD_KEYS_CONFIG}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
.queryBar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
39
frontend/src/pages/AuditLogs/components/QueryBar.tsx
Normal file
39
frontend/src/pages/AuditLogs/components/QueryBar.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import { QueryBuilderV2 } from '@/components/QueryBuilderV2';
|
||||
import styles from './QueryBar.module.scss';
|
||||
import { DataSource } from '@/types/common/queryBuilder';
|
||||
import { initialQueriesMap, PANEL_TYPES } from '@/constants/queryBuilder';
|
||||
import { useQueryBuilder } from '@/hooks/queryBuilder/useQueryBuilder';
|
||||
import { useMemo } from 'react';
|
||||
import { useShareBuilderUrl } from '@/hooks/queryBuilder/useShareBuilderUrl';
|
||||
import { TelemetrytypesSourceDTO } from '@/api/generated/services/sigNoz.schemas';
|
||||
|
||||
export function QueryBar(): JSX.Element {
|
||||
const { updateAllQueriesOperators } = useQueryBuilder();
|
||||
|
||||
const defaultValue = useMemo(
|
||||
() =>
|
||||
updateAllQueriesOperators(
|
||||
initialQueriesMap.logs,
|
||||
PANEL_TYPES.LIST,
|
||||
DataSource.LOGS,
|
||||
TelemetrytypesSourceDTO.audit,
|
||||
),
|
||||
[updateAllQueriesOperators],
|
||||
);
|
||||
|
||||
useShareBuilderUrl({ defaultValue });
|
||||
|
||||
return (
|
||||
<div className={styles.queryBar}>
|
||||
<QueryBuilderV2
|
||||
isRawQuery
|
||||
config={{
|
||||
initialDataSource: DataSource.LOGS,
|
||||
queryVariant: 'static',
|
||||
}}
|
||||
panelType={PANEL_TYPES.LIST}
|
||||
showOnlyWhereClause
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
.emailCell {
|
||||
--tanstack-table-cell-color: var(--l1-foreground);
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-3);
|
||||
min-width: 0;
|
||||
padding-right: var(--spacing-8);
|
||||
}
|
||||
|
||||
.email {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Badge } from '@signozhq/ui/badge';
|
||||
import { Tooltip } from '@signozhq/ui/tooltip';
|
||||
import TanStackTable from 'components/TanStackTableView';
|
||||
|
||||
import styles from './EmailCell.module.scss';
|
||||
|
||||
interface EmailCellProps {
|
||||
email: string;
|
||||
isBot: boolean;
|
||||
}
|
||||
|
||||
export function EmailCell({ email, isBot }: EmailCellProps): JSX.Element {
|
||||
return (
|
||||
<div className={styles.emailCell}>
|
||||
<Tooltip title={email}>
|
||||
<TanStackTable.Text className={styles.email} data-testid="audit-logs-email">
|
||||
{email}
|
||||
</TanStackTable.Text>
|
||||
</Tooltip>
|
||||
{isBot && (
|
||||
<span className={styles.badge} data-testid="audit-logs-bot-badge">
|
||||
<Badge variant="outlined" color="info" textTransform="none">
|
||||
BOT
|
||||
</Badge>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
.monospaceCell {
|
||||
--tanstack-table-cell-color: var(--l1-foreground);
|
||||
|
||||
font-family: var(--code-base-400-font-family);
|
||||
font-weight: 500;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user