Repository navigation
vtselect: fix trace search when running with a non-UTC time zone #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jiekun
merged 6 commits into
VictoriaMetrics:master
from
Vandit1604:vtselect-trace-search-timezone
Oct 1, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
87da845
vtselect: fix trace search when running with a non-UTC time zone
Vandit1604 1e6cdc8
unify the time string format to RFC3339Nano when handling trace queries
jiekun 226fc37
docs: update changelog entry to the proper place and add credit to th…
jiekun 2c56fe8
replace string comparison with unix nano timestamp comparison
jiekun 19f2ccb
apptest: run trace search with a non-UTC time zone
Vandit1604 a3fdccd
test: update apptest without indroducing extra function
jiekun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/VictoriaMetrics/VictoriaTraces/app/vtselect/traces/query" | ||
| at "github.com/VictoriaMetrics/VictoriaTraces/apptest" | ||
| otelpb "github.com/VictoriaMetrics/VictoriaTraces/lib/protoparser/opentelemetry/pb" | ||
| ) | ||
|
|
||
| // TestSingleSearchTracesNonUTCTimezone verifies that Jaeger and Tempo trace search return correct traces | ||
| // when VictoriaTraces runs in a time zone other than UTC. | ||
| // | ||
| // See https://github.com/VictoriaMetrics/VictoriaTraces/issues/260 | ||
| func TestSingleSearchTracesNonUTCTimezone(t *testing.T) { | ||
| tc := at.NewTestCase(t) | ||
| defer tc.Stop() | ||
|
|
||
| sut := tc.MustStartVtsingle("vtsingle", []string{ | ||
| "-storageDataPath=" + tc.Dir() + "/vtsingle", | ||
| "-retentionPeriod=100y", | ||
| }, []string{"TZ=America/New_York"}...) | ||
|
|
||
| serviceName := "testSearchTimezoneService" | ||
| spanTime := time.Now().Add(-2 * time.Hour) | ||
| req := &otelpb.ExportTraceServiceRequest{ | ||
| ResourceSpans: []*otelpb.ResourceSpans{ | ||
| { | ||
| Resource: otelpb.Resource{ | ||
| Attributes: []*otelpb.KeyValue{ | ||
| {Key: "service.name", Value: &otelpb.AnyValue{StringValue: &serviceName}}, | ||
| }, | ||
| }, | ||
| ScopeSpans: []*otelpb.ScopeSpans{ | ||
| { | ||
| Spans: []*otelpb.Span{ | ||
| { | ||
| TraceID: "5b8efff798038103d269b633813fc60c", | ||
| SpanID: "eee19b7ec3c1b174", | ||
| Name: "testSearchTimezoneSpan", | ||
| StartTimeUnixNano: uint64(spanTime.UnixNano()), | ||
| EndTimeUnixNano: uint64(spanTime.Add(time.Millisecond).UnixNano()), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| sut.OTLPHTTPExportTraces(t, req, at.QueryOpts{}) | ||
| sut.ForceFlush(t) | ||
|
|
||
| startTime := spanTime.Add(-time.Hour) | ||
| endTime := time.Now() | ||
|
|
||
| tc.Assert(&at.AssertOptions{ | ||
| Msg: "unexpected number of traces from /select/jaeger/api/traces", | ||
| Got: func() any { | ||
| res := sut.JaegerAPITraces(t, at.JaegerQueryParam{ | ||
| TraceQueryParam: query.TraceQueryParam{ | ||
| ServiceName: serviceName, | ||
| StartTimeMin: startTime, | ||
| StartTimeMax: endTime, | ||
| }, | ||
| }, at.QueryOpts{}) | ||
| return len(res.Data) | ||
| }, | ||
| Want: 1, | ||
| }) | ||
|
|
||
| tc.Assert(&at.AssertOptions{ | ||
| Msg: "unexpected number of traces from /select/tempo/api/search", | ||
| Got: func() any { | ||
| res := sut.TempoAPISearch(t, fmt.Sprintf(`{resource.service.name=%q}`, serviceName), startTime, endTime) | ||
| return len(res.Traces) | ||
| }, | ||
| Want: 1, | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: Merging
MustStartVtsingleWithEnvback intoMustStartVtsinglesilently drops the documentation of the newenvparameter: the removed helper's doc comment explicitly explained that environment variables such asTZare passed to the process, whileMustStartVtsingle(andMustStartVtagent) now takeenv ...stringwithout any doc mention. Mention the optionalenvin both doc comments so tests that need a non-UTCTZare discoverable.Prompt for AI agents