Documentation ¶
Index ¶
- type InstrumentedStore
- type InstrumentedStoreOption
- func WithMeterProvider(provider metric.MeterProvider) InstrumentedStoreOption
- func WithMetricNamespace(namespace string) InstrumentedStoreOption
- func WithMetricsEnabled(enabled bool) InstrumentedStoreOption
- func WithTraceNamespace(namespace string) InstrumentedStoreOption
- func WithTracerProvider(provider trace.TracerProvider) InstrumentedStoreOption
- func WithTracingEnabled(enabled bool) InstrumentedStoreOption
- type InstrumentedStreamIterator
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 ¶
func (s *InstrumentedStore) AppendStream(ctx context.Context, id typeid.UUID, events []*eventstore.WritableEvent, opts eventstore.AppendStreamOptions) (e error)
Hydrate hydrates an aggregate while capturing telemetry.
func (*InstrumentedStore) ReadStream ¶
func (s *InstrumentedStore) ReadStream(ctx context.Context, id typeid.UUID, opts eventstore.ReadStreamOptions) (_ eventstore.StreamIterator, e error)
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 ¶
func (i *InstrumentedStreamIterator) Next(ctx context.Context) (_ *eventstore.Event, e error)