metricserver

package
v1.3.12 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package metricserver provides a dedicated HTTP server for operational endpoints: a /status health-check and a /metrics Prometheus scrape endpoint.

The server implements the runner.Service interface (Start, Stop, Name) and is designed to run independently from the main application server. This separation allows metrics and health to be monitored on a different port/interface from the API.

Basic usage:

msrv := metricserver.New(&metricserver.Config{
    Host: "0.0.0.0",
    Port: 9090,
})
err := msrv.Start(ctx)
defer msrv.Stop()

// Endpoints:
// GET /status     returns {"status":"ok"}
// GET /metrics    returns Prometheus-formatted metrics

The metrics endpoint integrates with Prometheus client via echoprometheus middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string
	Port         int
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	GracePeriod  time.Duration
}

type Server

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

func New

func New(cfg *Config) *Server

func (*Server) Name

func (s *Server) Name() string

func (*Server) Start

func (s *Server) Start(_ context.Context) error

func (*Server) Stop

func (s *Server) Stop() error

Jump to

Keyboard shortcuts

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