Documentation
¶
Index ¶
- type DatadogMetricHandler
- func (dd *DatadogMetricHandler) Close() error
- func (dd *DatadogMetricHandler) Distribution(ctx context.Context, metric string, value float64, tags types.Tags) error
- func (dd *DatadogMetricHandler) Event(ctx context.Context, title, text string, tags types.Tags) error
- func (dd *DatadogMetricHandler) Gauge(ctx context.Context, metric string, value float64, tags types.Tags) error
- func (dd *DatadogMetricHandler) Histogram(ctx context.Context, metric string, value float64, tags types.Tags) error
- func (dd *DatadogMetricHandler) Increment(ctx context.Context, metric string, value int64, tags types.Tags) error
- type MetricHandler
- type OtelMetricHandler
- func (c *OtelMetricHandler) Close() error
- func (c *OtelMetricHandler) Gauge(ctx context.Context, metricName string, value float64, tags types.Tags) error
- func (c *OtelMetricHandler) Histogram(ctx context.Context, metricName string, value float64, tags types.Tags) error
- func (c *OtelMetricHandler) Increment(ctx context.Context, metricName string, value int64, tags types.Tags) error
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.
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.