Documentation ¶
Index ¶
- Constants
- func Cleanup() error
- func GetTraceClient() (client otlptrace.Client, err error)
- func Must[T any](val T, err error) T
- func RecordErrorOnSpan(span trace.Span) func(error) error
- func RecordErrorOnSpanOneChannel[T any](span trace.Span) func(<-chan T, error) (<-chan T, error)
- func RecordErrorOnSpanReadCloserAndClose(span trace.Span) func(io.ReadCloser, error) (io.ReadCloser, error)
- func RecordErrorOnSpanReadCloserTwoAndClose[T any](span trace.Span) func(io.ReadCloser, T, error) (io.ReadCloser, T, error)
- func RecordErrorOnSpanThree[T any, S any](span trace.Span) func(T, S, error) (T, S, error)
- func RecordErrorOnSpanTwo[T any](span trace.Span) func(T, error) (T, error)
- func RecordErrorOnSpanTwoChannels[T any](span trace.Span) func(<-chan T, <-chan error) (<-chan T, <-chan error)
- func SetupFromEnvs()
- func Timer(ctx context.Context, durationRecorder metric.Int64Histogram, ...) func() time.Duration
- type Counter
- type Gauge
- type MetricRecorder
- func (t *MetricRecorder) RecordFault(ctx context.Context, counter metric.Int64Counter, options ...metric.AddOption)
- func (t *MetricRecorder) RecordFaultAndLatency(ctx context.Context, counter metric.Int64Counter, ...)
- func (t *MetricRecorder) RecordLatency(ctx context.Context, histogram metric.Int64Histogram, ...)
- func (t *MetricRecorder) RecordTotalLatency(ctx context.Context, histogram metric.Int64Histogram, ...)
- func (t *MetricRecorder) Success()
Constants ¶
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 RecordErrorOnSpan ¶
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 ¶
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 ¶
RecordErrorOnSpanThree is similar to RecordError but the function being called takes an additional parameter.
func RecordErrorOnSpanTwo ¶
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 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
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
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.