metricsservice

package
v0.44.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 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 Options

type Options struct {
	// Enabled is the flag to enable the metrics service.
	Enabled bool `yaml:"enabled"`

	// ServiceName is the name of the service.
	ServiceName string `yaml:"serviceName,omitempty"`

	// Prometheus is the options for the prometheus metrics provider.
	Prometheus *PrometheusOptions `yaml:"prometheus,omitempty"`
}

Options represents the options of the providers for publishing metrics.

type PrometheusExporter

type PrometheusExporter struct {
	// MeterProvider is used in the creation and coordination of Meters
	MeterProvider *sdkmetric.MeterProvider

	// Handler is the HTTP handler with basic metrics
	Handler http.Handler
}

PrometheusExporter is the struct that holds the metrics reklated data

func NewPrometheusExporter

func NewPrometheusExporter(options *Options) (*PrometheusExporter, error)

NewPrometheusExporter creates a PrometheusExporter instance with a MeterProvider and a Handler, and returns it along with any errors.

type PrometheusOptions

type PrometheusOptions struct {
	// Path is the path where the prometheus metrics are exposed.
	Path string `yaml:"path"`

	// Address is the address where the prometheus metrics are exposed.
	Port int `yaml:"port"`
}

PrometheusOptions represents prometheus metrics provider options.

type Service

type Service struct {
	Options *Options
}

Service implements the metrics service.

func (*Service) Name

func (s *Service) Name() string

Name returns the name of the metrics service.

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run creates a new server for exposing an endpoint to collect metrics from. It sets up a Prometheus exporter, initializes metrics, creates an HTTP server and handles shutdown based on the context, returning an error if one occurs.

Jump to

Keyboard shortcuts

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