monitoring

package
v0.0.0-...-809e4d2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package monitoring exposes per-tenant request counters and a Prometheus-compatible /metrics endpoint.

Per gocodealone-multisite SPEC.md T30.

Intentionally dependency-free — no prometheus client library. The /metrics body uses the OpenMetrics text exposition format, which Prometheus + Grafana Agent + DataDog scrape cleanly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counters

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

Counters tracks per-tenant request counts + a global aggregate.

func New

func New() *Counters

New returns a fresh Counters.

func (*Counters) Inc

func (c *Counters) Inc(tenant string, statusCode int)

Inc records one request for tenant (empty = unresolved). statusCode >= 500 also increments the error counter.

func (*Counters) ServeHTTP

func (c *Counters) ServeHTTP(w http.ResponseWriter, _ *http.Request)

ServeHTTP is the /metrics handler.

func (*Counters) Snapshot

func (c *Counters) Snapshot() map[string]int64

Snapshot returns a copy of the current totals (for tests).

type StatusRecorder

type StatusRecorder struct {
	http.ResponseWriter
	Status int
}

StatusRecorder wraps http.ResponseWriter to capture the status code for the Counters.Inc call.

func (*StatusRecorder) WriteHeader

func (r *StatusRecorder) WriteHeader(code int)

Jump to

Keyboard shortcuts

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