metrics

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(collectors ...NamedCollector) http.Handler

NewHandler returns an HTTP handler that gathers metrics from the provided NamedCollectors. Each collector is wrapped with tracing and the request context (if supported).

Types

type ContextAwareCollector

type ContextAwareCollector interface {
	prometheus.Collector
	WithContext(ctx context.Context) NamedCollector
}

ContextAwareCollector allows injecting context into a wrapped collector.

type HTTPMetricsCollector

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

HTTPMetricsCollector implements NamedCollector and integrates OpenTelemetry HTTP metrics with the existing Prometheus metrics infrastructure.

func NewHTTPMetricsCollector

func NewHTTPMetricsCollector(ctx context.Context, _ *config.Config, serviceName string, log logrus.FieldLogger) *HTTPMetricsCollector

NewHTTPMetricsCollector creates a new HTTPMetricsCollector that integrates OpenTelemetry HTTP metrics with Prometheus. It initializes the OpenTelemetry meter provider and creates a Prometheus exporter for metrics collection.

func (*HTTPMetricsCollector) Collect

func (c *HTTPMetricsCollector) Collect(ch chan<- prometheus.Metric)

Collect forwards the Collect call to the OpenTelemetry Prometheus registry

func (*HTTPMetricsCollector) Describe

func (c *HTTPMetricsCollector) Describe(ch chan<- *prometheus.Desc)

Describe forwards the Describe call to the OpenTelemetry Prometheus registry

func (*HTTPMetricsCollector) MetricsName

func (c *HTTPMetricsCollector) MetricsName() string

MetricsName returns the name of this collector for tracing purposes

func (*HTTPMetricsCollector) Shutdown

func (c *HTTPMetricsCollector) Shutdown() error

Shutdown gracefully shuts down the OpenTelemetry meter provider

type NamedCollector

type NamedCollector interface {
	prometheus.Collector
	MetricsName() string
}

NamedCollector is a Prometheus collector that also exposes a consistent name used for tracing purposes.

func WrapWithTrace

func WrapWithTrace(c NamedCollector) NamedCollector

WrapWithTrace wraps a NamedCollector with tracing and precomputes metric descriptor names.

type SystemCollector

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

SystemCollector implements NamedCollector and gathers system resource usage like CPU, memory, and disk.

func NewSystemCollector

func NewSystemCollector(ctx context.Context, cfg *config.Config) *SystemCollector

func (*SystemCollector) Collect

func (c *SystemCollector) Collect(ch chan<- prometheus.Metric)

func (*SystemCollector) Describe

func (c *SystemCollector) Describe(ch chan<- *prometheus.Desc)

func (*SystemCollector) MetricsName

func (c *SystemCollector) MetricsName() string

func (*SystemCollector) Shutdown

func (c *SystemCollector) Shutdown() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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