Documentation
¶
Overview ¶
Package loza provides canonical wide-event logging for Go services.
Index ¶
- Constants
- Variables
- func Abandon(ctx context.Context, reason string) error
- func Add(ctx context.Context, key string, value interface{}) error
- func Alias(service string) (*logger, error)
- func Append(ctx context.Context, attrs ...Attr) error
- func AssertEvent(t testing.TB, ev *Event, key string, expected any)
- func AssertHasCheckpoint(t testing.TB, ev *Event, name string)
- func AssertRedacted(t testing.TB, ev *Event, key string)
- func Audit(name string, attrs ...Attr)
- func Breadcrumb(name string, attrs ...Attr)
- func Cancel(ctx context.Context, reason string) error
- func CardinalityPolicy(policy map[string]any) map[string]any
- func Checkpoint(ctx context.Context, name string, attrs ...Attr) error
- func ClearEvents(store *MemorySinkStore)
- func Configure(cfg Config) error
- func ConformanceSuite() map[string]string
- func Count(name string, value int64, attrs ...Attr)
- func CreateLoza(cfg Config) (*logger, error)
- func Debug(msg string, attrs ...Attr)
- func DebugContext(ctx context.Context, msg, event string, attrs ...Attr)
- func Default() *logger
- func Delete(ctx context.Context, keys ...string) error
- func Drain(ctx context.Context, s Sink) error
- func Drop(ctx context.Context, reason string) error
- func Emit(ctx context.Context) error
- func EmitEvent(ev *Event) error
- func Enrich(ctx context.Context, attrs ...Attr) error
- func EnrichGroup(ctx context.Context, key string, attrs ...Attr) error
- func Error(msg string, attrs ...Attr)
- func ErrorContext(ctx context.Context, msg string, err error, event string, attrs ...Attr)
- func EventID(ctx context.Context) string
- func ExpectAttr(t testing.TB, ev *Event, key string, expected any)
- func Fatal(msg string, attrs ...Attr)
- func FatalContext(ctx context.Context, msg string, err error, event string, attrs ...Attr)
- func Finish(ctx context.Context, outcome string, attrs ...Attr) error
- func FinishError(ctx context.Context, err error, attrs ...Attr) error
- func FinishGroup(h *GroupHandle, attrs ...Attr) error
- func FinishGroupError(h *GroupHandle, err error, attrs ...Attr) error
- func FinishProcess(h *ProcessHandle, attrs ...Attr) error
- func FinishProcessError(h *ProcessHandle, err error, statusCode int, attrs ...Attr) error
- func Flush(ctx context.Context) error
- func Gauge(name string, value float64, attrs ...Attr)
- func Get(ctx context.Context, key string) (any, bool)
- func GetGroup(ctx context.Context, name string) (map[string]any, bool)
- func GoldenTest(path string) string
- func HasEvent(ctx context.Context) bool
- func Health(ctx context.Context, s Sink) error
- func Histogram(name string, value float64, attrs ...Attr)
- func IncidentIDFromContext(ctx context.Context) string
- func Info(msg string, attrs ...Attr)
- func InfoContext(ctx context.Context, msg, event string, attrs ...Attr)
- func InjectHTTPHeaderCarrier(ctx context.Context, header http.Header) http.Header
- func InjectHTTPHeaders(req *http.Request)
- func LinkEvent(ctx context.Context, target string, attrs ...Attr) (context.Context, error)
- func MemorySink() (Sink, *MemorySinkStore)
- func Merge(ctx context.Context, group string, attrs ...Attr) error
- func Metric(name string, value float64, attrs ...Attr)
- func MustShutdown(timeout time.Duration)
- func New(cfg Config) (*logger, error)
- func NewClient(cfg Config) (*logger, error)
- func NewRoundTripper(base http.RoundTripper) http.RoundTripper
- func NormalizeEvent(payload map[string]any) bool
- func NormalizeIncidentContext(ctx *IncidentContext)
- func NormalizeRemediation(r *Remediation)
- func NormalizeRemediationFeedback(rf *RemediationFeedback)
- func Notice(msg string, attrs ...Attr)
- func NoticeContext(ctx context.Context, msg, event string, attrs ...Attr)
- func PanicRecoveryEnabled() bool
- func Partial(ctx context.Context, attrs ...Attr) error
- func Pause(s Sink)
- func Phase(ctx context.Context, name string, fn func() error) error
- func QueueSize(s Sink) int
- func RenderPrometheus(metrics *MetricsCollector) string
- func RequestIDFromContext(ctx context.Context) string
- func RequestIDFromHTTP(r *http.Request) string
- func Reset() error
- func ResetForTest()
- func Resume(s Sink)
- func Retry(ctx context.Context, attrs ...Attr) error
- func RunCLI(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func RunCron(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func RunEvent(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func RunHTTP(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func RunJob(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func RunQueue(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error
- func Security(name string, attrs ...Attr)
- func Set(ctx context.Context, attrs ...Attr) error
- func SetDefault(l *logger)
- func ShouldSample(sampler Sampler, event *Event) bool
- func Shutdown(ctx context.Context) error
- func ShutdownTimeout(timeout time.Duration) error
- func SnapshotEvent(t testing.TB, ev *Event) string
- func Span(ctx context.Context, name string, fn func() error) error
- func SpanIDFromContext(ctx context.Context) string
- func StartCLIEvent(ctx context.Context, params Params) context.Context
- func StartCron(ctx context.Context, name string) context.Context
- func StartCronEvent(ctx context.Context, params Params) context.Context
- func StartEvent(ctx context.Context, params Params) context.Context
- func StartHTTPEvent(ctx context.Context, params Params) context.Context
- func StartHTTPEventFromRequest(r *http.Request, params Params) context.Context
- func StartJob(ctx context.Context, name string) context.Context
- func StartJobEvent(ctx context.Context, params Params) context.Context
- func StartQueueEvent(ctx context.Context, params Params) context.Context
- func StartQueueJob(ctx context.Context, queue, messageID string) context.Context
- func Step(ctx context.Context, name string, fn func() error) error
- func StopTimer(h *TimerHandle, attrs ...Attr) error
- func TraceFromOTel(ctx context.Context) (traceID string, spanID string)
- func TraceIDFromContext(ctx context.Context) string
- func Track(name string, attrs ...Attr)
- func TryNew(cfg Config) (*logger, error)
- func ValidateEvent(raw []byte, strict bool) error
- func ValidateGraphView(gv *GraphView) error
- func ValidateIncidentContext(ctx *IncidentContext) error
- func ValidateIngestEnvelopeBytes(raw []byte, strict bool) error
- func ValidateRemediation(r *Remediation) error
- func ValidateRemediationFeedback(rf *RemediationFeedback) error
- func Warn(msg string, attrs ...Attr)
- func WarnContext(ctx context.Context, msg, event string, attrs ...Attr)
- func WithGroup(ctx context.Context, name string, fn func() error, attrs ...Attr) error
- func WithProcess(ctx context.Context, name string, fn func() error, attrs ...Attr) error
- func WithTimer(ctx context.Context, name string, fn func() error, attrs ...Attr) error
- func Wrap(name string, fn func() error) error
- func WrapHTTPClient(client *http.Client) *http.Client
- type Attr
- func ExtractHTTPHeaderAttrs(header http.Header) []Attr
- func ExtractHTTPHeaders(r *http.Request) []Attr
- func HTTPMethod(method string) Attr
- func HTTPPath(path string) Attr
- func HTTPReferer(ref string) Attr
- func HTTPRequest(r *http.Request) Attr
- func HTTPResponse(statusCode int) Attr
- func HTTPRoute(route string) Attr
- func HTTPUserAgent(ua string) Attr
- func Measure(name string, fn func()) Attr
- type BackpressurePolicy
- type CollectorClient
- type CollectorClientConfig
- type CollectorSinkConfig
- type Config
- type ConfigOption
- func WithAPIKey(apiKey string) ConfigOption
- func WithAlias(alias string) ConfigOption
- func WithAsync(enabled bool) ConfigOption
- func WithAsyncFlushInterval(interval time.Duration) ConfigOption
- func WithAsyncMaxBatchBytes(maxBytes int) ConfigOption
- func WithAsyncQueue(size int) ConfigOption
- func WithBackpressure(policy BackpressurePolicy) ConfigOption
- func WithBatchSize(size int) ConfigOption
- func WithCollectorEndpoint(endpoint string) ConfigOption
- func WithCollectorURL(url string) ConfigOption
- func WithCompression(enabled bool) ConfigOption
- func WithConnectionTimeout(timeout time.Duration) ConfigOption
- func WithDeploymentID(deploymentID string) ConfigOption
- func WithDuplicatePolicy(policy DuplicateFieldPolicy) ConfigOption
- func WithEncoder(encoder Encoder) ConfigOption
- func WithEnricher(enricher ContextEnricher) ConfigOption
- func WithEnvironment(environment string) ConfigOption
- func WithEventSchema(schema Schema) ConfigOption
- func WithFallbackSink(sink Sink) ConfigOption
- func WithFlushInterval(interval time.Duration) ConfigOption
- func WithIncludeHost(includeHost bool) ConfigOption
- func WithLevel(level Level) ConfigOption
- func WithLogger(l *logger) ConfigOption
- func WithMaxBackoff(backoff time.Duration) ConfigOption
- func WithMaxBufferSize(size int) ConfigOption
- func WithMaxRetries(retries int) ConfigOption
- func WithNamespace(namespace string) ConfigOption
- func WithOtelBridge(enabled bool) ConfigOption
- func WithPanicRecovery(panicRecovery bool) ConfigOption
- func WithQueueSize(size int) ConfigOption
- func WithRedactor(redactor Redactor) ConfigOption
- func WithRegion(region string) ConfigOption
- func WithRelease(release string) ConfigOption
- func WithRetry(maxRetries int) ConfigOption
- func WithSampler(sampler Sampler) ConfigOption
- func WithSchema(schema Schema) ConfigOption
- func WithService(service string) ConfigOption
- func WithSink(sink Sink) ConfigOption
- func WithStatsHandler(handler StatsHandler) ConfigOption
- func WithStrict(strict bool) ConfigOption
- func WithTenantID(tenantID string) ConfigOption
- func WithTimeout(timeout time.Duration) ConfigOption
- func WithValidateEncoded(validate bool) ConfigOption
- func WithVersion(version string) ConfigOption
- func WithWorkers(workers int) ConfigOption
- type ConfigValidationError
- type ContextEnricher
- type CortexClient
- type DeliveryFailureHandler
- type DuplicateEmitError
- type DuplicateFieldError
- type DuplicateFieldPolicy
- type Encoder
- type Event
- func Capture(fn func()) ([]*Event, error)
- func CloneEvent(ctx context.Context) (*Event, error)
- func CurrentEvent(ctx context.Context) (*Event, bool)
- func Events(store *MemorySinkStore) []*Event
- func ExpectEvent(t testing.TB, store *MemorySinkStore) *Event
- func FromContext(ctx context.Context) (*Event, bool)
- func LastEvent(store *MemorySinkStore) *Event
- func NewEvent(params Params) *Event
- func SanitizeEvent(ev *Event) *Event
- type EventAlreadyFinishedError
- type EventClosedError
- type EventFunc
- type EventState
- type EventView
- type FakeClock
- type FileConfig
- type GraphView
- type GroupHandle
- type HTTPBatchSinkConfig
- type IDGenerator
- type IncidentContext
- type JSONEventEncoder
- type LQLCompilationError
- type LQLDiagnostic
- type LQLQueryOptions
- type Level
- type Logger
- type MemorySinkStore
- type MetricsCollector
- type MetricsSnapshot
- type MockSink
- type Params
- type ProcessHandle
- type PrometheusStatsHandler
- type QueryResult
- type QueryValue
- type Redactor
- func ComposeRedactors(redactors ...Redactor) Redactor
- func DefaultRedactor() Redactor
- func DropKeys(keys ...string) Redactor
- func HashKeys(keys ...string) Redactor
- func MaskKeys(keys ...string) Redactor
- func Redact(keys ...string) Redactor
- func RedactKeys(keys ...string) Redactor
- func RedactPatterns(patterns ...string) Redactor
- type Remediation
- type RemediationFeedback
- type RotatingFileConfig
- type Sampler
- func AllSampler(samplers ...Sampler) Sampler
- func AllowFields(keys ...string) Sampler
- func AnySampler(samplers ...Sampler) Sampler
- func BlockFields(keys ...string) Sampler
- func NotSampler(sampler Sampler) Sampler
- func SampleAll() Sampler
- func SampleByEvent(names ...string) Sampler
- func SampleByHeader(header, value string) Sampler
- func SampleByOutcome(outcomes ...string) Sampler
- func SampleErrors() Sampler
- func SampleFeatureFlag(name string, value any) Sampler
- func SampleNone() Sampler
- func SampleRandom(rate float64) Sampler
- func SampleRate(rate float64) Sampler
- func SampleRateLimited(rate float64, window time.Duration) Sampler
- func SampleRoutes(routes ...string) Sampler
- func SampleSlowRequests(d time.Duration) Sampler
- func SampleStatusCodes(codes ...int) Sampler
- func SampleTenants(ids ...string) Sampler
- func SampleUsers(ids ...string) Sampler
- type Schema
- type SchemaFunc
- type SecurityConfig
- type Sink
- func CollectorSink(cfg CollectorSinkConfig) (Sink, error)
- func FileSink(path string) (Sink, error)
- func HTTPBatchSink(cfg HTTPBatchSinkConfig) (Sink, error)
- func KafkaSink(endpoint, topic string) (Sink, error)
- func LegacyHTTPBatchSink(endpoint string) (Sink, error)
- func MultiSink(sinks ...Sink) Sink
- func NoopSink() Sink
- func OTLSink(endpoint string) (Sink, error)
- func RotatingFileSink(cfg RotatingFileConfig) (Sink, error)
- func StderrSink() Sink
- func StdoutSink() Sink
- type StatsHandler
- type StopwatchHandle
- type TimerHandle
Constants ¶
const ( LOZA_SPEC_VERSION = core.LOZA_SPEC_VERSION LOZA_INGEST_API_VERSION = core.LOZA_INGEST_API_VERSION LOZA_EVENT_VERSION = core.LOZA_EVENT_VERSION LevelDebug = core.LevelDebug LevelInfo = core.LevelInfo LevelNotice = core.LevelNotice LevelWarn = core.LevelWarn LevelError = core.LevelError LevelFatal = core.LevelFatal // Backpressure policies Block = core.Block DropNewest = core.DropNewest DropOldest = core.DropOldest DropDebug = core.DropDebug DropSampled = core.DropSampled SyncFallback = core.SyncFallback // Duplicate field policies CanonicalWins = core.CanonicalWins UserWins = core.UserWins FirstWins = core.FirstWins LastWins = core.LastWins KeepBoth = core.KeepBoth ErrorOnDuplicate = core.ErrorOnDuplicate // Deprecated aliases — kept for backward compatibility //nolint:staticcheck AttrWins = core.AttrWins //nolint:staticcheck AttrsWin = core.AttrsWin //nolint:staticcheck KeepBothUnderAttrs = core.KeepBothUnderAttrs //nolint:staticcheck DropDuplicateAttr = core.DropDuplicateAttr EventStateCreated = core.EventStateCreated EventStateActive = core.EventStateActive EventStateFinished = core.EventStateFinished EventStateEmitting = core.EventStateEmitting EventStateEmitted = core.EventStateEmitted EventStateInvalid = core.EventStateInvalid EventStateDropped = core.EventStateDropped EventStateEmitFailed = core.EventStateEmitFailed EventStateSpooled = core.EventStateSpooled EventStateDLQWritten = core.EventStateDLQWritten EventStateFailedValidation = core.EventStateFailedValidation EventStateDeliveryFailed = core.EventStateDeliveryFailed )
Variables ¶
var ( // ErrInvalidConfig indicates config validation failure. ErrInvalidConfig = core.ErrInvalidConfig // ErrConfigFileNotFound is returned when no config file is found. ErrConfigFileNotFound = core.ErrConfigFileNotFound )
var ( String = core.String Int = core.Int Int64 = core.Int64 Uint64 = core.Uint64 Float = core.Float64 Float64 = core.Float64 Bool = core.Bool Time = core.Time Duration = core.Duration Any = core.Any JSON = core.Any Null = core.Null Err = core.Err Stringer = core.Stringer Group = core.Group // Canonical fields RequestID = core.RequestID TraceID = core.TraceID SpanID = core.SpanID IncidentID = core.IncidentID Service = core.Service Version = core.Version DeploymentID = core.DeploymentID Region = core.Region Method = core.Method Path = core.Path Route = core.Route StatusCode = core.StatusCode DurationMS = core.DurationMS Outcome = core.Outcome // Domain fields UserID = core.UserID TenantID = core.TenantID WorkspaceID = core.WorkspaceID OrganizationID = core.OrganizationID SessionID = core.SessionID OrderID = core.OrderID CartID = core.CartID ProductID = core.ProductID CustomerID = core.CustomerID Plan = core.Plan Currency = core.Currency Amount = core.Amount Country = core.Country Device = core.Device Platform = core.Platform AppVersion = core.AppVersion JobName = core.JobName QueueName = core.QueueName MessageID = core.MessageID Attempt = core.Attempt ErrorType = core.ErrorType ErrorCode = core.ErrorCode ErrorMessage = core.ErrorMessage ErrorStack = core.ErrorStack Retryable = core.Retryable // Sensitive MarkSensitive = core.MarkSensitive SensitiveString = core.SensitiveString HashString = core.HashString // Additional domain helpers PaymentID = core.PaymentID SubscriptionID = core.SubscriptionID InvoiceID = core.InvoiceID JobID = core.JobID CorrelationID = core.CorrelationID CommitSha = core.CommitSha Release = core.Release Money = core.Money Percent = core.Percent Bytes = core.Bytes HTTPStatus = core.HTTPStatus Bucket = core.Bucket Tags = core.Tags Masked = core.Masked URL = core.URL EmailHash = core.EmailHash IPHash = core.IPHash // Checkout domain helpers CheckoutCartItemCount = core.CheckoutCartItemCount CheckoutCartTotal = core.CheckoutCartTotal CheckoutPaymentMethod = core.CheckoutPaymentMethod CheckoutStatus = core.CheckoutStatus // Payment domain helpers PaymentMethod = core.PaymentMethod PaymentIntentID = core.PaymentIntentID PaymentFailureCode = core.PaymentFailureCode PaymentRetryAttempt = core.PaymentRetryAttempt // Billing domain helpers BillingPlan = core.BillingPlan BillingSubscriptionID = core.BillingSubscriptionID BillingInvoiceID = core.BillingInvoiceID BillingAmount = core.BillingAmount BillingInterval = core.BillingInterval // Agent/AI domain helpers AgentName = core.AgentName AgentProvider = core.AgentProvider AgentModel = core.AgentModel AgentRunType = core.AgentRunType AgentToolName = core.AgentToolName AgentToolOutcome = core.AgentToolOutcome AgentInputTokens = core.AgentInputTokens AgentOutputTokens = core.AgentOutputTokens AgentCost = core.AgentCost // RAG domain helpers RAGIndex = core.RAGIndex RAGEmbeddingModel = core.RAGEmbeddingModel RAGChunksRetrieved = core.RAGChunksRetrieved RAGTopScore = core.RAGTopScore RAGQueryHash = core.RAGQueryHash RAGCitationCount = core.RAGCitationCount RAGRetrievalLatency = core.RAGRetrievalLatency // Generic typed attr constructors List = core.List Map = core.Map Enum = core.Enum ID = core.ID Hash = core.Hash Redacted = core.Redacted // Domain logic FeatureFlag = core.FeatureFlag FeatureFlagBool = core.FeatureFlagBool Experiment = core.Experiment // Identity AccountID = core.AccountID )
Functions ¶
func AssertEvent ¶
AssertEvent checks that ev has the expected value at the given key.
func AssertHasCheckpoint ¶
AssertHasCheckpoint checks that ev contains a checkpoint with the given name.
func AssertRedacted ¶
AssertRedacted checks that ev has "[REDACTED]" at the given key.
func Breadcrumb ¶
func Checkpoint ¶
Checkpoint records a named breadcrumb.
func ClearEvents ¶
func ClearEvents(store *MemorySinkStore)
func ConformanceSuite ¶
func CreateLoza ¶
CreateLoza creates a new Logger. Cross-language parity factory.
func DebugContext ¶
DebugContext emits an immediate debug log line with explicit context and event name.
func EnrichGroup ¶
EnrichGroup appends attrs as a named group.
func ErrorContext ¶
ErrorContext emits an immediate error log line with explicit context and event name.
func ExpectAttr ¶
ExpectAttr asserts ev contains an attr with the given key and value.
func FatalContext ¶
FatalContext emits an immediate fatal log line with explicit context and exits the process.
func FinishError ¶
FinishError records error outcome and metadata.
func FinishGroup ¶
func FinishGroup(h *GroupHandle, attrs ...Attr) error
FinishGroup completes a group handle.
func FinishGroupError ¶
func FinishGroupError(h *GroupHandle, err error, attrs ...Attr) error
FinishGroupError completes a group handle with an error.
func FinishProcess ¶
func FinishProcess(h *ProcessHandle, attrs ...Attr) error
FinishProcess completes a process handle.
func FinishProcessError ¶
func FinishProcessError(h *ProcessHandle, err error, statusCode int, attrs ...Attr) error
FinishProcessError completes a process handle with error metadata.
func GoldenTest ¶
func IncidentIDFromContext ¶
IncidentIDFromContext returns the incident ID of the active event.
func InfoContext ¶
InfoContext emits an immediate info log line with explicit context and event name.
func InjectHTTPHeaderCarrier ¶
InjectHTTPHeaderCarrier injects LOZA + trace headers into a header map.
func InjectHTTPHeaders ¶
InjectHTTPHeaders injects LOZA + trace headers into an outbound request.
func MemorySink ¶
func MemorySink() (Sink, *MemorySinkStore)
func MustShutdown ¶
MustShutdown drains and closes sinks, panicking on error.
func NewClient ¶
NewClient creates a new Logger applying the full configuration precedence: code initialization > environment variables > configuration file > defaults. This is the recommended way to create a production SDK client. Requirements: 32.1, 32.4, 32.5, 32.6, 32.7, 32.8, 32.9
func NewRoundTripper ¶
func NewRoundTripper(base http.RoundTripper) http.RoundTripper
func NormalizeEvent ¶
NormalizeEvent normalizes event field aliases in a JSON map payload.
func NormalizeIncidentContext ¶
func NormalizeIncidentContext(ctx *IncidentContext)
Cortex normalization
func NormalizeRemediation ¶
func NormalizeRemediation(r *Remediation)
func NormalizeRemediationFeedback ¶
func NormalizeRemediationFeedback(rf *RemediationFeedback)
func NoticeContext ¶
NoticeContext emits an immediate notice log line with explicit context and event name.
func PanicRecoveryEnabled ¶
func PanicRecoveryEnabled() bool
PanicRecoveryEnabled reports whether wrapper helpers recover panics.
func RenderPrometheus ¶
func RenderPrometheus(metrics *MetricsCollector) string
RenderPrometheus returns a stable textual metrics endpoint hint for SDK parity.
func RequestIDFromContext ¶
RequestIDFromContext returns the request ID of the active event.
func RequestIDFromHTTP ¶
RequestIDFromHTTP resolves request id from header or active event context.
func Reset ¶
func Reset() error
Reset restores the global default logger to the SDK development preset.
func ResetForTest ¶
func ResetForTest()
ResetForTest clears all global mutable state: global logger, clock, and ID generator.
func SetDefault ¶
func SetDefault(l *logger)
SetDefault replaces the global default logger instance.
func ShouldSample ¶
func ShutdownTimeout ¶
ShutdownTimeout drains and closes sinks with timeout-bound context.
func SnapshotEvent ¶
SnapshotEvent returns a JSON snapshot of the event for comparison.
func SpanIDFromContext ¶
SpanIDFromContext returns the span ID of the active event.
func StartCLIEvent ¶
StartCLIEvent starts a CLI execution event.
func StartCronEvent ¶
StartCronEvent starts a cron execution event.
func StartEvent ¶
StartEvent begins a canonical wide event.
func StartHTTPEvent ¶
StartHTTPEvent starts an event with HTTP defaults.
func StartHTTPEventFromRequest ¶
StartHTTPEventFromRequest starts an HTTP event using request metadata and propagated headers. It fills Method/Path defaults from r when absent, starts the event, then enriches with extracted request/trace attrs.
func StartJobEvent ¶
StartJobEvent starts a background job event.
func StartQueueEvent ¶
StartQueueEvent starts a queue-processing event.
func StartQueueJob ¶
StartQueueJob is a convenience wrapper for queue jobs.
func StopTimer ¶
func StopTimer(h *TimerHandle, attrs ...Attr) error
StopTimer completes a timer handle.
func TraceFromOTel ¶
TraceFromOTel returns trace/span ids from OTel span context.
func TraceIDFromContext ¶
TraceIDFromContext returns the trace ID of the active event.
func ValidateEvent ¶
ValidateEvent validates a single event JSON payload against the spec contract.
func ValidateGraphView ¶
func ValidateIncidentContext ¶
func ValidateIncidentContext(ctx *IncidentContext) error
Cortex validation
func ValidateIngestEnvelopeBytes ¶
ValidateIngestEnvelopeBytes validates an ingest envelope against the spec contract.
func ValidateRemediation ¶
func ValidateRemediation(r *Remediation) error
func ValidateRemediationFeedback ¶
func ValidateRemediationFeedback(rf *RemediationFeedback) error
func WarnContext ¶
WarnContext emits an immediate warn log line with explicit context and event name.
func WithProcess ¶
WithProcess is an alias for Step — runs fn as a named process step.
Types ¶
type Attr ¶
Attr is a typed key-value pair.
func ExtractHTTPHeaderAttrs ¶
ExtractHTTPHeaderAttrs extracts common LOZA tracing/request attrs from headers.
func ExtractHTTPHeaders ¶
ExtractHTTPHeaders extracts common LOZA tracing/request attrs from inbound headers.
func HTTPMethod ¶
func HTTPReferer ¶
func HTTPRequest ¶
func HTTPResponse ¶
func HTTPUserAgent ¶
type BackpressurePolicy ¶
type BackpressurePolicy = core.BackpressurePolicy
BackpressurePolicy determines what happens when the async queue is full.
type CollectorClient ¶
type CollectorClient = core.CollectorClient
CollectorClient communicates with the LOZA collector REST API.
func NewCollectorClient ¶
func NewCollectorClient(cfg CollectorClientConfig) *CollectorClient
NewCollectorClient creates a new collector REST API client.
type CollectorClientConfig ¶
type CollectorClientConfig = core.CollectorClientConfig
CollectorClientConfig configures the collector client.
type CollectorSinkConfig ¶
type CollectorSinkConfig = core.CollectorSinkConfig
CollectorSinkConfig configures the collector sink.
type Config ¶
Config is the SDK configuration.
func ApplyConfig ¶
func ApplyConfig(cfg Config, options ...ConfigOption) Config
ApplyConfig applies options to cfg in order.
func LoadFromEnv ¶
LoadFromEnv loads configuration from environment variables.
func Production ¶
func Production() Config
func SetIDGenerator ¶
func SetIDGenerator(cfg Config, gen IDGenerator) Config
SetIDGenerator replaces the ID generator on a Config for deterministic IDs.
type ConfigOption ¶
type ConfigOption = core.ConfigOption
ConfigOption mutates and returns Config.
func WithAPIKey ¶
func WithAPIKey(apiKey string) ConfigOption
func WithAlias ¶
func WithAlias(alias string) ConfigOption
func WithAsync ¶
func WithAsync(enabled bool) ConfigOption
func WithAsyncFlushInterval ¶
func WithAsyncFlushInterval(interval time.Duration) ConfigOption
func WithAsyncMaxBatchBytes ¶
func WithAsyncMaxBatchBytes(maxBytes int) ConfigOption
func WithAsyncQueue ¶
func WithAsyncQueue(size int) ConfigOption
func WithBackpressure ¶
func WithBackpressure(policy BackpressurePolicy) ConfigOption
func WithBatchSize ¶
func WithBatchSize(size int) ConfigOption
func WithCollectorEndpoint ¶
func WithCollectorEndpoint(endpoint string) ConfigOption
func WithCollectorURL ¶
func WithCollectorURL(url string) ConfigOption
func WithCompression ¶
func WithCompression(enabled bool) ConfigOption
func WithConnectionTimeout ¶
func WithConnectionTimeout(timeout time.Duration) ConfigOption
func WithDeploymentID ¶
func WithDeploymentID(deploymentID string) ConfigOption
func WithDuplicatePolicy ¶
func WithDuplicatePolicy(policy DuplicateFieldPolicy) ConfigOption
func WithEncoder ¶
func WithEncoder(encoder Encoder) ConfigOption
func WithEnricher ¶
func WithEnricher(enricher ContextEnricher) ConfigOption
func WithEnvironment ¶
func WithEnvironment(environment string) ConfigOption
func WithEventSchema ¶
func WithEventSchema(schema Schema) ConfigOption
func WithFallbackSink ¶
func WithFallbackSink(sink Sink) ConfigOption
func WithFlushInterval ¶
func WithFlushInterval(interval time.Duration) ConfigOption
func WithIncludeHost ¶
func WithIncludeHost(includeHost bool) ConfigOption
func WithLevel ¶
func WithLevel(level Level) ConfigOption
func WithLogger ¶
func WithLogger(l *logger) ConfigOption
func WithMaxBackoff ¶
func WithMaxBackoff(backoff time.Duration) ConfigOption
func WithMaxBufferSize ¶
func WithMaxBufferSize(size int) ConfigOption
func WithMaxRetries ¶
func WithMaxRetries(retries int) ConfigOption
func WithNamespace ¶
func WithNamespace(namespace string) ConfigOption
func WithOtelBridge ¶
func WithOtelBridge(enabled bool) ConfigOption
func WithPanicRecovery ¶
func WithPanicRecovery(panicRecovery bool) ConfigOption
func WithQueueSize ¶
func WithQueueSize(size int) ConfigOption
func WithRedactor ¶
func WithRedactor(redactor Redactor) ConfigOption
func WithRegion ¶
func WithRegion(region string) ConfigOption
func WithRelease ¶
func WithRelease(release string) ConfigOption
func WithRetry ¶
func WithRetry(maxRetries int) ConfigOption
func WithSampler ¶
func WithSampler(sampler Sampler) ConfigOption
func WithSchema ¶
func WithSchema(schema Schema) ConfigOption
func WithService ¶
func WithService(service string) ConfigOption
func WithSink ¶
func WithSink(sink Sink) ConfigOption
func WithStatsHandler ¶
func WithStatsHandler(handler StatsHandler) ConfigOption
func WithStrict ¶
func WithStrict(strict bool) ConfigOption
func WithTenantID ¶
func WithTenantID(tenantID string) ConfigOption
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ConfigOption
func WithValidateEncoded ¶
func WithValidateEncoded(validate bool) ConfigOption
func WithVersion ¶
func WithVersion(version string) ConfigOption
func WithWorkers ¶
func WithWorkers(workers int) ConfigOption
type ConfigValidationError ¶
type ConfigValidationError = core.ConfigValidationError
ConfigValidationError is returned when config validation fails.
type ContextEnricher ¶
type ContextEnricher = core.ContextEnricher
ContextEnricher derives attrs from context during Emit(ctx).
type CortexClient ¶
CortexClient is an HTTP client for the Cortex incident intelligence API.
func NewCortexClient ¶
func NewCortexClient(endpoint string) *CortexClient
NewCortexClient creates an HTTP client for the Cortex incident intelligence API.
type DeliveryFailureHandler ¶
type DeliveryFailureHandler = core.DeliveryFailureHandler
DeliveryFailureHandler receives explicit delivery-failure callbacks.
type DuplicateEmitError ¶
type DuplicateEmitError = core.DuplicateEmitError
DuplicateEmitError is returned when Emit is called after emitted.
type DuplicateFieldError ¶
type DuplicateFieldError = core.DuplicateFieldError
DuplicateFieldError is returned for ErrorOnDuplicate policy violations.
type DuplicateFieldPolicy ¶
type DuplicateFieldPolicy = core.DuplicateFieldPolicy
DuplicateFieldPolicy controls custom attr collisions with canonical fields.
type Event ¶
Event is the canonical wide event.
func Events ¶
func Events(store *MemorySinkStore) []*Event
func ExpectEvent ¶
func ExpectEvent(t testing.TB, store *MemorySinkStore) *Event
ExpectEvent asserts that store contains at least one event and returns it.
func FromContext ¶
FromContext retrieves the active Event from ctx.
func LastEvent ¶
func LastEvent(store *MemorySinkStore) *Event
func SanitizeEvent ¶
SanitizeEvent clones the event and applies the global config's redactor and security settings. The original event is never mutated.
type EventAlreadyFinishedError ¶
type EventAlreadyFinishedError = core.EventAlreadyFinishedError
EventAlreadyFinishedError is returned when finishing twice.
type EventClosedError ¶
type EventClosedError = core.EventClosedError
EventClosedError is returned when mutating or finishing a closed event.
type EventState ¶
type EventState = core.EventState
EventState is the canonical event lifecycle state.
type FakeClock ¶
FakeClock implements the Clock interface with a controllable time.
func NewFakeClock ¶
NewFakeClock creates a new FakeClock for testing.
type FileConfig ¶
type FileConfig = core.FileConfig
FileConfig is the YAML-serializable SDK configuration.
func LoadFromFile ¶
func LoadFromFile(path string) (FileConfig, error)
LoadFromFile loads configuration from a loza.yaml file. If path is empty, it searches for loza.yaml in the current directory and then in ~/.loza/loza.yaml. Requirements: 32.3
type GroupHandle ¶
type GroupHandle = core.GroupHandle
GroupHandle tracks a running group phase.
func StartGroup ¶
StartGroup starts a named group phase and returns a handle to finish it.
type HTTPBatchSinkConfig ¶
type HTTPBatchSinkConfig = core.HTTPBatchSinkConfig
HTTPBatchSinkConfig configures the HTTP batch sink.
type IDGenerator ¶
type IDGenerator = core.IDGenerator
IDGenerator generates unique string IDs for events.
type IncidentContext ¶
type IncidentContext = cortex.IncidentContext
IncidentContext is the result of incident reconstruction.
type JSONEventEncoder ¶
type JSONEventEncoder = core.JSONEventEncoder
JSONEventEncoder is the default JSON encoder.
func JSONEncoder ¶
func JSONEncoder() *JSONEventEncoder
JSONEncoder returns the default compact JSON encoder.
func PrettyJSONEncoder ¶
func PrettyJSONEncoder() *JSONEventEncoder
PrettyJSONEncoder returns a pretty-print JSON encoder.
type LQLCompilationError ¶ added in v0.3.1
type LQLCompilationError = core.LQLCompilationError
LQLCompilationError reports structured LQL compilation failures.
type LQLDiagnostic ¶ added in v0.3.1
type LQLDiagnostic = core.LQLDiagnostic
LQLDiagnostic is a structured compiler diagnostic.
type LQLQueryOptions ¶ added in v0.3.1
type LQLQueryOptions = core.LQLQueryOptions
LQLQueryOptions controls server-side LQL compilation.
type MemorySinkStore ¶
type MemorySinkStore = core.MemorySinkStore
MemorySinkStore holds captured events for testing.
func TestKit ¶
func TestKit() (*logger, *MemorySinkStore, error)
TestKit creates a Logger backed by a MemorySink for testing. Spec-aligned alias for TestLogger.
func TestLogger ¶
func TestLogger() (*logger, *MemorySinkStore, error)
TestLogger creates a Logger backed by a MemorySink for testing.
func Testkit ¶
func Testkit() (*logger, *MemorySinkStore, error)
type MetricsCollector ¶
type MetricsCollector = core.MetricsCollector
MetricsCollector exposes Prometheus metrics for SDK and transport observability.
func NewMetricsCollector ¶
func NewMetricsCollector(namespace string, maxBufferSize int) *MetricsCollector
type MetricsSnapshot ¶
MetricsSnapshot is the stable cross-SDK metrics snapshot placeholder.
type ProcessHandle ¶
type ProcessHandle = core.ProcessHandle
ProcessHandle tracks a running process step.
func StartProcess ¶
StartProcess is an alias for Process.
type PrometheusStatsHandler ¶
type PrometheusStatsHandler = core.PrometheusStatsHandler
PrometheusStatsHandler wraps a MetricsCollector for StatsHandler integration.
func NewPrometheusStatsHandler ¶
func NewPrometheusStatsHandler(namespace string, maxBufferSize int) *PrometheusStatsHandler
type QueryResult ¶ added in v0.3.1
type QueryResult = core.QueryResult
QueryResult contains rows returned by collector queries.
type QueryValue ¶ added in v0.3.1
type QueryValue = core.QueryValue
QueryValue is a typed LQL parameter.
type Redactor ¶
Redactor masks sensitive data.
func ComposeRedactors ¶
func DefaultRedactor ¶
func DefaultRedactor() Redactor
func RedactKeys ¶
func RedactPatterns ¶
type Remediation ¶
type Remediation = cortex.Remediation
Remediation records a remediation action taken for an incident.
type RemediationFeedback ¶
type RemediationFeedback = cortex.RemediationFeedback
RemediationFeedback records the outcome of a remediation action.
type RotatingFileConfig ¶
type RotatingFileConfig = core.RotatingFileConfig
RotatingFileConfig configures the rotating file sink.
type Sampler ¶
Sampler decides whether an event should be emitted.
func AllSampler ¶
func AllowFields ¶
func AnySampler ¶
func BlockFields ¶
func NotSampler ¶
func SampleByEvent ¶
func SampleByHeader ¶
func SampleByOutcome ¶
func SampleErrors ¶
func SampleErrors() Sampler
func SampleFeatureFlag ¶
func SampleNone ¶
func SampleNone() Sampler
func SampleRandom ¶
func SampleRate ¶
func SampleRoutes ¶
func SampleSlowRequests ¶
func SampleStatusCodes ¶
func SampleTenants ¶
func SampleUsers ¶
type Schema ¶
Schema controls final output shape for emitted events.
func DatadogSchema ¶
func DatadogSchema() Schema
func DefaultSchema ¶
func DefaultSchema() Schema
func FlatSchema ¶
func FlatSchema() Schema
func NestedSchema ¶
func NestedSchema() Schema
func OTelLogSchema ¶
func OTelLogSchema() Schema
func OTelSchema ¶
func OTelSchema() Schema
type SecurityConfig ¶
type SecurityConfig = core.SecurityConfig
SecurityConfig controls event-size and sensitive-data limits.
func MaxAttrLength ¶
func MaxAttrLength(length int) SecurityConfig
func MaxAttrs ¶
func MaxAttrs(count int) SecurityConfig
func MaxEventBytes ¶
func MaxEventBytes(bytes int) SecurityConfig
type Sink ¶
Sink is the interface for event destinations.
func CollectorSink ¶
func CollectorSink(cfg CollectorSinkConfig) (Sink, error)
func HTTPBatchSink ¶
func HTTPBatchSink(cfg HTTPBatchSinkConfig) (Sink, error)
HTTPBatchSink creates a sink that batches events as NDJSON and flushes to the endpoint when BatchSize is reached or FlushInterval elapses. This is the default sink when CollectorURL is configured.
func KafkaSink ¶
KafkaSink sends events to the collector with Kafka routing metadata. The collector must have a Kafka sink configured to handle these events.
func LegacyHTTPBatchSink ¶
LegacyHTTPBatchSink is a convenience wrapper around CollectorSink. Deprecated: Use HTTPBatchSink with HTTPBatchSinkConfig for real batching.
func RotatingFileSink ¶
func RotatingFileSink(cfg RotatingFileConfig) (Sink, error)
func StderrSink ¶
func StderrSink() Sink
func StdoutSink ¶
func StdoutSink() Sink
type StatsHandler ¶
type StatsHandler = core.StatsHandler
StatsHandler receives logger telemetry callbacks.
type StopwatchHandle ¶
type StopwatchHandle = core.StopwatchHandle
StopwatchHandle is a standalone elapsed-time measurer.
func Stopwatch ¶
func Stopwatch() *StopwatchHandle
Stopwatch creates a standalone stopwatch for manual timing.
type TimerHandle ¶
type TimerHandle = core.TimerHandle
TimerHandle tracks a running timer.
func StartTimer ¶
StartTimer starts a named timer and returns a handle to stop it.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
config-demo
command
|
|
|
state-machine
command
|
|
|
src
|
|
|
core
Package core provides internal implementation utilities for LOZA-Go.
|
Package core provides internal implementation utilities for LOZA-Go. |
|
libs
Package libs hosts shared library helpers for optional adapters.
|
Package libs hosts shared library helpers for optional adapters. |
|
packages
Package packages groups optional package-level conveniences.
|
Package packages groups optional package-level conveniences. |
|
testkit
Package testkit provides testing helpers for LOZA event assertions and capture.
|
Package testkit provides testing helpers for LOZA event assertions and capture. |
|
utils
Package utils hosts utility helpers used by examples and tooling.
|
Package utils hosts utility helpers used by examples and tooling. |