Documentation ¶
Overview ¶
Package service defines a service to configure monitoring for your Indigo Node. Metrics are collected and can be exposed to a Prometheus server. Traces are collected and can be exported to a tracing agent (Jaeger or Stackdriver).
Index ¶
- Constants
- Variables
- type Config
- func (c *Config) CreateMetricsExporter(ctx context.Context, errChan chan<- error) (view.Exporter, context.CancelFunc, error)
- func (c *Config) CreateTraceExporter() (trace.Exporter, error)
- func (c *Config) ValidateMetricsConfig() error
- func (c *Config) ValidateSamplingRatio() error
- func (c *Config) ValidateTraceConfig() error
- type JaegerConfig
- type PrometheusConfig
- type Service
- func (s *Service) AddToGRPCServer(gs *grpc.Server)
- func (s *Service) Config() interface{}
- func (s *Service) Desc() string
- func (s *Service) Expose() interface{}
- func (s *Service) ID() string
- func (s *Service) Name() string
- func (s *Service) Run(ctx context.Context, running, stopping func()) error
- func (s *Service) SetConfig(config interface{}) error
- type StackdriverConfig
Constants ¶
const ( PrometheusExporter = "prometheus" JaegerExporter = "jaeger" StackdriverExporter = "stackdriver" )
Available exporters.
Variables ¶
var ( ErrInvalidRatio = errors.New("invalid ratio (must be in [0;1])") ErrInvalidMetricsExporter = errors.New("metrics exporter should be 'prometheus' or 'stackdriver'") ErrInvalidTraceExporter = errors.New("trace exporter should be 'jaeger' or 'stackdriver'") ErrMissingExporterConfig = errors.New("missing exporter configuration section") ErrMissingProjectID = errors.New("missing stackdriver project id") )
Errors used by the configuration component.
var ( // available. ErrUnavailable = errors.New("the service is not available") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Interval is the interval between updates of periodic stats. Interval string `toml:"interval" comment:"Interval between updates of periodic stats."` // TraceSamplingRatio is the fraction of traces to record. TraceSamplingRatio float64 `toml:"trace_sampling_ratio" comment:"Fraction of traces to record."` // MetricsExporter is the name of the metrics exporter. MetricsExporter string `toml:"metrics_exporter" comment:"Name of the metrics exporter (prometheus or stackdriver). Leave empty to disable metrics."` // TraceExporter is the name of the trace exporter. TraceExporter string `toml:"trace_exporter" comment:"Name of the trace exporter (jaeger or stackdriver). Leave empty to disable tracing."` // JaegerConfig options (if enabled). JaegerConfig *JaegerConfig `toml:"jaeger" comment:"Jaeger configuration options (if enabled)."` // PrometheusConfig options (if enabled). PrometheusConfig *PrometheusConfig `toml:"prometheus" comment:"Prometheus configuration options (if enabled)."` // StackdriverConfig options (if enabled). StackdriverConfig *StackdriverConfig `toml:"stackdriver" comment:"Stackdriver configuration options (if enabled)."` }
Config contains configuration options for the Monitoring service.
func (*Config) CreateMetricsExporter ¶
func (c *Config) CreateMetricsExporter(ctx context.Context, errChan chan<- error) (view.Exporter, context.CancelFunc, error)
CreateMetricsExporter configures the metrics exporter. It returns the exporter itself and a cancel function to stop the exporter.
func (*Config) CreateTraceExporter ¶
CreateTraceExporter configures the trace exporter.
func (*Config) ValidateMetricsConfig ¶
ValidateMetricsConfig validates the metrics configuration.
func (*Config) ValidateSamplingRatio ¶
ValidateSamplingRatio validates the tracing sampling ratio.
func (*Config) ValidateTraceConfig ¶
ValidateTraceConfig validates the tracing configuration.
type JaegerConfig ¶
type JaegerConfig struct { // Endpoint is the address of the Jaeger agent to collect traces. Endpoint string `toml:"endpoint" comment:"Address of the Jaeger agent to collect traces."` }
JaegerConfig contains configuration options for Jaeger (tracing).
func (*JaegerConfig) Validate ¶
func (c *JaegerConfig) Validate() error
Validate the jaeger configuration section.
type PrometheusConfig ¶
type PrometheusConfig struct { // Endpoint is the address of the endpoint to expose prometheus metrics. Endpoint string `toml:"endpoint" comment:"Address of the endpoint to expose Prometheus metrics."` }
PrometheusConfig contains configuration options for Prometheus.
func (*PrometheusConfig) Validate ¶
func (c *PrometheusConfig) Validate() error
Validate the prometheus configuration section.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Monitoring service.
func (*Service) AddToGRPCServer ¶
AddToGRPCServer adds the service to a gRPC server.
func (*Service) Config ¶
func (s *Service) Config() interface{}
Config returns the current service configuration or creates one with good default values.
func (*Service) Expose ¶
func (s *Service) Expose() interface{}
Expose returns the interval at which periodic metrics should be retrieved. The monitoring service uses pull model instead of push: every component should expose custom metric views and collect them at the interval specified by the monitoring service, and we choose here which views we export.
type StackdriverConfig ¶
type StackdriverConfig struct { // ProjectID is the identifier of the Stackdriver project ProjectID string `toml:"project_id" comment:"Identifier of the Stackdriver project."` }
StackdriverConfig contains configuration options for Stackdriver.
func (*StackdriverConfig) Validate ¶
func (c *StackdriverConfig) Validate() error
Validate the stackdriver configuration section.