observability

package
v0.1.59 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	PropertyErrorLevel            = "log.level.error"
	PropertySlowLevel             = "log.level.slow"
	PropertySlowThreshold         = "log.slowThreshold"
	PropertyOperationLevel        = "log.level.operation"
	PropertySQLLevel              = "log.level.sql"
	PropertySQLParamsLevel        = "log.level.sql.params"
	PropertyHTTPLevel             = "log.level.http"
	PropertyHTTPHeadersLevel      = "log.level.http.headers"
	PropertyHTTPRequestBodyLevel  = "log.level.http.request.body"
	PropertyHTTPResponseBodyLevel = "log.level.http.response.body"
	DefaultCollectorEntries       = 100
)

Variables

This section is empty.

Functions

func ApplyHTTPClientObservability added in v0.1.59

func ApplyHTTPClientObservability(ctx any, feature string, client *commonsHTTP.Client, explicit *har.Collector) middlewares.Middleware

ApplyHTTPClientObservability attaches HAR capture and HTTP logging to a commons HTTP client for the given feature. It returns a middleware suitable for reuse on derived (e.g. token) clients, or nil when nothing was attached.

func ApplyHTTPObservability added in v0.1.59

func ApplyHTTPObservability(ctx any, feature string, base netHTTP.RoundTripper, explicit *har.Collector) netHTTP.RoundTripper

ApplyHTTPObservability wraps a RoundTripper with HAR capture and HTTP logging for the given feature, honouring the context's effective levels.

func ObserveHTTP added in v0.1.59

func ObserveHTTP(feature string, collector *har.Collector) (release func())

ObserveHTTP hands collector every exchange that ApplyHTTPObservability and ApplyHTTPClientObservability transports of feature make, whatever the feature's HAR level, until release is called. Feature names match as the HAR level's do: case-insensitively, with an empty name meaning "http".

func ParseLevelName

func ParseLevelName(name string) (level logger.LogLevel, off bool, ok bool)

ParseLevelName resolves one of SupportedLevelNames to its level. "off" is not a level and reports ok=false along with off=true, so a caller can tell "switch this feature off" from "that is not a level I know" and reject the latter rather than quietly running at a level nobody asked for.

func SupportedLevelNames

func SupportedLevelNames() []string

Types

type Capability

type Capability struct {
	Family         ProviderFamily    `json:"family"`
	SlowThreshold  string            `json:"slowThreshold"`
	ThresholdLabel string            `json:"thresholdLabel"`
	Events         []EventDefinition `json:"events"`
}

func CapabilityFor

func CapabilityFor(connectionType string) Capability

type Event

type Event string
const (
	EventError            Event = "error"
	EventSlow             Event = "slow"
	EventOperation        Event = "operation"
	EventSQL              Event = "sql"
	EventSQLParams        Event = "sql_params"
	EventHTTP             Event = "http"
	EventHTTPHeaders      Event = "http_headers"
	EventHTTPRequestBody  Event = "http_request_body"
	EventHTTPResponseBody Event = "http_response_body"
)

type EventDefinition

type EventDefinition struct {
	Event         Event          `json:"event"`
	Property      string         `json:"property"`
	Label         string         `json:"label"`
	Description   string         `json:"description"`
	Default       string         `json:"default"`
	Captures      []string       `json:"captures"`
	Example       map[string]any `json:"example"`
	PrettyExample string         `json:"prettyExample"`
}

type Policy

type Policy struct {
	Family        ProviderFamily
	SlowThreshold time.Duration
	// contains filtered or unexported fields
}

func PolicyFor

func PolicyFor(connection *models.Connection) (Policy, error)

func (Policy) Completion

func (p Policy) Completion(duration time.Duration, err error) (Event, logger.LogLevel)

func (Policy) Enabled

func (p Policy) Enabled(event Event) bool

func (Policy) Level

func (p Policy) Level(event Event) logger.LogLevel

type ProviderFamily

type ProviderFamily string
const (
	ProviderGeneric ProviderFamily = "generic"
	ProviderSQL     ProviderFamily = "sql"
	ProviderHTTP    ProviderFamily = "http"
)

Jump to

Keyboard shortcuts

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