postgres

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 16 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.

Connection precedence (first match wins):

  1. literal dsn — local development only
  2. dsn_env — env var holding a pre-built DSN (legacy chart path)
  3. the service's own DatabaseConfig — discrete DB_* / POSTGRES_LOGIN parts

When neither dsn nor dsn_env is set the template falls back to (3), so a hybrid pod needs no SENSIBLE_PG_DSN at all.

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, dbCfg *config.DatabaseConfig) *Template

NewTemplate returns a postgres ExporterTemplate bound to the given logger and the service's DatabaseConfig (used when settings name neither dsn nor dsn_env).

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.

Connection precedence: literal dsn > dsn_env > service DatabaseConfig.

Jump to

Keyboard shortcuts

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