message

package
v0.0.0-...-3ab55c3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 21 Imported by: 1

Documentation

Overview

Package message defines the interface for the measurements and observations made by the "gomon" command. The package also implements the formatting of the output streamed by the "gomon" command.

The message package defines the following command line flags:

  • -document: document the output that Gomon produces
  • -pretty: format output in a manner that is human readable
  • -rotate: an interval at which to rotate the output file

Index

Constants

This section is empty.

Variables

View Source
var (
	// LokiStreams counts the number of observations streamed to Loki.
	LokiStreams int
)
View Source
var (

	// MeasureEvents has only the single type "measure".
	MeasureEvents = gocore.ValidValue[MeasureEvent]{}.Define(measure)
)
View Source
var (
	// Messages contains a map of all message definitions.
	Messages = map[string][]field{}
)

Functions

func Close

func Close()

Close completes the jsonEncoder's operation.

func Define

func Define(m Content)

Define a Message's Content.

func Document

func Document()

Document the messages when the document flag specified on the command line.

func Encoder

func Encoder(ctx context.Context) error

Encoder configures the message encoder. Its Encode function marshals objects.

func Measurements

func Measurements(ms []Content) error

Measurements sends measurements to encode.

func Observations

func Observations(ms []Content) error

Observations sends observations to encode.

func Rotate

func Rotate(t time.Time)

Rotate obtains lock and calls encoder's rotate method.

Types

type Content

type Content interface {
	Events() []string
	ID() string
}

Content interface methods for all messages.

func Gather

func Gather(fs []Request, timeout time.Duration) []Content

Gather metrics from each Request, waiting for results for at most timeout duration. If timeout is 0, wait until all requests complete.

type Header[T ~string] struct {
	Timestamp time.Time `json:"timestamp" gomon:"property"`
	Host      string    `json:"host" gomon:"property"`
	Platform  string    `json:"platform" gomon:"property"`
	Source    string    `json:"source" gomon:"property"`
	Event     T         `json:"event" gomon:"property"`
}

Header for a message.

func Measurement

func Measurement() Header[MeasureEvent]

Measurement initializes the message header for measurement. Measurement types are distinguised by their source.

func Observation

func Observation[T ~string](t time.Time, event T) Header[T]

Observation initializes the message header for an observation. An observer (source) may detect several types of events, so the source qualifies an event type by its origin.

type MeasureEvent

type MeasureEvent string

MeasureEvent defines the event type for a measurement.

type Request

type Request func() []Content

Request returns []Content.

Jump to

Keyboard shortcuts

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