stack_backend

package
v0.0.0-...-fb32a43 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"

	LevelSpan    = "span+"
	LevelSpanEnd = "span-"
)

Variables

This section is empty.

Functions

func Operation

func Operation(skip int) (funcName string, file string, line int)

func Put

func Put(ctx context.Context, s *Stack) context.Context

func Shutdown

func Shutdown(ctx context.Context)

func Stacktrace

func Stacktrace(skip int) *gostackparse.Goroutine

Types

type Attr

type Attr struct {
	Name  string
	Value any
}

func (Attr) ApplyToStack

func (a Attr) ApplyToStack(s *Stack)

type Backend

type Backend interface {
	Handle(e Event)
	Shutdown(ctx context.Context)
}

func EventFilter

func EventFilter(backend Backend, filterFn func(e *Event) bool) Backend

EventFilter

func LevelFilter

func LevelFilter(backend Backend) Backend

TODO

func MuxBackend

func MuxBackend(rules ...MuxBackendRule) Backend

MuxBackend

func TeeBackend

func TeeBackend(backends ...Backend) Backend

TeeBackend

type BackendFuncs

type BackendFuncs struct {
	HandleFn   func(e Event)
	ShutdownFn func(ctx context.Context)
}

backendFuncs

func (BackendFuncs) Handle

func (bf BackendFuncs) Handle(e Event)

func (BackendFuncs) Shutdown

func (bf BackendFuncs) Shutdown(ctx context.Context)

type Event

type Event struct {
	Kind Kind

	State *Stack

	LogEvent LogEvent
}

type ID

type ID [8]byte

func IDFromString

func IDFromString(hx string) (id ID, err error)

func NewID

func NewID() (id ID)

func (ID) Bytes

func (id ID) Bytes() []byte

func (ID) IsZero

func (id ID) IsZero() bool

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (ID) String

func (id ID) String() string

type Kind

type Kind uint8
const (
	KindSpan Kind = 1 << iota
	KindSpanEnd
	KindLog
	KindError
)

type LogEvent

type LogEvent struct {
	ID ID

	Name string

	File string
	Line int

	Time time.Time

	Level      string
	Error      error
	Panic      any
	IsTypedLog bool

	OwnAttrs   []Attr
	StackTrace *gostackparse.Goroutine
}

type MuxBackendRule

type MuxBackendRule struct {
	Backend Backend
	Kinds   Kind
	Filter  func(e Event) bool
}

func (MuxBackendRule) TryHandle

func (r MuxBackendRule) TryHandle(e Event)

type Option

type Option interface {
	ApplyToStack(s *Stack)
}

type OptionFunc

type OptionFunc func(s *Stack)

func (OptionFunc) ApplyToStack

func (a OptionFunc) ApplyToStack(s *Stack)

type Options

type Options []Option

func (Options) Apply

func (options Options) Apply(ctx context.Context) context.Context

func (Options) ApplyToStack

func (options Options) ApplyToStack(s *Stack)

func (Options) Attrs

func (options Options) Attrs(attrs ...Attr) Options

func (Options) Backend

func (options Options) Backend(backend Backend) Options

func (Options) EmbedLogsIntoSpans

func (options Options) EmbedLogsIntoSpans(embed bool) Options

func (Options) Name

func (options Options) Name(name string) Options

func (Options) Option

func (options Options) Option(option Option) Options

func (Options) ParentSpanID

func (options Options) ParentSpanID(id []byte) Options

func (Options) ScopeAttrs

func (options Options) ScopeAttrs(attrs ...Attr) Options

func (Options) ServiceName

func (options Options) ServiceName(name string) Options

func (Options) TraceID

func (options Options) TraceID(traceID []byte) Options

func (Options) W3CTraceContext

func (options Options) W3CTraceContext(traceparent, tracestate string) Options

func (Options) W3CTraceContextFromRequest

func (options Options) W3CTraceContextFromRequest(q *http.Request) Options

type RawAttrValue

type RawAttrValue string

type Span

type Span struct {
	ID           ID
	ParentSpanID ID
	TraceID      TraceID

	Name string

	File string
	Line int

	Time    time.Time
	EndTime time.Time

	Error           error
	ErrorStackTrace *gostackparse.Goroutine

	Attrs []Attr

	OwnLogs []SpanLog
}

func (Span) IsValid

func (s Span) IsValid() bool

type SpanLog

type SpanLog struct {
	Time  time.Time
	Name  string
	Attrs []Attr
}

type Stack

type Stack struct {
	Span Span

	Backend Backend

	Options struct {
		AttrPrefix    string
		AddLogsToSpan bool

		ServiceName string
		ScopeAttrs  []Attr
	}
}

func Get

func Get(ctx context.Context) *Stack

func (*Stack) Clone

func (s *Stack) Clone() *Stack

type TraceID

type TraceID [16]byte

func NewTraceID

func NewTraceID() (id TraceID)

func TraceIDFromString

func TraceIDFromString(hx string) (id TraceID, err error)

func (TraceID) Bytes

func (id TraceID) Bytes() []byte

func (TraceID) IsZero

func (id TraceID) IsZero() bool

func (TraceID) MarshalJSON

func (id TraceID) MarshalJSON() ([]byte, error)

func (TraceID) String

func (id TraceID) String() string

Jump to

Keyboard shortcuts

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