observability

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package observability provides tools for observing the behavior of an application, such as logging, metrics collection and tracing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDomainLogger

func NewDomainLogger(
	next twelf.Logger,
	env ax.Envelope,
) twelf.Logger

NewDomainLogger returns a new logger that can be used to log information about the domain logic that results from handling env.Message.

func NewProjectionLogger

func NewProjectionLogger(
	next twelf.Logger,
	env ax.Envelope,
) twelf.Logger

NewProjectionLogger returns a new logger that can be used to log information about the projections built as a result of applying env.Message.

Types

type InboundHook

type InboundHook struct {
	Observers []Observer
	Next      endpoint.InboundPipeline
}

InboundHook is an inbound pipeline stage that invokes hook methods on a set of observers.

func (*InboundHook) Accept

Accept forwards an inbound message through the pipeline until it is handled by some application-defined message handler(s).

func (*InboundHook) Initialize

func (h *InboundHook) Initialize(ctx context.Context, ep *endpoint.Endpoint) error

Initialize is called during initialization of the endpoint, after the transport is initialized. It can be used to inspect or further configure the endpoint as per the needs of the pipeline.

type Logger

type Logger struct {
	Next     twelf.Logger
	Envelope ax.Envelope
	Icon     string
}

Logger is an implementation of twelf.Logger that adds information about the messaging being handled.

func (*Logger) Debug

func (l *Logger) Debug(f string, v ...interface{})

Debug writes a debug log message formatted according to a format specifier.

If IsDebug() returns false, no logging is performed.

It should be used for messages that are intended for the software developers that maintain the application.

f is the format specifier, as per fmt.Printf(), etc.

func (*Logger) DebugString

func (l *Logger) DebugString(s string)

DebugString writes a pre-formatted debug log message.

If IsDebug() returns false, no logging is performed.

It should be used for messages that are intended for the software developers that maintain the application.

func (*Logger) IsDebug

func (l *Logger) IsDebug() bool

IsDebug returns true if this logger will perform debug logging.

Generally the application should just call Debug() or DebugString() without calling IsDebug(), however it can be used to check if debug logging is necessary before executing expensive code that is only used to obtain debug information.

func (*Logger) Log

func (l *Logger) Log(f string, v ...interface{})

Log writes an application log message formatted according to a format specifier.

It should be used for messages that are intended for people responsible for operating the application, such as the end-user or operations staff.

f is the format specifier, as per fmt.Printf(), etc.

func (*Logger) LogString

func (l *Logger) LogString(s string)

LogString writes a pre-formatted application log message.

It should be used for messages that are intended for people responsible for operating the application, such as the end-user or operations staff.

type LoggingObserver

type LoggingObserver struct {
	Logger twelf.Logger
}

LoggingObserver is an observer that logs about messages.

func (*LoggingObserver) AfterInbound

func (o *LoggingObserver) AfterInbound(ctx context.Context, env endpoint.InboundEnvelope, err error)

AfterInbound logs information about errors that occur processing an inbound message.

func (*LoggingObserver) AfterOutbound

func (o *LoggingObserver) AfterOutbound(ctx context.Context, env endpoint.OutboundEnvelope, err error)

AfterOutbound logs information about an outbound message.

func (*LoggingObserver) BeforeInbound

func (o *LoggingObserver) BeforeInbound(ctx context.Context, env endpoint.InboundEnvelope)

BeforeInbound logs information about an inbound message.

func (*LoggingObserver) BeforeOutbound

func (o *LoggingObserver) BeforeOutbound(ctx context.Context, env endpoint.OutboundEnvelope)

BeforeOutbound logs information about an outbound message.

type NullObserver

type NullObserver struct{}

NullObserver is an observer that does nothing.

It can be embedded into observer implementations to avoid having to write empty methods.

func (NullObserver) AfterInbound

AfterInbound is called after a message is accepted by the next pipeline stage. err is the error returned by the next pipeline stage, which may be nil.

func (NullObserver) AfterOutbound

AfterOutbound is called after a message is accepted by the next pipeline stage. err is the error returned by the next pipeline stage, which may be nil.

func (NullObserver) BeforeInbound

BeforeInbound is called before a message is passed to the next pipeline stage.

func (NullObserver) BeforeOutbound

BeforeOutbound is called before a message is passed to the next pipeline stage.

type Observer

type Observer interface {
	// BeforeInbound is called before a message is passed to the next pipeline stage.
	BeforeInbound(ctx context.Context, env endpoint.InboundEnvelope)

	// AfterInbound is called after a message is accepted by the next pipeline stage.
	// err is the error returned by the next pipeline stage, which may be nil.
	AfterInbound(ctx context.Context, env endpoint.InboundEnvelope, err error)

	// BeforeOutbound is called before a message is passed to the next pipeline stage.
	BeforeOutbound(ctx context.Context, env endpoint.OutboundEnvelope)

	// AfterOutbound is called after a message is accepted by the next pipeline stage.
	// err is the error returned by the next pipeline stage, which may be nil.
	AfterOutbound(ctx context.Context, env endpoint.OutboundEnvelope, err error)
}

Observer is an interface for types that observe the messages sent and received by an endpoint.

type OutboundHook

type OutboundHook struct {
	Observers []Observer
	Next      endpoint.OutboundPipeline
}

OutboundHook is an outbound pipeline stage that invokes hook methods on a set of observers.

func (*OutboundHook) Accept

Accept processes the message encapsulated in env.

func (*OutboundHook) Initialize

func (h *OutboundHook) Initialize(ctx context.Context, ep *endpoint.Endpoint) error

Initialize is called during initialization of the endpoint, after the transport is initialized. It can be used to inspect or further configure the endpoint as per the needs of the pipeline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