postgres

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ExporterName = "postgres"

ExporterName is the registered name of the postgres exporter template. It is the only sink allowed to carry sensible data.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

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

Exporter persists the sensible view of an event (request and response bodies only) into the owner-controlled Postgres store. It is sensible-only and can never be reused as a metadata sink.

func (*Exporter) Close

func (e *Exporter) Close()

Close releases the connection pool exactly once; further Publish calls fail fast rather than touching a closed pool.

func (*Exporter) DataClass

func (e *Exporter) DataClass() metrics.DataClass

DataClass fixes this exporter to the sensible class; the pipeline uses it to route only the sensible view here (ENG-1021).

func (*Exporter) Name

func (e *Exporter) Name() string

func (*Exporter) Publish

func (e *Exporter) Publish(ctx context.Context, evt *events.Event) error

Publish writes the sensible projection of the event as one row. The write is idempotent on trace_id so a retried event does not duplicate a row.

type Settings

type Settings struct {
	DSN    string `mapstructure:"dsn"`
	DSNEnv string `mapstructure:"dsn_env"`
	// Table is validated against the module-owned table name; it is an explicit,
	// forward-compatible knob and is not allowed to point anywhere else.
	Table string `mapstructure:"table"`
}

Settings is the per-gateway configuration for the postgres exporter, decoded from the telemetry exporter Settings map. The DSN is referenced by env-var name so secrets stay out of the config file; a literal dsn is accepted for local development only.

type Template

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

Template builds postgres.Exporter instances and runs the sensible-store migrations the first time the exporter is built.

func NewTemplate

func NewTemplate(logger *slog.Logger) *Template

NewTemplate returns a postgres ExporterTemplate bound to the given logger.

func (*Template) Name

func (t *Template) Name() string

func (*Template) ValidateConfig

func (t *Template) ValidateConfig(settings map[string]interface{}) error

ValidateConfig performs structural validation only; it never opens a connection or resolves the DSN env var.

func (*Template) WithSettings

func (t *Template) WithSettings(settings map[string]interface{}) (appmetrics.Exporter, error)

WithSettings validates the settings, opens a dedicated pool, and applies the schema migrations (advisory-locked) before returning the exporter.

Jump to

Keyboard shortcuts

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