-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from grafana/chore/cleanup
Deprecate unused options
- Loading branch information
Showing
12 changed files
with
316 additions
and
315 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,64 @@ | ||
# Profiling Instrumentation | ||
# Profiling Instrumentation for OpenTelemetry Go SDK | ||
|
||
**NOTE**: This is an experimental package -- and will be officially supported in future versions of Pyroscope | ||
|
||
The package provides means to integrate tracing with profiling. More specifically, a `TracerProvider` implementation, | ||
that annotates profiling data with span IDs: when a new trace span emerges, the tracer adds a `profile_id` [pprof tag](https://github.com/google/pprof/blob/master/doc/README.md#tag-filtering) | ||
that annotates profiling data with span IDs: when a new trace span emerges, the tracer adds a `span_id` [pprof tag](https://github.com/google/pprof/blob/master/doc/README.md#tag-filtering) | ||
that points to the span. This makes it possible to filter out a profile of a particular trace span in [Pyroscope](https://pyroscope.io). | ||
|
||
### Jaeger Example | ||
You can find a full Jaeger example (with custom Jaeger UI) in the [tracing/jaeger](https://github.com/pyroscope-io/pyroscope/tree/main/examples/tracing/jaeger) folder in the Pyroscope repository. | ||
![image](https://user-images.githubusercontent.com/23323466/164025573-1f6e713b-ec94-4d82-842c-faf2be652b7f.png) | ||
Note that the module does not control `pprof` profiler itself – it still needs to be started for profiles to be | ||
collected. This can be done either via `runtime/pprof` package, or using the [Pyroscope client](https://github.com/grafana/pyroscope-go). | ||
|
||
#### Baseline Diffs | ||
We also added functionality where each individual span is compared to a baseline of spans with similar properties and the diff can be shown in the UI: | ||
By default, only the root span gets labeled (the first span created locally): such spans are marked with the | ||
`pyroscope.profile.id` attribute set to the span ID. Please note that presence of the attribute does not necessarily | ||
indicate that the span has a profile: stack trace samples might not be collected, if the utilized CPU time is | ||
less than the sample interval (10ms). | ||
|
||
[![Watch the video](https://user-images.githubusercontent.com/23323466/165633049-9591b0fd-b8be-4fbd-a0af-d90a1dd89b7b.mov)](https://user-images.githubusercontent.com/23323466/165633049-9591b0fd-b8be-4fbd-a0af-d90a1dd89b7b.mov) | ||
Limitations: | ||
- Only CPU profiling is fully supported at the moment. | ||
|
||
### Trace spans profiles | ||
|
||
### Grafana Example | ||
For another example of what this package allows you to do you can see with Grafana the ability to link between logs, traces and profiles in the following video ([source](https://github.com/pyroscope-io/pyroscope/tree/main/examples/tracing/jaeger)): | ||
To start profiling trace spans, you need to include our go module in your app: | ||
|
||
[![Watch the video](https://user-images.githubusercontent.com/23323466/172881613-842f67f0-6bfa-4671-a44a-e966d5ca67a4.mov)](https://user-images.githubusercontent.com/23323466/172881613-842f67f0-6bfa-4671-a44a-e966d5ca67a4.mov) | ||
``` | ||
go get github.com/grafana/otel-profiling-go | ||
``` | ||
|
||
Then add the pyroscope tracer provider: | ||
|
||
### Other Notes | ||
Note that the module does not control `pprof` profiler itself – it still needs to be started for profiles to be | ||
collected. This can be done either via `runtime/pprof` package, or using the [Pyroscope client](https://github.com/pyroscope-io/client). | ||
```go | ||
package main | ||
|
||
import ( | ||
otelpyroscope "github.com/grafana/otel-profiling-go" | ||
"github.com/grafana/pyroscope-go" | ||
) | ||
|
||
func main() { | ||
// Initialize your tracer provider as usual. | ||
tp := initTracer() | ||
|
||
// Wrap it with otelpyroscope tracer provider. | ||
otel.SetTracerProvider(otelpyroscope.NewTracerProvider(tp)) | ||
|
||
// If you're using Pyroscope Go SDK, initialize pyroscope profiler. | ||
_, _ = pyroscope.Start(pyroscope.Config{ | ||
ApplicationName: "my-service", | ||
ServerAddress: "http://localhost:4040", | ||
}) | ||
|
||
// Your code goes here. | ||
} | ||
``` | ||
|
||
Tracing integration is supported in pull mode as well: if you scrape profiles using Grafana Agent, you should | ||
make sure that the pyroscope `service_name` label matches `service.name` attribute specified in the OTel SDK configuration. | ||
Please refer to the [Grafana Agent](https://grafana.com/docs/pyroscope/latest/configure-client/grafana-agent/go_pull/) | ||
documentation to learn more. | ||
|
||
## Example | ||
|
||
By default, only the root span gets annotated (the first span created locally), this is done to circumvent the fact that the profiler records only the time spent on CPU. Otherwise, all the children profiles should be merged to get the full representation of the root span profile. | ||
You can find a complete example setup with Grafana Tempo in the [Pyroscope repository](https://github.com/grafana/pyroscope/tree/main/examples/tracing/tempo). | ||
|
||
There are few limitations: | ||
- Only Go CPU profiling is fully supported at the moment. | ||
- Due to the very idea of the sampling profilers, spans shorter than the sample interval may not be captured. For example, Go CPU profiler probes stack traces 100 times per second, meaning that spans shorter than 10ms may not be captured. | ||
![image](https://github.com/grafana/otel-profiling-go/assets/12090599/31e33cd1-818b-4116-b952-c9ec7b1fb593) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package otelpyroscope | ||
|
||
// Config describes tracer configuration. | ||
// DEPRECATED: Do not use. | ||
type Config struct { | ||
AppName string | ||
PyroscopeURL string | ||
IncludeProfileURL bool | ||
IncludeProfileBaselineURL bool | ||
ProfileBaselineLabels map[string]string | ||
|
||
RootOnly bool | ||
AddSpanName bool | ||
} | ||
|
||
// WithRootSpanOnly indicates that only the root span is to be profiled. | ||
// The profile includes samples captured during child span execution | ||
// but the spans won't have their own profiles and won't be annotated | ||
// with pyroscope.profile attributes. | ||
// The option is enabled by default. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithRootSpanOnly(bool) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithAddSpanName specifies whether the current span name should be added | ||
// to the profile labels. N.B if the name is dynamic, or too many values | ||
// are supposed, this may significantly deteriorate performance. | ||
// By default, span name is not added to profile labels. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithAddSpanName(bool) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithAppName specifies the profiled application name. | ||
// It should match the name specified in pyroscope configuration. | ||
// Required, if profile URL or profile baseline URL is enabled. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithAppName(string) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithPyroscopeURL provides a base URL for the profile and baseline URLs. | ||
// Required, if profile URL or profile baseline URL is enabled. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithPyroscopeURL(string) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithProfileURL specifies whether to add the pyroscope.profile.url | ||
// attribute with the URL to the span profile. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithProfileURL(bool) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithProfileBaselineURL specifies whether to add the | ||
// pyroscope.profile.baseline.url attribute with the URL | ||
// to the baseline profile. See WithProfileBaselineLabels. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithProfileBaselineURL(bool) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithProfileBaselineLabels provides a map of extra labels to be added to the | ||
// baseline query alongside with pprof labels set in runtime. Typically, | ||
// it should match the labels specified in the Pyroscope profiler config. | ||
// Note that the map must not be modified. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithProfileBaselineLabels(map[string]string) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithProfileURLBuilder specifies how profile URL is to be built. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithProfileURLBuilder(func(_ string) string) Option { return func(tp *tracerProvider) {} } | ||
|
||
// WithDefaultProfileURLBuilder specifies the default profile URL builder. | ||
// DEPRECATED: Ignored by tracer. | ||
func WithDefaultProfileURLBuilder(_, _ string) Option { return func(tp *tracerProvider) {} } |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module github.com/pyroscope-io/otel-profiling-go | ||
module github.com/grafana/otel-profiling-go | ||
|
||
go 1.16 | ||
|
||
require ( | ||
go.opentelemetry.io/otel v1.20.0 | ||
go.opentelemetry.io/otel/trace v1.20.0 | ||
go.opentelemetry.io/otel v1.21.0 | ||
go.opentelemetry.io/otel/sdk v1.21.0 | ||
go.opentelemetry.io/otel/trace v1.21.0 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.