Skip to content

Commit

Permalink
Ingester: bridge tracing spans to Otel
Browse files Browse the repository at this point in the history
So we see spans and events inside Prometheus.

The bridge added in #2704 works when Prometheus creates a new Otel span,
but when Prometheus calls `SpanFromContext` we need to have already set
up a link from the current OpenTracing span to Otel.
  • Loading branch information
bboreham committed Jun 3, 2024
1 parent 1566732 commit 8ad8a7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* [ENHANCEMENT] Query-frontend: include route name in query stats log lines. #8191
* [ENHANCEMENT] OTLP: Speed up conversion from OTel to Mimir format by about 8% and reduce memory consumption by about 30%. Can be disabled via `-distributor.direct-otlp-translation-enabled=false` #7957
* [ENHANCEMENT] Ingester/Querier: Optimise regexps with long lists of alternates. #8221
* [ENHANCEMENT] Ingester: Include more detail in tracing of queries. #8242
* [BUGFIX] Rules: improve error handling when querier is local to the ruler. #7567
* [BUGFIX] Querier, store-gateway: Protect against panics raised during snappy encoding. #7520
* [BUGFIX] Ingester: Prevent timely compaction of empty blocks. #7624
Expand Down
2 changes: 2 additions & 0 deletions pkg/ingester/active_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/grafana/mimir/pkg/mimirpb"
"github.com/grafana/mimir/pkg/storage/sharding"
"github.com/grafana/mimir/pkg/util/spanlogger"
"github.com/grafana/mimir/pkg/util/tracing"
)

const activeSeriesMaxSizeBytes = 1 * 1024 * 1024
Expand All @@ -35,6 +36,7 @@ func (i *Ingester) ActiveSeries(request *client.ActiveSeriesRequest, stream clie

spanlog, ctx := spanlogger.NewWithLogger(stream.Context(), i.logger, "Ingester.ActiveSeries")
defer spanlog.Finish()
ctx = tracing.BridgeOpenTracingToOtel(ctx)

userID, err := tenant.TenantID(ctx)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/ingester/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import (
util_math "github.com/grafana/mimir/pkg/util/math"
"github.com/grafana/mimir/pkg/util/shutdownmarker"
"github.com/grafana/mimir/pkg/util/spanlogger"
"github.com/grafana/mimir/pkg/util/tracing"
"github.com/grafana/mimir/pkg/util/validation"
)

Expand Down Expand Up @@ -1550,6 +1551,7 @@ func (i *Ingester) QueryExemplars(ctx context.Context, req *client.ExemplarQuery

spanlog, ctx := spanlogger.NewWithLogger(ctx, i.logger, "Ingester.QueryExemplars")
defer spanlog.Finish()
ctx = tracing.BridgeOpenTracingToOtel(ctx)

userID, err := tenant.TenantID(ctx)
if err != nil {
Expand Down Expand Up @@ -1996,6 +1998,7 @@ func (i *Ingester) QueryStream(req *client.QueryRequest, stream client.Ingester_

spanlog, ctx := spanlogger.NewWithLogger(stream.Context(), i.logger, "Ingester.QueryStream")
defer spanlog.Finish()
ctx = tracing.BridgeOpenTracingToOtel(ctx)

userID, err := tenant.TenantID(ctx)
if err != nil {
Expand Down

0 comments on commit 8ad8a7e

Please sign in to comment.