Documentation
¶
Overview ¶
Package auto provides OpenTelemetry automatic tracing instrumentation for Go packages using eBPF.
Index ¶
- func Version() string
- type AlwaysOffSampler
- type AlwaysOnSampler
- type ConfigProvider
- type Instrumentation
- type InstrumentationConfig
- type InstrumentationLibrary
- type InstrumentationLibraryID
- type InstrumentationOption
- func WithConfigProvider(cp ConfigProvider) InstrumentationOption
- func WithEnv() InstrumentationOption
- func WithHandler(h *pipeline.Handler) InstrumentationOption
- func WithLogger(logger *slog.Logger) InstrumentationOption
- func WithPID(pid int) InstrumentationOption
- func WithSampler(sampler Sampler) InstrumentationOption
- type ParentBasedSampler
- type Sampler
- type TraceIDRatioSampler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlwaysOffSampler ¶ added in v0.20.0
type AlwaysOffSampler struct{}
AlwaysOffSampler returns a Sampler that samples no traces.
type AlwaysOnSampler ¶ added in v0.20.0
type AlwaysOnSampler struct{}
AlwaysOnSampler is a Sampler that samples every trace. Be careful about using this sampler in a production application with significant traffic: a new trace will be started and exported for every request.
type ConfigProvider ¶ added in v0.20.0
type ConfigProvider interface {
// InitialConfig returns the initial instrumentation configuration.
InitialConfig(ctx context.Context) InstrumentationConfig
// Watch returns a channel that receives updates to the instrumentation configuration.
Watch() <-chan InstrumentationConfig
// Shutdown releases any resources held by the provider.
// It is an error to send updates after Shutdown is called.
Shutdown(ctx context.Context) error
}
ConfigProvider provides the initial configuration and updates to the instrumentation configuration.
type Instrumentation ¶ added in v0.20.0
type Instrumentation struct {
// contains filtered or unexported fields
}
Instrumentation manages and controls all OpenTelemetry Go auto-instrumentation.
func NewInstrumentation ¶ added in v0.20.0
func NewInstrumentation( ctx context.Context, opts ...InstrumentationOption, ) (*Instrumentation, error)
NewInstrumentation returns a new Instrumentation configured with the provided opts.
If conflicting or duplicate options are provided, the last one will have precedence and be used.
func (*Instrumentation) Close ¶ added in v0.20.0
func (i *Instrumentation) Close() error
Close closes the Instrumentation, cleaning up all used resources.
func (*Instrumentation) Load ¶ added in v0.20.0
func (i *Instrumentation) Load(ctx context.Context) error
Load loads and attaches the relevant probes to the target process.
func (*Instrumentation) Run ¶ added in v0.20.0
func (i *Instrumentation) Run(ctx context.Context) error
Run starts the instrumentation. It must be called after Instrumentation.Load.
This function will not return until either ctx is done, an unrecoverable error is encountered, or Close is called.
type InstrumentationConfig ¶ added in v0.20.0
type InstrumentationConfig struct {
// InstrumentationLibraryConfigs defines library-specific configuration.
// If a package is referenced by more than one key, the most specific key is used.
// For example, if ("net/http", unspecified) and ("net/http", client) are both present,
// the configuration for ("net/http", client) is used for client spans and the configuration for ("net/http", unspecified) is used for server spans.
InstrumentationLibraryConfigs map[InstrumentationLibraryID]InstrumentationLibrary
// DefaultTracesDisabled determines whether traces are disabled by default.
// If set to true, traces are disabled by default for all libraries, unless the library is explicitly enabled.
// If set to false, traces are enabled by default for all libraries, unless the library is explicitly disabled.
// default is false - traces are enabled by default.
DefaultTracesDisabled bool
// Sampler is used to determine whether a trace should be sampled and exported.
Sampler Sampler
}
InstrumentationConfig is used to configure instrumentation.
type InstrumentationLibrary ¶ added in v0.20.0
type InstrumentationLibrary struct {
// TracesEnabled determines whether traces are enabled for the instrumentation library.
// if nil - take DefaultTracesDisabled value.
TracesEnabled *bool
}
InstrumentationLibrary is used to configure instrumentation for a specific library.
type InstrumentationLibraryID ¶ added in v0.20.0
type InstrumentationLibraryID struct {
// Name of the instrumentation pkg (e.g. "net/http").
InstrumentedPkg string
// SpanKind is the relevant span kind for the instrumentation.
// This can be used to configure server-only, client-only spans.
// If not set, the identifier is assumed to be applicable to all span kinds relevant to the instrumented package.
SpanKind trace.SpanKind
}
InstrumentationLibraryID is used to identify an instrumentation library.
type InstrumentationOption ¶ added in v0.20.0
type InstrumentationOption interface {
// contains filtered or unexported methods
}
InstrumentationOption applies a configuration option to Instrumentation.
func WithConfigProvider ¶ added in v0.20.0
func WithConfigProvider(cp ConfigProvider) InstrumentationOption
WithConfigProvider returns an InstrumentationOption that will configure an Instrumentation to use the provided ConfigProvider. The ConfigProvider is used to provide the initial configuration and update the configuration of the instrumentation in runtime.
func WithEnv ¶ added in v0.20.0
func WithEnv() InstrumentationOption
WithEnv returns an InstrumentationOption that will configure Instrumentation using the values defined by the following environment variables:
- OTEL_LOG_LEVEL: sets the default logger's minimum logging level
- OTEL_TRACES_SAMPLER: sets the trace sampler
- OTEL_TRACES_SAMPLER_ARG: optionally sets the trace sampler argument
This option may conflict with WithSampler if their respective environment variable is defined. If more than one of these options are used, the last one provided to an Instrumentation will be used.
If WithLogger is used, OTEL_LOG_LEVEL will not be used for the Instrumentation logger. Instead, the slog.Logger passed to that option will be used as-is.
If WithLogger is not used, OTEL_LOG_LEVEL will be parsed and the default logger used by the configured Instrumentation will use that level as its minimum logging level.
func WithHandler ¶ added in v0.22.0
func WithHandler(h *pipeline.Handler) InstrumentationOption
WithHandler returns an InstrumentationOption that will configure an Instrumentation to use h to handle generated telemetry.
If this options is not used, the Handler returned from otelsdk.NewHandler with environment configuration will be used.
func WithLogger ¶ added in v0.20.0
func WithLogger(logger *slog.Logger) InstrumentationOption
WithLogger returns an InstrumentationOption that will configure an Instrumentation to use the provided logger.
If this option is used and WithEnv is also used, OTEL_LOG_LEVEL is ignored by the configured Instrumentation. This passed logger takes precedence and is used as-is.
If this option is not used, the Instrumentation will use an slog.Loogger backed by an slog.JSONHandler outputting to STDERR as a default.
func WithPID ¶ added in v0.20.0
func WithPID(pid int) InstrumentationOption
WithPID returns an InstrumentationOption defining the target binary for Instrumentation that is being run with the provided PID.
If multiple of these options are provided to an Instrumentation, the last one will be used.
func WithSampler ¶ added in v0.20.0
func WithSampler(sampler Sampler) InstrumentationOption
WithSampler returns an InstrumentationOption that will configure an Instrumentation to use the provided sampler to sample OpenTelemetry traces.
This currently is a no-op. It is expected to take effect in the next release.
type ParentBasedSampler ¶ added in v0.20.0
type ParentBasedSampler struct {
// Root is the Sampler used when a span is created without a parent.
Root Sampler
// RemoteSampled is the Sampler used when the span parent is remote and sampled.
RemoteSampled Sampler
// RemoteNotSampled is the Sampler used when the span parent is remote and not sampled.
RemoteNotSampled Sampler
// LocalSampled is the Sampler used when the span parent is local and sampled.
LocalSampled Sampler
// LocalNotSampled is the Sampler used when the span parent is local and not sampled.
LocalNotSampled Sampler
}
ParentBasedSampler is a Sampler which behaves differently, based on the parent of the span. If the span has no parent, the Root sampler is used to make sampling decision. If the span has a parent, depending on whether the parent is remote and whether it is sampled, one of the following samplers will apply:
- RemoteSampled (default: [AlwaysOn])
- RemoteNotSampled (default: [AlwaysOff])
- LocalSampled (default: [AlwaysOn])
- LocalNotSampled (default: [AlwaysOff])
type Sampler ¶ added in v0.20.0
type Sampler interface {
// contains filtered or unexported methods
}
Sampler decides whether a trace should be sampled and exported.
func DefaultSampler ¶ added in v0.20.0
func DefaultSampler() Sampler
DefaultSampler returns a ParentBased sampler with the following defaults:
- Root: AlwaysOn
- RemoteSampled: AlwaysOn
- RemoteNotSampled: AlwaysOff
- LocalSampled: AlwaysOn
- LocalNotSampled: AlwaysOff
type TraceIDRatioSampler ¶ added in v0.20.0
type TraceIDRatioSampler struct {
// Fraction is the fraction of traces to sample. This value needs to be in the interval [0, 1].
Fraction float64
}
TraceIDRatioSampler samples a given fraction of traces. Fraction should be in the closed interval [0, 1]. To respect the parent trace's SampledFlag, the TraceIDRatioSampler sampler should be used as a delegate of a [ParentBased] sampler.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli runs OpenTelemetry automatic instrumentation for Go packages using eBPF.
|
Package cli runs OpenTelemetry automatic instrumentation for Go packages using eBPF. |
|
examples
module
|
|
|
httpPlusdb
module
|
|
|
kafka-go
module
|
|
|
kafka-go/consumer
module
|
|
|
kafka-go/producer
module
|
|
|
rolldice
module
|
|
|
rolldice/user
module
|
|
|
internal
|
|
|
pkg/inject
Package inject provides types and functionality to extract offset information from target ELF and inject that data into eBPF probes.
|
Package inject provides types and functionality to extract offset information from target ELF and inject that data into eBPF probes. |
|
pkg/instrumentation
Package instrumentation provides functionality to manage instrumentation using eBPF for Go programs.
|
Package instrumentation provides functionality to manage instrumentation using eBPF for Go programs. |
|
pkg/instrumentation/bpf/database/sql
Package sql provides an instrumentation probe for database clients using the database/sql package.
|
Package sql provides an instrumentation probe for database clients using the database/sql package. |
|
pkg/instrumentation/bpf/github.com/segmentio/kafka-go/consumer
Package consumer provides an instrumentation probe for Kafka consumer using the github.com/segmentio/kafka-go package.
|
Package consumer provides an instrumentation probe for Kafka consumer using the github.com/segmentio/kafka-go package. |
|
pkg/instrumentation/bpf/github.com/segmentio/kafka-go/producer
Package producer provides an instrumentation probe for Kafka producers using the github.com/segmentio/kafka-go package.
|
Package producer provides an instrumentation probe for Kafka producers using the github.com/segmentio/kafka-go package. |
|
pkg/instrumentation/bpf/go.opentelemetry.io/auto/sdk
Package sdk provides an instrumentation probe for the go.opentelemetry.io/auto/sdk package.
|
Package sdk provides an instrumentation probe for the go.opentelemetry.io/auto/sdk package. |
|
pkg/instrumentation/bpf/go.opentelemetry.io/otel/trace
Package sdk provides an auto-instrumentation probe for the built-in auto-SDK in the go.opentelemetry.io/otel/trace package.
|
Package sdk provides an auto-instrumentation probe for the built-in auto-SDK in the go.opentelemetry.io/otel/trace package. |
|
pkg/instrumentation/bpf/go.opentelemetry.io/otel/traceglobal
Package global provides an instrumentation probe for the go.opentelemetry.io/otel global trace API.
|
Package global provides an instrumentation probe for the go.opentelemetry.io/otel global trace API. |
|
pkg/instrumentation/bpf/google.golang.org/grpc/client
Package grpc provides an instrumentation probe for google.golang.org/grpc clients.
|
Package grpc provides an instrumentation probe for google.golang.org/grpc clients. |
|
pkg/instrumentation/bpf/google.golang.org/grpc/server
Package server provides an instrumentation probe for google.golang.org/grpc servers.
|
Package server provides an instrumentation probe for google.golang.org/grpc servers. |
|
pkg/instrumentation/bpf/net/http
Package http provides common functionality for net/http probe instrumentation.
|
Package http provides common functionality for net/http probe instrumentation. |
|
pkg/instrumentation/bpf/net/http/client
Package client provides an instrumentation probe for net/http clients.
|
Package client provides an instrumentation probe for net/http clients. |
|
pkg/instrumentation/bpf/net/http/server
Package server provides an instrumentation probe for net/http servers.
|
Package server provides an instrumentation probe for net/http servers. |
|
pkg/instrumentation/bpffs
Package bpffs manages the BPF file-system.
|
Package bpffs manages the BPF file-system. |
|
pkg/instrumentation/context
Package context contains tracing types used among probes.
|
Package context contains tracing types used among probes. |
|
pkg/instrumentation/debug
Package debug provides utilities for debugging instrumentation.
|
Package debug provides utilities for debugging instrumentation. |
|
pkg/instrumentation/kernel
Package kernel provides access to the operating system kernel state and settings.
|
Package kernel provides access to the operating system kernel state and settings. |
|
pkg/instrumentation/pdataconv
Package pdataconv provides conversion functions for the pdata format.
|
Package pdataconv provides conversion functions for the pdata format. |
|
pkg/instrumentation/probe
Package probe provides instrumentation probe types and definitions.
|
Package probe provides instrumentation probe types and definitions. |
|
pkg/instrumentation/probe/sampling
Package sampling provides types and functionality to support sampling of auto-instrumentation generated trace telemetry.
|
Package sampling provides types and functionality to support sampling of auto-instrumentation generated trace telemetry. |
|
pkg/process
Package process provides type and functionality for target Go processes.
|
Package process provides type and functionality for target Go processes. |
|
pkg/process/binary
Package binary provides types and functionality to handle function definitions within a target Go binary.
|
Package binary provides types and functionality to handle function definitions within a target Go binary. |
|
pkg/structfield
Package structfield provides types to track struct field offsets.
|
Package structfield provides types to track struct field offsets. |
|
test/getlog
Package getlog provides logger setup utilities for end-to-end integration testing applications.
|
Package getlog provides logger setup utilities for end-to-end integration testing applications. |
|
test/trigger
Package trigger provides trigger utilities for end-to-end integration testing applications.
|
Package trigger provides trigger utilities for end-to-end integration testing applications. |
|
test/e2e
module
|
|
|
test/e2e/autosdk
module
|
|
|
test/e2e/databasesql
module
|
|
|
test/e2e/gin
module
|
|
|
test/e2e/gorillamux
module
|
|
|
test/e2e/grpc
module
|
|
|
test/e2e/kafka-go
module
|
|
|
test/e2e/nethttp
module
|
|
|
test/e2e/otelglobal
module
|
|
|
tools
module
|
|
|
offsets-tracker
module
|
|
|
Package pipeline provides interfaces and types shared by other packages that handle processing and export of auto instrumentation generated telemetry.
|
Package pipeline provides interfaces and types shared by other packages that handle processing and export of auto instrumentation generated telemetry. |
|
otelsdk
Package otelsdk provides an implementation of pipeline.Handler that uses the default OpenTelemetry Go SDK to process and export the telemetry generated by auto-instrumentation.
|
Package otelsdk provides an implementation of pipeline.Handler that uses the default OpenTelemetry Go SDK to process and export the telemetry generated by auto-instrumentation. |
|
sdk
module
|
|
|
internal/telemetry/test
module
|
|
|
telemetry/test
module
|
|
|
test
|
|
|
e2e/gin
module
|
|
|
e2e/gorillamux
module
|
|
|
e2e/nethttp
module
|