From 67a3cbb31a8fe3f4b4d6132a0f4f321beb5dcaca Mon Sep 17 00:00:00 2001 From: Joe Elliott Date: Fri, 25 Oct 2024 15:45:51 -0400 Subject: [PATCH] changelog, docs and lint Signed-off-by: Joe Elliott --- CHANGELOG.md | 1 + docs/sources/tempo/traceql/_index.md | 9 +++++++++ modules/frontend/search_sharder.go | 6 ++++-- pkg/traceql/combine.go | 1 - 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e58871a3e44..32d1c662a6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ * [ENHANCEMENT] Speedup collection of results from ingesters in the querier [#4100](https://github.com/grafana/tempo/pull/4100) (@electron0zero) * [ENHANCEMENT] Speedup DistinctValue collector and exit early for ingesters [#4104](https://github.com/grafana/tempo/pull/4104) (@electron0zero) * [ENHANCEMENT] Add disk caching in ingester SearchTagValuesV2 for completed blocks [#4069](https://github.com/grafana/tempo/pull/4069) (@electron0zero) +* [ENHANCEMENT] Added most_recent=true query hint to TraceQL to return most recent results. [#4238](https://github.com/grafana/tempo/pull/4238) (@joe-elliott) * [BUGFIX] Replace hedged requests roundtrips total with a counter. [#4063](https://github.com/grafana/tempo/pull/4063) [#4078](https://github.com/grafana/tempo/pull/4078) (@galalen) * [BUGFIX] Metrics generators: Correctly drop from the ring before stopping ingestion to reduce drops during a rollout. [#4101](https://github.com/grafana/tempo/pull/4101) (@joe-elliott) * [BUGFIX] Correctly handle 400 Bad Request and 404 Not Found in gRPC streaming [#4144](https://github.com/grafana/tempo/pull/4144) (@mapno) diff --git a/docs/sources/tempo/traceql/_index.md b/docs/sources/tempo/traceql/_index.md index cc97015b423..1742f259d2d 100644 --- a/docs/sources/tempo/traceql/_index.md +++ b/docs/sources/tempo/traceql/_index.md @@ -451,6 +451,15 @@ TraceQL can select arbitrary fields from spans. This is particularly performant { status=error } | select(span.http.status_code, span.http.url) ``` +## Retrieving most recent results (experimental) + +The TraceQL query hint `most_recent=true` can be used with any TraceQL selection query to force Tempo to return the most recent results ordered by time. Examples: + +``` +{} with (most_recent=true) +{ span.foo = "bar" } >> { status = error } with (most_recent=true) +``` + ## Experimental TraceQL metrics TraceQL metrics are experimental, but easy to get started with. Refer to [the TraceQL metrics]({{< relref "../operations/traceql-metrics.md" >}}) documentation for more information. diff --git a/modules/frontend/search_sharder.go b/modules/frontend/search_sharder.go index 16fd6f48fcc..6fe03ad11e1 100644 --- a/modules/frontend/search_sharder.go +++ b/modules/frontend/search_sharder.go @@ -405,8 +405,10 @@ func buildIngesterRequestChan(ctx context.Context, tenantID string, parent pipel return nil } -type shardIterFn func(jobs int, sz uint64, completedThroughTime uint32) -type jobIterFn func(m *backend.BlockMeta, shard, startPage, pages int) +type ( + shardIterFn func(jobs int, sz uint64, completedThroughTime uint32) + jobIterFn func(m *backend.BlockMeta, shard, startPage, pages int) +) // backendJobsFunc provides an iter func with 2 callbacks designed to be used once to calculate job and shard metrics and a second time // to generate actual jobs. diff --git a/pkg/traceql/combine.go b/pkg/traceql/combine.go index 1c7ab688a06..a25b01619e0 100644 --- a/pkg/traceql/combine.go +++ b/pkg/traceql/combine.go @@ -22,7 +22,6 @@ type MetadataCombiner interface { } const TimestampNever = uint32(math.MaxUint32) -const TimestampAllTime = uint32(1) func NewMetadataCombiner(limit int, keepMostRecent bool) MetadataCombiner { if keepMostRecent {