Documentation
¶
Overview ¶
Package otlp implements a minimal OTLP/HTTP log exporter for audit events. It is configured entirely through the standard OTEL_* environment variables (https://opentelemetry.io/docs/specs/otel/protocol/exporter/) and supports only the http/protobuf transport.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRetryAfter ¶ added in v1.3.6
ParseRetryAfter handles both delta-seconds and HTTP-date forms. Exported for reuse by the policy-fetch retry loop in cmd, which faces the same header from the same SaaS.
Types ¶
type Config ¶
type Config struct {
Endpoint string // final URL with /v1/logs path already applied
Headers map[string]string // extra HTTP headers for each export request
Timeout time.Duration // per-attempt HTTP timeout
Compression string // "gzip" or "none"
ServiceName string // resource service.name
ResourceAttrs map[string]string // parsed OTEL_RESOURCE_ATTRIBUTES (excluding service.name)
}
Config is the resolved OTLP/HTTP exporter configuration.
func ConfigFromEnv ¶
ConfigFromEnv resolves the exporter configuration from OTEL_* environment variables via getenv (pass os.Getenv outside tests). It returns enabled == false when no OTLP endpoint is configured; an error means an endpoint was configured but unusable, in which case export stays disabled.
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter batches audit events and ships them to an OTLP/HTTP logs endpoint. It implements events.EventSink; Consume never blocks — events are dropped when the queue is full or after shutdown.
func NewFromEnv ¶
NewFromEnv builds an exporter from the standard OTEL_* environment variables. It returns (nil, nil) when no OTLP endpoint is configured and (nil, err) when the configuration is present but unusable.
func (*Exporter) Consume ¶
func (e *Exporter) Consume(ev events.AuditEvent)
Consume implements events.EventSink. It never blocks: when the queue is full or the exporter has been shut down, the event is counted as dropped. The mutex makes the closed check and the send atomic with respect to Shutdown closing the queue (a bare closed-flag check would race and panic on send-to-closed-channel); it is only ever held for a non-blocking send.