service

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: AGPL-3.0 Imports: 18 Imported by: 1

Documentation

Overview

Package service defines a service to configure monitoring for your Stratumn 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

View Source
const (
	PrometheusExporter  = "prometheus"
	JaegerExporter      = "jaeger"
	StackdriverExporter = "stackdriver"
)

Available exporters.

Variables

View Source
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.

View Source
var (
	// ErrUnavailable is returned from gRPC methods when the service is not
	// 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

func (c *Config) CreateTraceExporter() (trace.Exporter, error)

CreateTraceExporter configures the trace exporter.

func (*Config) ValidateMetricsConfig

func (c *Config) ValidateMetricsConfig() error

ValidateMetricsConfig validates the metrics configuration.

func (*Config) ValidateSamplingRatio

func (c *Config) ValidateSamplingRatio() error

ValidateSamplingRatio validates the tracing sampling ratio.

func (*Config) ValidateTraceConfig

func (c *Config) ValidateTraceConfig() error

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

func (s *Service) AddToGRPCServer(gs *grpc.Server)

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) Desc

func (s *Service) Desc() string

Desc returns a description of what the service does.

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.

func (*Service) ID

func (s *Service) ID() string

ID returns the unique identifier of the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the human friendly name of the service.

func (*Service) Run

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

Run starts the service.

func (*Service) SetConfig

func (s *Service) SetConfig(config interface{}) error

SetConfig configures the service.

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.

Jump to

Keyboard shortcuts

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