Documentation
¶
Overview ¶
Package status provides request tracing and HTTP server status pages.
Index ¶
- Constants
- Variables
- func Register(rt *runner.Runtime)
- func RequestID(ctx context.Context) string
- type Flag
- type MemorySnapshot
- type Options
- type PoolEstimate
- type Request
- type RequestSpan
- type RequestStatistic
- type ServerStatus
- func (s *ServerStatus) Middleware(next http.Handler) http.Handler
- func (s *ServerStatus) Mount(_ context.Context, r platform.Router) error
- func (s *ServerStatus) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *ServerStatus) Snapshot() Snapshot
- func (s *ServerStatus) StartSpan(ctx context.Context, name string) model.Span
- func (s *ServerStatus) Trace(ctx context.Context, message string, flags ...model.Flag) *model.RequestSpan
- func (s *ServerStatus) TrackLifecycle(ctx context.Context, name, filename string, run func(context.Context) error) error
- func (s *ServerStatus) UpdateFilename(ctx context.Context, filename string)
- func (s *ServerStatus) UpdateIncludedFiles(ctx context.Context, count int)
- func (s *ServerStatus) UpdateStatus(ctx context.Context, status model.Status)
- type Snapshot
- type SpanDuration
- type StateDuration
- type StatisticsSnapshot
Constants ¶
const ( ServerStatusLivePath = ServerStatusPath + "/live" ServerStatusLogPath = ServerStatusPath + "/log" ServerStatusStatsPath = ServerStatusPath + "/stats" ServerStatusDetailPath = ServerStatusPath + "/detail/" )
const ServerStatusPath = "/debug/server-status"
ServerStatusPath is the default status overview served by ServerStatus.
Variables ¶
Functions ¶
Types ¶
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.
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 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) 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) 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) TrackLifecycle ¶ added in v0.2.3
func (s *ServerStatus) TrackLifecycle(ctx context.Context, name, filename string, run func(context.Context) error) error
TrackLifecycle records a non-HTTP lifecycle event and its runtime spans.
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"`
}
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"`
}
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.