oteleventually

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package oteleventually provides extension components for eventually library to enable OpenTelemetry instrumentation.

Index

Constants

View Source
const (
	EventStreamIDKey              attribute.Key = "event_stream.id"
	EventStreamVersionSelectorKey attribute.Key = "event_stream.select_from_version"
	EventStreamExpectedVersionKey attribute.Key = "event_stream.expected_version"
	EventStoreNumEventsKey        attribute.Key = "event_store.num_events"
)

Attribute keys used by the InstrumentedEventStore instrumentation.

View Source
const (
	ErrorAttribute            attribute.Key = "error"
	AggregateTypeAttribute    attribute.Key = "aggregate.type"
	AggregateVersionAttribute attribute.Key = "aggregate.version"
	AggregateIDAttribute      attribute.Key = "aggregate.id"
)

Attribute keys used by the InstrumentedRepository instrumentation.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstrumentedEventStore

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

InstrumentedEventStore is a wrapper type over an event.Store instance to provide instrumentation, in the form of metrics and traces using OpenTelemetry.

Use NewInstrumentedEventStore for constructing a new instance of this type.

func NewInstrumentedEventStore

func NewInstrumentedEventStore(eventStore event.Store, options ...Option) (*InstrumentedEventStore, error)

NewInstrumentedEventStore returns a wrapper type to provide OpenTelemetry instrumentation (metrics and traces) around an event.Store.

An error is returned if metrics could not be registered.

func (*InstrumentedEventStore) Append

func (ies *InstrumentedEventStore) Append(
	ctx context.Context,
	id event.StreamID,
	expected version.Check,
	events ...event.Envelope,
) (newVersion version.Version, err error)

Append calls the wrapped event.Store.Append method and records metrics and traces around it.

func (*InstrumentedEventStore) Stream

func (ies *InstrumentedEventStore) Stream(
	ctx context.Context,
	stream event.StreamWrite,
	id event.StreamID,
	selector version.Selector,
) (err error)

Stream calls the wrapped event.Store.Stream method and records metrics and traces around it.

type InstrumentedRepository

type InstrumentedRepository[I aggregate.ID, T aggregate.Root[I]] struct {
	// contains filtered or unexported fields
}

InstrumentedRepository is a wrapper type over an aggregate.Repository instance to provide instrumentation, in the form of metrics and traces using OpenTelemetry.

Use NewInstrumentedRepository for constructing a new instance of this type.

func NewInstrumentedRepository

func NewInstrumentedRepository[I aggregate.ID, T aggregate.Root[I]](
	aggregateType aggregate.Type[I, T],
	repository aggregate.Repository[I, T],
	options ...Option,
) (*InstrumentedRepository[I, T], error)

NewInstrumentedRepository returns a wrapper type to provide OpenTelemetry instrumentation (metrics and traces) around an aggregate.Repository.

The aggregate.Type for the Repository is also used for reporting the Aggregate Type name as an attribute.

An error is returned if metrics could not be registered.

func (*InstrumentedRepository[I, T]) Get

func (ir *InstrumentedRepository[I, T]) Get(ctx context.Context, id I) (result T, err error)

Get calls the wrapped aggregate.Repository.Get method and records metrics and traces around it.

func (*InstrumentedRepository[I, T]) Save

func (ir *InstrumentedRepository[I, T]) Save(ctx context.Context, root T) (err error)

Save calls the wrapped aggregate.Repository.Save method and records metrics and traces around it.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option specifies instrumentation configuration options.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) Option

WithMeterProvider specifies the metric.MeterProvider instance to use for the instrumentation. By default, the global metric.MeterProvider is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) Option

WithTracerProvider specifies the trace.TracerProvider instance to use for the instrumentation. By default, the global trace.TracerProvider is used.

Jump to

Keyboard shortcuts

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