telemetry

package module
v0.0.0-...-b94d56c Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 8 Imported by: 1

README

Framework which aims to ease logging affair: Logs, Traces and Metrics .

DRYRUN=1 VERSION=0.0.1 make release

Documentation

Index

Constants

View Source
const (
	DefaultInstrumentationName = "go-wrapper/telemetry"
)

Variables

View Source
var ErrMultipleInstance = errors.New("not allow to create multiple instances")

Functions

func Version

func Version() string

Version returns current version.

Types

type Closer

type Closer func(context.Context) error

func New

func New(ctx context.Context, cfg Config) (ctxTel context.Context, stopTel Closer, err error)

type Config

type Config struct {
	Provider       Provider
	ProviderConfig ProviderConfig

	InstrumentationName string `env:"TEL_INSTRUMENTATION_NAME"`
	ServiceName         string `env:"TEL_SERVICE_NAME"`
}

func NewConfig

func NewConfig() *Config

func (*Config) ApplyOptions

func (m *Config) ApplyOptions(options ...Option)

type ContextKey

type ContextKey struct{}

type LogConfig

type LogConfig struct {
	Enabled             bool `env:"TEL_LOG_ENABLED"`
	InstrumentationName string
}

type Logger

type Logger interface {
	Debug(ctx context.Context, msg string, attrs ...slog.Attr)
	Info(ctx context.Context, msg string, attrs ...slog.Attr)
	Warn(ctx context.Context, msg string, attrs ...slog.Attr)
	Error(ctx context.Context, msg string, attrs ...slog.Attr)
	Panic(ctx context.Context, msg string, attrs ...slog.Attr)
}

type LoggerConfig

type LoggerConfig struct {
}

type LoggerControl

type LoggerControl interface {
	LoggerProvider
	Shutdown(ctx context.Context) error
}

type LoggerOption

type LoggerOption func(config *LoggerConfig)

type LoggerProvider

type LoggerProvider interface {
	NewLogger(options ...LoggerOption) Logger
}

type Meter

type Meter interface {
}

type MeterConfig

type MeterConfig struct {
}

type MeterControl

type MeterControl interface {
	MeterProvider
	Shutdown(ctx context.Context) error
}

type MeterOption

type MeterOption func(config *MeterConfig)

type MeterProvider

type MeterProvider interface {
	NewMeter(name string, options ...MeterOption) Meter
}

type MetricConfig

type MetricConfig struct {
	Enabled  bool          `env:"TEL_METRIC_ENABLED"`
	Interval time.Duration `env:"TEL_METRIC_INTERVAL"`
}

type NoopLog

type NoopLog struct{}

func NewNoopLoggerControl

func NewNoopLoggerControl(_ LogConfig) *NoopLog

func (*NoopLog) Debug

func (m *NoopLog) Debug(_ context.Context, _ string, _ ...slog.Attr)

func (*NoopLog) Error

func (m *NoopLog) Error(_ context.Context, _ string, _ ...slog.Attr)

func (*NoopLog) Info

func (m *NoopLog) Info(_ context.Context, _ string, _ ...slog.Attr)

func (*NoopLog) NewLogger

func (m *NoopLog) NewLogger(options ...LoggerOption) Logger

func (*NoopLog) Panic

func (m *NoopLog) Panic(_ context.Context, _ string, _ ...slog.Attr)

func (*NoopLog) Shutdown

func (m *NoopLog) Shutdown(_ context.Context) error

func (*NoopLog) Warn

func (m *NoopLog) Warn(_ context.Context, _ string, _ ...slog.Attr)

type NoopMetric

type NoopMetric struct{}

func NewNoopMetricControl

func NewNoopMetricControl(_ MetricConfig) *NoopMetric

func (*NoopMetric) NewMeter

func (m *NoopMetric) NewMeter(name string, options ...MeterOption) Meter

func (*NoopMetric) Shutdown

func (m *NoopMetric) Shutdown(_ context.Context) error

type NoopPropagate

type NoopPropagate struct{}

func NewNoopPropagatorControl

func NewNoopPropagatorControl(_ PropagateConfig) *NoopPropagate

func (*NoopPropagate) Shutdown

