Skip to content

[bugfix] Fix search by trace:id for short IDs with leading zeros - #5587

Merged
ruslan-mikhailov merged 4 commits into
grafana:mainfrom
ruslan-mikhailov:bugfix/trace-id-search
Oct 31, 2025
Merged

[bugfix] Fix search by trace:id for short IDs with leading zeros#5587
ruslan-mikhailov merged 4 commits into
grafana:mainfrom
ruslan-mikhailov:bugfix/trace-id-search

Conversation

@ruslan-mikhailov

@ruslan-mikhailov ruslan-mikhailov commented Aug 28, 2025

Copy link
Copy Markdown
Contributor

What this PR does: fixed trace:id queries with leading zeroes like { trace:id = "00000000000000008bb87d091822a2f9" }

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]
@ruslan-mikhailov ruslan-mikhailov changed the title [bugfix] Fix for search by trace:id for short ID with leading zeroes Aug 28, 2025
@ruslan-mikhailov
ruslan-mikhailov marked this pull request as ready for review August 28, 2025 12:47
@joe-elliott

joe-elliott commented Aug 28, 2025

Copy link
Copy Markdown
Collaborator

I believe this fixes:
#5370
#4967

Edit:
Well maybe I'm wrong. It's strange that both of those issues are examples of trace ids that have leading 0s that are not in the traceql query string.

Comment thread pkg/traceql/ast_conditions.go Outdated
Operands: nil,
})
} else {
operand := o.RHS.(Static)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it feels strange to me to perform this normalization in these very specific places. should we instead do this in newBinaryOperation and then we can feel confident that trace id's are represented the same everywhere in the ast regardless?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a very nice idea, thank you for that! Fixed

@joe-elliott

Copy link
Copy Markdown
Collaborator

I was thinking about this and realized that it doesn't fix cases like:

{ trace:id = span.foo }

Unfortunately, to fix this completely I feel like we'd need some kind of IdsEqual(a, b) function in the traceql package that is used by both the engine and the fetch layers. Right now we're just treating it as a string type, but obviously that's not quite correct.

@joe-elliott

Copy link
Copy Markdown
Collaborator

One more thought! Should we stop comparing strings and start comparing byte slices?

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has not had any activity in the past 60 days.
The next time this stale check runs, the stale label will be removed if there is new activity. This pull request will be closed in 15 days if there is no new activity.
Please apply keepalive label to exempt this Pull Request.

@github-actions github-actions Bot added the stale Used for stale issues / PRs label Oct 29, 2025
@ruslan-mikhailov

Copy link
Copy Markdown
Contributor Author

+ rebase from latest main to revive the branch and resolve conflicts

@ruslan-mikhailov ruslan-mikhailov removed the stale Used for stale issues / PRs label Oct 29, 2025
Comment thread pkg/traceql/ast.go
RHS: rhs,
}

if attr, ok := lhs.(Attribute); ok && attr.Intrinsic == IntrinsicTraceID {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

a unit test on newBinaryOperation to lock this down would be nice.

@joe-elliott joe-elliott left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

a small test on newBinaryOperation to lock down the behavior would be nice, but other than that lgtm

@ruslan-mikhailov

Copy link
Copy Markdown
Contributor Author

+ unit test

@ruslan-mikhailov
ruslan-mikhailov merged commit a97f399 into grafana:main Oct 31, 2025
22 checks passed
@ruslan-mikhailov
ruslan-mikhailov deleted the bugfix/trace-id-search branch October 31, 2025 15:05
mattdurham pushed a commit to mattdurham/tempo that referenced this pull request Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants