telemetry

package
v0.26.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 41 Imported by: 2

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Name               = "github.com/foomo/keel"
	DefaultServiceName = "undefined"
)
View Source
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 CodeCaller(skip int) []attribute.KeyValue

func CodeStacktrace added in v0.24.0

func CodeStacktrace(num, skip int) attribute.KeyValue

func End deprecated

func End(sp trace.Span, err error)

Deprecated: use Ctx instead.

func EnvAttributes added in v0.22.0

func EnvAttributes() []attribute.KeyValue

func Log added in v0.22.0

func Log(ctx context.Context, lvl zapcore.Level, msg string, skip int, kv ...attribute.KeyValue)

func LogDebug added in v0.26.0

func LogDebug(ctx context.Context, msg string, kv ...attribute.KeyValue)

func LogError added in v0.26.0

func LogError(ctx context.Context, msg string, kv ...attribute.KeyValue)

func LogInfo added in v0.26.0

func LogInfo(ctx context.Context, msg string, kv ...attribute.KeyValue)

func LogWarn added in v0.26.0

func LogWarn(ctx context.Context, msg string, kv ...attribute.KeyValue)

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 NewProfiler(ctx context.Context) (*pyroscope.Profiler, error)

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

func NewResource(ctx context.Context) (*resource.Resource, error)

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

func NewZapLoggerProvider(ctx context.Context, logger *zap.Logger) (log.LoggerProvider, error)

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 PyroscopeLabels(kv ...attribute.KeyValue) pyroscope.LabelSet

func Start deprecated

func Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Deprecated: use Ctx instead.

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

type Context struct {
	context.Context
}

func Ctx added in v0.22.0

func Ctx(ctx context.Context) Context

func (Context) AddSpanEvent added in v0.22.0

func (c Context) AddSpanEvent(name string, kv ...attribute.KeyValue)

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) LogDebug added in v0.22.0

func (c Context) LogDebug(msg string, kv ...attribute.KeyValue)

LogDebug logs a message at debug level.

func (Context) LogError added in v0.22.0

func (c Context) LogError(msg string, kv ...attribute.KeyValue)

LogError logs a message at error level.

func (Context) LogInfo added in v0.22.0

func (c Context) LogInfo(msg string, kv ...attribute.KeyValue)

LogInfo logs a message at info level.

func (Context) LogWarn added in v0.22.0

func (c Context) LogWarn(msg string, kv ...attribute.KeyValue)

LogWarn logs a message at warn level.

func (Context) RecordError added in v0.22.0

func (c Context) RecordError(err error, kv ...attribute.KeyValue)

RecordError records an error on the span and logs it.

func (Context) RecordSpanError added in v0.22.0

func (c Context) RecordSpanError(err error, kv ...attribute.KeyValue)

RecordSpanError records an error on the span.

func (Context) SetProfileAttributes added in v0.22.0

func (c Context) SetProfileAttributes(kv ...attribute.KeyValue) Context

SetProfileAttributes sets the labels for the profile.

func (Context) SetSpanAttributes added in v0.22.0

func (c Context) SetSpanAttributes(kv ...attribute.KeyValue)

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

func (c Context) SetSpanName(name string)

SetSpanName sets the name of the span.

func (Context) SetSpanStatusError added in v0.22.0

func (c Context) SetSpanStatusError(description string)

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) Span added in v0.22.0

func (c Context) Span() trace.Span

Span returns the span from the context.

func (Context) StartProfile added in v0.22.0

func (c Context) StartProfile(name string, handler func(ctx Context), kv ...attribute.KeyValue)

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.

func (Context) StartSpanWithProfile added in v0.22.0

func (c Context) StartSpanWithProfile(name string, handler func(ctx Context), kv ...attribute.KeyValue)

StartSpanWithProfile starts a span and profiles the handler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL