handlers

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatadogMetricHandler

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

DatadogMetricHandler implements the MetricHandler interface for Datadog.

func NewDatadogMetricHandler

func NewDatadogMetricHandler(metricPrefix, serverHost string, serverPort int) (*DatadogMetricHandler, error)

NewDatadogMetricHandler creates a new Datadog client using the statsd protocol. It configures the client with a namespace (metric prefix) and server address.

func (*DatadogMetricHandler) Close

func (dd *DatadogMetricHandler) Close() error

Close closes the underlying statsd client connection.

func (*DatadogMetricHandler) Distribution

func (dd *DatadogMetricHandler) Distribution(ctx context.Context, metric string, value float64, tags types.Tags) error

Distribution sends a distribution sample, used for percentile analysis in Datadog. Note: This method is not part of the common MetricHandler interface.

func (*DatadogMetricHandler) Event

func (dd *DatadogMetricHandler) Event(ctx context.Context, title, text string, tags types.Tags) error

Event sends a custom event to the Datadog event stream. Note: This method is not part of the common MetricHandler interface.

func (*DatadogMetricHandler) Gauge

func (dd *DatadogMetricHandler) Gauge(ctx context.Context, metric string, value float64, tags types.Tags) error

Gauge sets a gauge metric value in Datadog.

func (*DatadogMetricHandler) Histogram

func (dd *DatadogMetricHandler) Histogram(ctx context.Context, metric string, value float64, tags types.Tags) error

Histogram sends a histogram sample value to Datadog.

func (*DatadogMetricHandler) Increment

func (dd *DatadogMetricHandler) Increment(ctx context.Context, metric string, value int64, tags types.Tags) error

Increment increments a counter metric in Datadog.

type MetricHandler

type MetricHandler interface {
	// Increment sends a counter metric.
	Increment(ctx context.Context, metric string, value int64, tags types.Tags) error
	// Gauge sends a gauge metric.
	Gauge(ctx context.Context, metric string, value float64, tags types.Tags) error
	// Histogram sends a histogram metric.
	Histogram(ctx context.Context, metric string, value float64, tags types.Tags) error
	// Close flushes and closes the connection to the backend.
	Close() error
}

MetricHandler defines the interface for a metrics backend client. It abstracts the specific implementation details of different metric collectors like Datadog or OpenTelemetry.

type OtelMetricHandler

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

OtelMetricHandler implements the MetricHandler interface for OpenTelemetry.

func NewOtelMetricHandler

func NewOtelMetricHandler(serviceName, serviceVersion, otelEndpoint string) (*OtelMetricHandler, error)

NewOtelMetricHandler creates a new OpenTelemetry client, including trace and metric providers. It establishes a GRPC connection to an OTEL collector.

func (*OtelMetricHandler) Close

func (c *OtelMetricHandler) Close() error

Close gracefully shuts down the OpenTelemetry trace and meter providers, ensuring all buffered telemetry is exported.

func (*OtelMetricHandler) Gauge

func (c *OtelMetricHandler) Gauge(ctx context.Context, metricName string, value float64, tags types.Tags) error

Gauge records a value for a gauge metric in OpenTelemetry. It creates the gauge on-demand if it doesn't already exist.

func (*OtelMetricHandler) Histogram

func (c *OtelMetricHandler) Histogram(ctx context.Context, metricName string, value float64, tags types.Tags) error

Histogram records a value for a histogram metric in OpenTelemetry. It creates the histogram on-demand if it doesn't already exist.

func (*OtelMetricHandler) Increment

func (c *OtelMetricHandler) Increment(ctx context.Context, metricName string, value int64, tags types.Tags) error

Increment adds a value to a counter metric in OpenTelemetry. It creates the counter on-demand if it doesn't already exist.

Jump to

Keyboard shortcuts

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