metrics

package
v0.0.0-...-e308f56 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMetric

func NewMetric[OM any](meter metric.Meter, path, unit, description string) OM

Types

type Client

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

Client provides OpenTelemetry metrics with configurable exporters.

func New

func New(ctx context.Context, cfg Config) (*Client, error)

New creates a new OpenTelemetry metrics client with configurable exporters.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the meter provider.

func (*Client) Handler

func (c *Client) Handler() http.Handler

Handler returns the HTTP handler for the /metrics endpoint.

func (*Client) ServeMetrics

func (c *Client) ServeMetrics(ctx context.Context) error

ServeMetrics starts a dedicated HTTP server for Prometheus metrics scraping. This is only started if Prometheus exporter is enabled.

type Config

type Config struct {
	ServiceName        string `hcl:"service-name" help:"Service name for metrics." default:"cachew"`
	Port               int    `hcl:"port" help:"Port for Prometheus metrics server." default:"9102"`
	EnablePrometheus   bool   `hcl:"enable-prometheus" help:"Enable Prometheus exporter." default:"true"`
	EnableOTLP         bool   `hcl:"enable-otlp" help:"Enable OTLP exporter." default:"false"`
	OTLPEndpoint       string `hcl:"otlp-endpoint" help:"OTLP endpoint URL." default:"http://localhost:4318"`
	OTLPInsecure       bool   `hcl:"otlp-insecure" help:"Use insecure connection for OTLP." default:"false"`
	OTLPExportInterval int    `hcl:"otlp-export-interval" help:"OTLP export interval in seconds." default:"60"`
}

Config holds metrics configuration.

Jump to

Keyboard shortcuts

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