metric

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const EndpointFieldName = "server.http.routes.metrics"

EndpointFieldName имя поля в конфигурации

Variables

View Source
var Component = &compogo.Component{
	Dependencies: compogo.Components{
		&chi.Component,
	},
	Init: compogo.StepFunc(func(container compogo.Container) error {
		return container.Provide(NewConfig)
	}),
	BindFlags: compogo.BindFlags(func(flagSet flag.FlagSet, container compogo.Container) error {
		return container.Invoke(func(config *Config) {
			flagSet.StringVar(&config.Endpoint, EndpointFieldName, EndpointDefault, "path for metrics endpoint")
		})
	}),
	Configuration: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(Configuration)
	}),
	PreExecute: compogo.StepFunc(func(container compogo.Container) error {
		return container.Invoke(func(config *Config, r httpServer.Router, logger compogo.Logger) {
			logger.GetLogger("http").
				GetLogger("server").
				GetLogger("router").
				GetLogger("chi").
				Infof("add metrics endpoint - '%s'", config.Endpoint)

			r.Mount(config.Endpoint, promhttp.Handler())
		})
	}),
}

Component — компонент metrics эндпоинта для chi-роутера. Добавляет эндпоинт для сбора метрик Prometheus.

View Source
var EndpointDefault = "/metrics"

EndpointDefault путь по умолчанию

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint string
}

Config содержит конфигурацию metrics эндпоинта.

func Configuration

func Configuration(config *Config, configurator compogo.Configurator) *Config

Configuration загружает конфигурацию из Configurator.

func NewConfig

func NewConfig() *Config

NewConfig создаёт новую конфигурацию.

Jump to

Keyboard shortcuts

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