otelcolclient

package
v0.0.0-...-96cdf77 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package otelcolclient contains client code for communicating with an OTel Collector.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(w Writer, emitTraces bool) *Client

New creates a new Client that will batch metrics.

func (*Client) Close

func (c *Client) Close() error

Close cancels the underlying context. TODO: add flushing of batcher before canceling

func (*Client) Write

func (c *Client) Write(e *loggregator_v2.Envelope) error

Write translates an envelope to OTLP and forwards it to the connected OTel Collector.

type GRPCWriter

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

func NewGRPCWriter

func NewGRPCWriter(addr string, tlsConfig *tls.Config, l *log.Logger) (*GRPCWriter, error)

NewGRPCWriter dials the provided gRPC address and returns a *GRPCWriter.

func (GRPCWriter) Close

func (w GRPCWriter) Close() error

func (GRPCWriter) WriteMetrics

func (w GRPCWriter) WriteMetrics(batch []*metricspb.Metric)

func (GRPCWriter) WriteTrace

func (w GRPCWriter) WriteTrace(batch []*tracepb.ResourceSpans)

type SignalBatcher

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

SignalBatcher batches OpenTelemetry signals.

func NewSignalBatcher

func NewSignalBatcher(size int, interval time.Duration, writer Writer) *SignalBatcher

NewSignalBatcher creates a new OpenTelemetry Metric Batcher.

func (*SignalBatcher) Flush

func (b *SignalBatcher) Flush()

Flush will write a partial batch if there is data and the interval has lapsed. Otherwise it is a NOP. This method should be called freqently to make sure batches do not stick around for long periods of time. As a result it would be a bad idea to call Flush after an operation that might block for an un-specified amount of time.

func (*SignalBatcher) WriteMetric

func (b *SignalBatcher) WriteMetric(data *metricspb.Metric)

WriteMetric stores data to the metric batch. It will not submit the batch to the writer until either the batch has been filled, or the interval has lapsed.

func (*SignalBatcher) WriteTrace

func (b *SignalBatcher) WriteTrace(data *tracepb.ResourceSpans)

WriteTrace stores data to the trace batch. It will not submit the batch to the writer until either the batch has been filled, or the interval has lapsed.

type Writer

type Writer interface {
	// WriteMetrics submits the batch.
	WriteMetrics(batch []*metricspb.Metric)
	// WriteTrace submits the batch.
	WriteTrace(batch []*tracepb.ResourceSpans)
	Close() error
}

Writer is used to submit the completed batches of OpenTelemetry signals. The batch may not be full if the interval lapsed instead of filling the batch.

Jump to

Keyboard shortcuts

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