Documentation
¶
Index ¶
- Variables
- func CodeCaller(skip int) []attribute.KeyValue
- func CodeStacktrace(num, skip int) attribute.KeyValue
- func End(sp trace.Span, err error)deprecated
- func EnvAttributes() []attribute.KeyValue
- func Log(ctx context.Context, lvl zapcore.Level, msg string, skip int, ...)
- func LogDebug(ctx context.Context, msg string, kv ...attribute.KeyValue)
- func LogError(ctx context.Context, msg string, kv ...attribute.KeyValue)
- func LogInfo(ctx context.Context, msg string, kv ...attribute.KeyValue)
- func LogWarn(ctx context.Context, msg string, kv ...attribute.KeyValue)
- func LoggerProvider() log.LoggerProvider
- func Meter(opts ...metric.MeterOption) metric.Meter
- func MeterProvider() metric.MeterProvider
- func NewFloatCounter(name string, opts ...any) metric.Float64Counter
- func NewFloatGauge(name string, opts ...any) metric.Float64Gauge
- func NewFloatHistogram(name string, opts ...any) metric.Float64Histogram
- func NewFloatUpDownCounter(name string, opts ...any) metric.Float64UpDownCounter
- func NewIntCounter(name string, opts ...any) metric.Int64Counter
- func NewIntGauge(name string, opts ...any) metric.Int64Gauge
- func NewIntHistogram(name string, opts ...any) metric.Int64Histogram
- func NewIntUpDownCounter(name string, opts ...any) metric.Int64UpDownCounter
- func NewNoopMeterProvider() metric.MeterProvider
- func NewNoopTraceProvider() trace.TracerProvider
- func NewOTLPGRCPLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
- func NewOTLPGRPCTraceProvider(ctx context.Context, opts ...otlptracegrpc.Option) (trace.TracerProvider, error)
- func NewOTLPHTTPLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
- func NewOTLPHTTPTraceProvider(ctx context.Context, opts ...otlptracehttp.Option) (trace.TracerProvider, error)
- func NewProfiler(ctx context.Context) (*pyroscope.Profiler, error)
- func NewPrometheusMeterProvider(ctx context.Context) (metric.MeterProvider, error)
- func NewResource(ctx context.Context) (*resource.Resource, error)
- func NewStdOutLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
- func NewStdOutMeterProvider(ctx context.Context, opts ...stdoutmetric.Option) (metric.MeterProvider, error)
- func NewStdOutTraceProvider(ctx context.Context) (trace.TracerProvider, error)
- func NewZapLoggerProvider(ctx context.Context, logger *zap.Logger) (log.LoggerProvider, error)
- func PyroscopeLabels(kv ...attribute.KeyValue) pyroscope.LabelSet
- func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)deprecated
- func Tracer(opts ...trace.TracerOption) trace.Tracer
- func TracerProvider() trace.TracerProvider
- type Context
- func (c Context) AddSpanEvent(name string, kv ...attribute.KeyValue)
- func (c Context) DeferEndSpan(err *error, opts ...trace.SpanEndOption)
- func (c Context) EndSpan(err error, opts ...trace.SpanEndOption)
- func (c Context) LogDebug(msg string, kv ...attribute.KeyValue)
- func (c Context) LogError(msg string, kv ...attribute.KeyValue)
- func (c Context) LogInfo(msg string, kv ...attribute.KeyValue)
- func (c Context) LogWarn(msg string, kv ...attribute.KeyValue)
- func (c Context) RecordError(err error, kv ...attribute.KeyValue)
- func (c Context) RecordSpanError(err error, kv ...attribute.KeyValue)
- func (c Context) SetProfileAttributes(kv ...attribute.KeyValue) Context
- func (c Context) SetSpanAttributes(kv ...attribute.KeyValue)
- func (c Context) SetSpanDebug()
- func (c Context) SetSpanName(name string)
- func (c Context) SetSpanStatusError(description string)
- func (c Context) SetSpanStatusOK()
- func (c Context) Span() trace.Span
- func (c Context) StartProfile(name string, handler func(ctx Context), kv ...attribute.KeyValue)
- func (c Context) StartSpan(opts ...trace.SpanStartOption) Context
- func (c Context) StartSpanWithNewRoot(opts ...trace.SpanStartOption) Context
- func (c Context) StartSpanWithProfile(name string, handler func(ctx Context), kv ...attribute.KeyValue)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( Name = "github.com/foomo/keel" DefaultServiceName = "undefined" )
var ( // Deprecated: DefaultHistogramBuckets units are selected for metrics in "seconds" unit DefaultHistogramBuckets = []float64{.001, .005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 25, 60, 120, 300, 600} )
Functions ¶
func CodeCaller ¶ added in v0.24.0
func CodeStacktrace ¶ added in v0.24.0
func EnvAttributes ¶ added in v0.22.0
func LoggerProvider ¶ added in v0.22.0
func LoggerProvider() log.LoggerProvider
LoggerProvider returns the global logger provider instance used throughout the application.
func Meter ¶ added in v0.2.0
func Meter(opts ...metric.MeterOption) metric.Meter
Meter returns a metric.Meter instance with the provided options, using the default MeterProvider and the defined Name.
func MeterProvider ¶ added in v0.22.0
func MeterProvider() metric.MeterProvider
MeterProvider returns the default metric.MeterProvider instance for creating meters.
func NewFloatCounter ¶ added in v0.22.1
func NewFloatCounter(name string, opts ...any) metric.Float64Counter
NewFloatCounter creates and returns a Float64Counter metric instrument with the specified name and optional settings.
func NewFloatGauge ¶ added in v0.22.1
func NewFloatGauge(name string, opts ...any) metric.Float64Gauge
NewFloatGauge creates and returns a Float64Gauge metric with the specified name and optional configurations.
func NewFloatHistogram ¶ added in v0.22.1
func NewFloatHistogram(name string, opts ...any) metric.Float64Histogram
NewFloatHistogram creates and returns a Float64Histogram metric instrument with the specified name and optional settings.
func NewFloatUpDownCounter ¶ added in v0.22.1
func NewFloatUpDownCounter(name string, opts ...any) metric.Float64UpDownCounter
NewFloatUpDownCounter creates and returns a Float64UpDownCounter metric instrument with the specified name and optional settings.
func NewIntCounter ¶ added in v0.22.1
func NewIntCounter(name string, opts ...any) metric.Int64Counter
NewIntCounter creates and returns a Int64Counter metric instrument with the specified name and optional settings.
func NewIntGauge ¶ added in v0.22.1
func NewIntGauge(name string, opts ...any) metric.Int64Gauge
NewIntGauge creates and returns a Int64Gauge metric instrument with the specified name and optional settings.
func NewIntHistogram ¶ added in v0.22.1
func NewIntHistogram(name string, opts ...any) metric.Int64Histogram
NewIntHistogram creates and returns a Int64Histogram metric instrument with the specified name and optional settings.
func NewIntUpDownCounter ¶ added in v0.22.1
func NewIntUpDownCounter(name string, opts ...any) metric.Int64UpDownCounter
NewIntUpDownCounter creates and returns a Int64UpDownCounter metric instrument with the specified name and optional settings.
func NewNoopMeterProvider ¶ added in v0.8.0
func NewNoopMeterProvider() metric.MeterProvider
NewNoopMeterProvider returns a no-op metric.MeterProvider and sets it as the global MeterProvider.
func NewNoopTraceProvider ¶ added in v0.8.0
func NewNoopTraceProvider() trace.TracerProvider
NewNoopTraceProvider creates and returns a no-op tracer provider, setting it as the global otel tracer provider.
func NewOTLPGRCPLoggerProvider ¶ added in v0.22.0
func NewOTLPGRCPLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
NewOTLPGRCPLoggerProvider creates a new OTLP gRPC-based logger provider using the provided context.
func NewOTLPGRPCTraceProvider ¶ added in v0.8.0
func NewOTLPGRPCTraceProvider(ctx context.Context, opts ...otlptracegrpc.Option) (trace.TracerProvider, error)
NewOTLPGRPCTraceProvider creates a new trace provider configured for OTLP over gRPC with optional settings. It uses environment variables for settings like endpoint and insecure mode if not provided explicitly. Returns a configured TracerProvider or an error if initialization fails.
func NewOTLPHTTPLoggerProvider ¶ added in v0.22.0
func NewOTLPHTTPLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
NewOTLPHTTPLoggerProvider creates a new OTLP HTTP LoggerProvider with a batch processor and default resource.
func NewOTLPHTTPTraceProvider ¶ added in v0.8.0
func NewOTLPHTTPTraceProvider(ctx context.Context, opts ...otlptracehttp.Option) (trace.TracerProvider, error)
NewOTLPHTTPTraceProvider creates an OTLP HTTP trace provider using the given context and options. It configures the provider based on environment variables, such as endpoint and insecure transport. Returns a configured trace.TracerProvider instance or an error if the initialization fails.
func NewProfiler ¶ added in v0.22.0
func NewPrometheusMeterProvider ¶ added in v0.8.0
func NewPrometheusMeterProvider(ctx context.Context) (metric.MeterProvider, error)
NewPrometheusMeterProvider initializes and returns a Prometheus-based metric.MeterProvider with default configuration.
func NewResource ¶ added in v0.22.0
NewResource creates and returns a default resource for telemetry data, using the provided context.
func NewStdOutLoggerProvider ¶ added in v0.22.0
func NewStdOutLoggerProvider(ctx context.Context) (log.LoggerProvider, error)
NewStdOutLoggerProvider creates a logger provider that exports logs to standard output with configurable options.
func NewStdOutMeterProvider ¶ added in v0.8.0
func NewStdOutMeterProvider(ctx context.Context, opts ...stdoutmetric.Option) (metric.MeterProvider, error)
NewStdOutMeterProvider creates a new MeterProvider that exports metrics to standard output with configurable options.
func NewStdOutTraceProvider ¶ added in v0.8.0
func NewStdOutTraceProvider(ctx context.Context) (trace.TracerProvider, error)
NewStdOutTraceProvider creates a new stdout trace provider with optional configurations from the environment variables. It uses pretty print and timestamps by default unless overridden by the respective environment variables. Returns a configured trace.TracerProvider or an error if the setup fails.
func NewZapLoggerProvider ¶ added in v0.22.0
NewZapLoggerProvider creates a new log.LoggerProvider using a Zap logger for structured logging with OpenTelemetry.
Example ¶
package main
import (
"context"
"github.com/foomo/keel/telemetry"
"go.opentelemetry.io/otel/log"
"go.uber.org/zap"
)
func main() {
l := zap.NewExample()
ctx := context.Background()
_, _ = telemetry.NewZapLoggerProvider(ctx, l)
// Raw log record
record := log.Record{}
record.SetSeverity(log.SeverityInfo)
record.SetBody(log.StringValue("something really cool"))
tl := telemetry.LoggerProvider().Logger(telemetry.Name)
tl.Emit(ctx, record)
}
Output: {"level":"info","msg":"something really cool"}
func PyroscopeLabels ¶ added in v0.22.0
func Tracer ¶
func Tracer(opts ...trace.TracerOption) trace.Tracer
Tracer returns a trace.Tracer instance configured with optional TracerOptions.
func TracerProvider ¶ added in v0.2.0
func TracerProvider() trace.TracerProvider
TracerProvider returns the global TracerProvider instance used for creating tracers.
Types ¶
type Context ¶ added in v0.22.0
func (Context) AddSpanEvent ¶ added in v0.22.0
AddSpanEvent adds an event to the span.
func (Context) DeferEndSpan ¶ added in v0.22.1
func (c Context) DeferEndSpan(err *error, opts ...trace.SpanEndOption)
DeferEndSpan is a helper so you can do `defer ctx.DeferEndSpan(&err)` instead of `defer func(){ ctx.EndSpan(err) }()`
func (Context) EndSpan ¶ added in v0.22.0
func (c Context) EndSpan(err error, opts ...trace.SpanEndOption)
EndSpan ends the span.
func (Context) RecordError ¶ added in v0.22.0
RecordError records an error on the span and logs it.
func (Context) RecordSpanError ¶ added in v0.22.0
RecordSpanError records an error on the span.
func (Context) SetProfileAttributes ¶ added in v0.22.0
SetProfileAttributes sets the labels for the profile.
func (Context) SetSpanAttributes ¶ added in v0.22.0
SetSpanAttributes sets the attributes of the span.
func (Context) SetSpanDebug ¶ added in v0.22.1
func (c Context) SetSpanDebug()
func (Context) SetSpanName ¶ added in v0.22.0
SetSpanName sets the name of the span.
func (Context) SetSpanStatusError ¶ added in v0.22.0
SetSpanStatusError sets the status of the span to error.
func (Context) SetSpanStatusOK ¶ added in v0.22.0
func (c Context) SetSpanStatusOK()
SetSpanStatusOK sets the status of the span to ok.
func (Context) StartProfile ¶ added in v0.22.0
StartProfile starts a profile for the handler.
func (Context) StartSpan ¶ added in v0.22.0
func (c Context) StartSpan(opts ...trace.SpanStartOption) Context
StartSpan starts a span.
func (Context) StartSpanWithNewRoot ¶ added in v0.22.1
func (c Context) StartSpanWithNewRoot(opts ...trace.SpanStartOption) Context
StartSpanWithNewRoot sets the name of the span.