eventstore

package
v0.0.0-...-2aa0edd Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstrumentedStore

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

An InstrumentedStore wraps an event store for OpenTelemetry instrumentation.

The store wraps and emits metrics and traces for the ReadStream and AppendStream methods. The metrics are emitted using the OpenTelemetry metric API, and the traces are emitted using the OpenTelemetry trace API.

The store can be configured to enable or disable tracing and metrics, and to use a custom tracer or meter provider. By default, the store uses the global tracer and meter provider from the OpenTelemetry SDK.

The store emits metrics under the "eventstore" namespace by default. The namespace can be customized using the WithMetricNamespace option.

func NewInstrumentedStore

func NewInstrumentedStore(inner eventstore.Store, opts ...InstrumentedStoreOption) (*InstrumentedStore, error)

NewInstrumentedStore creates a new instrumented event store.

func (*InstrumentedStore) AppendStream

Hydrate hydrates an aggregate while capturing telemetry.

func (*InstrumentedStore) ReadStream

Load loads an aggregate by ID while capturing telemetry.

type InstrumentedStoreOption

type InstrumentedStoreOption func(*InstrumentedStore) error

An InstrumentedStoreOption configures an instrumented store.

func WithMeterProvider

func WithMeterProvider(provider metric.MeterProvider) InstrumentedStoreOption

WithMeterProvider sets the OTEL meter provider for the store.

func WithMetricNamespace

func WithMetricNamespace(namespace string) InstrumentedStoreOption

WithMetricNamespace sets the namespace for the metrics emitted by the store.

The default namespace is "aggregatestore". For example, if the namespace is set to "customstore", the metrics will be emitted under the following names:

  • customstore.load
  • customstore.hydrate
  • customstore.save

Overriding the default namespace is useful when you are layering multiple aggregate stores and want to instrument each one while differentiating between them in telemetry.

func WithMetricsEnabled

func WithMetricsEnabled(enabled bool) InstrumentedStoreOption

WithMetricsEnabled enables or disables metrics for the store.

By default, metrics are enabled.

func WithTraceNamespace

func WithTraceNamespace(namespace string) InstrumentedStoreOption

WithTraceNamespace sets the namespace for the traces emitted by the store.

The default namespace is "aggregatestore". For example, if the namespace is set to "customstore", the tracer will be emitted under the following names:

  • customstore.Load
  • customstore.Hydrate
  • customstore.Save

Overriding the default namespace is useful when you are layering multiple aggregate stores and want to instrument each one while differentiating between them in telemetry.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) InstrumentedStoreOption

WithTracerProvider sets the OTEL tracer provider for the store.

func WithTracingEnabled

func WithTracingEnabled(enabled bool) InstrumentedStoreOption

WithTracingEnabled enables or disables tracing for the store.

By default, tracing is enabled.

type InstrumentedStreamIterator

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

func (*InstrumentedStreamIterator) Close

func (i *InstrumentedStreamIterator) Close(ctx context.Context) (e error)

func (*InstrumentedStreamIterator) Next

Jump to

Keyboard shortcuts

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