monitoring

package
v0.0.0-...-e16fa07 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type D

type D map[string]interface{}

D is a shortcut to use for adding events

type Event

type Event struct {
	Data interface{} `json:"data"`
	When int64       `json:"when"` // unix timestamp
}

Event is a single event.

type EventMap

type EventMap map[string]*Event

EventMap contains the map of all registered events

type HttpMonitoring

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

The monitoring server with API to add events.

func NewHttpMonitoring

func NewHttpMonitoring(config HttpMonitoringConfig, logger log.Logger) (*HttpMonitoring, error)

func (*HttpMonitoring) AddEvent

func (m *HttpMonitoring) AddEvent(name string, value interface{}) error

AddEvent adds an event with the current timestamp. It overwrites the previous event of the same name (if existing).

func (*HttpMonitoring) GetEvent

func (m *HttpMonitoring) GetEvent(name string) *Event

GetEvent returns a registered event value.

func (*HttpMonitoring) ListenHttp

func (m *HttpMonitoring) ListenHttp(ctx context.Context) error

Starts to serve monitoring data on the configured address. This call is blocking.

func (*HttpMonitoring) ServeHTTP

func (m *HttpMonitoring) ServeHTTP(writer http.ResponseWriter, req *http.Request)

Respond with monitoring data to an HTTP request. Only needed if you want to integrate the monitoring package into another HTTP server (instead of calling HttpMonitoring.ListenHttp() ).

type HttpMonitoringConfig

type HttpMonitoringConfig struct {
	HttpListenAddress string   // for example ":8080"
	Path              string   // the HTTP path to serve monitoring data on - defaults to "/monitoring"
	Events            []string // A list of event names to keep track of
}

type MonitoringHttpResponse

type MonitoringHttpResponse struct {
	Error bool     `json:"error"`
	Data  EventMap `json:"data"`
	Time  int64    `json:"time"` // unix timestamp
}

Jump to

Keyboard shortcuts

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