metrics

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package metrics holds the Prometheus instruments on the hot path of the pad message handler: etherpad-lite's prom-instruments (scaling dive, #7756). They let a load test tell the apply path from the fan-out and see per-pad concurrency. Everything is off unless scalingDiveMetrics is set: the recorders are no-ops then and nothing is registered.

Index

Constants

This section is empty.

Variables

View Source
var (
	ChangesetApplyDuration = prometheus.NewHistogram(prometheus.HistogramOpts{
		Name:    "etherpad_changeset_apply_duration_seconds",
		Help:    "Time spent applying an incoming USER_CHANGES message on the server (apply path only, excludes fan-out to other clients)",
		Buckets: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 5},
	})
	SocketEmitsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
		Name: "etherpad_socket_emits_total",
		Help: "Number of socket broadcast emits, bucketed by message type",
	}, []string{"type"})
	// PadUsers is keyed by a pseudonym of the pad, not its name: /metrics
	// is not behind a login, and pad names (of group pads, of unguessable
	// pads) are what gives access to them.
	PadUsers = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Name: "etherpad_pad_users",
		Help: "Active users connected to a pad, keyed by a pseudonym of the pad (stable within one process)",
	}, []string{"pad"})
)

Functions

func Enabled

func Enabled() bool

Enabled reports whether the instruments record.

func PadLabel

func PadLabel(padID string) string

PadLabel is the pseudonym of padID in the metrics: 12 hex digits of an HMAC-SHA256 with the process's key.

func RecordChangesetApply

func RecordChangesetApply() func()

RecordChangesetApply starts timing the apply path; call the result once the revision is stored. A failed apply leaves it uncalled, so the distribution is of successful applies only.

func RecordSocketEmit

func RecordSocketEmit(msgType string)

RecordSocketEmit counts one emit of a message type.

func Register

func Register(reg prometheus.Registerer)

Register adds the instruments to reg when they are enabled.

func SetEnabled

func SetEnabled(on bool)

SetEnabled turns the instruments on or off (settings.scalingDiveMetrics).

func SetPadUsers

func SetPadUsers(counts map[string]int)

SetPadUsers replaces the per-pad user counts, so drained pads leave no stale series.

Types

This section is empty.

Jump to

Keyboard shortcuts

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