health

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MetricOnline = "up" // current status
	MetricStatus = "up.status"
)

Variables

This section is empty.

Functions

func SemVersion

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

func Version

func Version() string

Version is the current release version of the health instrumentation.

Types

type Checker

type Checker interface {
	Check(context.Context) ReportDocument
}

Checker is interface used to provide an indication of application health.

type CheckerFunc

type CheckerFunc func(ctx context.Context) ReportDocument

CheckerFunc is an adapter to allow the use of ordinary go functions as Checkers.

func (CheckerFunc) Check

type Controller

type Controller interface {
	AddChecker(checker Checker)

	Checker
}

Controller of checker set

type Handler

type Handler struct {
	Controller
}

func NewHandler

func NewHandler(c Controller) *Handler

NewHandler returns a new Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP returns a json encoded health set the status to http.StatusServiceUnavailable if the check is down

type Metrics

type Metrics struct {
	*Simple
	// contains filtered or unexported fields
}

func NewMetric

func NewMetric(pr metric.MeterProvider, checker ...Checker) *Metrics

func (*Metrics) Run

func (m *Metrics) Run(ctx context.Context)

Run too sensitive

type Report

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

Report is a health State struct

func NewReport

func NewReport(name string, online bool, kv ...attribute.KeyValue) *Report

NewReport return data with report result

func (*Report) AddInfo

func (h *Report) AddInfo(kv ...attribute.KeyValue)

AddInfo additional info

func (*Report) GetAttr

func (h *Report) GetAttr() []attribute.KeyValue

GetAttr provide open telemetry friendly information about current report

func (*Report) IsOnline

func (h *Report) IsOnline() bool

IsOnline return if report online

func (*Report) MarshalJSON

func (h *Report) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaller for pretty http json body

func (*Report) Set

func (h *Report) Set(online bool)

Set not important function-setter

type ReportDocument

type ReportDocument interface {
	IsOnline() bool
}

type ReportDocumentList

type ReportDocumentList []ReportDocument

func (ReportDocumentList) IsOnline

func (l ReportDocumentList) IsOnline() bool

IsOnline check if any check if down we should declare service is not ready

type Simple

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

Simple aggregate a list of Checkers

func NewSimple

func NewSimple(checker ...Checker) *Simple

NewSimple creates a new Simple

func (*Simple) AddChecker

func (c *Simple) AddChecker(checker Checker)

AddChecker add a Checker to the aggregator

func (*Simple) Check

func (c *Simple) Check(ctx context.Context) ReportDocument

Check returns the combination of all checkers added if some check is not UP, the combined is marked as Down

Jump to

Keyboard shortcuts

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