Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Directive = service.Directive{ Name: "metrics", Init: func(s *service.Instance, c config.Dispenser) error { cfg := Config{} c.Next() for c.NextBlock() { switch c.Val() { case "namespace", "ns": if !c.NextArg() { return c.ArgErr() } cfg.Namespace = c.Val() case "subsystem", "sub": if !c.NextArg() { return c.ArgErr() } cfg.Subsystem = c.Val() case "token": if !c.NextArg() { return c.ArgErr() } cfg.Token = c.Val() case "path": if !c.NextArg() { return c.ArgErr() } cfg.Path = c.Val() case "ignore": if !c.NextArg() { return c.ArgErr() } cfg.Ingore = c.RemainingArgs() default: return c.SyntaxErr("unexpected keyword") } } if cfg.Namespace == "" && s.Name() != "" { cfg.Namespace = s.Name() } if c.Next() { return c.SyntaxErr("unexpected keyword %q, metrics can only be used once", c.Val()) } s.AddRouterOption(WithMetrics(cfg)) return nil }, }
Directive allows configuration of service metrics
Functions ¶
func WithMetrics ¶
func WithMetrics(c Config) api.RouterOption
WithMetrics enables prometheus metrics on an api.Router
Types ¶
type Config ¶
type Config struct { // Ignore holds a list of paths that should be ingored by metrics collection // TODO(ppacher): it is currently not possible to set the Ignore fields // in the service itself if the directive is used Ingore []string // Namespace is the prometheus namespace Namespace string // Path holds the path of the metrics endpoint. // It defaults to /metrics Path string // Subsystem is the prometheus subsystem Subsystem string // Token enables as bearer authentication on the metrics // endpoint Token string }
Config configures the prometheus metrics collector and endpoint
Click to show internal directories.
Click to hide internal directories.