Skip to content

Jaeger API: inverted tag filters (key!) for exact and regex matches#137

Open
emamihe wants to merge 1 commit into
VictoriaMetrics:masterfrom
emamihe:feature/negative-regex-search
Open

Jaeger API: inverted tag filters (key!) for exact and regex matches#137
emamihe wants to merge 1 commit into
VictoriaMetrics:masterfrom
emamihe:feature/negative-regex-search

Conversation

@emamihe
Copy link
Copy Markdown
Contributor

@emamihe emamihe commented Apr 16, 2026

Summary

Implements inverted tag filtering for the Jaeger trace query API, matching how the Jaeger UI encodes negation: key!=value is sent as JSON {"key!": "value"}. Regex continues to use the existing ~ prefix on the value (e.g. {"key!": "~pattern"} for negated regex).

Motivation

Requested in review and aligned with #120: users need to exclude spans/traces by tag (including regex), not only include them.

Changes

  • app/vtselect/traces/jaeger/jaeger.go: After unmarshalling tags, strip a trailing ! from each key before mapping to storage field names (span_attr:…, resource/scope prefixes, spanAttributeMap). Mark negated filters by prefixing the internal attribute key with !.
  • app/vtselect/traces/query/query.go: In getTraceIDList, if the attribute key is negated (! prefix), append LogsQL !(field:=…) or !(field:re(…)) instead of positive filters.
  • app/vtselect/traces/query/query_test.go: Parse test to ensure the inverted LogsQL shape is accepted by logstorage.
  • apptest/tests/otlp_ingestion_test.go: Integration-style checks for inverted regex (non-matching pattern keeps the trace; matching pattern excludes it).
  • docs/victoriatraces/changelog/CHANGELOG.md: tip changelog entry for this feature.

How to verify

  • Unit tests: go test ./app/vtselect/traces/query/ ./app/vtselect/traces/jaeger/
  • With a built victoria-traces binary: go test ./apptest/tests/ -run TestSingleOTLPIngestionJaegerQuery

Summary by cubic

Adds inverted tag filters to the Jaeger trace query API so you can exclude spans/traces using key!=value and key!=~regex, matching the Jaeger UI’s encoding {"key!": "value"} and {"key!": "~pattern"}.

  • New Features
    • Parse tags with keys ending in !, map to storage fields, and carry negation internally.
    • Generate negated LogsQL for both exact and regex filters: !(field:=...) and !(field:re(...)).
    • Add unit and integration tests for inverted exact/regex behavior; update changelog.

Written for commit 8c83dd7. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

@jiekun jiekun self-requested a review May 12, 2026 12:27
@jiekun jiekun self-assigned this May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants