supervisor

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

README

Supervisor

Observe and control application data

Documentation

Index

Constants

View Source
const (
	KeyRequestID              = "request.id"
	KeyHttpRoute              = string(semconv.HTTPRouteKey)
	KeyHttpRequest            = "http.request"
	KeyHttpMethod             = string(semconv.HTTPRequestMethodKey)
	KeyHttpPath               = "http.request.path"
	KeyHttpRequestClientIP    = string(semconv.ClientAddressKey)
	KeyHttpResponseSize       = string(semconv.HTTPResponseSizeKey)
	KeyHttpRequestDuration    = string(semconv.HTTPClientRequestDurationName)
	KeyHttpResponseStatusCode = string(semconv.HTTPStatusCodeKey)
)
View Source
const (
	OtelEnvLocal = "LOCAL"
)

Variables

View Source
var (
	ErrUnsupportedOtelEnv = errors.New("unsupported otel environment")
)

Functions

func ContextAddAttributes

func ContextAddAttributes(ctx context.Context, attr slog.Attr)

func GetIPFromHeaders

func GetIPFromHeaders(r *http.Request) netip.Addr

GetIPFromHeaders returns the IP address from the request headers The request headers can be injected and ips can be spoofed They are also injected by proxies

func NewChild

func NewChild(ctx context.Context, name string) context.Context

func SetDefaultTelemetry

func SetDefaultTelemetry(t Telemetry)

Types

type Child

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

func (Child) Debug added in v0.0.4

func (c Child) Debug(ctx context.Context, msg string, attrs ...slog.Attr)

func (Child) End

func (c Child) End()

func (Child) Error

func (c Child) Error(err error) error

func (Child) Log

func (c Child) Log(ctx context.Context, msg string, attrs ...slog.Attr)

type Config

type Config struct {
	LogLevel        slog.Level
	ApplicationName string
	OtelEnvironment string
}

type ContextSupervisor

type ContextSupervisor struct {
	slog.Handler
}

func (ContextSupervisor) Handle

func (h ContextSupervisor) Handle(ctx context.Context, r slog.Record)

type DefaultTelemetry

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

func NewDefaultTelemetry

func NewDefaultTelemetry(ctx context.Context, applicationName string) (*DefaultTelemetry, error)

func (*DefaultTelemetry) Log

func (d *DefaultTelemetry) Log() *slog.Logger

func (*DefaultTelemetry) Shutdown

func (d *DefaultTelemetry) Shutdown(ctx context.Context) error

func (*DefaultTelemetry) StartChild

func (d *DefaultTelemetry) StartChild(ctx context.Context, moduleName, childName string) (context.Context, Child)

type HttpRequest

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

func NewHttpRequest

func NewHttpRequest(r *http.Request) *HttpRequest

func (HttpRequest) LogValue

func (r HttpRequest) LogValue() slog.Value

type Otel

type Otel interface {
	GetSpanExporter() trace.SpanExporter
	GetTraceProvider() *trace.TracerProvider
	GetLogger() *slog.Logger
	Shutdown(ctx context.Context) error
}

type Telemetry

type Telemetry interface {
	StartChild(ctx context.Context, moduleName, childName string) (context.Context, Child)
	Log() *slog.Logger
	Shutdown(ctx context.Context) error
}

func GetDefaultTelemetry

func GetDefaultTelemetry() Telemetry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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