Documentation
¶
Index ¶
- type Config
- type Impl
- func (obs *Impl) AreMetricsEnabled() bool
- func (obs *Impl) IsProfilingEnabled() bool
- func (obs *Impl) IsTracingEnabled() bool
- func (obs *Impl) Log() *otelzap.Logger
- func (obs *Impl) LogSpan(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func(), otelzap.LoggerWithCtx)
- func (obs *Impl) LogSpanWithTimeout(ctx context.Context, spanName string, timeout time.Duration, ...) (context.Context, func(), otelzap.LoggerWithCtx)
- func (obs *Impl) Metrics() *Metrics
- func (obs *Impl) SetupGinMiddleware(router *gin.Engine, opts ...MetricMiddlewareOpt)
- func (obs *Impl) Shutdown(ctx context.Context) error
- func (obs *Impl) Span(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func())
- func (obs *Impl) WithSpanKind(spanKind trace.SpanKind) Observability
- type LogConfig
- type LogFormat
- type LogLevel
- type Logging
- type MetricMiddlewareOpt
- type MetricMiddlewareOpts
- type Metrics
- type MetricsConfig
- type Observability
- type OtelLogger
- type Profiling
- type ProfilingConfig
- type ServiceInfo
- type Tracing
- type TracingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Tracing TracingConfig `json:"tracing" yaml:"tracing" mapstructure:"tracing"`
Metrics MetricsConfig `json:"metrics" yaml:"metrics" mapstructure:"metrics"`
Logging LogConfig `json:"logging" yaml:"logging" mapstructure:"logging"`
Profiling ProfilingConfig `json:"profiling" yaml:"profiling" mapstructure:"profiling"`
}
Config configures logs, traces and metrics for the application
type Impl ¶
type Impl struct {
metric.MeterProvider
// contains filtered or unexported fields
}
func NewObservability ¶
func (*Impl) AreMetricsEnabled ¶ added in v0.2.2
func (*Impl) IsProfilingEnabled ¶ added in v0.2.2
func (*Impl) IsTracingEnabled ¶ added in v0.2.2
func (*Impl) LogSpan ¶
func (obs *Impl) LogSpan(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func(), otelzap.LoggerWithCtx)
LogSpan creates a new span with the given name and fields and logs the span and trace id fields
func (*Impl) LogSpanWithTimeout ¶
func (obs *Impl) LogSpanWithTimeout(ctx context.Context, spanName string, timeout time.Duration, fields ...zap.Field) (context.Context, func(), otelzap.LoggerWithCtx)
LogSpanWithTimeout creates a new span with the given name and fields and logs the span and trace id fields
func (*Impl) SetupGinMiddleware ¶ added in v0.2.0
func (obs *Impl) SetupGinMiddleware(router *gin.Engine, opts ...MetricMiddlewareOpt)
SetupGinMiddleware adds middleware to the Gin router based on the observability configuration
func (*Impl) Span ¶
func (obs *Impl) Span(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func())
Span creates a new span
func (*Impl) WithSpanKind ¶
func (obs *Impl) WithSpanKind(spanKind trace.SpanKind) Observability
WithSpanKind returns a copy of the observability instance with the given span type
type LogConfig ¶
type LogConfig struct {
Level *LogLevel `yaml:"level" json:"level,omitempty" mapstructure:"level"` // debug, info, warn, error
OtelLogger *OtelLogger `yaml:"otelLogger" json:"otelLogger,omitempty" mapstructure:"otelLogger"`
}
LogConfig is the configuration for the logging
type MetricMiddlewareOpt ¶ added in v0.2.4
type MetricMiddlewareOpt func(*MetricMiddlewareOpts)
func WithAdditionalAttributes ¶ added in v0.2.4
func WithAdditionalAttributes(attrs []attribute.KeyValue) MetricMiddlewareOpt
func WithTracingEnabled ¶ added in v0.2.4
func WithTracingEnabled(enabled bool) MetricMiddlewareOpt
func WithUserHeader ¶ added in v0.2.4
func WithUserHeader(header string) MetricMiddlewareOpt
type MetricMiddlewareOpts ¶ added in v0.2.4
type MetricMiddlewareOpts struct {
// contains filtered or unexported fields
}
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics(ctx context.Context, info ServiceInfo, config MetricsConfig) (*Metrics, error)
NewMetrics Creates a new metrics instance
func (*Metrics) Middleware ¶
func (m *Metrics) Middleware(opts ...MetricMiddlewareOpt) func(c *gin.Context)
Middleware returns a gin middleware that records metrics for each HTTP request.
type MetricsConfig ¶
type MetricsConfig struct {
Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
Address string `json:"address,omitempty" yaml:"address" mapstructure:"address"`
TLS tls.TLS `json:"tls" yaml:"tls" mapstructure:"tls"`
PushInterval int64 `json:"pushInterval,omitempty" yaml:"pushInterval" mapstructure:"pushInterval"`
}
MetricsConfig configures the metrics for the application (over OpenTelemetry GRPC).
type Observability ¶
type Observability interface {
Shutdown(ctx context.Context) error
Span(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func())
LogSpan(ctx context.Context, spanName string, fields ...zap.Field) (context.Context, func(), otelzap.LoggerWithCtx)
LogSpanWithTimeout(ctx context.Context, spanName string, timeout time.Duration, fields ...zap.Field) (context.Context, func(), otelzap.LoggerWithCtx)
Log() *otelzap.Logger
Metrics() *Metrics
SetupGinMiddleware(router *gin.Engine, opts ...MetricMiddlewareOpt)
WithSpanKind(spanKind trace.SpanKind) Observability
IsTracingEnabled() bool
IsProfilingEnabled() bool
AreMetricsEnabled() bool
metric.MeterProvider
}
func NewNoopObservability ¶
func NewNoopObservability() Observability
type OtelLogger ¶ added in v0.2.1
type Profiling ¶
type Profiling struct {
// contains filtered or unexported fields
}
func NewProfiler ¶
type ProfilingConfig ¶
type ProfilingConfig struct {
Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
Address string `json:"address,omitempty" yaml:"address" mapstructure:"address"`
// Deprecated: Use username and password instead
AuthToken string `json:"authToken,omitempty" yaml:"authToken" mapstructure:"authToken"`
Username string `json:"username,omitempty" yaml:"username" mapstructure:"username"`
Password string `json:"password,omitempty" yaml:"password" mapstructure:"password"`
}
type ServiceInfo ¶
type Tracing ¶
type Tracing struct {
// contains filtered or unexported fields
}
func NewTracing ¶
func NewTracing(ctx context.Context, info ServiceInfo, config TracingConfig) (*Tracing, error)
NewTracing creates a new tracing instance
func (*Tracing) TracerProvider ¶ added in v0.2.0
func (t *Tracing) TracerProvider() trace.TracerProvider
type TracingConfig ¶
type TracingConfig struct {
Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled"`
Address string `json:"address,omitempty" yaml:"address" mapstructure:"address"`
TLS tls.TLS `json:"tls" yaml:"tls" mapstructure:"tls"`
}
TracingConfig configures the tracing for the application (over OpenTelemetry GRPC).