Skip to content

Commit

Permalink
feat: Add tracing integration to profiling. (#11633)
Browse files Browse the repository at this point in the history
Same as grafana/tempo#3276 this adds profiling
integration to tracing instrumentation allowing to get profile for a
single request removing the noise of everything else.
  • Loading branch information
cyriltovena authored Jan 12, 2024
1 parent 6bcac00 commit 5517eaa
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

##### Enhancements

* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11633](https://github.com/grafana/loki/pull/11633) **cyriltovena**: Add profiling integrations to tracing instrumentation.
* [11571](https://github.com/grafana/loki/pull/11571) **MichelHollands**: Add a metrics.go log line for requests from querier to ingester
* [11477](https://github.com/grafana/loki/pull/11477) **MichelHollands**: support GET for /ingester/shutdown
* [11363](https://github.com/grafana/loki/pull/11363) **kavirajk**: bugfix(memcached): Make memcached batch fetch truely context aware.
* [11319](https://github.com/grafana/loki/pull/11319) **someStrangerFromTheAbyss**: Helm: Add extraContainers to the write pods.
Expand Down
6 changes: 5 additions & 1 deletion cmd/loki/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (

"github.com/go-kit/log/level"
"github.com/grafana/dskit/log"
"github.com/grafana/dskit/spanprofiler"
"github.com/grafana/dskit/tracing"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"

Expand Down Expand Up @@ -84,7 +86,9 @@ func main() {
if err != nil {
level.Error(util_log.Logger).Log("msg", "error in initializing tracing. tracing will not be enabled", "err", err)
}

if config.Tracing.ProfilingEnabled {
opentracing.SetGlobalTracer(spanprofiler.NewTracer(opentracing.GlobalTracer()))
}
defer func() {
if trace != nil {
if err := trace.Close(); err != nil {
Expand Down
4 changes: 3 additions & 1 deletion pkg/tracing/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
)

type Config struct {
Enabled bool `yaml:"enabled"`
Enabled bool `yaml:"enabled"`
ProfilingEnabled bool `yaml:"profiling_enabled" category:"experimental" doc:"hidden"`
}

func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
Expand All @@ -14,4 +15,5 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {

func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.BoolVar(&cfg.Enabled, prefix+"tracing.enabled", true, "Set to false to disable tracing.")
f.BoolVar(&cfg.ProfilingEnabled, prefix+"tracing.profiling-enabled", true, "Set to true to enable profiling integration.")
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ github.com/grafana/dskit/server
github.com/grafana/dskit/services
github.com/grafana/dskit/signals
github.com/grafana/dskit/spanlogger
github.com/grafana/dskit/spanprofiler
github.com/grafana/dskit/tenant
github.com/grafana/dskit/test
github.com/grafana/dskit/tracing
Expand Down

0 comments on commit 5517eaa

Please sign in to comment.