telemetry

package
v1.1.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

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 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()

Types

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