Skip to content

mimir: Inject span profiler into tracer #7363

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
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* [ENHANCEMENT] Distributor: invalid metric name error message gets cleaned up to not include non-ascii strings. #7146
* [ENHANCEMENT] Store-gateway: add `source`, `level`, and `out_or_order` to `cortex_bucket_store_series_blocks_queried` metric that indicates the number of blocks that were queried from store gateways by block metadata. #7112 #7262 #7267
* [ENHANCEMENT] Compactor: After updating bucket-index, compactor now also computes estimated number of compaction jobs based on current bucket-index, and reports the result in `cortex_bucket_index_estimated_compaction_jobs` metric. If computation of jobs fails, `cortex_bucket_index_estimated_compaction_jobs_errors_total` is updated instead. #7299
* [ENHANCEMENT] Mimir: Integrate profiling into tracing instrumentation. #7363
* [BUGFIX] Ingester: don't ignore errors encountered while iterating through chunks or samples in response to a query request. #6451
* [BUGFIX] Fix issue where queries can fail or omit OOO samples if OOO head compaction occurs between creating a querier and reading chunks #6766
* [BUGFIX] Fix issue where concatenatingChunkIterator can obscure errors #6766
Expand Down
10 changes: 9 additions & 1 deletion pkg/mimir/mimir.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/grafana/dskit/server"
"github.com/grafana/dskit/services"
"github.com/grafana/dskit/signals"
"github.com/grafana/dskit/spanprofiler"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -756,7 +757,14 @@ func New(cfg Config, reg prometheus.Registerer) (*Mimir, error) {
}

mimir.setupObjstoreTracing()
otel.SetTracerProvider(NewOpenTelemetryProviderBridge(opentracing.GlobalTracer()))

// Injects span profiler into the tracer for cross-referencing between traces and profiles.
// Note, for performance reasons, span profiler only labels root spans.
tracer := spanprofiler.NewTracer(opentracing.GlobalTracer())
Copy link
Contributor

@ying-jeanne ying-jeanne Feb 12, 2024

Choose a reason for hiding this comment

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

I think we are missing assigning global tracer with the wrapped tracer again opentracing.SetGlobalTracer(wrappedTracer) so that opentracing.StartSpan is going to use the wrapped spanprofiler tracer whenever start a new span. as in the doc https://github.com/grafana/mimir/pull/7363/files#diff-1229eeb4fc2584d9d38b29af0cb7d1170ecbfa94a97923d265f227d6038ba845R33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I didn't release we're using both opentracing and opentelemetry, thank you 🆙

// We are passing the wrapped tracer to both opentracing and opentelemetry until after the ecosystem
// gets converged into the latter.
opentracing.SetGlobalTracer(tracer)
otel.SetTracerProvider(NewOpenTelemetryProviderBridge(tracer))

mimir.Cfg.Server.Router = mux.NewRouter()

Expand Down
104 changes: 104 additions & 0 deletions vendor/github.com/grafana/dskit/spanprofiler/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 107 additions & 0 deletions vendor/github.com/grafana/dskit/spanprofiler/spanprofiler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions vendor/github.com/grafana/dskit/spanprofiler/tracer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.