metrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package metrics defines the server's Prometheus metrics. Labels stay bounded: route patterns, methods, status codes, job and source IDs, never URLs with IDs, titles, user names or credentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	Registry *prometheus.Registry

	HTTPRequests *prometheus.CounterVec
	HTTPDuration *prometheus.HistogramVec

	JobRuns     *prometheus.CounterVec
	JobDuration *prometheus.HistogramVec
	JobRunning  *prometheus.GaugeVec

	TasksFinished *prometheus.CounterVec
	TaskDuration  *prometheus.HistogramVec
	TasksRunning  *prometheus.GaugeVec

	ImageRetries *prometheus.CounterVec
}

Metrics holds every collector the server updates. A nil *Metrics is valid and records nothing, so code doesn't have to check whether metrics are on.

func New

func New() *Metrics

New registers the server's metrics, plus the Go runtime and process ones, on a fresh registry.

func (*Metrics) HTTP

func (m *Metrics) HTTP(route, method string, code int, d time.Duration)

HTTP records one request. route is the matched pattern (e.g. "/api/v1/works/{id}"), or "unmatched".

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the metrics in the Prometheus text format.

func (*Metrics) ImageRetry

func (m *Metrics) ImageRetry(outcome string)

ImageRetry records how a failed page image ended.

func (*Metrics) JobFinished

func (m *Metrics) JobFinished(job, status, trigger string, d time.Duration)

JobFinished records a finished (or skipped) run.

func (*Metrics) JobStarted

func (m *Metrics) JobStarted(job string)

JobStarted marks a job as running. Safe on a nil *Metrics.

func (*Metrics) TaskEnded

func (m *Metrics) TaskEnded(kind, outcome string, d time.Duration)

TaskEnded records how a task attempt ended.

func (*Metrics) TaskStarted

func (m *Metrics) TaskStarted(kind string)

TaskStarted counts a running task.

Jump to

Keyboard shortcuts

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