serverdiag

package
v1.1.1 Latest Latest
Warning

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

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

Overview

Package serverdiag is the server's bounded, value-free stderr boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Emit

func Emit(e Event)

func ErrorLog

func ErrorLog() *log.Logger

ErrorLog discards net/http's raw text, including unknown formats.

func RegisterRoutes

func RegisterRoutes(routes ...string)

RegisterRoutes is called with the static dispatch inventory during package init.

func Shutdown

func Shutdown(ctx context.Context)

func Use

func Use(s *Sink) func()

Use installs the process diagnostic sink. The caller owns its bounded shutdown.

Types

type Event

type Event struct {
	Bind             string  `json:"bind,omitempty"`
	Detail           string  `json:"detail,omitempty"`
	Flag             string  `json:"flag,omitempty"`
	ForwardedHint    bool    `json:"-"`
	Status           string  `json:"status,omitempty"`
	Message          string  `json:"message,omitempty"`
	Type             string  `json:"type"`
	Reason           string  `json:"reason,omitempty"`
	Route            string  `json:"route,omitempty"`
	Peer             string  `json:"peer,omitempty"`
	Count            uint64  `json:"count,omitempty"`
	Targets          int     `json:"targets,omitempty"`
	Accepted         int     `json:"accepted,omitempty"`
	Failed           int     `json:"failed,omitempty"`
	Bytes            int64   `json:"bytes,omitempty"`
	PanicType        string  `json:"panic_type,omitempty"`
	Stack            []Frame `json:"stack,omitempty"`
	ProcessStartedAt string  `json:"process_started_at"`
	DroppedTotal     uint64  `json:"diagnostics_dropped_total"`
}

Event contains only classified fields; it never holds requests or errors. Route must already be a registered constant template (controlpanel.AccessRoute).

func Panic

func Panic(v any) Event

Panic never invokes Error/String or reflect.Type.String on a dynamic type.

type Frame

type Frame struct {
	Function string `json:"function"`
	File     string `json:"file"`
	Line     int    `json:"line"`
}

type Sink

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

Sink owns one writer and a fixed-size queue. A blocked writer never blocks Emit.

func New

func New(w io.Writer) *Sink

func (*Sink) Close

func (s *Sink) Close(ctx context.Context)

func (*Sink) Emit

func (s *Sink) Emit(e Event)

func (*Sink) Flush

func (s *Sink) Flush(ctx context.Context) bool

Flush waits for earlier events without creating an I/O goroutine per caller.

Jump to

Keyboard shortcuts

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