telemetry

package
v0.0.0-...-97cac26 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ManualReader *sdkmetric.ManualReader

ManualReader is initialized only when the in-memory metric provider is used. It will be nil otherwise. ManualReader is primarily intended for use in tests.

Functions

func NewLogger

func NewLogger(name string) *slog.Logger

NewLogger creates a new slog.Logger. If OpenTelemetry logging is enabled, the logger is connected to the OpenTelemetry logging bridge.

func ReleaseTestMetricReader

func ReleaseTestMetricReader(t *testing.T)

ReleaseTestMetricReader releases the test metric reader lock.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown gracefully shutdown all OpenTelemetry exporters, providers that were previously enabled.

Shutdown can be safely called before Start.

func Start

func Start(ctx context.Context, service, version string) error

Start initializes OpenTelemetry exporters, resources, and providers for logging, tracing, and metrics based on the standard OTEL_* environment variables: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/

This function should be called only once at the beginning of the program.

Types

type TestMetricReader

type TestMetricReader struct {
	*sdkmetric.ManualReader
}

func AcquireTestMetricReader

func AcquireTestMetricReader(t *testing.T) *TestMetricReader

AcquireTestMetricReader initializes an in-memory metric reader for inspecting metric changes during tests. ReleaseTestMetricReader must be called after AcquireTestMetricReader.

func (*TestMetricReader) Collect

func (m *TestMetricReader) Collect(t *testing.T) TestMetrics

Collect returns the accumulated metric changes and resets all metrics to zero.

type TestMetrics

type TestMetrics struct {
	*metricdata.ResourceMetrics
}

func (*TestMetrics) Counter

func (tm *TestMetrics) Counter(t *testing.T, name string, attrs ...attribute.KeyValue) float64

Counter returns the counter metric value that matches the provided name and attributes.

Jump to

Keyboard shortcuts

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