Compare commits

...

3 Commits

Author SHA1 Message Date
Hardik
2edb9c1bfb chore(sentry): exclude anonymous sentry errors 2026-11-16 08:52:11 +05:30
dependabot[bot]
f7220ae79c chore(deps): bump certifi from 2026.7.22 to 2026.10.19 in /tests (#13209)
Some checks are pending
build-staging / prepare (push) Waiting to run
build-staging / js-build (push) Blocked by required conditions
build-staging / go-build (push) Blocked by required conditions
build-staging / staging (push) Blocked by required conditions
cacheci / tests (push) Waiting to run
Release Drafter / update_release_draft (push) Waiting to run
Bumps [certifi](https://github.com/certifi/python-certifi) from
2026.7.22 to 2026.10.19.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="662df63d79"><code>662df63</code></a>
Restore unaffected emSign roots (<a
href="https://redirect.github.com/certifi/python-certifi/issues/439">#439</a>)
(<a
href="https://redirect.github.com/certifi/python-certifi/issues/440">#440</a>)</li>
<li><a
href="5cb238caee"><code>5cb238c</code></a>
Remove emsign (<a
href="https://redirect.github.com/certifi/python-certifi/issues/437">#437</a>)</li>
<li><a
href="69494a764d"><code>69494a7</code></a>
Bump actions/download-artifact from 8.0.1 to 8.0.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/436">#436</a>)</li>
<li><a
href="029c7b0913"><code>029c7b0</code></a>
Bump actions/upload-artifact from 7.0.1 to 7.0.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/435">#435</a>)</li>
<li><a
href="9d0a8f1f3a"><code>9d0a8f1</code></a>
Add support for Python 3.15 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/432">#432</a>)</li>
<li><a
href="db472abf0a"><code>db472ab</code></a>
Bump pypa/gh-action-pypi-publish from 1.14.1 to 1.14.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/431">#431</a>)</li>
<li>See full diff in <a
href="https://github.com/certifi/python-certifi/compare/2026.07.22...2026.10.19">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=certifi&package-manager=uv&previous-version=2026.7.22&new-version=2026.10.19)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/SigNoz/signoz/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2026-11-15 19:52:26 +00:00
Gaurav Tewari
e010c4fa03 fix (ai-o11y): use ai endpoint in query aggregate suggestion (#13521)
Some checks failed
build-staging / prepare (push) Has been cancelled
cacheci / tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
build-staging / js-build (push) Has been cancelled
build-staging / go-build (push) Has been cancelled
build-staging / staging (push) Has been cancelled
#### Description

- AI queries now suggest the aggregates in the aggregation input with
/ai endpoint
- Keys come from `useFieldKeysSuggestion`, which routes AI queries to
`/api/v1/ai_observability/fields/keys`, replacing the deprecated
`getKeySuggestions`. AI queries send the same `fieldDataType=number`
filter as other query types.

#### Issues closed by this PR


https://github.com/orgs/SigNoz/projects/59/views/18?pane=issue&itemId=257298696&issue=SigNoz%7Cnerve-pod%7C377


#### Screenshots / Screen Recordings



https://github.com/user-attachments/assets/a0493d43-9c1b-4768-8ce8-4d4a67a67f25


#### Additional Information

- The `trace.*` suggestions need the backend to return the trace
aggregates for `fieldDataType=number`. Until it does, AI queries suggest
numeric span keys only.

---------

Co-authored-by: Gaurav Tewari <tewarig@users.noreply.github.com>
2026-11-14 06:40:46 +00:00
6 changed files with 256 additions and 70 deletions

View File

@@ -3,6 +3,7 @@ import { AxiosError, AxiosHeaders } from 'axios';
import {
hasNoAppFrames,
isInjectedScriptError,
isExpectedRequestFailure,
isExternalIntegrationError,
SENTRY_IGNORE_ERRORS,
@@ -129,6 +130,24 @@ describe('hasNoAppFrames', () => {
});
});
describe('isInjectedScriptError', () => {
it('drops an error thrown from eval code behind the Sentry wrapper', () => {
expect(
isInjectedScriptError(eventWithFrames(APP_BUNDLE, '<anonymous>')),
).toBe(true);
});
it('keeps an error thrown from our bundle', () => {
expect(
isInjectedScriptError(eventWithFrames('<anonymous>', APP_BUNDLE)),
).toBe(false);
});
it('keeps an error without a stack trace', () => {
expect(isInjectedScriptError({ type: undefined })).toBe(false);
});
});
describe('SENTRY_IGNORE_ERRORS', () => {
it('ignores the bundled PostHog recorder load failure', () => {
expect(

View File

@@ -42,6 +42,7 @@ import {
hasNoAppFrames,
isExpectedRequestFailure,
isExternalIntegrationError,
isInjectedScriptError,
SENTRY_IGNORE_ERRORS,
} from './sentryFilters';
@@ -355,7 +356,7 @@ function App(): JSX.Element {
return null;
}
if (isExternalIntegrationError(event)) {
if (isExternalIntegrationError(event) || isInjectedScriptError(event)) {
return null;
}

View File

@@ -44,6 +44,15 @@ export function hasNoAppFrames(event: ErrorEvent): boolean {
);
}
// The throwing frame is the last one. Sentry's own timer wrapper is bundled
// with the app, so only the top frame shows the code came from an eval.
export function isInjectedScriptError(event: ErrorEvent): boolean {
return (event.exception?.values ?? []).some((exception) => {
const frames = exception.stacktrace?.frames ?? [];
return frames[frames.length - 1]?.filename === '<anonymous>';
});
}
// PostHog's lazy recorder, the Pylon widget and Appcues.
const EXTERNAL_SCRIPT_URLS = [
/^https?:\/\/[^/]+\.posthog\.com\//,

View File

@@ -1,7 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable sonarjs/cognitive-complexity */
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useQuery } from 'react-query';
import {
autocompletion,
closeCompletion,
@@ -24,14 +23,16 @@ import CodeMirror, {
ViewUpdate,
} from '@uiw/react-codemirror';
import { Button, Popover, Tooltip } from 'antd';
import { getKeySuggestions } from 'api/querySuggestions/getKeySuggestions';
import { QueryBuilderKeys } from 'constants/queryBuilder';
import { TelemetrytypesFieldDataTypeDTO } from 'api/generated/services/sigNoz.schemas';
import { tracesAggregateOperatorOptions } from 'constants/queryBuilderOperators';
import { useFieldKeysSuggestion } from 'hooks/querySuggestions/useFieldKeysSuggestion';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { Info, TriangleAlert } from '@signozhq/icons';
import { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
import { FieldDataType } from 'types/api/v5/queryRange';
import { TracesAggregatorOperator } from 'types/common/queryBuilder';
import {
DATA_SOURCE_TO_SIGNAL,
TracesAggregatorOperator,
} from 'types/common/queryBuilder';
import { useQueryBuilderV2Context } from '../../QueryBuilderV2Context';
@@ -41,6 +42,12 @@ const chipDecoration = Decoration.mark({
class: 'chip-decorator',
});
const OPERATORS_WITHOUT_DATA_TYPE: string[] = [
TracesAggregatorOperator.COUNT,
TracesAggregatorOperator.COUNT_DISTINCT,
TracesAggregatorOperator.RATE,
];
const operatorArgMeta: Record<
string,
{ acceptsArgs: boolean; multiple: boolean }
@@ -310,31 +317,19 @@ function QueryAggregationSelect({
// Find function context for fetching suggestions
const functionContextForFetch = getFunctionContextAtCursor(input, cursorPos);
const { data: aggregateAttributeData, isLoading: isLoadingFields } = useQuery(
[
QueryBuilderKeys.GET_AGGREGATE_ATTRIBUTE,
functionContextForFetch,
queryData.dataSource,
],
() => {
const operatorsWithoutDataType: (string | undefined)[] = [
TracesAggregatorOperator.COUNT,
TracesAggregatorOperator.COUNT_DISTINCT,
TracesAggregatorOperator.RATE,
];
const fieldDataType: FieldDataType | undefined =
functionContextForFetch &&
operatorsWithoutDataType.includes(functionContextForFetch)
? undefined
: 'number';
return getKeySuggestions({
signal: queryData.dataSource,
searchText: '',
fieldDataType,
});
const numericKeysOnly = !(
functionContextForFetch &&
OPERATORS_WITHOUT_DATA_TYPE.includes(functionContextForFetch)
);
const { data: fieldKeys, isLoading: isLoadingFields } = useFieldKeysSuggestion(
{
signal: DATA_SOURCE_TO_SIGNAL[queryData.dataSource],
searchText: '',
fieldDataType: numericKeysOnly
? TelemetrytypesFieldDataTypeDTO.number
: undefined,
},
queryData.builderQueryType,
{
enabled:
!!functionContextForFetch &&
@@ -427,48 +422,42 @@ function QueryAggregationSelect({
}),
);
// Memoize field suggestions from API (no filtering here)
// Memoize field suggestions from API (no search filtering here)
const fieldSuggestions = useMemo(
() =>
Object.keys(aggregateAttributeData?.data.data.keys || {}).flatMap((key) => {
const attributeKeys = aggregateAttributeData?.data.data.keys[key];
if (!attributeKeys) {
return [];
}
(fieldKeys ?? []).map((key) => ({
// The backend reads trace.-prefixed columns as per-trace aggregates.
label: key.fieldContext === 'trace' ? `trace.${key.name}` : key.name,
type: 'variable',
info: key.fieldDataType,
apply: (
view: EditorView,
completion: Completion,
from: number,
to: number,
): void => {
const text = view.state.sliceDoc(0, from);
const funcName = getFunctionContextAtCursor(text, from);
const multiple = funcName ? operatorArgMeta[funcName]?.multiple : false;
return attributeKeys.map((attributeKey) => ({
label: attributeKey.name,
type: 'variable',
info: attributeKey.fieldDataType,
apply: (
view: EditorView,
completion: Completion,
from: number,
to: number,
): void => {
const text = view.state.sliceDoc(0, from);
const funcName = getFunctionContextAtCursor(text, from);
const multiple = funcName ? operatorArgMeta[funcName]?.multiple : false;
// Insert the selected key followed by either a comma or closing parenthesis
const insertText = multiple
? `${completion.label},`
: `${completion.label}) `;
const cursorPos = from + insertText.length; // Use insertText.length instead of hardcoded values
// Insert the selected key followed by either a comma or closing parenthesis
const insertText = multiple
? `${completion.label},`
: `${completion.label}) `;
const cursorPos = from + insertText.length; // Use insertText.length instead of hardcoded values
view.dispatch({
changes: { from, to, insert: insertText },
selection: { anchor: cursorPos },
});
view.dispatch({
changes: { from, to, insert: insertText },
selection: { anchor: cursorPos },
});
// Trigger next suggestions after a small delay
setTimeout(() => {
safeStartCompletion();
}, 50);
},
}));
}) || [],
[aggregateAttributeData, safeStartCompletion],
// Trigger next suggestions after a small delay
setTimeout(() => {
safeStartCompletion();
}, 50);
},
})),
[fieldKeys, safeStartCompletion],
);
const aggregatorAutocomplete = useMemo(

View File

@@ -0,0 +1,168 @@
import {
GetAIObservabilityFieldsKeys200,
GetFieldsKeys200,
TelemetrytypesFieldContextDTO,
TelemetrytypesFieldDataTypeDTO,
TelemetrytypesSignalDTO,
TelemetrytypesTelemetryFieldKeyDTO,
} from 'api/generated/services/sigNoz.schemas';
import { ENVIRONMENT } from 'constants/env';
import { initialQueriesMap } from 'constants/queryBuilder';
import { rest, server } from 'mocks-server/server';
import { render, screen, userEvent, waitFor } from 'tests/test-utils';
import type { IBuilderQuery } from 'types/api/queryBuilder/queryBuilderData';
import { QueryBuilderV2Provider } from '../../QueryBuilderV2Context';
import QueryAggregationSelect from '../QueryAggregation/QueryAggregationSelect';
import { mockCodeMirrorDomApis } from './codemirrorDomMocks';
const EDITOR_TEST_ID = 'query-aggregation-editor';
// CodeMirror's suggestion popup is slow to open under a parallel jest run.
const SUGGESTIONS_TIMEOUT_MS = 5000;
const TEST_TIMEOUT_MS = 15000;
const fieldKey = (
name: string,
fieldContext: TelemetrytypesFieldContextDTO,
fieldDataType: TelemetrytypesFieldDataTypeDTO,
): TelemetrytypesTelemetryFieldKeyDTO => ({
name,
fieldContext,
fieldDataType,
signal: TelemetrytypesSignalDTO.traces,
});
const durationNano = fieldKey(
'duration_nano',
TelemetrytypesFieldContextDTO.span,
TelemetrytypesFieldDataTypeDTO.float64,
);
const serviceName = fieldKey(
'service.name',
TelemetrytypesFieldContextDTO.resource,
TelemetrytypesFieldDataTypeDTO.string,
);
const totalTokens = fieldKey(
'total_tokens',
TelemetrytypesFieldContextDTO.trace,
TelemetrytypesFieldDataTypeDTO.float64,
);
const aiKeysResponse = (
keys: TelemetrytypesTelemetryFieldKeyDTO[],
): GetAIObservabilityFieldsKeys200 => ({
status: 'success',
data: {
complete: true,
keys: Object.fromEntries(keys.map((key) => [key.name, [key]])),
},
});
// Assumes the AI endpoint's number filter also returns the float64 trace aggregates.
const aiKeysFor = (
params: URLSearchParams,
): TelemetrytypesTelemetryFieldKeyDTO[] =>
params.get('fieldDataType') === TelemetrytypesFieldDataTypeDTO.number
? [durationNano, totalTokens]
: [durationNano, serviceName, totalTokens];
const keysResponse: GetFieldsKeys200 = {
status: 'success',
data: { complete: true, keys: { duration_nano: [durationNano] } },
};
const aiQuery: IBuilderQuery = {
...(initialQueriesMap.traces.builder.queryData[0] as IBuilderQuery),
builderQueryType: 'builder_ai_query',
aggregations: [],
};
const aiKeysRequests: URLSearchParams[] = [];
const keysRequests: URLSearchParams[] = [];
beforeAll(() => {
mockCodeMirrorDomApis();
});
beforeEach(() => {
aiKeysRequests.length = 0;
keysRequests.length = 0;
server.use(
rest.get(
`${ENVIRONMENT.baseURL}/api/v1/ai_observability/fields/keys`,
(req, res, ctx) => {
aiKeysRequests.push(req.url.searchParams);
return res(
ctx.status(200),
ctx.json(aiKeysResponse(aiKeysFor(req.url.searchParams))),
);
},
),
rest.get(`${ENVIRONMENT.baseURL}/api/v1/fields/keys`, (req, res, ctx) => {
keysRequests.push(req.url.searchParams);
return res(ctx.status(200), ctx.json(keysResponse));
}),
);
});
async function enterAggregation(text: string): Promise<void> {
const user = userEvent.setup({ pointerEventsCheck: 0 });
render(
<QueryBuilderV2Provider>
<QueryAggregationSelect queryData={aiQuery} />
</QueryBuilderV2Provider>,
);
const content = (
await screen.findByTestId(EDITOR_TEST_ID)
).querySelector<HTMLElement>('.cm-content');
if (!content) {
throw new Error('CodeMirror content element not rendered');
}
await user.click(content);
// Typed keys drop under load: a re-render's dispatch discards DOM input CodeMirror hasn't read yet.
await user.paste(text);
await user.keyboard('{Control>} {/Control}');
}
function suggestionLabels(): string[] {
return Array.from(
screen.getByTestId(EDITOR_TEST_ID).querySelectorAll('.cm-completionLabel'),
(label) => label.textContent ?? '',
).sort();
}
describe('QueryAggregationSelect field suggestions for an AI query', () => {
it.each([
{
aggregation: 'avg(',
fieldDataType: TelemetrytypesFieldDataTypeDTO.number,
labels: ['duration_nano', 'trace.total_tokens'],
},
{
aggregation: 'count_distinct(',
fieldDataType: null,
labels: ['duration_nano', 'service.name', 'trace.total_tokens'],
},
])(
'suggests keys from the AI keys endpoint, with trace aggregates as trace.<name>, for $aggregation',
async ({ aggregation, fieldDataType, labels }) => {
await enterAggregation(aggregation);
await waitFor(() => expect(suggestionLabels()).toStrictEqual(labels), {
timeout: SUGGESTIONS_TIMEOUT_MS,
});
expect(keysRequests).toHaveLength(0);
expect(
aiKeysRequests.map((params) => ({
signal: params.get('signal'),
fieldDataType: params.get('fieldDataType'),
fieldContext: params.get('fieldContext'),
})),
).toStrictEqual([{ signal: 'traces', fieldDataType, fieldContext: null }]);
},
TEST_TIMEOUT_MS,
);
});

6
tests/uv.lock generated
View File

@@ -86,11 +86,11 @@ wheels = [
[[package]]
name = "certifi"
version = "2026.7.22"
version = "2026.10.19"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/a3/c2/24167ea9858356b47a87a50d39908bfdb72ceeefe0041586e704e5376b3a/certifi-2026.7.22.tar.gz", hash = "sha256:741e2c3b351ddf169a738da9f2c048608ff7f2c5cc02f1ebc6b118bb090d5d55", size = 138112, upload-time = "2026-07-22T03:35:12.644Z" }
sdist = { url = "https://files.pythonhosted.org/packages/a6/bd/1436c50cc46699de0230fbaacc1d1de7bfec413176099949e9d5112e88f2/certifi-2026.10.19.tar.gz", hash = "sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae", size = 137598, upload-time = "2026-10-20T02:24:16.604Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/0b/a7/71ac2cff56fec219ed242bb11b8efb69fcc4bec75db06fb7bfe35de520e6/certifi-2026.7.22-py3-none-any.whl", hash = "sha256:62f22742b58a1a33014a2b6b706588a8d7e2a88ae7bd1a6ebe8c992928483775", size = 136983, upload-time = "2026-07-22T03:35:11.276Z" },
{ url = "https://files.pythonhosted.org/packages/c4/51/29046e48f693c54e5b7412216d447a1d8362c9653148d98c02cdf65fa733/certifi-2026.10.19-py3-none-any.whl", hash = "sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b", size = 136464, upload-time = "2026-10-20T02:24:15.072Z" },
]
[[package]]