func (m *NoopPropagate) Shutdown(_ context.Context) error

type NoopProvide

type NoopProvide struct{}

func NewNoopProvider

func NewNoopProvider() *NoopProvide

func (*NoopProvide) CollectorEndpoint

func (m *NoopProvide) CollectorEndpoint() string

func (*NoopProvide) NewLogControl

func (m *NoopProvide) NewLogControl(cfg LogConfig) (LoggerControl, error)

func (*NoopProvide) NewMetricControl

func (m *NoopProvide) NewMetricControl(cfg MetricConfig) (MeterControl, error)

func (*NoopProvide) NewPropagateControl

func (m *NoopProvide) NewPropagateControl(cfg PropagateConfig) (PropagatorControl, error)

func (*NoopProvide) NewTraceControl

func (m *NoopProvide) NewTraceControl(cfg TraceConfig) (TracerControl, error)

type NoopTrace

type NoopTrace struct{}

func (*NoopTrace) NewTracer

func (m *NoopTrace) NewTracer(options ...TracerOption) Tracer

func (*NoopTrace) Shutdown

func (m *NoopTrace) Shutdown(_ context.Context) error

type Option

type Option func(config *Config)

Option

  • WithProvider

  • WithProviderConfig

  • WithServiceName

  • WithInstrumentationName

func WithInstrumentationName

func WithInstrumentationName(name string) Option

func WithProvider

func WithProvider(provider Provider) Option

func WithProviderConfig

func WithProviderConfig(cfg ProviderConfig) Option

func WithServiceName

func WithServiceName(name string) Option

type PropagateConfig

type PropagateConfig struct {
	Enabled bool `env:"TEL_PROPAGATE_ENABLED"`
}

type Propagator

type Propagator interface{}

type PropagatorControl

type PropagatorControl interface {
	Propagator
	Shutdown(ctx context.Context) error
}

type Provider

type Provider interface {
	NewPropagateControl(cfg PropagateConfig) (PropagatorControl, error)

	NewLogControl(cfg LogConfig) (LoggerControl, error)
	NewTraceControl(cfg TraceConfig) (TracerControl, error)
	NewMetricControl(cfg MetricConfig) (MeterControl, error)

	CollectorEndpoint() string
}

type ProviderConfig

type ProviderConfig struct {
	Propagate PropagateConfig
	Log       LogConfig
	Trace     TraceConfig
	Metric    MetricConfig
}

type Telemetry

type Telemetry struct {
	// contains filtered or unexported fields
}

func FromCtx

func FromCtx(ctx context.Context) *Telemetry

func (*Telemetry) Debug

func (m *Telemetry) Debug(ctx context.Context, msg string, attrs ...slog.Attr)

func (*Telemetry) Error

func (m *Telemetry) Error(ctx context.Context, msg string, attrs ...slog.Attr)

func (*Telemetry) Info

func (m *Telemetry) Info(ctx context.Context, msg string, attrs ...slog.Attr)

func (*Telemetry) NewMeter

func (m *Telemetry) NewMeter(name string, options ...MeterOption) Meter

func (*Telemetry) Panic

func (m *Telemetry) Panic(ctx context.Context, msg string, attrs ...slog.Attr)

func (*Telemetry) Warn

func (m *Telemetry) Warn(ctx context.Context, msg string, attrs ...slog.Attr)

func (*Telemetry) WithCtx

func (m *Telemetry) WithCtx(ctx context.Context) context.Context

type TraceConfig

type TraceConfig struct {
	Enabled bool          `env:"TEL_TRACE_ENABLED"`
	Timeout time.Duration `env:"TEL_TRACE_TIMEOUT"`
}

type Tracer

type Tracer interface{}

type TracerConfig

type TracerConfig struct {
}

type TracerControl

type TracerControl interface {
	TracerProvider
	Shutdown(ctx context.Context) error
}

func NewNoopTracerControl

func NewNoopTracerControl(_ TraceConfig) TracerControl

type TracerOption

type TracerOption func(config *TracerConfig)

type TracerProvider

type TracerProvider interface {
	NewTracer(options ...TracerOption) Tracer
}

Directories

Path Synopsis
native
provider
otel Module

Jump to

Keyboard shortcuts

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