metrics

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 7 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

Index

Constants

View Source
const (
	// Number of services. Labels: host.
	MetricServicesGauge metrics.MetricName = "tnet_services"
	// Total service requests. Labels: host, service, client.
	MetricServiceRequestsCounter metrics.MetricName = "tnet_service_requests_total"
	// Number of in-flight requests. Labels: host, service, client.
	MetricServiceRequestsInFlightGauge metrics.MetricName = "tnet_service_requests_in_flight"
	// Request duration histogram. Labels: host, service.
	MetricServiceRequestsDurationObserver metrics.MetricName = "tnet_service_request_duration_seconds"
	// Total service input data transfer size in bytes. Labels: host, service, client.
	MetricServiceTransferInputBytesCounter metrics.MetricName = "tnet_service_transfer_input_bytes_total"
	// Total service output data transfer size in bytes. Labels: host, service, client.
	MetricServiceTransferOutputBytesCounter metrics.MetricName = "tnet_service_transfer_output_bytes_total"
	// Chain node connect duration histogram. Labels: host, chain, node.
	MetricNodeConnectDurationObserver metrics.MetricName = "tnet_chain_node_connect_duration_seconds"
	// Total service handler errors. Labels: host, service, client.
	MetricServiceHandlerErrorsCounter metrics.MetricName = "tnet_service_handler_errors_total"
	// Total chain connect errors. Labels: host, chain, node.
	MetricChainErrorsCounter metrics.MetricName = "tnet_chain_errors_total"
	// Total recorder records. Labels: host, recorder.
	MetricRecorderRecordsCounter metrics.MetricName = "tnet_recorder_records_total"
	// Number of services in each state. Labels: host, state.
	MetricServiceStatusGauge metrics.MetricName = "tnet_service_status"
)

Variables

This section is empty.

Functions

func Enable added in v0.0.3

func Enable(b bool)

Enable enables or disables metrics collection globally. When disabled, all GetCounter, GetGauge, and GetObserver calls return noop implementations.

func GetCounter

func GetCounter(name metrics.MetricName, labels metrics.Labels) metrics.Counter

GetCounter returns a Counter for the given name and labels. When metrics are disabled, a noop implementation is returned.

func GetGauge

func GetGauge(name metrics.MetricName, labels metrics.Labels) metrics.Gauge

GetGauge returns a Gauge for the given name and labels. When metrics are disabled, a noop implementation is returned.

func GetObserver

func GetObserver(name metrics.MetricName, labels metrics.Labels) metrics.Observer

GetObserver returns an Observer for the given name and labels. When metrics are disabled, a noop implementation is returned.

func IsEnabled

func IsEnabled() bool

IsEnabled reports whether metrics collection is enabled.

func NewMetrics

func NewMetrics(reg *prometheus.Registry) metrics.Metrics

NewMetrics returns a Prometheus-based Metrics implementation. All metrics are registered with the given registry. Use nil to register with the default Prometheus registry.

func Noop

func Noop() metrics.Metrics

Noop returns a Metrics implementation whose counters, gauges, and observers are all no-ops.

func RegisterServiceStatusFunc added in v0.28.1

func RegisterServiceStatusFunc(fn ServiceStatusFunc)

RegisterServiceStatusFunc registers a callback invoked at each scrape to collect the aggregate service status counts, exposed as MetricServiceStatusGauge.

func Registry added in v0.28.1

func Registry() *prometheus.Registry

Registry returns the custom Prometheus registry that holds all TNET metrics plus the Go and process collectors. The metrics HTTP endpoint should serve from this registry rather than prometheus.DefaultGatherer.

Types

type ServiceStatusFunc added in v0.28.1

type ServiceStatusFunc func() map[string]float64

ServiceStatusFunc returns the number of services in each state, keyed by state name (e.g. "running", "ready", "failed", "closed").

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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