apimonitor

package
v0.109.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package apimonitor observes local API lifecycle and request metadata in memory. Its ResponseWriter facade tracks operations that ResponseController would otherwise reach through Unwrap, while retaining each operation's downstream errors and behavior. It deliberately never retains request headers, bodies, query strings or fragments.

Index

Constants

View Source
const (
	MaxRequests     = 500
	BucketCount     = 60
	BucketDuration  = 5 * time.Second
	MaxServers      = 32
	MaxRouteLength  = 160
	MaxMethodLength = 16
)

Variables

View Source
var Default = &Registry{}

Default is the process-local observer for the current local API service.

View Source
var ErrRegistryFull = errors.New(registryFullError)

Functions

func Render

func Render(s Snapshot, width, height, offset int) string

Render renders current, real observations. offset is distance from the newest request; zero follows incoming traffic. No sample traffic is generated.

Types

type Bucket

type Bucket struct {
	At    time.Time
	Count uint64
}

type Monitor

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

func New

func New(name string) *Monitor

func (*Monitor) Live

func (m *Monitor) Live(baseURL string)

func (*Monitor) Snapshot

func (m *Monitor) Snapshot() Snapshot

func (*Monitor) Stop

func (m *Monitor) Stop(err error)

func (*Monitor) Wrap

func (m *Monitor) Wrap(next http.Handler) http.Handler

Wrap belongs outside authorization and routing so rejected requests appear too.

type Registry

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

Registry aggregates independent server instances. A full registry evicts one stopped instance; if every slot is live, NewServer returns a non-admitted monitor in the explicit "error" state and preserves every existing server.

func (*Registry) NewServer

func (r *Registry) NewServer(name string) *Monitor

func (*Registry) NewServerChecked

func (r *Registry) NewServerChecked(name string) (*Monitor, error)

NewServerChecked provides an error-returning admission path for new callers.

func (*Registry) Snapshot

func (r *Registry) Snapshot() Snapshot

type Request

type Request struct {
	ID           uint64
	At           time.Time
	Method, Path string
	Status       int // The final HTTP status observed on the ResponseWriter; zero means none was sent.
	Outcome      string
	Duration     time.Duration
	Active       bool
}

type Snapshot

type Snapshot struct {
	Name, State, BaseURL, Error string
	Started                     time.Time
	Total, Failures             uint64
	Active                      int
	Duration                    time.Duration
	Requests                    []Request
	Buckets                     []Bucket
}

Jump to

Keyboard shortcuts

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