otlp

package module
v0.0.0-...-8fc3242 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxMetrics is the default maximum of metrics kept in memory
	// by the handler.
	DefaultMaxMetrics = 5000

	// DefaultFlushInterval is the default interval to flush the metrics
	// to the OpenTelemetry destination.
	//
	// Metrics will be flushed to the destination when DefaultFlushInterval or
	// DefaultMaxMetrics are reached, whichever comes first.
	DefaultFlushInterval = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Handle(context.Context, *colmetricpb.ExportMetricsServiceRequest) error
}

type HTTPClient

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

HTTPClient implements the Client interface and is used to export metrics to an OpenTelemetry Collector through the HTTP interface.

The current implementation is a fire and forget approach where we do not retry or buffer any failed-to-flush data on the client.

func NewHTTPClient

func NewHTTPClient(endpoint string) *HTTPClient

func (*HTTPClient) Handle

type Handler

type Handler struct {
	Client        Client
	Context       context.Context
	FlushInterval time.Duration
	MaxMetrics    int
	// contains filtered or unexported fields
}

Status: Alpha. This Handler is still in heavy development phase.

Do not use in production.

Handler implements stats.Handler to be used to forward metrics to an OpenTelemetry destination. Usually an OpenTelemetry Collector.

With the current implementation this Handler is targeting a Prometheus based backend or any backend expecting cumulative values.

This Handler leverages a doubly linked list with a map to implement a ring buffer with a lookup to ensure a low memory usage.

func NewHandler

func NewHandler(ctx context.Context, endpoint string) *Handler

NewHandler return an instance of Handler with the default client, flush interval and in-memory metrics limit.

func (*Handler) HandlerMeasure

func (h *Handler) HandlerMeasure(t time.Time, measures ...stats.Measure)

Jump to

Keyboard shortcuts

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