loxa

package module
v0.0.0-...-0a1c337 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 5 Imported by: 0

README

LOXA-Go

CI

Status: 🟢 STABLE (v1.0.0) - Production-ready, collector-first stable-v1 SDK

Full emitter SDK conformance is tracked through Astraive/loxa-spec:

  • docs/SDK_CONFORMANCE_CONTRACT.md
  • docs/SDK_CONFORMANCE_TEST_SUITE.md
  • docs/SDK_COMPLETION_MATRIX.md

LOXA-Go is a canonical wide-event SDK for Go.
It builds one structured event per operation (request, job, queue message, CLI run, cron run), then emits to your log/analytics backend.

For the shared event contract, see Astraive/loxa-spec. For the collector runtime, see Astraive/loxa-collector. For the operations CLI, see Astraive/loxa-cli.

slog/zap/zerolog still fit: LOXA is the operation event layer above line-by-line logs.

Install

Core:

go get github.com/astraive/loxa-go

Optional modules:

go get github.com/astraive/loxa-go/middleware
go get github.com/astraive/loxa-go/integrations
go get github.com/astraive/loxa-go/sinks/httpbatch

Quick Start

package main

import (
	"context"

	"github.com/astraive/loxa-go"
)

func main() {
	_ = loxa.Configure(loxa.Production().WithService("checkout"))
	defer loxa.Shutdown(context.Background())

	ctx := loxa.StartEvent(context.Background(), loxa.Params{
		Event:  "checkout.request",
		Method: "POST",
		Path:   "/checkout",
		Route:  "/checkout",
	})
	defer loxa.Emit(ctx)

	loxa.Enrich(ctx, loxa.UserID("u-1"), loxa.String("payment.provider", "stripe"))
	loxa.Finish(ctx, "success", loxa.Int("status_code", 200))
}

Lifecycle:

StartEvent -> Enrich -> Finish / FinishError -> Emit

Sample event:

{
  "timestamp": "2026-05-11T10:30:00Z",
  "event_id": "evt_abc",
  "request_id": "req_123",
  "trace_id": "trace_456",
  "service": "checkout",
  "event": "checkout.request",
  "method": "POST",
  "path": "/checkout",
  "route": "/checkout",
  "status_code": 200,
  "duration_ms": 42,
  "outcome": "success",
  "user": {
    "id": "u-1"
  },
  "payment": {
    "provider": "stripe"
  }
}

API Stability (v0)

The intended frozen core surface for v0.1.x is:

  • StartEvent, StartHTTPEvent, StartJobEvent, StartQueueEvent, StartCLIEvent, StartCronEvent
  • Enrich, Set, Merge, Delete
  • Finish, FinishError, Emit, Flush, Shutdown
  • CustomSchema, DuplicateFieldPolicy, Sampler, Redactor, StatsHandler

Other helpers remain available, but they should be treated as less stable until the first tagged release line is established.

For cross-language stable-v1 parity, treat docs/sdk-parity-manifest.json as the authoritative shared API surface. Go may still expose language-specific helpers outside that manifest, but those helpers are not part of the cross-language stable-v1 promise unless the manifest is updated.

