Documentation
¶
Index ¶
- Constants
- func ConfigureLogger(ctx context.Context, globalTags map[string]string, logLevel string) (*slog.Logger, error)
- func Gauge(metrics *statsd.Client, name string, value float64, tags map[string]string, ...)
- func GaugeDuration(metrics *statsd.Client, name string, startedAt time.Time, ...)
- func GetClient(ctx context.Context) *statsd.Client
- func Increment(metrics *statsd.Client, name string, tags map[string]string)
- func WithStatsd(ctx context.Context, metricsNamespace string) context.Context
- type Config
- type DatadogLoggerConfiguration
- type PeriodicMetricsReporter
- type PeriodicMetricsReporterConfig
Constants ¶
View Source
const LevelLoggingDisabled slog.Level = 100
LevelLoggingDisabled sets the slog log level for LoggingDisabled string constant
View Source
const LoggingDisabled = "DISABLED"
LoggingDisabled holds a value to use when logging should be globally disabled, without removing the log handler
View Source
const (
// MetricsClientContextKey sets the context key for the metrics client
MetricsClientContextKey contextKey = "metrics"
)
Variables ¶
This section is empty.
Functions ¶
func ConfigureLogger ¶
func Gauge ¶
func Gauge(metrics *statsd.Client, name string, value float64, tags map[string]string, rate float64)
Gauge reports a GAUGE metric using best-effort approach
func GaugeDuration ¶
func GaugeDuration(metrics *statsd.Client, name string, startedAt time.Time, tags map[string]string, rate float64)
GaugeDuration reports a GAUGE metric corresponding to a duration of an operation that started at a specified time, in milliseconds
Types ¶
type Config ¶
type Config struct {
// LogLevel sets the logging level (e.g., "debug", "info", "warn", "error").
LogLevel string `mapstructure:"log-level,omitempty"`
// ClusterName sets the name of the cluster where the application is running.
ClusterName string `mapstructure:"cluster-name,omitempty"`
// MetricsBindAddress sets the address for binding the metrics server.
MetricsBindAddress string `mapstructure:"metrics-bind-address,omitempty"`
}
type DatadogLoggerConfiguration ¶
type DatadogLoggerConfiguration struct {
Endpoint string
ApiKey string
Hostname string
ServiceName string
}
func NewDatadogLoggerConfiguration ¶
func NewDatadogLoggerConfiguration() (*DatadogLoggerConfiguration, error)
type PeriodicMetricsReporter ¶
type PeriodicMetricsReporter struct {
// contains filtered or unexported fields
}
func NewPeriodicMetricsReporter ¶
func NewPeriodicMetricsReporter(client *statsd.Client, settings *PeriodicMetricsReporterConfig) *PeriodicMetricsReporter
func (*PeriodicMetricsReporter) AddStreamClass ¶
func (d *PeriodicMetricsReporter) AddStreamClass(kind string, metricName string, tags map[string]string)
func (*PeriodicMetricsReporter) RemoveStreamClass ¶
func (d *PeriodicMetricsReporter) RemoveStreamClass(kind string)
func (*PeriodicMetricsReporter) RunPeriodicMetricsReporter ¶
func (d *PeriodicMetricsReporter) RunPeriodicMetricsReporter(ctx context.Context)
RunPeriodicMetricsReporter starts the metrics reporting loop for stream classes. It reports a metric for each registered stream class at regular intervals. When context is cancelled, the reporting loop exits.
type PeriodicMetricsReporterConfig ¶
type PeriodicMetricsReporterConfig struct {
// InitialDelay is the delay before the first metrics report is sent.
InitialDelay time.Duration `mapstructure:"initial-delay,omitempty"`
// ReportInterval is the interval between successive metrics reports.
ReportInterval time.Duration `mapstructure:"report-interval,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.