diag

package
v0.0.0-...-4dcfcdd Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package diag contains a mechanism for cdc-sink components to report structured diagnostic information.

Index

Constants

This section is empty.

Variables

View Source
var Schema = ident.MustSchema(ident.New("_"), ident.New("diag"))

Schema is passed to the authenticator.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic interface {
	// Diagnostic returns a json-serializable value that represent the
	// reportable state of the component.
	Diagnostic(context.Context) any
}

Diagnostic is implemented by any type that can provide structured diagnostic data for use in a support engagement.

type DiagnosticFn

type DiagnosticFn func(context.Context) any

A DiagnosticFn is passed to Diagnostics.Register. This type is use similarly to http.HandlerFunc.

func (DiagnosticFn) Diagnostic

func (c DiagnosticFn) Diagnostic(ctx context.Context) any

Diagnostic implements Diagnostic.

type Diagnostics

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

Diagnostics serves as a registry for Diagnostic implementations.

func New

func New(ctx *stopper.Context) *Diagnostics

New constructs a Diagnostics. The instance will write itself to the log stream if the process receives a SIGUSR1.

func (*Diagnostics) Handler

func (d *Diagnostics) Handler(auth types.Authenticator) http.Handler

Handler returns an http.Handler to provide a summary report. The Schema value will be passed to the Authenticator.

func (*Diagnostics) Payload

func (d *Diagnostics) Payload(ctx context.Context) map[string]any

Payload returns the diagnostic payload.

func (*Diagnostics) Register

func (d *Diagnostics) Register(name string, intf Diagnostic) error

Register adds a callback to generate a portion of the diagnostics output. The name will be used as the key in the emitted JSON literal, and the value will be the serialized form of the callback's return value. This method will return an error if the same name is registered twice.

Note that the callback may be called at any time (possibly concurrently), so implementations should be written in a thread-safe manner.

func (*Diagnostics) Unregister

func (d *Diagnostics) Unregister(name string)

Unregister removes a registration.

func (*Diagnostics) Wrap

func (d *Diagnostics) Wrap(name string) (*Diagnostics, error)

Wrap returns a new instance of Diagnostics that will report its values as an embedded value.

func (*Diagnostics) Write

func (d *Diagnostics) Write(ctx context.Context, w io.Writer, pretty bool) error

Write the diagnostic report.

Jump to

Keyboard shortcuts

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