wool

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 18 Imported by: 7

README

Observability

Wool

Wrapper Over Open-Telemetry is accurate and has a meaningful acronym. Yarn, fiber, we are in the "context" space.

Goal of this package is to provide a Canvas that satisfies the following requirements:

Requirement:

  • context.Context based
  • opentelemetry support with flexible backend
  • logger support as Events (where opentelemetry is going) with flexible backend

Documentation

Index

Constants

View Source
const CodePathKey = "codepath"
View Source
const KeyInContext = ContextKey("provider")
View Source
const LogEvent = "log"

Variables

This section is empty.

Functions

func TypeOf added in v0.0.55

func TypeOf[T any]() string

func WithTelemetry

func WithTelemetry() bool

Types

type CodePath added in v0.0.55

type CodePath struct {
	Method string      `json:"method"`
	Fields []*LogField `json:"fields"`
}

type CodefReference added in v0.0.55

type CodefReference struct {
	Line int    `json:"line"`
	File string `json:"file"`
}

type Console added in v0.0.57

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

func (Console) Process added in v0.0.57

func (c Console) Process(msg *Log)

type ContextKey

type ContextKey string

type Identifier added in v0.0.55

type Identifier struct {
	Kind   string `json:"kind"`
	Unique string `json:"unique"`
}

type Log

type Log struct {
	Level   Loglevel    `json:"level"`
	Message string      `json:"message"`
	Header  string      `json:"header"`
	Fields  []*LogField `json:"fields"`
}

func (*Log) AtLevel

func (l *Log) AtLevel(debug Loglevel) *Log

func (*Log) Event

func (l *Log) Event() trace.SpanStartEventOption

type LogField

type LogField struct {
	Key   string   `json:"key"`
	Level Loglevel `json:"level"`
	Value any      `json:"value"`
}

LogField is a key value pair with a log level A Field is shown only if the log level is equal or higher than the log level of the log

func DebugField

func DebugField(key string, value string) *LogField

func DirField added in v0.0.55

func DirField(dir string) *LogField

func ErrField added in v0.0.55

func ErrField(err error) *LogField

func ErrorField added in v0.0.55

func ErrorField(s string, value any) *LogField

func Field

func Field(key string, value any) *LogField

Field with default level

func FileField added in v0.0.55

func FileField(file string) *LogField

func GenericField added in v0.0.55

func GenericField[T any]() *LogField

func InfoField added in v0.0.55

func InfoField(key string, value any) *LogField

func NameField added in v0.0.55

func NameField(name string) *LogField

func PathField added in v0.0.55

func PathField(dir string) *LogField

func PointerField added in v0.0.57

func PointerField[T any](override *T) *LogField

func RequestField added in v0.0.55

func RequestField(req any) *LogField

func SliceCountField added in v0.0.57

func SliceCountField[T any](slice []T) *LogField

func StatusFailed added in v0.0.55

func StatusFailed() *LogField

func StatusOK added in v0.0.55

func StatusOK() *LogField

func ThisField added in v0.0.55

func ThisField(this Unique) *LogField

func TraceField added in v0.0.55

func TraceField(key string, value string) *LogField

func WarnField added in v0.0.55

func WarnField(key string, value any) *LogField

func (*LogField) String added in v0.0.57

func (f *LogField) String() string

type LogProcessor added in v0.0.55

type LogProcessor interface {
	Process(msg *Log)
}

type LogProcessorWithSource added in v0.0.55

type LogProcessorWithSource interface {
	ProcessWithSource(msg *Log, source *Identifier)
}

type Loglevel

type Loglevel int
const (
	DEFAULT Loglevel = iota
	TRACE
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

type Otel added in v0.0.55

type Otel interface {
}

type Provider added in v0.0.55

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

Provider keeping track

func New

func New(ctx context.Context, r *Resource) *Provider

func (*Provider) Done added in v0.0.55

func (w *Provider) Done()

func (*Provider) Get added in v0.0.55

func (provider *Provider) Get(ctx context.Context) *Wool

func (*Provider) WithContext added in v0.0.55

func (w *Provider) WithContext(ctx context.Context) context.Context

func (*Provider) WithLogger added in v0.0.55

func (w *Provider) WithLogger(l LogProcessor) *Provider

type Resource added in v0.0.55

type Resource struct {
	Resource *resource.Resource
	*Identifier
}

type Unique added in v0.0.55

type Unique interface {
	Unique() string
}

type Wool

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

func Get

func Get(ctx context.Context) *Wool

func (*Wool) Catch added in v0.0.55

func (c *Wool) Catch()

Catch recovers from a panic and logs the error

func (*Wool) Close added in v0.0.55

func (c *Wool) Close()

func (*Wool) Context

func (c *Wool) Context() context.Context

func (*Wool) Debug added in v0.0.55

func (c *Wool) Debug(msg string, fields ...*LogField)

func (*Wool) Error added in v0.0.55

func (c *Wool) Error(msg string, fields ...*LogField)

func (*Wool) Fatal added in v0.0.55

func (c *Wool) Fatal(msg string, fields ...*LogField)

func (*Wool) File added in v0.0.55

func (w *Wool) File() string

func (*Wool) In added in v0.0.55

func (c *Wool) In(method string, fields ...*LogField) *Wool

func (*Wool) Info added in v0.0.55

func (c *Wool) Info(msg string, fields ...*LogField)

func (*Wool) Name added in v0.0.55

func (c *Wool) Name() string

func (*Wool) NewError added in v0.0.55

func (c *Wool) NewError(format string, args ...any) error

func (*Wool) StackTrace added in v0.0.55

func (c *Wool) StackTrace() []CodePath

func (*Wool) Trace added in v0.0.55

func (c *Wool) Trace(msg string, fields ...*LogField)

func (*Wool) Warn added in v0.0.55

func (c *Wool) Warn(msg string, fields ...*LogField)

func (*Wool) WithLogger added in v0.0.55

func (c *Wool) WithLogger(l LogProcessor) *Wool

func (*Wool) Wrap added in v0.0.55

func (c *Wool) Wrap(err error) error

func (*Wool) Wrapf added in v0.0.55

func (c *Wool) Wrapf(err error, msg string, args ...any) error

Directories

Path Synopsis
adapters
log

Jump to

Keyboard shortcuts

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