Package Boundaries

  • github.com/astraive/loxa-go: lifecycle, attrs, config, schema, sampler, security, core sinks.
  • github.com/astraive/loxa-go/middleware/*: HTTP/RPC adapters.
  • github.com/astraive/loxa-go/integrations/*: slog/zap/zerolog/otel bridges.
  • github.com/astraive/loxa-go/sinks/httpbatch: collector HTTP batch transport.
  • github.com/astraive/loxa-go/testkit: capture/assert helpers for tests.

Repository boundaries:

  • Astraive/loxa-spec: protocol, schemas, compatibility rules
  • Astraive/loxa-collector: ingest server, worker, durability, fanout, deployment, and heavy sinks
  • Astraive/loxa-cli: operator and developer CLI

Migration Pattern

  1. Keep existing slog/zap/zerolog.
  2. Add LOXA lifecycle around business operations.
  3. Emit one canonical event per operation for analytics and support workflows.

Examples

Heavy production sinks such as Kafka, ClickHouse, Postgres, DuckDB, OTLP, S3, GCS, and Loki are collector-owned. Applications should emit to the collector using the SDK HTTP batch sink.

Documentation

Breaking Changes in Current Refactor

  • Root testing helpers moved to github.com/astraive/loxa-go/testkit.
  • Root net/http middleware wrapper removed; use github.com/astraive/loxa-go/middleware/nethttp.

Current Focus

  • SDK lifecycle and canonical event emission for Go applications
  • app-side middleware, integrations, and sinks
  • compatibility with the shared LOXA spec and public collector ingest API

SDK Helpers

  • shutdown helpers:
    • loxa.ShutdownTimeout(10 * time.Second)
    • loxa.MustShutdown(10 * time.Second)
  • config ergonomics:
    • ApplyConfig(...)
    • WithAsyncQueue
    • WithWorkers
    • WithAsyncFlushInterval
    • WithAsyncMaxBatchBytes
    • WithBackpressure
    • WithDuplicatePolicy
    • WithStrict
  • HTTP context propagation:
    • RequestIDFromHTTP
    • TraceFromOTel
    • InjectHTTPHeaders
    • InjectHTTPHeaderCarrier
    • ExtractHTTPHeaders
    • ExtractHTTPHeaderAttrs

WithStrict(true) enables stronger runtime checks for missing service/event, invalid attr keys, canonical key collisions from custom attrs, and unsupported custom values. It also enables strict config validation (Config.Validate / New / Configure) for required service identity and async/security bounds.

Documentation

Overview

Package loxa provides canonical wide-event logging for Go services.

Index

Constants

View Source
const (
	LOXA_SPEC_VERSION       = core.LOXA_SPEC_VERSION
	LOXA_INGEST_API_VERSION = core.LOXA_INGEST_API_VERSION
	LOXA_EVENT_VERSION      = core.LOXA_EVENT_VERSION

	LevelDebug = core.LevelDebug
	LevelInfo  = core.LevelInfo
	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
	AttrWins           = core.AttrWins
	AttrsWin           = core.AttrsWin
	UserWins           = core.UserWins
	FirstWins          = core.FirstWins
	LastWins           = core.LastWins
	KeepBothUnderAttrs = core.KeepBothUnderAttrs
	DropDuplicateAttr  = core.DropDuplicateAttr
	ErrorOnDuplicate   = core.ErrorOnDuplicate
	KeepBoth           = core.KeepBoth

	EventStateCreated          = core.EventStateCreated
	EventStateActive           = core.EventStateActive
	EventStateFinished         = core.EventStateFinished
	EventStateEmitting         = core.EventStateEmitting
	EventStateEmitted          = core.EventStateEmitted
	EventStateFailedValidation = core.EventStateFailedValidation
	EventStateDeliveryFailed   = core.EventStateDeliveryFailed
)

Variables

View Source
var (
	// ErrInvalidConfig indicates config validation failure.
	ErrInvalidConfig = core.ErrInvalidConfig
	// ErrConfigFileNotFound is returned when no config file is found.
	ErrConfigFileNotFound = core.ErrConfigFileNotFound
)
View Source
var (
	String   = core.String
	Int      = core.Int
	Int64    = core.Int64
	Uint64   = core.Uint64
	Float64  = core.Float64
	Bool     = core.Bool
	Time     = core.Time
	Duration = core.Duration
	Any      = 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
	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

	// Domain logic
	FeatureFlag     = core.FeatureFlag
	FeatureFlagBool = core.FeatureFlagBool
	Experiment      = core.Experiment
)

Functions

func Add

func Add(ctx context.Context, key string, value interface{}) error

Add appends a value to an array field on the event in ctx.

func Append

func Append(ctx context.Context, attrs ...Attr) error

Append appends attrs to the event in ctx.

func Checkpoint

func Checkpoint(ctx context.Context, name string, attrs ...Attr) error

Checkpoint records a named breadcrumb.

func ComposeRedactors

func ComposeRedactors(redactors ...core.Redactor) core.Redactor

func Configure

func Configure(cfg Config) error

Configure replaces the global default logger with a new one built from cfg.

func Debug

func Debug(msg string, attrs ...Attr)

func DebugContext

func DebugContext(ctx context.Context, msg, event string, attrs ...Attr)

DebugContext emits an immediate debug log line with explicit context and event name.

func DefaultRedactor

func DefaultRedactor() core.Redactor

func Delete

func Delete(ctx context.Context, keys ...string) error

Delete removes attrs by key from the event in ctx.

func DropKeys

func DropKeys(keys ...string) core.Redactor

func Emit

func Emit(ctx context.Context) error

Emit delivers the event.

func EmitEvent

func EmitEvent(ev *Event) error

EmitEvent delivers an event directly.

func Enrich

func Enrich(ctx context.Context, attrs ...Attr) error

Enrich appends attrs to the event in ctx.

func EnrichGroup

func EnrichGroup(ctx context.Context, key string, attrs ...Attr) error

EnrichGroup appends attrs as a named group.

func Error

func Error(msg string, attrs ...Attr)

func ErrorContext

func ErrorContext(ctx context.Context, msg string, err error, event string, attrs ...Attr)

ErrorContext emits an immediate error log line with explicit context and event name.

func EventID

func EventID(ctx context.Context) string

EventID returns the ID of the active event in ctx.

func Fatal

func Fatal(msg string, attrs ...Attr)

func Finish

func Finish(ctx context.Context, outcome string, attrs ...Attr) error

Finish records outcome and duration.

func FinishError

func FinishError(ctx context.Context, err error, attrs ...Attr) error

FinishError records error outcome and metadata.

func Flush

func Flush(ctx context.Context) error

Flush drains the queue.

func Get

func Get(ctx context.Context, key string) (any, bool)

Get fetches a value by key (dot-path supported) from event in ctx.

func GetGroup

func GetGroup(ctx context.Context, name string) (map[string]any, bool)

GetGroup fetches a group object from event in ctx.

func HasEvent

func HasEvent(ctx context.Context) bool

HasEvent returns true if ctx contains a LOXA event.

func HashKeys

func HashKeys(keys ...string) core.Redactor

func Info

func Info(msg string, attrs ...Attr)

func InfoContext

func InfoContext(ctx context.Context, msg, event string, attrs ...Attr)

InfoContext emits an immediate info log line with explicit context and event name.

func InjectHTTPHeaderCarrier

func InjectHTTPHeaderCarrier(ctx context.Context, header http.Header) http.Header

InjectHTTPHeaderCarrier injects LOXA + trace headers into a header map.

func InjectHTTPHeaders

func InjectHTTPHeaders(req *http.Request)

InjectHTTPHeaders injects LOXA + trace headers into an outbound request.

func JSONEncoder

func JSONEncoder() *core.JSONEventEncoder

JSONEncoder returns the default compact JSON encoder.

func MaskKeys

func MaskKeys(keys ...string) core.Redactor

func Merge

func Merge(ctx context.Context, group string, attrs ...Attr) error

Merge merges attrs into a named group on the event in ctx.

func MustShutdown

func MustShutdown(timeout time.Duration)

MustShutdown drains and closes sinks, panicking on error.

func NewRoundTripper

func NewRoundTripper(base http.RoundTripper) http.RoundTripper

func PanicRecoveryEnabled

func PanicRecoveryEnabled() bool

PanicRecoveryEnabled reports whether wrapper helpers recover panics.

func PrettyJSONEncoder

func PrettyJSONEncoder() *core.JSONEventEncoder

PrettyJSONEncoder returns a pretty-print JSON encoder.

func RedactKeys

func RedactKeys(keys ...string) core.Redactor

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext returns the request ID of the active event.

func RequestIDFromHTTP

func RequestIDFromHTTP(r *http.Request) string

RequestIDFromHTTP resolves request id from header or active event context.

func RunCLI

func RunCLI(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunCLI wraps an operation in a CLI canonical event lifecycle.

func RunCron

func RunCron(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunCron wraps an operation in a cron canonical event lifecycle.

func RunEvent

func RunEvent(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunEvent wraps an operation in the canonical lifecycle.

func RunHTTP

func RunHTTP(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunHTTP wraps an operation in an HTTP canonical event lifecycle.

func RunJob

func RunJob(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunJob wraps an operation in a job canonical event lifecycle.

func RunQueue

func RunQueue(ctx context.Context, params Params, fn EventFunc, finishAttrs ...Attr) error

RunQueue wraps an operation in a queue canonical event lifecycle.

func Set

func Set(ctx context.Context, attrs ...Attr) error

Set upserts attrs on the event in ctx.

func SetDefault

func SetDefault(l *Logger)

SetDefault replaces the global default logger instance.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown drains and closes all sinks.

func ShutdownTimeout

func ShutdownTimeout(timeout time.Duration) error

ShutdownTimeout drains and closes sinks with timeout-bound context.

func SpanIDFromContext

func SpanIDFromContext(ctx context.Context) string

SpanIDFromContext returns the span ID of the active event.

func StartCLIEvent

func StartCLIEvent(ctx context.Context, params Params) context.Context

StartCLIEvent starts a CLI execution event.

func StartCron

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

StartCron is a convenience wrapper for cron jobs.

func StartCronEvent

func StartCronEvent(ctx context.Context, params Params) context.Context

StartCronEvent starts a cron execution event.

func StartEvent

func StartEvent(ctx context.Context, params Params) context.Context

StartEvent begins a canonical wide event.

func StartHTTPEvent

func StartHTTPEvent(ctx context.Context, params Params) context.Context

StartHTTPEvent starts an event with HTTP defaults.

func StartHTTPEventFromRequest

func StartHTTPEventFromRequest(r *http.Request, params Params) context.Context

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 StartJob

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

StartJob is a convenience wrapper for named jobs.

func StartJobEvent

func StartJobEvent(ctx context.Context, params Params) context.Context

StartJobEvent starts a background job event.

func StartQueueEvent

func StartQueueEvent(ctx context.Context, params Params) context.Context

StartQueueEvent starts a queue-processing event.

func StartQueueJob

func StartQueueJob(ctx context.Context, queue, messageID string) context.Context

StartQueueJob is a convenience wrapper for queue jobs.

func TraceFromOTel

func TraceFromOTel(ctx context.Context) (traceID string, spanID string)

TraceFromOTel returns trace/span ids from OTel span context.

func TraceIDFromContext

func TraceIDFromContext(ctx context.Context) string

TraceIDFromContext returns the trace ID of the active event.

func Warn

func Warn(msg string, attrs ...Attr)

func WarnContext

func WarnContext(ctx context.Context, msg, event string, attrs ...Attr)

WarnContext emits an immediate warn log line with explicit context and event name.

func WrapHTTPClient

func WrapHTTPClient(client *http.Client) *http.Client

Types

type Attr

type Attr = core.Attr

Attr is a typed key-value pair.

func ExtractHTTPHeaderAttrs

func ExtractHTTPHeaderAttrs(header http.Header) []Attr

ExtractHTTPHeaderAttrs extracts common LOXA tracing/request attrs from headers.

func ExtractHTTPHeaders

func ExtractHTTPHeaders(r *http.Request) []Attr

ExtractHTTPHeaders extracts common LOXA tracing/request attrs from inbound headers.

type BackpressurePolicy

type BackpressurePolicy = core.BackpressurePolicy

BackpressurePolicy determines what happens when the async queue is full.

type CollectorSinkConfig

type CollectorSinkConfig = core.CollectorSinkConfig

type Config

type Config = core.Config

Config is the SDK configuration.

func ApplyConfig

func ApplyConfig(cfg Config, options ...ConfigOption) Config

ApplyConfig applies options to cfg in order.

func Dev

func Dev() Config

func LoadFromEnv

func LoadFromEnv(base Config) Config

LoadFromEnv loads configuration from environment variables.

func Production

func Production() Config

func Test

func Test() Config

type ConfigOption

type ConfigOption = core.ConfigOption

ConfigOption mutates and returns Config.

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 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 WithMaxBackoff

func WithMaxBackoff(backoff time.Duration) ConfigOption

func WithMaxBufferSize

func WithMaxBufferSize(size int) ConfigOption

func WithMaxRetries

func WithMaxRetries(retries int) ConfigOption

func WithRedactor

func WithRedactor(redactor Redactor) 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 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 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 Encoder

type Encoder = core.Encoder

Encoder serializes events for sink delivery.

type Event

type Event = core.Event

Event is the canonical wide event.

func FromContext

func FromContext(ctx context.Context) (*Event, bool)

FromContext retrieves the active Event from ctx.

func NewEvent

func NewEvent(params Params) *Event

NewEvent creates a manual event instance.

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 EventFunc

type EventFunc = core.EventFunc

EventFunc wraps operation code in lifecycle helpers.

type EventState

type EventState = core.EventState

EventState is the canonical event lifecycle state.

type EventView

type EventView = core.EventView

EventView is a read-only event view for schemas.

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 loxa.yaml file. If path is empty, it searches for loxa.yaml in the current directory and then in ~/.loxa/loxa.yaml. Requirements: 32.3

type Level

type Level = core.Level

Level is the log level.

func ParseLevel

func ParseLevel(s string) Level

ParseLevel parses a level string.

type Logger

type Logger = core.Logger

Logger is an instance of the logging pipeline.

func Default

func Default() *Logger

Default returns the global default logger instance.

func New

func New(cfg Config) (*Logger, error)

New creates a new Logger.

func NewClient

func NewClient(cfg Config) (*Logger, error)

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

type MemorySinkStore

type MemorySinkStore = core.MemorySinkStore

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 Params

type Params = core.Params

Params carries metadata to start an event.

type PrometheusStatsHandler

type PrometheusStatsHandler = core.PrometheusStatsHandler

PrometheusStatsHandler wraps a MetricsCollector for StatsHandler integration.

func NewPrometheusStatsHandler

func NewPrometheusStatsHandler(namespace string, maxBufferSize int) *PrometheusStatsHandler

type Redactor

type Redactor = core.Redactor

Redactor masks sensitive data.

type RotatingFileConfig

type RotatingFileConfig = core.RotatingFileConfig

type Sampler

type Sampler = core.Sampler

Sampler decides whether an event should be emitted.

func AllSampler

func AllSampler(samplers ...Sampler) Sampler

func AnySampler

func AnySampler(samplers ...Sampler) Sampler

func NotSampler

func NotSampler(sampler Sampler) Sampler

func SampleAll

func SampleAll() Sampler

func SampleByHeader

func SampleByHeader(header, value string) Sampler

func SampleErrors

func SampleErrors() Sampler

func SampleFeatureFlag

func SampleFeatureFlag(name string, value any) Sampler

func SampleNone

func SampleNone() Sampler

func SampleRandom

func SampleRandom(rate float64) Sampler

func SampleRateLimited

func SampleRateLimited(rate float64, window time.Duration) Sampler

func SampleRoutes

func SampleRoutes(routes ...string) Sampler

func SampleSlowRequests

func SampleSlowRequests(d time.Duration) Sampler

func SampleStatusCodes

func SampleStatusCodes(codes ...int) Sampler

func SampleTenants

func SampleTenants(ids ...string) Sampler

func SampleUsers

func SampleUsers(ids ...string) Sampler

type Schema

type Schema = core.Schema

Schema controls final output shape for emitted events.

func CustomSchema

func CustomSchema(fn func(EventView) map[string]any) Schema

func DatadogSchema

func DatadogSchema() Schema

func DefaultSchema

func DefaultSchema() Schema

func ECSchema

func ECSchema() Schema

func FlatSchema

func FlatSchema() Schema

func NestedSchema

func NestedSchema() Schema

func OTelLogSchema

func OTelLogSchema() Schema

func OTelSchema

func OTelSchema() Schema

type SchemaFunc

type SchemaFunc = core.SchemaFunc

SchemaFunc maps EventView to output object.

type SecurityConfig

type SecurityConfig = core.SecurityConfig

SecurityConfig controls event-size and sensitive-data limits.

type Sink

type Sink = core.Sink

Sink is the interface for event destinations.

func CollectorSink

func CollectorSink(cfg core.CollectorSinkConfig) (Sink, error)

func FileSink

func FileSink(path string) (Sink, error)

func HTTPBatchSink

func HTTPBatchSink(endpoint string) (Sink, error)

func MemorySink

func MemorySink() (Sink, *core.MemorySinkStore)

func NoopSink

func NoopSink() Sink

func RotatingFileSink

func RotatingFileSink(cfg core.RotatingFileConfig) (Sink, error)

func StderrSink

func StderrSink() Sink

func StdoutSink

func StdoutSink() Sink

type StatsHandler

type StatsHandler = core.StatsHandler

StatsHandler receives logger telemetry callbacks.

Directories

Path Synopsis
Package core hosts optional high-level composition helpers for LOXA-Go.
Package core hosts optional high-level composition helpers for LOXA-Go.
examples
config-demo command
state-machine command
internal
core
Package core provides internal implementation utilities for LOXA-Go.
Package core provides internal implementation utilities for LOXA-Go.
env
Package libs hosts shared library helpers for optional adapters.
Package libs hosts shared library helpers for optional adapters.
middleware module
Package packages groups optional package-level conveniences.
Package packages groups optional package-level conveniences.
Package testkit provides testing helpers for LOXA event assertions and capture.
Package testkit provides testing helpers for LOXA event assertions and capture.
Package utils hosts utility helpers used by examples and tooling.
Package utils hosts utility helpers used by examples and tooling.

Jump to

Keyboard shortcuts

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