olly

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRecorderInContext = fmt.Errorf("no recorder found in context")

Functions

func Fail

func Fail(ctx context.Context, err error, opts ...trace.EventOption) error

Fail records the error and sets the status of the Span to Error.

func Failf

func Failf(ctx context.Context, format string, args ...any) error

Failf wraps around Fail, formatting the error message according to a format specifier and arguments.

func Float64Counter

func Float64Counter(
	ctx context.Context,
	name string,
	options ...metric.Float64CounterOption,
) (metric.Float64Counter, error)

Float64Counter returns a new Float64Counter instrument identified by name and configured with options. The instrument is used to synchronously record increasing float64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

func Float64Gauge

func Float64Gauge(
	ctx context.Context,
	name string,
	options ...metric.Float64GaugeOption,
) (metric.Float64Gauge, error)

Float64Gauge returns a new Float64Gauge instrument identified by name and configured with options. The instrument is used to synchronously record instantaneous float64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Float64Histogram

func Float64Histogram(
	ctx context.Context,
	name string,
	options ...metric.Float64HistogramOption,
) (metric.Float64Histogram, error)

Float64Histogram returns a new Float64Histogram instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of float64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Float64ObservableCounter

func Float64ObservableCounter(
	ctx context.Context,
	name string,
	options ...metric.Float64ObservableCounterOption,
) (metric.Float64ObservableCounter, error)

Float64ObservableCounter returns a new Float64ObservableCounter instrument identified by name and configured with options. The instrument is used to asynchronously record increasing float64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithFloat64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Float64ObservableGauge

func Float64ObservableGauge(
	ctx context.Context,
	name string,
	options ...metric.Float64ObservableGaugeOption,
) (metric.Float64ObservableGauge, error)

Float64ObservableGauge returns a new Float64ObservableGauge instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous float64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithFloat64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Float64ObservableUpDownCounter

func Float64ObservableUpDownCounter(
	ctx context.Context,
	name string,
	options ...metric.Float64ObservableUpDownCounterOption,
) (metric.Float64ObservableUpDownCounter, error)

Float64ObservableUpDownCounter returns a new Float64ObservableUpDownCounter instrument identified by name and configured with options. The instrument is used to asynchronously record float64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithFloat64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Float64UpDownCounter

func Float64UpDownCounter(
	ctx context.Context,
	name string,
	options ...metric.Float64UpDownCounterOption,
) (metric.Float64UpDownCounter, error)

Float64UpDownCounter returns a new Float64UpDownCounter instrument identified by name and configured with options. The instrument is used to synchronously record float64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64Counter

func Int64Counter(
	ctx context.Context,
	name string,
	options ...metric.Int64CounterOption,
) (metric.Int64Counter, error)

Int64Counter returns a new Int64Counter instrument identified by name and configured with options. The instrument is used to synchronously record increasing int64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64Gauge

func Int64Gauge(
	ctx context.Context,
	name string,
	options ...metric.Int64GaugeOption,
) (metric.Int64Gauge, error)

Int64Gauge returns a new Int64Gauge instrument identified by name and configured with options. The instrument is used to synchronously record instantaneous int64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64Histogram

func Int64Histogram(
	ctx context.Context,
	name string,
	options ...metric.Int64HistogramOption,
) (metric.Int64Histogram, error)

Int64Histogram returns a new Int64Histogram instrument identified by name and configured with options. The instrument is used to synchronously record the distribution of int64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64ObservableCounter

func Int64ObservableCounter(
	ctx context.Context,
	name string,
	options ...metric.Int64ObservableCounterOption,
) (metric.Int64ObservableCounter, error)

Int64ObservableCounter returns a new Int64ObservableCounter identified by name and configured with options. The instrument is used to asynchronously record increasing int64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithInt64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64ObservableGauge

func Int64ObservableGauge(
	ctx context.Context,
	name string,
	options ...metric.Int64ObservableGaugeOption,
) (metric.Int64ObservableGauge, error)

Int64ObservableGauge returns a new Int64ObservableGauge instrument identified by name and configured with options. The instrument is used to asynchronously record instantaneous int64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithInt64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64ObservableUpDownCounter

