metrics

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package metrics exposes Prometheus metrics for a Tern app, with no dependencies:

ternApp(kit.WithPlugins(metrics.New()))

GET /metrics serves, in the Prometheus text format:

tern_http_requests_total{method,route,status}
tern_http_request_duration_seconds{method,route} (histogram)
tern_http_requests_in_flight
go_goroutines, go_memstats_heap_alloc_bytes, process_uptime_seconds

The route label is the route's pattern, such as /projects/[id], never the raw URL, so the number of series stays bounded. Requests that match no route (assets, 404s) are labeled "other".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Plugin)

Option configures the plugin.

func Buckets

func Buckets(b ...float64) Option

Buckets sets the latency histogram's upper bounds, in seconds.

func Path

func Path(p string) Option

Path changes the endpoint from /metrics.

type Plugin

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

Plugin collects and serves metrics. Create it with New.

func New

func New(opts ...Option) *Plugin

New returns the metrics plugin.

func (*Plugin) Name

func (*Plugin) Name() string

Name implements kit.Plugin.

func (*Plugin) Setup

func (m *Plugin) Setup(s *kit.Setup) error

Setup implements kit.Plugin.

Jump to

Keyboard shortcuts

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