observe

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(target route.Target, runtimes ...*state)

Mount mounts observe endpoints into a route target.

func Provider

func Provider(config Config, options ...Option) runaprovider.Provider

Provider returns a Runa provider that registers observe endpoints.

Types

type Checker

type Checker interface {
	Name() string
	Check(ctx context.Context) Result
}

Checker checks one runtime dependency or subsystem.

func Cache

func Cache(app runaprovider.Context, name string) Checker

Cache returns a checker for a named cache pool.

func Database

func Database(app runaprovider.Context, name string) Checker

Database returns a checker for a named database runtime.

func Host

func Host(app runaprovider.Context, name string) Checker

Host returns a checker that reads a host unit status.

func Queue

func Queue(app runaprovider.Context, name string) Checker

Queue returns a checker for a named queue.

func Self

func Self() Checker

Self returns a process liveness checker.

func Storage

func Storage(app runaprovider.Context, name string) Checker

Storage returns a checker for a named storage disk.

type CheckerFunc

type CheckerFunc func(ctx context.Context) Result

CheckerFunc adapts a function to Checker.

func (CheckerFunc) Check

func (fn CheckerFunc) Check(ctx context.Context) Result

Check runs the checker function.

func (CheckerFunc) Name

func (fn CheckerFunc) Name() string

Name returns the default checker name.

type Config

type Config struct {
	Service string        `toml:"service"`
	Env     string        `toml:"env"`
	Version string        `toml:"version"`
	Timeout time.Duration `toml:"timeout"`
	Mount   string        `toml:"mount"`
	Debug   bool          `toml:"debug"`
}

Config configures the observe provider.

type Exporter

type Exporter interface {
	Serve(ctx *route.Context) error
}

Exporter renders metrics for an HTTP request.

func DefaultMetrics

func DefaultMetrics() Exporter

DefaultMetrics returns lightweight built-in metrics.

func TextMetrics

func TextMetrics(lines ...string) Exporter

TextMetrics creates a simple text metrics exporter.

type ExporterFunc

type ExporterFunc func(ctx *route.Context) error

ExporterFunc adapts a function to Exporter.

func (ExporterFunc) Serve

func (fn ExporterFunc) Serve(ctx *route.Context) error

Serve renders metrics.

type Installer

type Installer interface {
	Install(ctx runaprovider.Context) error
}

Installer installs trace propagation or instrumentation hooks.

type InstallerFunc

type InstallerFunc func(ctx runaprovider.Context) error

InstallerFunc adapts a function to Installer.

func (InstallerFunc) Install

func (fn InstallerFunc) Install(ctx runaprovider.Context) error

Install installs trace hooks.

type Option

type Option func(*state)

Option configures the observe provider.

func Debug

func Debug() Option

Debug enables debug endpoints.

func Health

func Health(name string, checker Checker) Option

Health registers a health checker.

func Metrics

func Metrics(exporter Exporter) Option

Metrics registers a metrics exporter.

func MountAt

func MountAt(prefix string) Option

MountAt sets the route prefix for observe endpoints.

func Ready

func Ready(name string, checker Checker) Option

Ready registers a ready checker.

func Timeout

func Timeout(value time.Duration) Option

Timeout sets checker timeout.

func Trace

func Trace(installer Installer) Option

Trace registers a trace installer.

type Registry

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

Registry stores named checkers.

func Default

func Default() *Registry

Default returns the default observe health registry.

func New

func New() *Registry

New creates a registry.

func (*Registry) Add

func (registry *Registry) Add(name string, checker Checker)

Add registers or replaces a checker.

func (*Registry) Run

func (registry *Registry) Run(ctx context.Context, timeout time.Duration) Report

Run executes all checkers and returns an aggregate report.

type Report

type Report struct {
	Status    Status   `json:"status"`
	Duration  string   `json:"duration"`
	CheckedAt string   `json:"checked_at"`
	Results   []Result `json:"results"`
}

Report describes aggregated checker results.

type Result

type Result struct {
	Name      string        `json:"name"`
	Status    Status        `json:"status"`
	Message   string        `json:"message,omitempty"`
	Meta      core.Map      `json:"meta,omitempty"`
	Error     string        `json:"error,omitempty"`
	Duration  time.Duration `json:"duration,omitempty"`
	CheckedAt time.Time     `json:"checked_at"`
}

Result describes one checker result.

type Status

type Status string

Status describes a health check result state.

const (
	Pass Status = "pass"
	Warn Status = "warn"
	Fail Status = "fail"
)

Jump to

Keyboard shortcuts

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