func Int64ObservableUpDownCounter(
	ctx context.Context,
	name string,
	options ...metric.Int64ObservableUpDownCounterOption,
) (metric.Int64ObservableUpDownCounter, error)

Int64ObservableUpDownCounter returns a new Int64ObservableUpDownCounter instrument identified by name and configured with options. The instrument is used to asynchronously record int64 measurements once per a measurement collection cycle.

Measurements for the returned instrument are made via a callback. Use the WithInt64Callback option to register the callback here, or use the RegisterCallback method of this Meter to register one later. See the Measurements section of the package documentation for more information.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Int64UpDownCounter

func Int64UpDownCounter(
	ctx context.Context,
	name string,
	options ...metric.Int64UpDownCounterOption,
) (metric.Int64UpDownCounter, error)

Int64UpDownCounter returns a new Int64UpDownCounter instrument identified by name and configured with options. The instrument is used to synchronously record int64 measurements during a computational operation.

The name needs to conform to the OpenTelemetry instrument name syntax. See the Instrument Name section of the package documentation for more information.

Implementations of this method need to be safe for a user to call concurrently.

func Nest

func Nest(ctx context.Context, name string, nestedFn func(ctx context.Context), opts ...trace.SpanStartOption)

Nest wraps around Nested, calling the provided nestedFn with the context containing the newly-created span. It automatically ends the span after nestedFn returns.

func Nested

func Nested(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Nested creates a span and a context.Context containing the newly-created span.

If the context.Context provided in `ctx` contains a Span then the newly-created Span will be a child of that span, otherwise it will be a root span. This behavior can be overridden by providing `WithNewRoot()` as a SpanOption, causing the newly-created Span to be a root span even if `ctx` contains a Span.

When creating a Span it is recommended to provide all known span attributes using the `WithAttributes()` SpanOption as samplers will only have access to the attributes provided when a Span is created.

Any Span that is created MUST also be ended. This is the responsibility of the user. Implementations of this API may leak memory or other resources if Spans are not ended.

func RecordError

func RecordError(ctx context.Context, err error, opts ...trace.EventOption)

RecordError will record err as an exception span event for this span. If the Status of the Span should be set to Error, Fail or Failf should be used instead. If this span is not being recorded or err is nil then this method does nothing.

func RegisterCallback

func RegisterCallback(
	ctx context.Context,
	f metric.Callback,
	instruments ...metric.Observable,
) (metric.Registration, error)

RegisterCallback registers f to be called during the collection of a measurement cycle.

If Unregister of the returned Registration is called, f needs to be unregistered and not called during collection.

The instruments f is registered with are the only instruments that f may observe values for.

If no instruments are passed, f should not be registered nor called during collection.

Implementations of this method need to be safe for a user to call concurrently.

The function f needs to be concurrent safe.

func WithInstrumentationAttributeSet

func WithInstrumentationAttributeSet(attrs attribute.Set) otelRecorderOptionAttrs

func WithInstrumentationAttributes

func WithInstrumentationAttributes(attrs ...attribute.KeyValue) otelRecorderOptionAttrs

func WithInstrumentationSchemaURL

func WithInstrumentationSchemaURL(schemaURL string) otelRecorderOptionSchemaURL

func WithInstrumentationVersion

func WithInstrumentationVersion(version string) otelRecorderOptionInstrumentationVersion

Types

type OTelRecorder

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

func NewOTelRecorder

func NewOTelRecorder(
	ctx context.Context,
	sdk otelconf.SDK,
	name string,
	options ...otelRecorderOptions,
) OTelRecorder

func RecorderFromContext

func RecorderFromContext(ctx context.Context) (OTelRecorder, bool)

func (OTelRecorder) NewLogger

func (r OTelRecorder) NewLogger(handler slog.Handler, options ...otelslog.Option) *slog.Logger

func (OTelRecorder) WrapContext added in v0.4.0

func (r OTelRecorder) WrapContext(ctx context.Context) context.Context

WrapContext Registers an OTelRecorder in the context, which can be retrieved using RecorderFromContext. This is necessary to allow other functions in this package to operate.

Jump to

Keyboard shortcuts

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