observe

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 15 Imported by: 5

Documentation

Overview

Package observe implements a type that combines statter, logger and tracer.

Example usage:

obsrv, err := observe.New(ctx, cliCmd, &observe.Options{})
if err != nil {
	// Handle error.
	return
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Observer

type Observer struct {
	Log       *logger.Logger
	Stats     *statter.Statter
	TraceProv trace.TracerProvider
	// contains filtered or unexported fields
}

Observer contains observability primitives.

func New

func New(ctx context.Context, cliCmd *cli.Command, svc string, opts *Options) (*Observer, error)

New returns an observer with the given observability primitives.

Example
var (
	ctx    context.Context
	cliCmd *cli.Command // Get this from your action
)

obsrv, err := observe.New(ctx, cliCmd, "my-service", &observe.Options{})
if err != nil {
	// Handle error.
	return
}

_ = obsrv

func NewFake

func NewFake() *Observer

NewFake returns a fake observer that reports nothing. This is useful for tests.

func (*Observer) Close

func (o *Observer) Close()

Close closes the observability primitives.

func (*Observer) Tracer

func (o *Observer) Tracer(name string, opts ...trace.TracerOption) trace.Tracer

Tracer returns a tracer with the given name and options. If no trace provider has been set, this function will panic.

type Options

type Options struct {
	LogTimeFormat string
	LogTimestamps bool
	LogCtx        []logger.Field
	LogWriter     io.Writer

	StatsRuntime bool
	StatsTags    []statter.Tag

	TracingAttrs []attribute.KeyValue
}

Options optionally configures an observer.

Jump to

Keyboard shortcuts

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