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)
- 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) *Impl
- type LogConfig
- type LogFormat
- type LogLevel
- type Logging
- type Metrics
- func (m *Metrics) DecrementConsumers(queueName string)
- func (m *Metrics) IncrementConsumers(queueName string)
- func (m *Metrics) IncrementMessagesAcknowledged(queueName string)
- func (m *Metrics) IncrementMessagesDelivered(queueName string)
- func (m *Metrics) IncrementMessagesDiscarded(queueName string)
- func (m *Metrics) IncrementMessagesPublished(ctx context.Context, queueName string)
- func (m *Metrics) IncrementMessagesRequeued(queueName string)
- func (m *Metrics) Middleware(tracingEnabled bool) func(c *gin.Context)
- 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
SetupGinMiddleware adds middleware to the Gin router based on the observability configuration
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 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) DecrementConsumers ¶
func (*Metrics) IncrementConsumers ¶
todo underlying implementation should use metrics package instead?
func (*Metrics) IncrementMessagesAcknowledged ¶
func (*Metrics) IncrementMessagesDelivered ¶
func (*Metrics) IncrementMessagesDiscarded ¶
func (*Metrics) IncrementMessagesPublished ¶
func (*Metrics) IncrementMessagesRequeued ¶
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) WithSpanKind(spanKind trace.SpanKind) *Impl 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 ¶
func NewProfiler(name string, config ProfilingConfig) (*Profiling, error)
type ProfilingConfig ¶
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).