From c507ebf7bf32ea4eb3cbfdfa3afa8ce8778d88eb Mon Sep 17 00:00:00 2001 From: Sanskar Sharma Date: Wed, 11 Nov 2026 23:58:11 +0530 Subject: [PATCH 1/2] vtselect: return 404 for Tempo /api/v2/traces/diff The v2 trace-by-ID prefix treated diff as a trace ID and scanned storage. Signed-off-by: Sanskar Sharma --- app/vtselect/traces/tempo/tempo.go | 3 +++ app/vtselect/traces/tempo/tempo_test.go | 21 +++++++++++++++++++++ docs/victoriatraces/changelog/CHANGELOG.md | 1 + docs/victoriatraces/querying/README.md | 1 + 4 files changed, 26 insertions(+) diff --git a/app/vtselect/traces/tempo/tempo.go b/app/vtselect/traces/tempo/tempo.go index a07b015d3..3d38b92ee 100644 --- a/app/vtselect/traces/tempo/tempo.go +++ b/app/vtselect/traces/tempo/tempo.go @@ -81,6 +81,9 @@ func RequestHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) processQueryRequest(ctx, w, r) tempoQueryDuration.UpdateDuration(startTime) return true + } else if path == "/select/tempo/api/v2/traces/diff" { + http.Error(w, "trace diff is not supported", http.StatusNotFound) + return true } else if strings.HasPrefix(path, "/select/tempo/api/v2/traces/") && len(path) > len("/select/tempo/api/v2/traces/") { tempoQueryV2Requests.Inc() processQueryV2Request(ctx, w, r) diff --git a/app/vtselect/traces/tempo/tempo_test.go b/app/vtselect/traces/tempo/tempo_test.go index 4fe3190ee..ad72f7d03 100644 --- a/app/vtselect/traces/tempo/tempo_test.go +++ b/app/vtselect/traces/tempo/tempo_test.go @@ -4,12 +4,33 @@ import ( "bytes" "context" "encoding/json" + "net/http" + "net/http/httptest" "slices" "testing" otelpb "github.com/VictoriaMetrics/VictoriaTraces/lib/protoparser/opentelemetry/pb" ) +func TestRequestHandlerTraceDiffNotSupported(t *testing.T) { + f := func(method, rawURL string) { + t.Helper() + r := httptest.NewRequest(method, rawURL, nil) + w := httptest.NewRecorder() + if !RequestHandler(context.Background(), w, r) { + t.Fatalf("%s %s must be handled", method, rawURL) + } + if w.Code != http.StatusNotFound { + t.Fatalf("unexpected status code for %s %s; got %d; want %d", + method, rawURL, w.Code, http.StatusNotFound) + } + } + + f(http.MethodGet, "/select/tempo/api/v2/traces/diff") + f(http.MethodPost, "/select/tempo/api/v2/traces/diff") + f(http.MethodPost, "/select/tempo/api/v2/traces/diff?start=1&end=2") +} + // Intrinsic span fields have no attribute prefix, so they are not discovered by // the field_names scan. They must be advertised explicitly under the "intrinsic" // scope of /api/v2/search/tags, otherwise they never appear in the Grafana diff --git a/docs/victoriatraces/changelog/CHANGELOG.md b/docs/victoriatraces/changelog/CHANGELOG.md index 81101e005..396382ee0 100644 --- a/docs/victoriatraces/changelog/CHANGELOG.md +++ b/docs/victoriatraces/changelog/CHANGELOG.md @@ -16,6 +16,7 @@ The following `tip` changes can be tested by building VictoriaTraces components * BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): return correct results for TraceQL filters with `||` in the Tempo API, such as `{ status = error || duration > 5s }`. Previously, such a filter could count extra spans, or the search failed with `cannot parse in()`, depending on the order of the conditions. Thank @ZeXi0308 for [the issue #319](https://github.com/VictoriaMetrics/VictoriaTraces/issues/319) and [the pull request #320](https://github.com/VictoriaMetrics/VictoriaTraces/pull/320). * BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): match attribute values that look like durations in TraceQL filters of the Tempo API, such as `{ span.cache.ttl = "30s" }`. Previously, such a value was converted to nanoseconds and the filter matched nothing. The conversion now applies to `duration` and `traceDuration` filters only. Thank @ZeXi0308 for [the issue #321](https://github.com/VictoriaMetrics/VictoriaTraces/issues/321) and [the pull request #322](https://github.com/VictoriaMetrics/VictoriaTraces/pull/322). +* BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): return status code `404` for requests to `/select/tempo/api/v2/traces/diff` without searching storage. Previously the `/select/tempo/api/v2/traces/` handler treated `diff` as a trace ID and performed unnecessary scan, and returned status code `200` with an empty trace. Thank @mastersans for [the pull request #315](https://github.com/VictoriaMetrics/VictoriaTraces/pull/315). ## [v0.13.0](https://github.com/VictoriaMetrics/VictoriaTraces/releases/tag/v0.13.0) diff --git a/docs/victoriatraces/querying/README.md b/docs/victoriatraces/querying/README.md index 1d8b25fd5..ab20f879b 100644 --- a/docs/victoriatraces/querying/README.md +++ b/docs/victoriatraces/querying/README.md @@ -242,6 +242,7 @@ VictoriaTraces provides the following Tempo HTTP endpoints: - `/select/tempo/api/v2/search/tag/{tag}/values` for listing values of a given attribute for query auto-completion. - `/select/tempo/api/traces/{trace_id}` for fetching a single trace by its ID (v1). - `/select/tempo/api/v2/traces/{trace_id}` for fetching a single trace by its ID (v2, similar to v1 but with different data structure). +- `/select/tempo/api/v2/traces/diff` always returns `404 Not Found`. Tempo's trace-diff API is not implemented. - `/select/tempo/api/metrics/query_range` for evaluating a TraceQL metrics query over a time range. #### Querying Examples From a33831c9df3bb99cf5de0796ecf7523d964f5176 Mon Sep 17 00:00:00 2001 From: Sanskar Sharma Date: Mon, 30 Nov 2026 14:43:37 +0530 Subject: [PATCH 2/2] fix: address review comments. Signed-off-by: Sanskar Sharma --- app/vtselect/traces/tempo/tempo.go | 2 +- docs/victoriatraces/changelog/CHANGELOG.md | 2 +- docs/victoriatraces/querying/README.md | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/vtselect/traces/tempo/tempo.go b/app/vtselect/traces/tempo/tempo.go index 3d38b92ee..c4396e7f4 100644 --- a/app/vtselect/traces/tempo/tempo.go +++ b/app/vtselect/traces/tempo/tempo.go @@ -82,7 +82,7 @@ func RequestHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) tempoQueryDuration.UpdateDuration(startTime) return true } else if path == "/select/tempo/api/v2/traces/diff" { - http.Error(w, "trace diff is not supported", http.StatusNotFound) + http.Error(w, "trace diff support is unavailable as this feature is experimental", http.StatusNotFound) return true } else if strings.HasPrefix(path, "/select/tempo/api/v2/traces/") && len(path) > len("/select/tempo/api/v2/traces/") { tempoQueryV2Requests.Inc() diff --git a/docs/victoriatraces/changelog/CHANGELOG.md b/docs/victoriatraces/changelog/CHANGELOG.md index 396382ee0..bfdb86762 100644 --- a/docs/victoriatraces/changelog/CHANGELOG.md +++ b/docs/victoriatraces/changelog/CHANGELOG.md @@ -16,7 +16,7 @@ The following `tip` changes can be tested by building VictoriaTraces components * BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): return correct results for TraceQL filters with `||` in the Tempo API, such as `{ status = error || duration > 5s }`. Previously, such a filter could count extra spans, or the search failed with `cannot parse in()`, depending on the order of the conditions. Thank @ZeXi0308 for [the issue #319](https://github.com/VictoriaMetrics/VictoriaTraces/issues/319) and [the pull request #320](https://github.com/VictoriaMetrics/VictoriaTraces/pull/320). * BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): match attribute values that look like durations in TraceQL filters of the Tempo API, such as `{ span.cache.ttl = "30s" }`. Previously, such a value was converted to nanoseconds and the filter matched nothing. The conversion now applies to `duration` and `traceDuration` filters only. Thank @ZeXi0308 for [the issue #321](https://github.com/VictoriaMetrics/VictoriaTraces/issues/321) and [the pull request #322](https://github.com/VictoriaMetrics/VictoriaTraces/pull/322). -* BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): return status code `404` for requests to `/select/tempo/api/v2/traces/diff` without searching storage. Previously the `/select/tempo/api/v2/traces/` handler treated `diff` as a trace ID and performed unnecessary scan, and returned status code `200` with an empty trace. Thank @mastersans for [the pull request #315](https://github.com/VictoriaMetrics/VictoriaTraces/pull/315). +* BUGFIX: [Single-node VictoriaTraces](https://docs.victoriametrics.com/victoriatraces/) and vtselect in [VictoriaTraces cluster](https://docs.victoriametrics.com/victoriatraces/cluster/): return status code `404` for requests to `/select/tempo/api/v2/traces/diff` without searching storage. Previously the `/select/tempo/api/v2/traces/` handler treated `diff` as a trace ID and performed an unnecessary scan, and returned status code `200` with an empty trace. Thank @mastersans for [the pull request #315](https://github.com/VictoriaMetrics/VictoriaTraces/pull/315). ## [v0.13.0](https://github.com/VictoriaMetrics/VictoriaTraces/releases/tag/v0.13.0) diff --git a/docs/victoriatraces/querying/README.md b/docs/victoriatraces/querying/README.md index ab20f879b..1d8b25fd5 100644 --- a/docs/victoriatraces/querying/README.md +++ b/docs/victoriatraces/querying/README.md @@ -242,7 +242,6 @@ VictoriaTraces provides the following Tempo HTTP endpoints: - `/select/tempo/api/v2/search/tag/{tag}/values` for listing values of a given attribute for query auto-completion. - `/select/tempo/api/traces/{trace_id}` for fetching a single trace by its ID (v1). - `/select/tempo/api/v2/traces/{trace_id}` for fetching a single trace by its ID (v2, similar to v1 but with different data structure). -- `/select/tempo/api/v2/traces/diff` always returns `404 Not Found`. Tempo's trace-diff API is not implemented. - `/select/tempo/api/metrics/query_range` for evaluating a TraceQL metrics query over a time range. #### Querying Examples