metrics

package
v5.0.0-...-2679821 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package metrics abstract various providers around OpenTelemetry metric.Reader

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPullServices

func GetPullServices() []otel2.PullServiceDiscovery

func HasProviders

func HasProviders() bool

func HasPullServices

func HasPullServices() bool

func InitReaders

func InitReaders(ctx context.Context, svc otel2.Service, cfg Config) error

InitReaders reads a Config and initializes the corresponding metric.Reader.

Types

type Config

type Config struct {
	Readers []string `json:"readers" yaml:"readers"`
}

Config is a serializable representation of a list of Readers.

type Counter

type Counter interface {
	// Inc increments the counter by a delta.
	Inc(delta int64)
}

Counter is the interface for emitting counter type metrics.

type Gauge

type Gauge interface {
	// Update sets the gauges absolute value.
	Update(value float64)
}

Gauge is the interface for emitting gauge metrics.

type MeterHelper

type MeterHelper interface {
	metric.Meter
	Counter(name string, descriptionAndUnit ...string) Counter
	Gauge(name string, descriptionAndUnit ...string) Gauge
	Timer(name string, description ...string) Timer
}

MeterHelper interface expands OpenTelemetry interface with some easy-to user counters/gauges. They are compatible with legacy tally+prometheus library.

func Helper

func Helper() MeterHelper

func ServiceHelper

func ServiceHelper(serviceName string) MeterHelper

ServiceHelper is a shorthand for TaggedHelper with service key.

func TaggedHelper

func TaggedHelper(tags map[string]string) MeterHelper

TaggedHelper stores tags internally and add them as Attributes at record time.

type ReaderProvider

type ReaderProvider interface {
	metric.Reader
}

func OpenReader

func OpenReader(ctx context.Context, urlstr string) (ReaderProvider, error)

OpenReader opens the Registry identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

type Stopwatch

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

Stopwatch is a helper for simpler tracking of elapsed time, use the Stop() method to report time elapsed since its created back to the timer or histogram.

func NewStopwatch

func NewStopwatch(start time.Time, r StopwatchRecorder) Stopwatch

NewStopwatch creates a new immutable stopwatch for recording the start time to a stopwatch reporter.

func (Stopwatch) Stop

func (sw Stopwatch) Stop()

Stop reports time elapsed since the stopwatch start to the recorder.

type StopwatchRecorder

type StopwatchRecorder interface {
	RecordStopwatch(stopwatchStart time.Time)
}

StopwatchRecorder is a recorder that is called when a stopwatch is stopped with Stop().

type Timer

type Timer interface {
	// Record a specific duration directly.
	Record(value time.Duration)

	// Start gives you back a specific point in time to report via Stop.
	Start() Stopwatch
}

Timer is the interface for emitting timer metrics.

type URLMux

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

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenReader

func (mux *URLMux) OpenReader(ctx context.Context, urlstr string) (ReaderProvider, error)

OpenReader calls OpenTopicURL with the URL parsed from urlstr. OpenTopic is safe to call from multiple goroutines.

func (*URLMux) Register

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

type URLOpener

type URLOpener interface {
	OpenURL(ctx context.Context, u *url.URL) (ReaderProvider, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

Directories

Path Synopsis
Package otlp provides an OpenTelemetry protocol exporter for metrics
Package otlp provides an OpenTelemetry protocol exporter for metrics
Package prometheus provides a Prometheus collector and the required cells HTTP services to expose metrics.
Package prometheus provides a Prometheus collector and the required cells HTTP services to expose metrics.

Jump to

Keyboard shortcuts

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