Documentation
¶
Index ¶
- func Init(portalProxy api.PortalProxy) (api.StratosPlugin, error)
- func WrapClient(client *http.Client, buffer *Buffer) *http.Client
- type Buffer
- type BufferConfig
- type Counter
- type Diagnostics
- func (d *Diagnostics) AddAdminGroupRoutes(echoGroup *echo.Group)
- func (d *Diagnostics) AddSessionGroupRoutes(echoGroup *echo.Group)
- func (d *Diagnostics) Buffer() *Buffer
- func (d *Diagnostics) Enabled() bool
- func (d *Diagnostics) GetEndpointPlugin() (api.EndpointPlugin, error)
- func (d *Diagnostics) GetMiddlewarePlugin() (api.MiddlewarePlugin, error)
- func (d *Diagnostics) GetRoutePlugin() (api.RoutePlugin, error)
- func (d *Diagnostics) Init() error
- type Handler
- type Sample
- type SnapshotEnvelope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(portalProxy api.PortalProxy) (api.StratosPlugin, error)
func WrapClient ¶
WrapClient returns a shallow copy of `client` with its Transport replaced by one that tallies every round-trip into `buffer`. Leaves the original client untouched so concurrent callers that didn't opt in are unaffected.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer accumulates counters and samples in memory, keyed by code family and dimension bucket. Thread-safe; designed for many emit callers and one snapshot reader.
func NewBuffer ¶
func NewBuffer(cfg BufferConfig) *Buffer
func (*Buffer) EmitCounter ¶
EmitCounter increments the bucket matching `code` + `dims` (creates if absent). Never blocks the caller beyond the internal mutex.
func (*Buffer) EmitSample ¶
EmitSample appends a sample. When per-family cap is exceeded, oldest samples are dropped and a buffer-overflow counter is incremented with the code they belonged to.
func (*Buffer) Snapshot ¶
func (b *Buffer) Snapshot() SnapshotEnvelope
Snapshot returns a deep-copied envelope safe for JSON serialization; holding the returned value does not leak the live buffer state.
type BufferConfig ¶
BufferConfig controls ring-buffer caps. PerFamilyCap is the max samples kept per code family; TotalCap is a global upper bound (not yet enforced — the per-family cap is sufficient for current traffic).
func DefaultBufferConfig ¶
func DefaultBufferConfig() BufferConfig
type Counter ¶
type Counter struct {
Code string `json:"code"`
Dimensions map[string]string `json:"dimensions"`
Count int64 `json:"count"`
FirstAt int64 `json:"firstAt"`
LastAt int64 `json:"lastAt"`
}
Counter is an aggregated count for a diagnostic code at a given dimension bucket. FirstAt / LastAt bracket the observation window.
type Diagnostics ¶
type Diagnostics struct {
// contains filtered or unexported fields
}
Diagnostics plugin — dev/operator-facing instrumentation surface. Admin-gated endpoint (/pp/v1/admin/diagnostics) returns a JSON envelope of counters and samples captured in-memory. Behind the DIAGNOSTICS_ENABLED env flag; off in production by default. See FWT-934 design doc for full context.
func (*Diagnostics) AddAdminGroupRoutes ¶
func (d *Diagnostics) AddAdminGroupRoutes(echoGroup *echo.Group)
func (*Diagnostics) AddSessionGroupRoutes ¶
func (d *Diagnostics) AddSessionGroupRoutes(echoGroup *echo.Group)
func (*Diagnostics) Buffer ¶
func (d *Diagnostics) Buffer() *Buffer
Buffer exposes the underlying Buffer so other packages (e.g. the CF HTTP client middleware) can emit into the same store the admin endpoint serves.
func (*Diagnostics) Enabled ¶
func (d *Diagnostics) Enabled() bool
Enabled reports whether the DIAGNOSTICS_ENABLED env flag is set. Middleware should skip emission when disabled to avoid paying the mutex cost for diagnostics nobody will read.
func (*Diagnostics) GetEndpointPlugin ¶
func (d *Diagnostics) GetEndpointPlugin() (api.EndpointPlugin, error)
func (*Diagnostics) GetMiddlewarePlugin ¶
func (d *Diagnostics) GetMiddlewarePlugin() (api.MiddlewarePlugin, error)
func (*Diagnostics) GetRoutePlugin ¶
func (d *Diagnostics) GetRoutePlugin() (api.RoutePlugin, error)
func (*Diagnostics) Init ¶
func (d *Diagnostics) Init() error
Init satisfies api.StratosPlugin. Nothing to do here — the plugin's state is set up in the package-level Init constructor.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the admin-gated diagnostics endpoint. Enabled is captured at plugin init; a disabled handler returns 404 (not 403) so the endpoint's existence isn't leaked to unauthenticated scanners in production.
func NewHandler ¶
type Sample ¶
type Sample struct {
Code string `json:"code"`
At int64 `json:"at"`
Dimensions map[string]string `json:"dimensions"`
Value *float64 `json:"value,omitempty"`
}
Sample is a single point-in-time observation for a diagnostic code. Value is a pointer so "counted but unvalued" events can be distinguished from zero-valued ones.
type SnapshotEnvelope ¶
type SnapshotEnvelope struct {
Version int `json:"version"`
CapturedAt int64 `json:"capturedAt"`
Counters map[string][]Counter `json:"counters"`
Samples map[string][]Sample `json:"samples"`
}
SnapshotEnvelope is the versioned JSON wire shape returned from the diagnostics HTTP endpoint. Mirrors the frontend's DiagnosticsSnapshotEnvelope so a single consumer can read both surfaces uniformly.