Documentation
¶
Overview ¶
Package telemetry provides an explicit, vendor-neutral OpenTelemetry runtime.
Index ¶
- Variables
- func BuildResource(ctx context.Context, config Config) (*resource.Resource, error)
- type BatchConfig
- type Compression
- type Config
- type ExporterConfig
- type MetricConfig
- type Option
- type Protocol
- type RetryConfig
- type Runtime
- func (r *Runtime) ForceFlush(ctx context.Context) error
- func (r *Runtime) Meter(name string, options ...metric.MeterOption) metric.Meter
- func (r *Runtime) MeterProvider() metric.MeterProvider
- func (r *Runtime) Propagator() otelpropagation.TextMapPropagator
- func (r *Runtime) Shutdown(ctx context.Context) error
- func (r *Runtime) Tracer(name string, options ...traceapi.TracerOption) traceapi.Tracer
- func (r *Runtime) TracerProvider() traceapi.TracerProvider
- type SamplerConfig
- type ServiceConfig
- type TLSConfig
- type TraceConfig
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAlreadyInitialized indicates that a globally registered runtime is // already active in this process. ErrAlreadyInitialized = errors.New("telemetry runtime already initialized") )
Functions ¶
Types ¶
type BatchConfig ¶
type BatchConfig struct {
MaxQueueSize int
MaxExportBatchSize int
BatchTimeout time.Duration
ExportTimeout time.Duration
}
BatchConfig bounds trace batching and its memory use.
type Compression ¶
type Compression string
Compression selects exporter payload compression.
const ( // CompressionNone disables payload compression. CompressionNone Compression = "none" // CompressionGZIP enables gzip payload compression. CompressionGZIP Compression = "gzip" )
type Config ¶
type Config struct {
Service ServiceConfig
Environment string
Resource map[string]string
Traces TraceConfig
Metrics MetricConfig
Propagation telemetrypropagation.Config
RegisterGlobal bool
ShutdownTimeout time.Duration
}
Config describes the complete runtime. Constructing it has no side effects.
func DefaultConfig ¶
DefaultConfig returns inspectable defaults suitable for exporting to a Collector sidecar or cluster-local agent.
type ExporterConfig ¶
type ExporterConfig struct {
Protocol Protocol
Endpoint string
URLPath string
Headers map[string]string
Compression Compression
TLS TLSConfig
Retry RetryConfig
Timeout time.Duration
}
ExporterConfig controls an OTLP exporter.
type MetricConfig ¶
type MetricConfig struct {
Enabled bool
Exporter ExporterConfig
ExportInterval time.Duration
ExportTimeout time.Duration
CardinalityLimit int
Views []telemetrymetric.ViewConfig
}
MetricConfig controls the metric provider and exporter.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option customizes runtime construction. Options are primarily useful for deterministic testing and custom Collector transports.
func WithMetricExporter ¶
func WithMetricExporter(exporter metricexport.Exporter) Option
WithMetricExporter supplies a standard OpenTelemetry metric exporter.
func WithTraceExporter ¶
func WithTraceExporter(exporter trace.SpanExporter) Option
WithTraceExporter supplies a standard OpenTelemetry span exporter.
type RetryConfig ¶
type RetryConfig struct {
Enabled bool
InitialInterval time.Duration
MaxInterval time.Duration
MaxElapsedTime time.Duration
}
RetryConfig bounds exporter retry behavior.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns the providers and their complete lifecycle.
func (*Runtime) ForceFlush ¶
ForceFlush exports all telemetry queued by the runtime.
func (*Runtime) MeterProvider ¶
func (r *Runtime) MeterProvider() metric.MeterProvider
MeterProvider returns the standard OpenTelemetry meter provider API.
func (*Runtime) Propagator ¶
func (r *Runtime) Propagator() otelpropagation.TextMapPropagator
Propagator returns the runtime's standard OpenTelemetry propagator.
func (*Runtime) Shutdown ¶
Shutdown unregisters globals owned by this runtime, flushes providers, and shuts them down. Every call returns the same aggregate result.
func (*Runtime) TracerProvider ¶
func (r *Runtime) TracerProvider() traceapi.TracerProvider
TracerProvider returns the standard OpenTelemetry tracer provider API.
type SamplerConfig ¶
type SamplerConfig struct {
Mode telemetrytrace.Mode
Ratio float64
ParentBased bool
}
SamplerConfig controls parent-based ratio sampling.
type ServiceConfig ¶
ServiceConfig identifies the process producing telemetry.
type TLSConfig ¶
type TLSConfig struct {
Insecure bool
CAFile string
CertificateFile string
PrivateKeyFile string
ServerName string
InsecureSkipVerify bool
}
TLSConfig controls transport security. Insecure is intended for a local or same-cluster Collector connection and must be selected explicitly.
type TraceConfig ¶
type TraceConfig struct {
Enabled bool
Exporter ExporterConfig
Batch BatchConfig
Sampler SamplerConfig
}
TraceConfig controls the trace provider and exporter.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
internal/exampleconfig
Package exampleconfig maps standard OpenTelemetry environment variables to the explicit telemetry configuration used by the examples.
|
Package exampleconfig maps standard OpenTelemetry environment variables to the explicit telemetry configuration used by the examples. |
|
service
command
Command service demonstrates HTTP service lifecycle and instrumentation.
|
Command service demonstrates HTTP service lifecycle and instrumentation. |
|
worker
command
Command worker demonstrates a bounded worker telemetry lifecycle.
|
Command worker demonstrates a bounded worker telemetry lifecycle. |
|
instrumentation
|
|
|
gocache
Package gocache provides dependency-neutral instrumentation for cache.
|
Package gocache provides dependency-neutral instrumentation for cache. |
|
gohttpclient
Package gohttpclient adapts the privacy-preserving net/http client bridge to http-client's standard RoundTripper composition seam.
|
Package gohttpclient adapts the privacy-preserving net/http client bridge to http-client's standard RoundTripper composition seam. |
|
gopostgres
Package gopostgres provides a privacy-preserving pgx tracing bridge for postgres.
|
Package gopostgres provides a privacy-preserving pgx tracing bridge for postgres. |
|
goqueue
Package goqueue provides dependency-neutral handler instrumentation for queue.
|
Package goqueue provides dependency-neutral handler instrumentation for queue. |
|
goruntime
Package goruntime exports bounded Go runtime metrics without starting a background collector or registering global providers.
|
Package goruntime exports bounded Go runtime metrics without starting a background collector or registering global providers. |
|
nethttp
Package nethttp instruments net/http servers and clients without recording raw URLs, hosts, headers, bodies, client addresses, or arbitrary methods.
|
Package nethttp instruments net/http servers and clients without recording raw URLs, hosts, headers, bodies, client addresses, or arbitrary methods. |
|
Package metric defines bounded metric SDK configuration, views, and cardinality controls.
|
Package metric defines bounded metric SDK configuration, views, and cardinality controls. |
|
Package otlp constructs explicitly configured OTLP trace and metric exporters without reading vendor-specific settings.
|
Package otlp constructs explicitly configured OTLP trace and metric exporters without reading vendor-specific settings. |
|
Package propagation provides bounded W3C propagation with explicit inbound trust decisions.
|
Package propagation provides bounded W3C propagation with explicit inbound trust decisions. |
|
Package telemetryservice adapts an explicit telemetry runtime to the service lifecycle.
|
Package telemetryservice adapts an explicit telemetry runtime to the service lifecycle. |
|
Package testtelemetry provides deterministic in-memory providers for tests.
|
Package testtelemetry provides deterministic in-memory providers for tests. |
|
Package trace defines stable trace configuration and sampling policies.
|
Package trace defines stable trace configuration and sampling policies. |