spectator

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Overview

Package spectator provides a minimal Go implementation of the Netflix Java Spectator library. The goal of this package is to allow Go programs to emit metrics to Atlas.

Please refer to the Java Spectator documentation for information on spectator / Atlas fundamentals: https://netflix.github.io/spectator/en/latest/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseProtocolLine

func ParseProtocolLine(line string) (string, *meter.Id, string, error)

ParseProtocolLine parses a line of the spectator protocol. Utility exposed for testing.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config represents the Registry's configuration.

func NewConfig

func NewConfig(
	location string,
	commonTags map[string]string,
	log logger.Logger,
) (*Config, error)

NewConfig creates a new configuration with the provided location, common tags, and logger. All fields are optional. Possible values for location are:

  • `none`: Configures a no-op writer that does nothing. Can be used to disable metrics collection.
  • `stdout`: Writes metrics to stdout.
  • `stderr`: Writes metrics to stderr.
  • `memory`: Writes metrics to memory. Useful for testing.
  • `file:///path/to/file`: Writes metrics to a file.
  • `unix:///path/to/socket`: Writes metrics to a Unix domain socket.
  • `udp://host:port`: Writes metrics to a UDP socket.

If location is not provided, the default value `udp://127.0.0.1:1234` will be used

type Meter

type Meter interface {
	MeterId() *meter.Id
}

Meter represents the functionality presented by the individual meter types.

type Registry

type Registry interface {
	GetLogger() logger.Logger
	NewId(name string, tags map[string]string) *meter.Id
	Counter(name string, tags map[string]string) *meter.Counter
	CounterWithId(id *meter.Id) *meter.Counter
	MonotonicCounter(name string, tags map[string]string) *meter.MonotonicCounter
	MonotonicCounterWithId(id *meter.Id) *meter.MonotonicCounter
	Timer(name string, tags map[string]string) *meter.Timer
	TimerWithId(id *meter.Id) *meter.Timer
	Gauge(name string, tags map[string]string) *meter.Gauge
	GaugeWithId(id *meter.Id) *meter.Gauge
	GaugeWithTTL(name string, tags map[string]string, ttl time.Duration) *meter.Gauge
	GaugeWithIdWithTTL(id *meter.Id, ttl time.Duration) *meter.Gauge
	AgeGauge(name string, tags map[string]string) *meter.AgeGauge
	AgeGaugeWithId(id *meter.Id) *meter.AgeGauge
	MaxGauge(name string, tags map[string]string) *meter.MaxGauge
	MaxGaugeWithId(id *meter.Id) *meter.MaxGauge
	DistributionSummary(name string, tags map[string]string) *meter.DistributionSummary
	DistributionSummaryWithId(id *meter.Id) *meter.DistributionSummary
	PercentileDistributionSummary(name string, tags map[string]string) *meter.PercentileDistributionSummary
	PercentileDistributionSummaryWithId(id *meter.Id) *meter.PercentileDistributionSummary
	PercentileTimer(name string, tags map[string]string) *meter.PercentileTimer
	PercentileTimerWithId(id *meter.Id) *meter.PercentileTimer
	GetWriter() writer.Writer
	Close()
}

Registry is the main entry point for interacting with the Spectator library.

func NewRegistry

func NewRegistry(config *Config) (Registry, error)

NewRegistry generates a new registry from a passed Config created through NewConfig.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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