telemetry

package
v1.5.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TracerAttributeNameNodeID = "nodeid"
	TracerAttributeNameJobID  = "jobid"
)

Variables

This section is empty.

Functions

func Cleanup

func Cleanup() error

Cleanup flushes the remaining traces and metrics in memory to the exporter and releases any telemetry resources.

func GetTraceClient added in v1.2.0

func GetTraceClient() (client otlptrace.Client, err error)

func Must added in v1.0.4

func Must[T any](val T, err error) T

func RecordErrorOnSpan

func RecordErrorOnSpan(span trace.Span) func(error) error

RecordErrorOnSpan records the error returned by the function in the given span. Should be used like `return RecordErrorOnSpan(span)(c.client.NetworkRemove(ctx, networkID))`

func RecordErrorOnSpanOneChannel

func RecordErrorOnSpanOneChannel[T any](span trace.Span) func(<-chan T, error) (<-chan T, error)

RecordErrorOnSpanOneChannel is similar to RecordErrorOnSpanTwo but one parameter is a channel.

func RecordErrorOnSpanReadCloserAndClose

func RecordErrorOnSpanReadCloserAndClose(span trace.Span) func(io.ReadCloser, error) (io.ReadCloser, error)

RecordErrorOnSpanReadCloserAndClose is similar to RecordError but takes an additional parameter that is an io.ReadCloser. The function will end the given span when the io.ReadCloser is closed. The caller is expected to _not_ call end on the span.

func RecordErrorOnSpanReadCloserTwoAndClose

func RecordErrorOnSpanReadCloserTwoAndClose[T any](span trace.Span) func(io.ReadCloser, T, error) (io.ReadCloser, T, error)

RecordErrorOnSpanReadCloserTwoAndClose is similar to RecordErrorOnSpanReadCloserAndClose but takes an additional parameter.

func RecordErrorOnSpanThree

func RecordErrorOnSpanThree[T any, S any](span trace.Span) func(T, S, error) (T, S, error)

RecordErrorOnSpanThree is similar to RecordError but the function being called takes an additional parameter.

func RecordErrorOnSpanTwo

func RecordErrorOnSpanTwo[T any](span trace.Span) func(T, error) (T, error)

RecordErrorOnSpanTwo is similar to RecordErrorOnSpan but the function being called takes an additional parameter.

func RecordErrorOnSpanTwoChannels

func RecordErrorOnSpanTwoChannels[T any](span trace.Span) func(<-chan T, <-chan error) (<-chan T, <-chan error)

RecordErrorOnSpanTwoChannels is similar to RecordErrorOnSpanTwo but both parameters are channels.

func SetupFromEnvs

func SetupFromEnvs()

func Timer added in v1.2.1

func Timer(
	ctx context.Context,
	durationRecorder metric.Int64Histogram,
	attrs ...attribute.KeyValue,
) func() time.Duration

Timer is a function to record a duration. Calling it starts the timer, calling the returned function will record the duration.

Types

type Counter added in v1.2.1

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

Counter is a synchronous Instrument which supports non-negative increments Example uses for Counter: - count the number of bytes received - count the number of requests completed - count the number of accounts created - count the number of checkpoints run - count the number of HTTP 5xx errors

func NewCounter added in v1.2.1

func NewCounter(meter metric.Meter, name string, description string) (*Counter, error)

func (*Counter) Add added in v1.2.1

func (c *Counter) Add(ctx context.Context, num int64, attrs ...attribute.KeyValue)

func (*Counter) Inc added in v1.2.1

func (c *Counter) Inc(ctx context.Context, attrs ...attribute.KeyValue)

type Gauge added in v1.2.1

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

Gauge is a synchronous Instrument which supports increments and decrements. Note: if the value is monotonically increasing, use Counter instead. Example uses for Gauge: - the number of active requests - the number of items in a queue

func NewGauge added in v1.2.1

func NewGauge(meter metric.Meter, name string, description string) (*Gauge, error)

func (*Gauge) Dec added in v1.2.1

func (g *Gauge) Dec(ctx context.Context, attrs ...attribute.KeyValue)

func (*Gauge) Inc added in v1.2.1

func (g *Gauge) Inc(ctx context.Context, attrs ...attribute.KeyValue)

type MetricRecorder added in v1.0.4

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

MetricRecorder is a helper for recording metrics. Specifically, it provides methods to record latency and faults.

Example usage:

recorder := NewMetricRecorder()
defer recorder.RecordFault(ctx, faultCounter) // Records fault if success was not reported
defer recorder.RecordTotalLatency(ctx, totalLatency) // Records total latency since start

// Alternatively, you can use the combined method to record fault and total latency
// defer recorder.RecordFaultAndLatency(ctx, faultCounter, totalLatency)

msg := queue.Receive()
recorder.RecordLatency(ctx, dequeueLatency) // Records dequeue latency since start

process(msg)
recorder.RecordLatency(ctx, processLatency) // Records process latency since queue.Receive()

recorder.Success()

func NewMetricRecorder added in v1.0.4

func NewMetricRecorder() *MetricRecorder

func (*MetricRecorder) RecordFault added in v1.0.4

func (t *MetricRecorder) RecordFault(ctx context.Context, counter metric.Int64Counter, options ...metric.AddOption)

RecordFault records a fault as 1 if success was not reported, 0 otherwise.

func (*MetricRecorder) RecordFaultAndLatency added in v1.0.4

func (t *MetricRecorder) RecordFaultAndLatency(
	ctx context.Context, counter metric.Int64Counter, histogram metric.Int64Histogram, options ...metric.MeasurementOption)

RecordFaultAndLatency records a fault and total latency.

func (*MetricRecorder) RecordLatency added in v1.0.4

func (t *MetricRecorder) RecordLatency(ctx context.Context, histogram metric.Int64Histogram, options ...metric.RecordOption)

RecordLatency records the latency since the last operation. If this the first operation, it records the latency since the start.

func (*MetricRecorder) RecordTotalLatency added in v1.0.4

func (t *MetricRecorder) RecordTotalLatency(ctx context.Context, histogram metric.Int64Histogram, options ...metric.RecordOption)

RecordTotalLatency records the latency since the start.

func (*MetricRecorder) Success added in v1.0.4

func (t *MetricRecorder) Success()

Success records that the operation was successful. It doesn't record anything, but it is used to determine whether a fault should be recorded.

Jump to

Keyboard shortcuts

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