status

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package status provides request tracing and HTTP server status pages.

Index

Constants

View Source
const (
	ServerStatusLivePath   = ServerStatusPath + "/live"
	ServerStatusLogPath    = ServerStatusPath + "/log"
	ServerStatusStatsPath  = ServerStatusPath + "/stats"
	ServerStatusDetailPath = ServerStatusPath + "/detail/"
)
View Source
const ServerStatusPath = "/debug/server-status"

ServerStatusPath is the default status overview served by ServerStatus.

Variables

View Source
var (
	StartSpan = model.StartSpan
	OpenSpan  = model.OpenSpan
	CloseSpan = model.CloseSpan
	SpanType  = model.SpanType
)

Functions

func Register

func Register(rt *runner.Runtime)

Register installs symbols into the runtime.

func RequestID

func RequestID(ctx context.Context) string

RequestID returns the ULID assigned to the request in ctx.

Types

type Flag

type Flag = model.Flag

type MemorySnapshot

type MemorySnapshot struct {
	HeapAlloc     uint64  `json:"heap_alloc_bytes"`
	HeapInuse     uint64  `json:"heap_inuse_bytes"`
	HeapObjects   uint64  `json:"heap_objects"`
	StackInuse    uint64  `json:"stack_inuse_bytes"`
	System        uint64  `json:"system_bytes"`
	NextGC        uint64  `json:"next_gc_bytes"`
	NumGC         uint32  `json:"gc_cycles"`
	GCPauseTotal  uint64  `json:"gc_pause_total_ns"`
	GCCPUFraction float64 `json:"gc_cpu_fraction"`
	MemoryLimit   uint64  `json:"memory_limit_bytes,omitempty"`
}

MemorySnapshot describes current process memory and GC pressure.

type Options

type Options struct {
	// RingBufferSize is the number of completed requests retained for the
	// request log and rolling statistics.
	RingBufferSize int `yaml:"ring_buffer_size"`

	// TopRequests is the maximum number of request groups returned in rolling
	// statistics.
	TopRequests int `yaml:"top_requests"`

	// TrackMemoryUse records process-wide allocation changes for each request.
	TrackMemoryUse bool `yaml:"track_memory_use"`
}

Options configures status page telemetry.

func NewOptions

func NewOptions() Options

NewOptions returns the default status page options.

type PoolEstimate

type PoolEstimate struct {
	Samples               uint64 `json:"samples"`
	AverageAllocatedBytes uint64 `json:"average_allocated_bytes"`
	BeforeNextGC          uint64 `json:"requests_before_next_gc,omitempty"`
	WithinMemoryLimit     uint64 `json:"requests_within_memory_limit,omitempty"`
}

PoolEstimate is a heuristic concurrency estimate based on observed request allocations. Allocations are process-wide, so concurrent requests overlap.

type Request

type Request = model.Request

type RequestSpan

type RequestSpan = model.RequestSpan

type RequestStatistic

type RequestStatistic = model.RequestStatistic

type ServerStatus

type ServerStatus struct {
	platform.UnimplementedModule
	// contains filtered or unexported fields
}

ServerStatus tracks requests, observes PHP runtimes, and serves status data. Use Middleware with routers that accept func(http.Handler) http.Handler. The type also implements http.Handler for explicitly mounting the status route.

func NewModule

func NewModule(options Options) *ServerStatus

NewModule creates an empty status module.

func NewServerStatus

func NewServerStatus(options Options) *ServerStatus

NewServerStatus creates an empty status module.

func (*ServerStatus) Middleware

func (s *ServerStatus) Middleware(next http.Handler) http.Handler

Middleware records requests handled by the platform.

func (*ServerStatus) Mount

Mount registers status page routes on the platform router.

func (*ServerStatus) ServeHTTP

func (s *ServerStatus) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP renders one server-status view as JSON, plain text, or HTML.

func (*ServerStatus) Snapshot

func (s *ServerStatus) Snapshot() Snapshot

Snapshot returns a race-free point-in-time process list.

func (*ServerStatus) StartSpan

func (s *ServerStatus) StartSpan(ctx context.Context, name string) model.Span

StartSpan starts a named span for ctx.

func (*ServerStatus) Trace

func (s *ServerStatus) Trace(ctx context.Context, message string, flags ...model.Flag) *model.RequestSpan

Trace will add a span with the invoked message. It's used to trace runtime internals, like including files.

func (*ServerStatus) UpdateFilename

func (s *ServerStatus) UpdateFilename(ctx context.Context, filename string)

UpdateFilename records the PHP entrypoint selected for an active request.

func (*ServerStatus) UpdateIncludedFiles

func (s *ServerStatus) UpdateIncludedFiles(ctx context.Context, count int)

UpdateIncludedFiles records the number of files included by an active PHP request.

func (*ServerStatus) UpdateStatus

func (s *ServerStatus) UpdateStatus(ctx context.Context, status model.Status)

UpdateStatus implements runner.Observer.

type Snapshot

type Snapshot struct {
	StartedAt   time.Time          `json:"started_at"`
	Uptime      time.Duration      `json:"uptime_ns"`
	PID         int                `json:"pid"`
	GoVersion   string             `json:"go_version"`
	GOMAXPROCS  int                `json:"gomaxprocs"`
	Goroutines  int                `json:"goroutines"`
	Total       uint64             `json:"total_requests"`
	Active      int                `json:"active_requests"`
	StatusCount map[string]int     `json:"status_counts"`
	StateTime   []StateDuration    `json:"state_time"`
	Memory      MemorySnapshot     `json:"memory"`
	Pool        PoolEstimate       `json:"pool_estimate"`
	Requests    []Request          `json:"requests"`
	Log         []Request          `json:"log"`
	Statistics  StatisticsSnapshot `json:"statistics"`

	StyleCSS template.CSS `json:"-"`
}

Snapshot is the complete server-status document.

type SpanDuration

type SpanDuration struct {
	Type        Flag          `json:"type"`
	Offset      time.Duration `json:"offset_ns"`
	Duration    time.Duration `json:"duration_ns"`
	OffsetShare float64       `json:"offset_percent"`
	Share       float64       `json:"share_percent"`
}

SpanDuration is one point-in-time segment where a span type was the active, innermost region of a request.

type StateDuration

type StateDuration struct {
	State    model.Status  `json:"state"`
	Label    string        `json:"label"`
	Duration time.Duration `json:"duration_ns"`
	Share    float64       `json:"share_percent"`
}

StateDuration is the lifetime request time observed in one scoreboard state.

type StatisticsSnapshot

type StatisticsSnapshot struct {
	WindowSize  int                `json:"window_size"`
	WindowLimit int                `json:"window_limit"`
	TopLimit    int                `json:"top_limit"`
	Top         []RequestStatistic `json:"top"`
}

StatisticsSnapshot contains the most frequent requests in the rolling completed-request window.

Jump to

Keyboard shortcuts

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