Documentation
¶
Index ¶
Constants ¶
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.
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):
- literal dsn — local development only
- dsn_env — env var holding a pre-built DSN (legacy chart path)
- 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) ValidateConfig ¶
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.