metrics

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConnectorConcurrencyScopeDeployment identifies database-coordinated admission.
	ConnectorConcurrencyScopeDeployment = "deployment"
	// ConnectorConcurrencyScopeProcess identifies in-process admission.
	ConnectorConcurrencyScopeProcess = "process"
)

Variables

This section is empty.

Functions

func NewHTTPClientRoundTripper

func NewHTTPClientRoundTripper(base http.RoundTripper, component, serverAddress string) http.RoundTripper

func RecordConnectorAdmission

func RecordConnectorAdmission(outcome string)

func RecordConnectorConcurrency

func RecordConnectorConcurrency(scope string, active, queued int64)

func RecordConnectorOperation

func RecordConnectorOperation(metric ConnectorOperationMetric)

func RecordExecutionBroker

func RecordExecutionBroker(metric ExecutionBrokerMetric)

func RecordExecutionBrokerSnapshot

func RecordExecutionBrokerSnapshot(snapshot ExecutionBrokerSnapshot)

func RecordHTTPClient

func RecordHTTPClient(metric HTTPClientMetric)

func RecordPipelineRun

func RecordPipelineRun(metric PipelineRunMetric)

func RecordProofControl

func RecordProofControl(action model.EventAction, outcome model.ProofControlOutcome)

func RecordQueryExecution

func RecordQueryExecution(metric QueryExecutionMetric)

func RecordQueryLimitHit

func RecordQueryLimitHit(metric QueryLimitHitMetric)

func RecordSQLConnectorPoolSnapshot

func RecordSQLConnectorPoolSnapshot(snapshot SQLConnectorPoolSnapshot)

func RecordTransformExecution

func RecordTransformExecution(metric TransformExecutionMetric)

func SetProcessMeter

func SetProcessMeter(meter *Meter) func()

Types

type Config

type Config struct {
	Enabled     bool
	Path        string
	ServiceName string
	Environment string
}

Config contains metrics runtime configuration.

type ConnectorOperationMetric

type ConnectorOperationMetric struct {
	DataSourceType string
	Operation      string
	Outcome        string
	ErrorType      string
	Duration       time.Duration
	ResultRows     int
	ResultBytes    int64
}

type ExecutionBrokerMetric

type ExecutionBrokerMetric struct {
	Kind     string
	Outcome  string
	Duration time.Duration
}

type ExecutionBrokerSnapshot

type ExecutionBrokerSnapshot struct {
	PendingCount            int64
	RunningCount            int64
	OldestPendingAgeSeconds float64
	Active                  int64
	Capacity                int64
	LastSuccessfulPoll      time.Time
	ConnectorActive         int64
	ConnectorQueued         int64
}

type HTTPClientMetric

type HTTPClientMetric struct {
	Component     string
	Method        string
	ServerAddress string
	StatusCode    int
	ErrorType     string
	Duration      time.Duration
}

type Meter

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

Meter owns the application metrics registry and Fiber instrumentation.

func New

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

New creates an isolated Prometheus registry and registers baseline collectors.

func (*Meter) HTTPMiddleware

func (m *Meter) HTTPMiddleware() fiber.Handler

HTTPMiddleware records low-cardinality HTTP server metrics.

func (*Meter) RecordConnectorAdmission

func (m *Meter) RecordConnectorAdmission(outcome string)

func (*Meter) RecordConnectorConcurrency

func (m *Meter) RecordConnectorConcurrency(scope string, active, queued int64)

func (*Meter) RecordConnectorOperation

func (m *Meter) RecordConnectorOperation(metric ConnectorOperationMetric)

func (*Meter) RecordExecutionBroker

func (m *Meter) RecordExecutionBroker(metric ExecutionBrokerMetric)

func (*Meter) RecordExecutionBrokerSnapshot

func (m *Meter) RecordExecutionBrokerSnapshot(snapshot ExecutionBrokerSnapshot)

func (*Meter) RecordHTTPClient

func (m *Meter) RecordHTTPClient(metric HTTPClientMetric)

func (*Meter) RecordPipelineRun

func (m *Meter) RecordPipelineRun(metric PipelineRunMetric)

func (*Meter) RecordProofControl

func (m *Meter) RecordProofControl(action model.EventAction, outcome model.ProofControlOutcome)

func (*Meter) RecordQueryExecution

func (m *Meter) RecordQueryExecution(metric QueryExecutionMetric)

func (*Meter) RecordQueryLimitHit

func (m *Meter) RecordQueryLimitHit(metric QueryLimitHitMetric)

func (*Meter) RecordSQLConnectorPoolSnapshot

func (m *Meter) RecordSQLConnectorPoolSnapshot(snapshot SQLConnectorPoolSnapshot)

func (*Meter) RecordTransformExecution

func (m *Meter) RecordTransformExecution(metric TransformExecutionMetric)

func (*Meter) RegisterPostgresPool

func (m *Meter) RegisterPostgresPool(provider PostgresPoolStatsProvider)

func (*Meter) RegisterProofActivity

func (m *Meter) RegisterProofActivity(provider func(context.Context) (proofevidence.ActivitySnapshot, error))

func (*Meter) RegisterProofMaintenanceHealth

