Compare commits

...

3 Commits

Author SHA1 Message Date
Naman Verma
31b8681ca5 test: add integration test 2026-11-18 14:21:18 +05:30
Naman Verma
d9d410b8a7 fix: use default title and body when notification content rendering fails 2026-11-18 14:10:52 +05:30
Nityananda Gohain
9d5c5871cb fix(ai-o11y): return trace aggregate keys as number (#13525)
Some checks failed
build-staging / prepare (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
cacheci / tests (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
## Description

- `/api/v1/ai_observability/fields/keys` returned the `trace.`
aggregates as `float64`, unlike every other numeric key, so
`fieldDataType=number` dropped them.
- Aggregates are now declared `number`, and
`FieldKeySelector.MatchesKey` treats `number`/`int64`/`float64` as one
family. The static-fields matcher in `telemetrymetadata` now reuses it
instead of keeping its
  own copy.
- Frontend default AI trace columns switch to `number` so their column
ids still match the keys endpoint. Otherwise the field selector offers
them again as not added.

  ## Issues closed by this PR

  Closes SigNoz/nerve-pod#639

  ## Additional Information

Concerns
* If the user have removed one of these columns in select fields, it
will appear again, user has to remove it once more.
* Since saved view is not released so not a problem if we merge this
before that goes out.
2026-11-18 04:43:28 +00:00
16 changed files with 313 additions and 81 deletions

View File

@@ -33,7 +33,7 @@ jest.mock('../../TracesTable/TracesTable', () => ({
<button
data-testid="remove-total-tokens"
type="button"
onClick={(): void => onColumnRemove?.('trace:total_tokens:float64')}
onClick={(): void => onColumnRemove?.('trace:total_tokens:number')}
>
remove
</button>
@@ -48,7 +48,7 @@ const QUERY_RANGE_URL = `${ENVIRONMENT.baseURL}/api/v5/query_range`;
const TOTAL_TOKENS = {
name: 'total_tokens',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
};
const storedColumnNames = (): string[] | undefined => {

View File

@@ -63,7 +63,7 @@ const mockFieldKeys = (names: string[]): void => {
{
name,
fieldContext: TelemetrytypesFieldContextDTO.trace,
fieldDataType: TelemetrytypesFieldDataTypeDTO.float64,
fieldDataType: TelemetrytypesFieldDataTypeDTO.number,
},
],
]),

View File

@@ -73,7 +73,7 @@ export const TRACE_VIEW_DEFAULT_COLUMNS: TelemetryFieldKey[] = [
name: 'estimated_total_cost',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{ name: 'trace_duration_nano' },
{ name: 'span_count' },
@@ -81,37 +81,37 @@ export const TRACE_VIEW_DEFAULT_COLUMNS: TelemetryFieldKey[] = [
name: 'total_tokens',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{
name: 'input_tokens',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{
name: 'output_tokens',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{
name: 'distinct_tool_count',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{
name: 'llm_call_count',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{
name: 'tool_call_count',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
{ name: 'start_time' },
{ name: 'end_time' },
@@ -122,7 +122,7 @@ export const TRACE_VIEW_DEFAULT_COLUMNS: TelemetryFieldKey[] = [
name: 'max_llm_duration_nano',
signal: 'traces',
fieldContext: 'trace',
fieldDataType: 'float64',
fieldDataType: 'number',
},
];

View File

@@ -154,8 +154,8 @@ func (n *Notifier) encodeSendMessage(chatID int64, text string) (*bytes.Buffer,
}
// buildMessage sends the title in bold above the message. Each half comes from
// the rule's template when it has one and from the channel's otherwise; an
// empty title sends the message alone.
// the rule's template when it has one that renders and from the channel's
// otherwise; an empty title sends the message alone.
func (n *Notifier) buildMessage(ctx context.Context, logger *slog.Logger, as []*types.Alert) (string, error) {
customTitle, customBody := alertmanagertemplate.ExtractTemplatesFromAnnotations(as)
@@ -179,7 +179,7 @@ func (n *Notifier) buildMessage(ctx context.Context, logger *slog.Logger, as []*
title, body string
err error
)
if customTitle != "" {
if result != nil && !result.IsDefaultTitle {
title, err = n.renderRuleTemplate(result.Title)
} else {
title, err = n.renderChannelTemplate(ctx, as, n.conf.Title)
@@ -188,7 +188,7 @@ func (n *Notifier) buildMessage(ctx context.Context, logger *slog.Logger, as []*
return "", err
}
if customBody != "" {
if result != nil && !result.IsDefaultBody {
body, err = n.renderRuleTemplate(strings.Join(nonEmpty(result.Body), "\n\n"))
} else {
body, err = n.renderChannelTemplate(ctx, as, n.conf.Message)

View File

@@ -225,6 +225,16 @@ func TestNotifyBuildsTheMessage(t *testing.T) {
},
wantContains: []string{"<b>Summary:</b> p99 is 612ms"},
},
{
// Templates written against the channel data model do not render
// against the rule's, and the channel's own title and message stand in.
name: "UnrenderableRuleTemplates_FallBackToChannel",
alerts: []*types.Alert{newAlert("web-3", model.LabelSet{
ruletypes.AnnotationTitleTemplate: "Rule title: {{ .CommonLabels.alertname }}",
ruletypes.AnnotationBodyTemplate: "{{ .Labels.alertname }}: {{ .Annotations.summary }}",
})},
wantContains: []string{"<b>[FIRING:1] checkout-latency-high</b>\n\n<b>Alert:</b>", "<b>Summary:</b> p99 is 612ms"},
},
}
for _, testCase := range testCases {

View File

@@ -36,11 +36,14 @@ func (at *templater) Expand(
title, titleMissingVars, err := at.expandTitle(req.TitleTemplate, ntd)
if err != nil {
return nil, err
at.logger.WarnContext(ctx, "custom title template failed, falling back to default template", slog.String("rule.id", ntd.Rule.ID), errors.Attr(err))
title, titleMissingVars = "", nil
}
// if title template results in empty string, use default template
// this happens for rules where custom title annotation was not set
if title == "" && req.DefaultTitleTemplate != "" {
// or failed to render
isDefaultTitle := title == ""
if isDefaultTitle && req.DefaultTitleTemplate != "" {
title, err = at.expandDefaultTemplate(ctx, req.DefaultTitleTemplate, alerts)
if err != nil {
return nil, err
@@ -52,10 +55,12 @@ func (at *templater) Expand(
isDefaultBody := false
body, bodyMissingVars, err := at.expandBody(req.BodyTemplate, ntd)
if err != nil {
return nil, err
at.logger.WarnContext(ctx, "custom body template failed, falling back to default template", slog.String("rule.id", ntd.Rule.ID), errors.Attr(err))
body, bodyMissingVars = nil, nil
}
// if body template results in nil, use default template
// this happens for rules where custom body annotation was not set
// or failed to render
if body == nil {
isDefaultBody = true
defaultBody, err := at.expandDefaultTemplate(ctx, req.DefaultBodyTemplate, alerts)
@@ -78,6 +83,7 @@ func (at *templater) Expand(
Title: title,
Body: body,
MissingVars: missingVarsList,
IsDefaultTitle: isDefaultTitle,
IsDefaultBody: isDefaultBody,
NotificationData: ntd,
}, nil

View File

@@ -54,14 +54,15 @@ func TestExpandTemplates(t *testing.T) {
at, ctx := testSetup(t)
tests := []struct {
name string
alerts []*types.Alert
input alertmanagertypes.ExpandRequest
wantTitle string
wantBody []string
wantMissingVars []string
errorContains string
wantIsDefaultBody bool
name string
alerts []*types.Alert
input alertmanagertypes.ExpandRequest
wantTitle string
wantBody []string
wantMissingVars []string
errorContains string
wantIsDefaultTitle bool
wantIsDefaultBody bool
}{
{
// High request throughput on a service — service is a custom label.
@@ -155,7 +156,8 @@ Description: Request rate exceeded 10k/s`},
" • *severity:* critical\n" +
" \n" +
" "},
wantIsDefaultBody: true,
wantIsDefaultTitle: true,
wantIsDefaultBody: true,
},
{
// Pod crash loop on multiple pods — body is expanded once per alert
@@ -238,9 +240,10 @@ Description: Request rate exceeded 10k/s`},
DefaultTitleTemplate: "{{ .CommonLabels.alertname }}",
DefaultBodyTemplate: `{{ range .Alerts }}{{ template "signoz.relatedLinks.slack" . }}{{ end }}`,
},
wantTitle: "HighLatency",
wantBody: []string{"<https://signoz.example/traces?q=2|View Related Traces>"},
wantIsDefaultBody: true,
wantTitle: "HighLatency",
wantBody: []string{"<https://signoz.example/traces?q=2|View Related Traces>"},
wantIsDefaultTitle: true,
wantIsDefaultBody: true,
},
{
// $environment is not a known AlertData or NotificationTemplateData field,
@@ -266,8 +269,9 @@ Description: Request rate exceeded 10k/s`},
input: alertmanagertypes.ExpandRequest{
BodyTemplate: "$rule.name: see runbook at $runbook_url",
},
wantBody: []string{"PodOOMKilled: see runbook at <no value>"},
wantMissingVars: []string{"runbook_url"},
wantBody: []string{"PodOOMKilled: see runbook at <no value>"},
wantMissingVars: []string{"runbook_url"},
wantIsDefaultTitle: true,
},
{
// Both title and body use unknown variables; MissingVars is the union of both.
@@ -295,17 +299,68 @@ Description: Request rate exceeded 10k/s`},
DefaultTitleTemplate: "{{ .CommonLabels.alertname }} ({{ .Status | toUpper }})",
DefaultBodyTemplate: "Runbook: https://runbook.example.com",
},
wantTitle: "HighCPU (RESOLVED)",
wantBody: []string{"Runbook: https://runbook.example.com"},
wantIsDefaultBody: true,
wantTitle: "HighCPU (RESOLVED)",
wantBody: []string{"Runbook: https://runbook.example.com"},
wantIsDefaultTitle: true,
wantIsDefaultBody: true,
},
{
name: "using non-existing function in template",
// A custom template that does not render must not cost the
// notification; the channel default stands in for that half.
name: "fallback: custom title using non-existing function falls back to default",
alerts: []*types.Alert{
createAlert(map[string]string{ruletypes.LabelAlertName: "HighCPU", ruletypes.LabelSeverityName: "critical"}, nil, true),
},
input: alertmanagertypes.ExpandRequest{
TitleTemplate: "$rule.name ({{$severity | toUpperAndTrim}}) for $alertname",
TitleTemplate: "$rule.name ({{$severity | toUpperAndTrim}}) for $alertname",
DefaultTitleTemplate: "{{ .CommonLabels.alertname }} ({{ .Status | toUpper }})",
DefaultBodyTemplate: "Runbook: https://runbook.example.com",
},
wantTitle: "HighCPU (FIRING)",
wantBody: []string{"Runbook: https://runbook.example.com"},
wantIsDefaultTitle: true,
wantIsDefaultBody: true,
},
{
// A title copied from a channel template reads .CommonLabels, which
// the rule data model does not carry.
name: "fallback: channel-style custom title falls back to default",
alerts: []*types.Alert{
createAlert(map[string]string{ruletypes.LabelAlertName: "HighCPU", ruletypes.LabelSeverityName: "critical"}, nil, true),
},
input: alertmanagertypes.ExpandRequest{
TitleTemplate: "Rule title: {{ .CommonLabels.alertname }}",
BodyTemplate: "$rule.name is $alert.status",
DefaultTitleTemplate: "[{{ .Status | toUpper }}] {{ .CommonLabels.alertname }}",
DefaultBodyTemplate: "Runbook: https://runbook.example.com",
},
wantTitle: "[FIRING] HighCPU",
wantBody: []string{"HighCPU is firing"},
wantIsDefaultTitle: true,
},
{
name: "fallback: channel-style custom body falls back to default",
alerts: []*types.Alert{
createAlert(map[string]string{ruletypes.LabelAlertName: "HighCPU", ruletypes.LabelSeverityName: "critical"}, map[string]string{"summary": "CPU above 90%"}, true),
},
input: alertmanagertypes.ExpandRequest{
TitleTemplate: "$rule.name",
BodyTemplate: "{{ .Labels.alertname }}: {{ .Annotations.summary }}",
DefaultTitleTemplate: "[{{ .Status | toUpper }}] {{ .CommonLabels.alertname }}",
DefaultBodyTemplate: "{{ range .Alerts }}{{ .Labels.alertname }}: {{ .Annotations.summary }}{{ end }}",
},
wantTitle: "HighCPU",
wantBody: []string{"HighCPU: CPU above 90%"},
wantIsDefaultBody: true,
},
{
// The channel's own template has no fallback left.
name: "default title template using non-existing function fails",
alerts: []*types.Alert{
createAlert(map[string]string{ruletypes.LabelAlertName: "HighCPU", ruletypes.LabelSeverityName: "critical"}, nil, true),
},
input: alertmanagertypes.ExpandRequest{
DefaultTitleTemplate: "{{ .CommonLabels.alertname | toUpperAndTrim }}",
},
errorContains: "function \"toUpperAndTrim\" not defined",
},
@@ -326,6 +381,7 @@ Description: Request rate exceeded 10k/s`},
if tc.wantBody != nil {
require.Equal(t, tc.wantBody, got.Body)
}
require.Equal(t, tc.wantIsDefaultTitle, got.IsDefaultTitle)
require.Equal(t, tc.wantIsDefaultBody, got.IsDefaultBody)
if len(tc.wantMissingVars) == 0 {

View File

@@ -1,53 +1,14 @@
package telemetrymetadata
import (
"strings"
"github.com/SigNoz/signoz/pkg/types/telemetrytypes"
)
func staticFieldMatchesAny(field telemetrytypes.TelemetryFieldKey, selectors []*telemetrytypes.FieldKeySelector) bool {
for _, selector := range selectors {
if staticFieldMatches(field, selector) {
if selector.MatchesKey(&field) {
return true
}
}
return false
}
// staticFieldMatches mirrors the keys-table lookup for a static field: the
// requested context and data type, when given, must agree with the field's,
// and the name matches case-insensitively, as a substring for fuzzy selectors
// and as the whole name for exact ones.
func staticFieldMatches(field telemetrytypes.TelemetryFieldKey, selector *telemetrytypes.FieldKeySelector) bool {
if selector.FieldContext != telemetrytypes.FieldContextUnspecified && selector.FieldContext != field.FieldContext {
return false
}
if selector.FieldDataType != telemetrytypes.FieldDataTypeUnspecified && !sameDataTypeFamily(selector.FieldDataType, field.FieldDataType) {
return false
}
if selector.Name == "" {
return true
}
if selector.SelectorMatchType == telemetrytypes.FieldSelectorMatchTypeExact {
return strings.EqualFold(field.Name, selector.Name)
}
return strings.Contains(strings.ToLower(field.Name), strings.ToLower(selector.Name))
}
// sameDataTypeFamily treats the numeric types as one family: static fields
// declare "number" while callers may ask for int64 or float64.
func sameDataTypeFamily(requested, actual telemetrytypes.FieldDataType) bool {
if requested == actual {
return true
}
return isNumericDataType(requested) && isNumericDataType(actual)
}
func isNumericDataType(dataType telemetrytypes.FieldDataType) bool {
switch dataType {
case telemetrytypes.FieldDataTypeNumber, telemetrytypes.FieldDataTypeInt64, telemetrytypes.FieldDataTypeFloat64:
return true
}
return false
}

View File

@@ -54,6 +54,6 @@ func traceAggregate(name string) telemetrytypes.TelemetryFieldKey {
Name: name,
Signal: telemetrytypes.SignalTraces,
FieldContext: telemetrytypes.FieldContextTrace,
FieldDataType: telemetrytypes.FieldDataTypeFloat64,
FieldDataType: telemetrytypes.FieldDataTypeNumber,
}
}

View File

@@ -0,0 +1,40 @@
package aitelemetryschema
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/SigNoz/signoz/pkg/types/telemetrytypes"
)
func TestFieldKeysDataTypeFilter(t *testing.T) {
testCases := []struct {
name string
fieldDataType telemetrytypes.FieldDataType
expectTrace bool
}{
{name: "Number_IncludesTraceAggregates", fieldDataType: telemetrytypes.FieldDataTypeNumber, expectTrace: true},
{name: "Float64_IncludesTraceAggregates", fieldDataType: telemetrytypes.FieldDataTypeFloat64, expectTrace: true},
{name: "Int64_IncludesTraceAggregates", fieldDataType: telemetrytypes.FieldDataTypeInt64, expectTrace: true},
{name: "String_ExcludesTraceAggregates", fieldDataType: telemetrytypes.FieldDataTypeString, expectTrace: false},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
selector := &telemetrytypes.FieldKeySelector{Signal: telemetrytypes.SignalTraces, FieldDataType: testCase.fieldDataType}
keys := FieldKeys(map[string][]*telemetrytypes.TelemetryFieldKey{}, selector)
for name := range TraceAggregateFields {
if !testCase.expectTrace {
assert.NotContains(t, keys, name)
continue
}
require.Len(t, keys[name], 1)
assert.Equal(t, telemetrytypes.FieldContextTrace, keys[name][0].FieldContext)
assert.Equal(t, telemetrytypes.FieldDataTypeNumber, keys[name][0].FieldDataType)
}
})
}
}

View File

@@ -37,7 +37,7 @@ func FilterPublicAnnotations(kv template.KV) template.KV {
// ExpandRequest carries the title/body templates and their defaults handed to
// Templater.Expand. Default templates are used when the custom templates
// expand to empty strings.
// expand to empty strings or fail to render.
type ExpandRequest struct {
TitleTemplate string
BodyTemplate string
@@ -52,8 +52,13 @@ type ExpandResult struct {
// Body is the expanded notification body, one entry per input alert. The
// body template is applied per-alert and concatenated by the caller.
Body []string
// IsDefaultTitle is true when Title came from the default template (no
// user-authored title was supplied, it expanded to nothing, or it failed
// to render), false when a custom template was used.
IsDefaultTitle bool
// IsDefaultBody is true when Body came from the default template (no
// user-authored body was supplied), false when a custom template was used.
// user-authored body was supplied, or it failed to render), false when a
// custom template was used.
IsDefaultBody bool
// MissingVars is the union of $-references in the title and body templates
// that did not resolve to any known field. Surfaced for preview warnings;

View File

@@ -260,7 +260,7 @@ func (s *FieldKeySelector) MatchesKey(key *TelemetryFieldKey) bool {
return false
}
if s.FieldDataType != FieldDataTypeUnspecified && s.FieldDataType != key.FieldDataType {
if s.FieldDataType != FieldDataTypeUnspecified && !sameDataTypeFamily(s.FieldDataType, key.FieldDataType) {
return false
}

View File

@@ -198,3 +198,22 @@ func (FieldDataType) Enum() []any {
// FieldDataTypeArrayNumber,
}
}
// sameDataTypeFamily treats the numeric types as one family: static fields
// declare "number" while callers may ask for int64 or float64.
func sameDataTypeFamily(requested, actual FieldDataType) bool {
if requested == actual {
return true
}
return isNumericDataType(requested) && isNumericDataType(actual)
}
// isNumericDataType also accepts spellings that skipped normalization, such as
// "double" sent as a query parameter.
func isNumericDataType(dataType FieldDataType) bool {
switch fieldDataTypes[strings.ToLower(dataType.StringValue())] {
case FieldDataTypeNumber, FieldDataTypeInt64:
return true
}
return false
}

View File

@@ -0,0 +1,73 @@
{
"alert": "content_templating_data_dependent",
"ruleType": "threshold_rule",
"alertType": "METRIC_BASED_ALERT",
"condition": {
"thresholds": {
"kind": "basic",
"spec": [
{
"name": "critical",
"target": 100,
"matchType": "1",
"op": "1",
"channels": [
"test channel"
]
}
]
},
"compositeQuery": {
"queryType": "builder",
"panelType": "graph",
"queries": [
{
"type": "builder_query",
"spec": {
"name": "A",
"signal": "metrics",
"aggregations": [
{
"metricName": "container_memory_bytes_content_templating",
"timeAggregation": "avg",
"spaceAggregation": "max"
}
],
"groupBy": [
{"name": "namespace", "fieldContext": "attribute", "fieldDataType": "string"},
{"name": "pod", "fieldContext": "attribute", "fieldDataType": "string"},
{"name": "container", "fieldContext": "attribute", "fieldDataType": "string"},
{"name": "node", "fieldContext": "attribute", "fieldDataType": "string"},
{"name": "severity", "fieldContext": "attribute", "fieldDataType": "string"}
]
}
}
]
},
"selectedQueryName": "A"
},
"evaluation": {
"kind": "rolling",
"spec": {
"evalWindow": "5m0s",
"frequency": "15s"
}
},
"labels": {},
"annotations": {
"description": "Container $container in pod $pod ($namespace) exceeded memory threshold",
"summary": "High container memory in $namespace/$pod",
"_title_template": "{{ slice .labels.pod 0 40 }} memory high",
"_body_template": "Pod {{ slice .labels.pod 0 40 }} in {{ .labels.namespace }} exceeded memory threshold"
},
"notificationSettings": {
"groupBy": [],
"usePolicy": false,
"renotify": {
"enabled": false,
"interval": "30m",
"alertStates": []
}
},
"schemaVersion": "v2alpha1"
}

View File

@@ -71,6 +71,50 @@ CONTENT_TEMPLATING_TEST = [
],
),
),
types.AlertManagerNotificationTestCase(
# The rule's templates slice 40 characters off a pod label that is 24 long.
name="msteams_metrics_rule_templates_failing_on_data_fall_back_to_channel",
rule_path="alertmanager/content_templating/metrics_rule_fallback.json",
alert_data=[
types.AlertData(
type="metrics",
data_path="alertmanager/content_templating/metrics_data.jsonl",
),
],
channel_config=msteams_default_config,
notification_expectation=types.AMNotificationExpectation(
should_notify=True,
wait_time_seconds=120,
notification_validations=[
types.NotificationValidation(
destination_type="webhook",
validation_data={
"path": "/msteams/webhook_url",
"json_body": {
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"text": re.compile(
r'\[FIRING:1\] content_templating_data_dependent for \(alertname="content_templating_data_dependent", container="checkout", namespace="production", node="ip-10-0-1-23", pod="checkout-7d9c8b5f4-x2k9p", ruleSource="http://localhost:8080/alerts/overview\?ruleId=[0-9a-f-]+", severity="critical", threshold\.name="critical"\)'
),
},
{"type": "TextBlock", "text": "Alerts"},
],
},
}
],
},
},
),
],
),
),
types.AlertManagerNotificationTestCase(
name="opsgenie_metrics_default_templating",
rule_path="alertmanager/content_templating/metrics_rule.json",

View File

@@ -59,6 +59,24 @@ def test_ai_fields_trace_prefix_search(
assert trace_context_names == {"output_tokens"}, keys
@pytest.mark.parametrize("field_data_type", ["number", "float64", "int64"])
def test_ai_fields_numeric_data_type_lists_aggregates(
signoz: types.SigNoz,
create_user_admin: None, # pylint: disable=unused-argument
get_token: Callable[[str, str], str],
field_data_type: str,
) -> None:
token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)
response = get_field_keys(signoz, token, {"fieldDataType": field_data_type}, AI_KEYS_PATH)
assert response.status_code == HTTPStatus.OK, response.text
keys = response.json()["data"]["keys"]
trace_keys = [key for variants in keys.values() for key in variants if key["fieldContext"] == "trace"]
assert {key["name"] for key in trace_keys} == AI_TRACE_AGGREGATES, keys
assert {key["fieldDataType"] for key in trace_keys} == {"number"}, keys
def test_ai_fields_bare_prefix_suggests_aggregate_and_attribute(
signoz: types.SigNoz,
create_user_admin: None, # pylint: disable=unused-argument