func (m *Meter) RegisterProofMaintenanceHealth(provider func(context.Context) (model.ProofMaintenanceHealth, error))

RegisterProofMaintenanceHealth exposes fixed-cardinality deployment health.

func (*Meter) RegisterRiverQueueHealth

func (m *Meter) RegisterRiverQueueHealth(config RiverQueueHealthConfig)

RegisterRiverQueueHealth exposes low-cardinality River queue health metrics.

func (*Meter) RegisterRoutes

func (m *Meter) RegisterRoutes(app *fiber.App)

RegisterRoutes exposes the Prometheus scrape endpoint when metrics are enabled.

type PipelineRunMetric

type PipelineRunMetric struct {
	Trigger   string
	Outcome   string
	ErrorType string
	Duration  time.Duration
}

type PostgresPoolStats

type PostgresPoolStats interface {
	AcquiredConns() int32
	IdleConns() int32
	TotalConns() int32
	ConstructingConns() int32
	MaxConns() int32
	AcquireCount() int64
	CanceledAcquireCount() int64
	EmptyAcquireCount() int64
	AcquireDuration() time.Duration
}

type PostgresPoolStatsProvider

type PostgresPoolStatsProvider func() PostgresPoolStats

type QueryExecutionMetric

type QueryExecutionMetric struct {
	DataSourceType string
	Outcome        string
	ErrorType      string
	Duration       time.Duration
}

type QueryLimitHitMetric

type QueryLimitHitMetric struct {
	DataSourceType string
	LimitType      string
}

type RiverJobAgeMetric

type RiverJobAgeMetric struct {
	Queue string
	State string
	Age   time.Duration
}

RiverJobAgeMetric is the age of the oldest River job in one queue and state.

type RiverJobFinalizedMetric

type RiverJobFinalizedMetric struct {
	Queue string
	State string
	Count int64
}

RiverJobFinalizedMetric is a finalized River job count grouped by queue and final state.

type RiverPeriodicJobLagMetric

type RiverPeriodicJobLagMetric struct {
	Queue string
	Lag   time.Duration
}

RiverPeriodicJobLagMetric is lag for periodic River work grouped by queue.

type RiverQueueCountMetric

type RiverQueueCountMetric struct {
	Queue string
	Count int64
}

RiverQueueCountMetric is a River queue cumulative count grouped by queue.

type RiverQueueDepthMetric

type RiverQueueDepthMetric struct {
	Queue string
	State string
	Depth int64
}

RiverQueueDepthMetric is a River queue depth value grouped by queue and state.

type RiverQueueHealthConfig

type RiverQueueHealthConfig struct {
	AllowedQueues []string
	Provider      RiverQueueHealthProvider
}

RiverQueueHealthConfig configures the River queue health collector.

type RiverQueueHealthPostgresConfig

type RiverQueueHealthPostgresConfig struct {
	AllowedQueues    []string
	PeriodicJobKinds []string
	QueryTimeout     time.Duration
	Now              func() time.Time
}

RiverQueueHealthPostgresConfig configures a Postgres-backed River health provider.

type RiverQueueHealthProvider

type RiverQueueHealthProvider func(ctx context.Context) RiverQueueHealthSnapshot

RiverQueueHealthProvider returns one point-in-time aggregate River queue snapshot.

func NewRiverQueueHealthPostgresProvider

func NewRiverQueueHealthPostgresProvider(
	pool *pgxpool.Pool,
	config RiverQueueHealthPostgresConfig,
) RiverQueueHealthProvider

NewRiverQueueHealthPostgresProvider builds River health snapshots from River's Postgres tables.

type RiverQueueHealthSnapshot

type RiverQueueHealthSnapshot struct {
	QueueDepth     []RiverQueueDepthMetric
	OldestJobAge   []RiverJobAgeMetric
	RetryTotal     []RiverQueueCountMetric
	DiscardedTotal []RiverQueueCountMetric
	FinalizedTotal []RiverJobFinalizedMetric
	Workers        []RiverWorkerMetric
	PeriodicJobLag []RiverPeriodicJobLagMetric
}

RiverQueueHealthSnapshot contains pre-aggregated River queue health values.

type RiverWorkerMetric

type RiverWorkerMetric struct {
	Queue            string
	ActiveWorkers    int64
	MaxWorkers       int64
	LastHeartbeatAge time.Duration
}

RiverWorkerMetric is River worker liveness and heartbeat information for one queue.

type SQLConnectorPoolSnapshot

type SQLConnectorPoolSnapshot struct {
	Entries            int
	Retired            int
	ActiveLeases       int
	OpenConnections    int
	InUseConnections   int
	IdleConnections    int
	MaxOpenConnections int
	WaitCount          int64
	WaitDuration       time.Duration
	MaxIdleClosed      int64
	MaxIdleTimeClosed  int64
	MaxLifetimeClosed  int64
}

type TransformExecutionMetric

type TransformExecutionMetric struct {
	Outcome              string
	LimitType            string
	Duration             time.Duration
	Work                 int64
	IntermediateRows     int64
	IntermediateBytes    int64
	OutputRows           int
	OutputBytes          int64
	MaxDepth             int
	RoundedDecimalValues int64
	InexactDecimalValues int64
}

Jump to

Keyboard shortcuts

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