Top.Mail.Ru
package reflector — KubFly SDK for Go

KubFly SDK for Go / reflector

package reflector

import "kubfly.io/sdk/reflector"

Package reflector reads what the collectors wrote to a bucket: the segments of the streams, decoded into items — the reflector of the Java SDK. An item is a record of a stream (Start, Begin, Event, Interval…) with its kind, its key and its time, and where it comes from (Origin); its canonical JSON (JSON) is that of the Java SDK, checked by the reference segments of sdk/spec/segments.

Read decodes one segment in memory:

items, err := reflector.Read(segment, keys, decoder.OrderReverse)
for _, item := range items {
	switch item := item.(type) {
	case *reflector.Event:
		show(item.Time(), item.Level, item.Message())
	case *reflector.Begin:
		…
	}
}

Constants

const EarthRadius = 6_371_008.8

EarthRadius is the mean radius of the Earth, metres (IUGG): the distances of a track are along a sphere.

const TrackLate = 3_600_000

TrackLate is how long after the end of a span the stream tracks is read for the fixes of the span, ms — Track.LATE of the Java SDK: an hour — a device that keeps its fixes while it is out of the network gives them late, and a fix is kept by the time of its call. Only the tables of the segments of that hour are read for it, unless a summary there wants the blocks. The events are read in the span alone: a point with a context is logged when it is fixed.

Variables

var ItemKinds = []ItemKind{ItemKindStart, ItemKindFinish, ItemKindBegin, ItemKindEnd, ItemKindEvent,
	ItemKindUsageSnapshot, ItemKindHealthChange, ItemKindGap, ItemKindClock, ItemKindInterval, ItemKindAlertResult,
	ItemKindHealthResult, ItemKindTrafficInterval, ItemKindProfileInterval, ItemKindStatusSnapshot, ItemKindPosition}

ItemKinds are the kinds of the items, in order.

var ResourceKinds = []ResourceKind{ResourceKindStand, ResourceKindNamespace, ResourceKindService, ResourceKindPod,
	ResourceKindContainer, ResourceKindInstance}

ResourceKinds are the kinds of the resources, from the root down.

var Streams = []Stream{StreamEvents, StreamMetrics, StreamAlerts, StreamHealth, StreamTraffic, StreamProfiles,
	StreamTracks}

Streams are the streams, in order.

Functions

func Distance

func Distance(a, b util.Location) float64

Distance is the great-circle distance between two places, metres (haversine, on a sphere of EarthRadius).

func JSON

func JSON(item Item) string

JSON is the canonical JSON of an item, the one the Java SDK writes (Json.of): an object with the name of its record as "record", then its fields in their order — the key as "id", its number only (the instance is that of the origin, left out as the origin is), an option as its value or null, the arguments of an event as {"kind","value"} or null and its message last, the tags as an array of {"key","value"}, a union of an entity as its kind and every part (null but one). Numbers are printed as Java prints them, NaN and the infinities as strings, bytes in Base64; the text is the same as that of the Java SDK, written by the JSON generator of codec.

func NameValid

func NameValid(name string) bool

NameValid tells whether a text may name a level of the stand: not empty, no slash. A level of another name reads nothing — its first read gives a *NameError; a name from outside (a request, a form) may be checked so before.

func WriteJSON

func WriteJSON(out *json.Buffer, item Item)

WriteJSON writes the canonical JSON of an item into a buffer, after what it holds, without a line break.

Types

type AlertResult

type AlertResult struct {

	// End is the end of the interval, ms of the epoch.
	End int64
	// Metric is the metric.
	Metric *MetricDef
	// Severity is the severity.
	Severity alert.Severity
	// Warnings are the values beyond a warning threshold.
	Warnings int64
	// Criticals are the values beyond a critical threshold.
	Criticals int64
	// Unassessed are the values not assessed.
	Unassessed int64
	// contains filtered or unexported fields
}

AlertResult is the verdict of an alert of a metric on an interval, from its time to End.

func (*AlertResult) Key

func (h *AlertResult) Key() ItemKey

Key is the key of the item.

func (*AlertResult) Kind

func (*AlertResult) Kind() ItemKind

Kind is ItemKindAlertResult.

func (*AlertResult) Origin

func (h *AlertResult) Origin() *Origin

Origin is where the item comes from.

func (*AlertResult) Time

func (h *AlertResult) Time() int64

Time is the time of the item, ms of the epoch.

type Begin

type Begin struct {

	// Late is how late the record came: ms after its time, 0 when on time.
	Late int64
	// Parent is the frame it runs in, None for a root.
	Parent util.Option[ItemKey]
	// Depth is the depth of the frame: 1 for a root.
	Depth int
	// ThreadID is the thread, None when not known.
	ThreadID util.Option[int64]
	// ThreadName is the name of the thread, None when not known.
	ThreadName util.Option[string]
	// Project is the project of the scope.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the scope.
	Area string
	// System is the system of the scope.
	System string
	// Component is the component of the scope.
	Component string
	// Tags are the tags of the frame, nil for none.
	Tags *api.Tag
	// Caller is the caller the frame serves, nil for none.
	Caller *api.Caller
	// contains filtered or unexported fields
}

Begin is the beginning of a frame — an operation of a component: its key is the frame, its parent the frame it runs in (None for a root, the first frame of its trace or one served for a caller), its depth there, its thread, its scope, its tags and the caller it serves (nil — none).

func (*Begin) Frame

func (b *Begin) Frame() ItemKey

Frame is the frame: the key of the item.

func (*Begin) Key

func (h *Begin) Key() ItemKey

Key is the key of the item.

func (*Begin) Kind

func (*Begin) Kind() ItemKind

Kind is ItemKindBegin.

func (*Begin) Origin

func (h *Begin) Origin() *Origin

Origin is where the item comes from.

func (*Begin) Scope

func (b *Begin) Scope() string

Scope is the scope of the frame: project/module/area/system/component.

func (*Begin) Time

func (h *Begin) Time() int64

Time is the time of the item, ms of the epoch.

func (*Begin) Trace

func (b *Begin) Trace() util.Option[uuid.UUID]

Trace is the trace of a frame that begins one or carries it: the trace of its caller, or the trace of a root that serves no caller; None for a frame inside another, whose trace is that of its root.

type Clock

type Clock struct {

	// Local is the time of the clock of the process, ms of the epoch.
	Local int64
	// Bucket is the time of the bucket, ms of the epoch.
	Bucket int64
	// contains filtered or unexported fields
}

Clock is a reading of the clocks: the time of the process (Local) and of the bucket against the time of the item.

func (*Clock) Key

func (h *Clock) Key() ItemKey

Key is the key of the item.

func (*Clock) Kind

func (*Clock) Kind() ItemKind

Kind is ItemKindClock.

func (*Clock) Origin

func (h *Clock) Origin() *Origin

Origin is where the item comes from.

func (*Clock) Time

func (h *Clock) Time() int64

Time is the time of the item, ms of the epoch.

type Container

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

Container is a container of a pod. Its instances — one per start of the process — are read anew from the tree on every iteration.

func (*Container) Instance

func (c *Container) Instance(id uuid.UUID) *Instance

Instance is an instance by its identifier, listed or not.

func (*Container) Instances

func (c *Container) Instances(ctx context.Context) iter.Seq2[*Instance, error]

Instances are the instances listed in the tree, in the order of their identifiers (UUIDv7: of their starts); a name that is not a UUID is skipped.

func (*Container) Kind

func (c *Container) Kind() ResourceKind

Kind is ResourceKindContainer.

func (*Container) Name

func (c *Container) Name() string

Name is the name of the container.

func (*Container) Parent

func (c *Container) Parent() *Pod

Parent is the pod.

func (*Container) Query

func (c *Container) Query() *Query

Query are the queries by time over everything in the container.

func (*Container) String

func (c *Container) String() string

String is the path of names: prod/orders/orders-7c9d4/main.

type End

type End struct {

	// Late is how late the record came: ms after its time, 0 when on time.
	Late int64
	// Frame is the frame that ended.
	Frame ItemKey
	// Duration is how long the frame ran, ns.
	Duration int64
	// ThreadID is the thread, None when not known.
	ThreadID util.Option[int64]
	// ThreadName is the name of the thread, None when not known.
	ThreadName util.Option[string]
	// Failure is the failure of the frame, nil when it succeeded.
	Failure *Failure
	// contains filtered or unexported fields
}

End is the end of a frame: the frame, how long it ran (ns), its thread and its failure, nil when it succeeded.

func (*End) Key

func (h *End) Key() ItemKey

Key is the key of the item.

func (*End) Kind

func (*End) Kind() ItemKind

Kind is ItemKindEnd.

func (*End) Origin

func (h *End) Origin() *Origin

Origin is where the item comes from.

func (*End) Time

func (h *End) Time() int64

Time is the time of the item, ms of the epoch.

type Event

type Event struct {

	// Late is how late the record came: ms after its time, 0 when on time.
	Late int64
	// Frame is the frame the event happened in, None outside one.
	Frame util.Option[ItemKey]
	// ThreadID is the thread, None when not known.
	ThreadID util.Option[int64]
	// ThreadName is the name of the thread, None when not known.
	ThreadName util.Option[string]
	// Project is the project of the path.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the path.
	Area string
	// System is the system of the path.
	System string
	// Level is the level.
	Level api.Level
	// Template is the template of the message: its {} take the arguments.
	Template string
	// Args are the arguments, in the order of the {} of the template: none to format.MaxArguments.
	Args []api.Arg
	// Tags are the tags of the event, nil for none.
	Tags *api.Tag
	// Failure is the failure of the event, nil for none.
	Failure *Failure
	// contains filtered or unexported fields
}

Event is an event: its frame (None outside one), its thread, its path, its level, its template with up to two arguments (ArgumentKindNone — none), its tags and its failure.

func (*Event) Key

func (h *Event) Key() ItemKey

Key is the key of the item.

func (*Event) Kind

func (*Event) Kind() ItemKind

Kind is ItemKindEvent.

func (*Event) Message

func (e *Event) Message() string

Message is the message: the template with its arguments, as the Java SDK prints them.

func (*Event) Origin

func (h *Event) Origin() *Origin

Origin is where the item comes from.

func (*Event) Path

func (e *Event) Path() string

Path is the path of the event: project/module/area/system.

func (*Event) Time

func (h *Event) Time() int64

Time is the time of the item, ms of the epoch.

type Failure

type Failure struct {
	// Type is the class: java.lang.IllegalStateException, *fs.PathError.
	Type string
	// Message is the message, None for none.
	Message util.Option[string]
	// Trace are the frames of the stack, the innermost first.
	Trace []api.StackFrame
	// Cause is the cause, or nil.
	Cause *Failure
	// Suppressed are the suppressed failures.
	Suppressed []*Failure
	// Cut tells whether the chain of causes and suppressed failures was cut.
	Cut bool
}

Failure is a failure as it was written: the class, the message (None — null), the frames of the stack, the cause (nil — none), the suppressed failures and whether the chain was cut. Err gives it as an error, to log it again.

func (*Failure) Err

func (f *Failure) Err() *FailureError

Err is the failure as an error that the collectors write as it was: an api.Exception.

type FailureError

type FailureError struct {
	// Failure is the failure.
	Failure *Failure
}

FailureError is a failure read from a segment as an error: an api.Exception of its class, its message, its stack, its cause and its suppressed failures, so that a collector writes it again as it was.

func (*FailureError) Error

func (e *FailureError) Error() string

Error is the class and the message, as Java prints an exception: java.io.IOException: disk.

func (*FailureError) ExceptionCause

func (e *FailureError) ExceptionCause() error

ExceptionCause is the cause, or nil.

func (*FailureError) ExceptionClass

func (e *FailureError) ExceptionClass() string

ExceptionClass is the class.

func (*FailureError) ExceptionFrames

func (e *FailureError) ExceptionFrames() []api.StackFrame

ExceptionFrames are the frames of the stack.

func (*FailureError) ExceptionMessage

func (e *FailureError) ExceptionMessage() (string, bool)

ExceptionMessage is the message, and false for none.

func (*FailureError) ExceptionSuppressed

func (e *FailureError) ExceptionSuppressed() []error

ExceptionSuppressed are the suppressed failures.

func (*FailureError) Unwrap

func (e *FailureError) Unwrap() error

Unwrap is the cause, for errors.Is and errors.As.

type Finish

type Finish struct {

	// Environment is the environment of the process, or nil.
	Environment *environment.Environment
	// contains filtered or unexported fields
}

Finish is the finish of a process: the last record of its events, with its environment and the time it finished at — nil when the record holds none.

func (*Finish) Key

func (h *Finish) Key() ItemKey

Key is the key of the item.

func (*Finish) Kind

func (*Finish) Kind() ItemKind

Kind is ItemKindFinish.

func (*Finish) Origin

func (h *Finish) Origin() *Origin

Origin is where the item comes from.

func (*Finish) Time

func (h *Finish) Time() int64

Time is the time of the item, ms of the epoch.

type Gap

type Gap struct {

	// Reason is why: format.GapLane, GapCollector, GapBucket, GapFinish, GapSpool.
	Reason int
	// Segments are the segments lost.
	Segments int64
	// Bytes are the bytes lost.
	Bytes int64
	// Records are the records lost.
	Records int64
	// contains filtered or unexported fields
}

Gap is what a process lost: the reason (format.GapLane…) and the segments, the bytes and the records lost.

func (*Gap) Key

func (h *Gap) Key() ItemKey

Key is the key of the item.

func (*Gap) Kind

func (*Gap) Kind() ItemKind

Kind is ItemKindGap.

func (*Gap) Origin

func (h *Gap) Origin() *Origin

Origin is where the item comes from.

func (*Gap) Time

func (h *Gap) Time() int64

Time is the time of the item, ms of the epoch.

type HealthChange

type HealthChange struct {

	// Project is the project of the path.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the path.
	Area string
	// System is the system of the path.
	System string
	// Component is the component of the path.
	Component string
	// Severity is the new severity.
	Severity alert.Severity
	// Message is the message of the check.
	Message string
	// Failure is the failure of the check, nil for none.
	Failure *Failure
	// contains filtered or unexported fields
}

HealthChange is a change of the health of a component: its path, its new severity, the message and the failure of its check (nil — none).

func (*HealthChange) Key

func (h *HealthChange) Key() ItemKey

Key is the key of the item.

func (*HealthChange) Kind

func (*HealthChange) Kind() ItemKind

Kind is ItemKindHealthChange.

func (*HealthChange) Origin

func (h *HealthChange) Origin() *Origin

Origin is where the item comes from.

func (*HealthChange) Path

func (h *HealthChange) Path() string

Path is the path of the component: project/module/area/system/component.

func (*HealthChange) Time

func (h *HealthChange) Time() int64

Time is the time of the item, ms of the epoch.

type HealthResult

type HealthResult struct {

	// Project is the project of the path.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the path.
	Area string
	// System is the system of the path.
	System string
	// Component is the component of the path.
	Component string
	// Duration is how long the check ran, ns.
	Duration int64
	// Severity is the severity.
	Severity alert.Severity
	// contains filtered or unexported fields
}

HealthResult is the result of a check of the health of a component: how long it ran (ns) and the severity.

func (*HealthResult) Key

func (h *HealthResult) Key() ItemKey

Key is the key of the item.

func (*HealthResult) Kind

func (*HealthResult) Kind() ItemKind

Kind is ItemKindHealthResult.

func (*HealthResult) Origin

func (h *HealthResult) Origin() *Origin

Origin is where the item comes from.

func (*HealthResult) Path

func (h *HealthResult) Path() string

Path is the path of the component: project/module/area/system/component.

func (*HealthResult) Time

func (h *HealthResult) Time() int64

Time is the time of the item, ms of the epoch.

type Instance

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

Instance is an instance: one start of the process in a container, with its markers in the tree — start-time.kfl with the start object and finish-time.kfl once it has finished.

func (*Instance) Build

func (i *Instance) Build(ctx context.Context) (util.Option[uuid.UUID], error)

Build is the build of the instance, by its start object: its KUBFLY_BUILD; None if the process had none or the tree has no start of it yet.

func (*Instance) Catalog

func (i *Instance) Catalog(ctx context.Context) (*decoder.Catalog, error)

Catalog is the catalog of the instance, read anew: every metric the process defined, with its description, by their paths, and the labels and the hints of the fields of STATUS in its language — catalog.kfl beside its start object (format.md §10), the latest the process put. Empty if the process put none (an older SDK) or the tree has no instance yet, no fields if its SDK is older; an error if it is damaged, of a newer version, or none of the keys of the stand opens it.

func (*Instance) Code

func (i *Instance) Code(ctx context.Context) (util.Option[*decoder.Code], error)

Code is the code the instance ran, read anew: the code of its build (Stand.Code, format.md §10c); None if the instance has no build or the bucket has no code of it — as Instance.code of the Java SDK.

func (*Instance) Finish

func (i *Instance) Finish(ctx context.Context) (util.Option[int64], error)

Finish is the time of the finish, by its marker; None while the instance has not finished.

func (*Instance) ID

func (i *Instance) ID() uuid.UUID

ID is the identifier of the instance.

func (*Instance) Info

func (i *Instance) Info(ctx context.Context) (*InstanceInfo, error)

Info is the start object, read anew; nil when there is none. One that does not read is a *format.Error.

func (*Instance) Kind

func (i *Instance) Kind() ResourceKind

Kind is ResourceKindInstance.

func (*Instance) Parent

func (i *Instance) Parent() *Container

Parent is the container.

func (*Instance) Query

func (i *Instance) Query() *Query

Query are the queries by time over the instance.

func (*Instance) Start

func (i *Instance) Start(ctx context.Context) (util.Option[int64], error)

Start is the time of the start, by its marker; None without one.

func (*Instance) State

func (i *Instance) State(ctx context.Context) (*InstanceState, error)

State is what the instance knew of itself now (StateAt).

func (*Instance) StateAt

func (i *Instance) StateAt(ctx context.Context, at int64) (*InstanceState, error)

StateAt is what the instance knew of itself at a moment, ms of the epoch (a finished instance — its finish at most): START from its first segment of events; the last STATUS and USAGE from the end of its last segments that began by then — the hours are listed back from the moment, the segments read backward; FINISH from its last segment. All nil without a start marker.

func (*Instance) String

func (i *Instance) String() string

String is the path of names: prod/orders/orders-7c9d4/main/0192f1c2-….

type InstanceInfo

type InstanceInfo struct {
	// Node is the node of Kubernetes.
	Node string
	// Namespace is the namespace.
	Namespace string
	// Service is the service.
	Service string
	// Pod is the pod.
	Pod string
	// Container is the container.
	Container string
	// Instance is the instance.
	Instance uuid.UUID
	// Process is the identifier of the process in its operating system, 0 when not known.
	Process int64
	// Language is the language of the texts of the process (English for an identifier this reader does not know).
	Language language.Language
	// Timezone is the identifier of the zone of the process.
	Timezone string
	// Start is the start of the process, ms of the epoch.
	Start int64
	// Version is the version of the application.
	Version string
	// Ref is the branch or the tag.
	Ref string
	// Commit is the commit.
	Commit string
	// Build is the build, None when not known.
	Build util.Option[uuid.UUID]
	// OS is the operating system.
	OS string
	// Arch is the architecture.
	Arch string
	// Variant is the variant of the architecture.
	Variant string
	// Intervals are the intervals of the segments of the streams, ms, by Stream.Interval.
	Intervals []int64
}

InstanceInfo is the start object of an instance in the tree of the stand (start-time.kfl, format.md §10): "KFLY", u8 version 1, the fields of the origin in the order of these fields, then the intervals of the streams, CRC32C. An empty text is a value not known.

func ReadInstanceInfo

func ReadInstanceInfo(data []byte) (*InstanceInfo, error)

ReadInstanceInfo reads a start object; one that is not of the format is a *format.Error.

func (*InstanceInfo) Interval

func (i *InstanceInfo) Interval(stream Stream) int64

Interval is the interval of the segments of a stream: their times span less than it (decision 60); 0 when not known.

type InstanceState

type InstanceState struct {
	// Start is the start, from the first segment of events; nil if not read.
	Start *Start
	// Status is the last status, from the end of the last segments of events; nil if none.
	Status *StatusSnapshot
	// Usage is the last usage snapshot; nil if none.
	Usage *UsageSnapshot
	// Finish is the finish, in the last segment; nil while it runs or if it did not get to the bucket.
	Finish *Finish
	// Newer is what the reading passed over as newer than this reader (decision 89).
	Newer *format.Newer
}

InstanceState is what an instance knew of itself at a moment (decision 87): the unchanging from START — the origin, the machine, the platform, the names of the variables of the environment — the resources from the last USAGE, the rest from the last STATUS, and FINISH if the process finished. Without FINISH a process that is no longer alive did not get its finish to the bucket (a timeout, SIGKILL): its last STATUS is all there is.

func (*InstanceState) Finished

func (s *InstanceState) Finished() bool

Finished tells whether the finish got to the bucket.

type Interval

type Interval struct {

	// End is the end of the interval, ms of the epoch.
	End int64
	// Samples are the samples of the metrics.
	Samples []Sample
	// contains filtered or unexported fields
}

Interval is an interval of metrics: from its time to End, the samples of its metrics.

func (*Interval) Key

func (h *Interval) Key() ItemKey

Key is the key of the item.

func (*Interval) Kind

func (*Interval) Kind() ItemKind

Kind is ItemKindInterval.

func (*Interval) Origin

func (h *Interval) Origin() *Origin

Origin is where the item comes from.

func (*Interval) Time

func (h *Interval) Time() int64

Time is the time of the item, ms of the epoch.

type Item

type Item interface {
	// Kind is the kind of the item.
	Kind() ItemKind
	// Origin is where the item comes from, shared by the items of its instance.
	Origin() *Origin
	// Key is the key of the item: its instance and its number there.
	Key() ItemKey
	// Time is the time of the item, ms of the epoch: of an interval, its beginning.
	Time() int64
	// contains filtered or unexported methods
}

Item is an item of a stand: a record of a stream — its kind, its time and where it comes from (Origin: the instance, its build, its platform, its place), shared by the items of an instance. Every item has a key of its own (Key): the instance and the number there, unique on the stand; with the time the number orders the items of an instance. The set is closed: the items are the pointers to the records of this package (*Start, *Event…), told apart by a type switch or by Kind.

func Read

func Read(segment []byte, keys []*decoder.RecipientKey, order decoder.Order) ([]Item, error)

Read decodes the items of a segment in memory, in an order of time: the records of the types this reader knows, with the definitions of the segment resolved; the keys open a segment in an envelope (none for one in clear). The origin of the items is that of the instance of the segment, nothing else known. A segment that is not of the format — a record that does not decode, a reference to a definition it lacks — is a *format.Error.

func ReadNewer

func ReadNewer(segment []byte, keys []*decoder.RecipientKey, order decoder.Order, newer *format.Newer) ([]Item,
	error)

ReadNewer decodes the items of a segment in memory as Read, telling what is passed over as newer than this reader (decision 89): a record of a type it does not know by its frame, an entity of a version it does not know by its length.

type ItemFilter

type ItemFilter interface {
	// Match tells whether an item is given.
	Match(item Item) bool
	// Where is what the items must come from, known before reading: instances that do not match are not read.
	Where() Where
}

ItemFilter is which items an iteration gives: a test of each item read (Match), and the part of it the reader knows before reading (Where) — the fields of the origin, which skip whole instances and their segments. A nil filter of a query gives every item.

query.Events(ctx, from, to, decoder.OrderReverse, reflector.FilterOf(reflector.Where{},
	func(event *reflector.Event) bool { return event.Level == api.LevelError }))
query.Events(ctx, from, to, decoder.OrderDirect, reflector.Where{Service: util.Some("orders"),
	Version: util.Some("2.3.1")}.And(func(item reflector.Item) bool { … }))

func FilterOf

func FilterOf[T Item](where Where, match func(item T) bool) ItemFilter

FilterOf is a filter of the items of a type that pass a test, from an origin: an item of another type is not given.

type ItemKey

type ItemKey struct {
	// Instance is the instance that wrote the item.
	Instance uuid.UUID
	// ID is the number of the item in its instance.
	ID int64
}

ItemKey is the key of an item: its instance and its number there, never negative — unique on the stand. Its text sorts as the key does: the instance, a dash and the number in 19 digits.

func NewItemKey

func NewItemKey(instance uuid.UUID, id int64) ItemKey

NewItemKey is the key of an item; a negative number panics.

func ParseItemKey

func ParseItemKey(text string) (ItemKey, error)

ParseItemKey takes apart the text of a key (String): the instance, a dash and the number in 19 digits — a key from outside, a link of a page; another text is an error. It is the inverse of String: a text that String would not give is not a key.

func (ItemKey) String

func (k ItemKey) String() string

String is the instance, a dash and the number in 19 digits: 0192f1c2-…-0000000000000000042.

type ItemKind

type ItemKind uint8

ItemKind is the kind of an item, one per record of this package.

const (
	// ItemKindStart is a Start.
	ItemKindStart ItemKind = iota + 1
	// ItemKindFinish is a Finish.
	ItemKindFinish
	// ItemKindBegin is a Begin.
	ItemKindBegin
	// ItemKindEnd is an End.
	ItemKindEnd
	// ItemKindEvent is an Event.
	ItemKindEvent
	// ItemKindUsageSnapshot is a UsageSnapshot.
	ItemKindUsageSnapshot
	// ItemKindHealthChange is a HealthChange.
	ItemKindHealthChange
	// ItemKindGap is a Gap.
	ItemKindGap
	// ItemKindClock is a Clock.
	ItemKindClock
	// ItemKindInterval is an Interval.
	ItemKindInterval
	// ItemKindAlertResult is an AlertResult.
	ItemKindAlertResult
	// ItemKindHealthResult is a HealthResult.
	ItemKindHealthResult
	// ItemKindTrafficInterval is a TrafficInterval.
	ItemKindTrafficInterval
	// ItemKindProfileInterval is a ProfileInterval.
	ItemKindProfileInterval
	// ItemKindStatusSnapshot is a StatusSnapshot.
	ItemKindStatusSnapshot
	// ItemKindPosition is a Position.
	ItemKindPosition
)

The kinds of the items.

func (ItemKind) String

func (k ItemKind) String() string

String is the name of the kind: EVENT.

type Link struct {
	// Protocol is the protocol.
	Protocol traffic.Protocol
	// Operation is the operation: GET, a topic of a broker.
	Operation string
	// Route is the route: that of the server when both sides are known, else that of the side known.
	Route string
	// Client is the client: a process of KubFly with its names, or the external caller of a server.
	Client traffic.Peer
	// Server is the server: a process of KubFly with its names, a host, a database, a broker.
	Server traffic.Peer
	// Out is the edge of the client, nil when not known.
	Out *traffic.Edge
	// In is the edge of the server, nil when not known.
	In *traffic.Edge
}

Link is one link between two sides, both edges of it joined (LinksOf): the outgoing edge of the client and the incoming edge of the server — one of them may be missing (nil), when the other side has no SDK or wrote to another bucket; never both.

func LinksOf

func LinksOf(intervals []*TrafficInterval) []Link

LinksOf joins the intervals of the traffic of the processes of a stand, of any processes and in any order (format.md §9a): their edges over the span summed, and the two sides of each link joined. The outgoing edge of a client A whose peer is the instance b1 and the incoming edge of b1 whose peer is A, of the same protocol, operation and route, are one link; when the routes differ (a client without a template gives its path, the server its pattern) and there is only one such pair, it is joined all the same. The names of a process come from the origin of its own intervals, else from what its peer saw. The joined links come first.

intervals, err := stand.Query().Traffic(ctx, from, to, decoder.OrderDirect, nil).Collect()
for _, link := range reflector.LinksOf(intervals) { … }

func (Link) Between

func (l Link) Between() util.Option[int64]

Between is the time between the sides: the mean duration of the client less that of the server — the network, the proxies and the queues between, ns. Known only when both sides are, and the client measures durations (a producer of a broker does not).

func (Link) Count

func (l Link) Count() int64

Count are the requests or messages of the link: as the client counted them, else as the server did.

type MetricDef

type MetricDef struct {
	// Project is the project of the path.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the path.
	Area string
	// System is the system of the path.
	System string
	// Component is the component of the path.
	Component string
	// Measure is the measure of the path.
	Measure string
	// Scale is the power of ten of the values: 3 — thousandths.
	Scale int8
	// Units are the units: kg, ms.
	Units string
	// Description is what it measures, for people: empty — none, or a segment written before descriptions.
	Description string
	// Scoped tells whether the metric is of a scope of frames.
	Scoped bool
	// Alert is the alert, alert.None for none.
	Alert alert.Alert
	// Source is where the values come from.
	Source int
}

MetricDef is a metric: its path, its scale and units, whether it is scoped, its alert and its source.

func (*MetricDef) Path

func (m *MetricDef) Path() string

Path is the path of the metric: project/module/area/system/component/measure.

type NameError

type NameError struct {
	// Level is the level: stand, namespace, service, pod, container.
	Level string
	// Name is the name as it was given.
	Name string
}

NameError is a name of a level of the stand that is not one: empty or with a slash — or a blank name of the stand. A level made of such a name reads nothing: its first read gives this error, before the bucket is asked.

func (*NameError) Error

func (e *NameError) Error() string

Error tells the level and the name.

type Namespace

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

Namespace is a namespace of the stand. Its children are read anew from the tree on every iteration.

func (*Namespace) Kind

func (n *Namespace) Kind() ResourceKind

Kind is ResourceKindNamespace.

func (*Namespace) Name

func (n *Namespace) Name() string

Name is the name of the namespace.

func (*Namespace) Parent

func (n *Namespace) Parent() *Stand

Parent is the stand.

func (*Namespace) Query

func (n *Namespace) Query() *Query

Query are the queries by time over everything in the namespace.

func (*Namespace) Service

func (n *Namespace) Service(name string) *Service

Service is a service by name, listed or not; one of a name that is not valid (NameValid) reads nothing, its first read gives a *NameError.

func (*Namespace) Services

func (n *Namespace) Services(ctx context.Context) iter.Seq2[*Service, error]

Services are the services listed in the tree.

func (*Namespace) String

func (n *Namespace) String() string

String is the name: prod.

type Origin

type Origin struct {
	// Stand is the name of the stand that holds the items.
	Stand util.Option[string]
	// Node is the node of Kubernetes (KUBFLY_NODE).
	Node util.Option[string]
	// Namespace is the namespace (KUBFLY_NAMESPACE).
	Namespace util.Option[string]
	// Service is the service (KUBFLY_SERVICE).
	Service util.Option[string]
	// Pod is the pod (KUBFLY_POD).
	Pod util.Option[string]
	// Container is the container (KUBFLY_CONTAINER).
	Container util.Option[string]
	// Instance is the instance.
	Instance uuid.UUID
	// Process is the identifier of the process in its operating system.
	Process util.Option[int64]
	// Language is the language of the texts of the process.
	Language util.Option[language.Language]
	// Timezone is the zone of the process: Europe/Moscow; nil when not known.
	Timezone *time.Location
	// Start is the start of the process, ms of the epoch.
	Start util.Option[int64]
	// Version is the version of the application (KUBFLY_VERSION).
	Version util.Option[string]
	// Ref is the branch or the tag (KUBFLY_REF).
	Ref util.Option[string]
	// Commit is the commit (KUBFLY_COMMIT).
	Commit util.Option[string]
	// Build is the build (KUBFLY_BUILD).
	Build util.Option[uuid.UUID]
	// OS is the operating system: linux.
	OS util.Option[string]
	// Arch is the architecture: amd64, arm64.
	Arch util.Option[string]
	// Variant is the variant of the architecture.
	Variant util.Option[string]
}

Origin is where items come from: the instance that wrote them, its build, its platform and its place on the stand — the Config of the process that wrote them and the stand that holds them. Shared by every item of an instance; a value that is not known is None, only the instance is always known.

func OriginOf

func OriginOf(instance uuid.UUID, lang language.Language) *Origin

OriginOf is the origin of a segment read alone: only its instance and its language, of its header, are known.

type Pod

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

Pod is a pod of a service. Its children are read anew from the tree on every iteration.

func (*Pod) Container

func (p *Pod) Container(name string) *Container

Container is a container by name, listed or not; one of a name that is not valid (NameValid) reads nothing, its first read gives a *NameError.

func (*Pod) Containers

func (p *Pod) Containers(ctx context.Context) iter.Seq2[*Container, error]

Containers are the containers listed in the tree.

func (*Pod) Kind

func (p *Pod) Kind() ResourceKind

Kind is ResourceKindPod.

func (*Pod) Name

func (p *Pod) Name() string

Name is the name of the pod.

func (*Pod) Parent

func (p *Pod) Parent() *Service

Parent is the service.

func (*Pod) Query

func (p *Pod) Query() *Query

Query are the queries by time over everything in the pod.

func (*Pod) String

func (p *Pod) String() string

String is the path of names: prod/orders/orders-7c9d4.

type Position

type Position struct {

	// Late is how late the record came: ms after its time, 0 when on time; the call was at time − late.
	Late int64
	// Project is the project of the path of the KubFly that tracks.
	Project string
	// Module is the second level of the path: a module of the build of the project.
	Module string
	// Area is the area of the path.
	Area string
	// System is the system of the path.
	System string
	// Point is the point.
	Point util.TrackPoint
	// Event is the event whose argument it was; nil — a point of the stream tracks.
	Event *Event
	// contains filtered or unexported fields
}

Position is a point of the track of a moving object (format.md §9c): who tracks it (project/module/area/system of the KubFly that called Track or logged the event) and the point — the track, the time of the fix, the place. The time of the item is that of the call: the points of a track come out of the order of their fixes; the reader orders a track by util.TrackPoint.Time (Track). A point of the stream tracks has no event; a point that was an argument of an event (api.ArgumentKindTrackPoint) has it — its message tells why the point is there — and its key, time and path are those of the event.

func (*Position) Key

func (h *Position) Key() ItemKey

Key is the key of the item.

func (*Position) Kind

func (*Position) Kind() ItemKind

Kind is ItemKindPosition.

func (*Position) Origin

func (h *Position) Origin() *Origin

Origin is where the item comes from.

func (*Position) Path

func (p *Position) Path() string

Path is the path of the KubFly that tracks: project/module/area/system.

func (*Position) Time

func (h *Position) Time() int64

Time is the time of the item, ms of the epoch.

type ProfileInterval

type ProfileInterval struct {

	// End is the end of the interval, ms of the epoch.
	End int64
	// Profile is the kind of the profile.
	Profile profile.Kind
	// Period is the period of sampling, ns; 0 when there is none.
	Period int64
	// Stacks are the stacks.
	Stacks []ProfileStack
	// contains filtered or unexported fields
}

ProfileInterval is an interval of a profile: from its time to End, its kind, its period of sampling (ns, 0 — none) and its stacks.

func (*ProfileInterval) Key

func (h *ProfileInterval) Key() ItemKey

Key is the key of the item.

func (*ProfileInterval) Kind

func (*ProfileInterval) Kind() ItemKind

Kind is ItemKindProfileInterval.

func (*ProfileInterval) Origin

func (h *ProfileInterval) Origin() *Origin

Origin is where the item comes from.

func (*ProfileInterval) Time

func (h *ProfileInterval) Time() int64

Time is the time of the item, ms of the epoch.

type ProfileStack

type ProfileStack struct {
	// Frames are the frames, the one that ran first.
	Frames []api.StackFrame
	// Truncated tells whether the stack was cut.
	Truncated bool
	// Count is the count of the samples.
	Count int64
	// Value is the value of the samples: ns, bytes.
	Value int64
	// Type is the type allocated, empty but for a profile ALLOC.
	Type string
}

ProfileStack is a stack of a profile: its frames from the one that ran to the lowest, whether it was cut, the count of its samples, their value (ns, bytes) and the type allocated (empty but for ALLOC).

type Query

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

Query are the queries by time over everything beneath a resource of the stand (Resource.Query): its instances alive in a span, the items of its streams merged by time, its segments. The resource itself gives only its own — its name, its parent, its children. Nothing is cached: every iteration lists the bucket anew. A nil filter gives every item; a level of a name that is not valid gives its *NameError.

stand.Namespace("prod").Service("orders").Query().Events(ctx, from, to, decoder.OrderReverse, nil)

func (*Query) Alerts

func (q *Query) Alerts(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*AlertResult]

Alerts are the assessments of metric thresholds a filter gives.

func (*Query) Alive

func (q *Query) Alive(ctx context.Context, from, to int64) iter.Seq2[*Instance, error]

Alive are the instances alive at some moment of a span: those with a pulse of the layout in its hours, started before its end and not finished before its beginning.

func (*Query) Events

func (q *Query) Events(ctx context.Context, from, to int64, order decoder.Order, filter ItemFilter) Timeline[*Event]

Events are the events a filter gives, without the other items of their stream (EventsAll gives them all).

func (*Query) EventsAll

func (q *Query) EventsAll(ctx context.Context, from, to int64, order decoder.Order, filter ItemFilter) Timeline[Item]

EventsAll are all the items of the stream events a filter gives: starts, finishes, frames, events, usage, changes of health, gaps, clocks — Stream(ctx, StreamEvents, …).

func (*Query) Health

func (q *Query) Health(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*HealthResult]

Health are the runs of health checks a filter gives.

func (*Query) Metrics

func (q *Query) Metrics(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*Interval]

Metrics are the metric intervals a filter gives.

func (*Query) Positions

func (q *Query) Positions(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*Position]

Positions are the points of the tracks of moving objects a filter gives, as the calls kept them: by the time of the call, not of the fix.

func (*Query) Profiles

func (q *Query) Profiles(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*ProfileInterval]

Profiles are the profiles of the processes a filter gives, one kind of one process over an interval at a time.

func (*Query) Read

func (q *Query) Read(ctx context.Context, key SegmentKey, order decoder.Order) ([]Item, error)

Read are the items of one segment, whole, with the origin of its instance.

func (*Query) ReadNewer

func (q *Query) ReadNewer(ctx context.Context, key SegmentKey, order decoder.Order, newer *format.Newer) ([]Item,
	error)

ReadNewer are the items of one segment, whole, with the origin of its instance, telling what is passed over as newer than this reader.

func (*Query) Segments

func (q *Query) Segments(ctx context.Context, stream Stream, from, to int64) ([]SegmentKey, error)

Segments are the segments of a stream beneath this level that may hold items of a span, by the time of their beginning. The hours are listed from the beginning of the span less the longest interval of the stream among the instances alive in it: a segment spans less than its interval (decision 60).

func (*Query) Stream

func (q *Query) Stream(ctx context.Context, stream Stream, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[Item]

Stream are the items of a stream a filter gives: the segments of every instance beneath, each read in the order, the instances merged by time; an item is in the span if its time is. The origin part of the filter (Where) is decided before reading — by the keys of the segments and the start objects of the instances — so an instance it rules out is not read.

func (*Query) Track

func (q *Query) Track(ctx context.Context, name string, from, to int64) (*Track, error)

Track is one track in a span (from, to: ms of the epoch of a fix, inclusive), as Tracks; nil without fixes in the span.

func (*Query) TrackSummaries

func (q *Query) TrackSummaries(ctx context.Context, from, to int64) ([]TrackSummary, error)

TrackSummaries are the tracks whose fixes fall in a span (from, to: ms of the epoch of a fix, inclusive), by name, as the tables of the segments of the stream tracks tell them — the blocks are not read (format.md §9c): the points of a track in the segments with a fix of the span (so a fix just before or after it counts too: at most so many), the frame of their places and the span of their fixes. The points that are arguments of events are not there: Tracks reads them. For a list of many tracks before their points — Query.trackSummaries of the Java SDK.

func (*Query) Tracks

func (q *Query) Tracks(ctx context.Context, from, to int64, names ...string) ([]*Track, error)

Tracks are the tracks whose fixes fall in a span (from, to: ms of the epoch of a fix, inclusive), by name: from the stream tracks and from the arguments of events of every instance beneath this level (Track); names — only these, none — every track. The fixes of the span are looked for in the stream up to TrackLate after it; a segment is read only if a summary of its table has such a fix (format.md §9c) — Query.tracks of the Java SDK.

func (*Query) Traffic

func (q *Query) Traffic(ctx context.Context, from, to int64, order decoder.Order,
	filter ItemFilter) Timeline[*TrafficInterval]

Traffic are the links with the peers a filter gives, an interval of each process at a time.

type Resource

type Resource interface {
	// Kind is the kind of the level.
	Kind() ResourceKind
	// Query are the queries by time over everything beneath this level: the instances alive, the items of the
	// streams, the segments.
	Query() *Query
	// String is the path of names: namespace/service/…, stand for the stand.
	String() string
	// contains filtered or unexported methods
}

Resource is a resource of the stand, a level of its tree — the stand, a namespace, a service, a pod, a container, an instance, named as Kubernetes and the stand name them: its kind and its queries by time over everything beneath it (Query); the resource itself gives its name, its parent and its children. Nothing is cached: every iteration lists the bucket anew. The set is closed: the resources are the pointers to the levels of this package (*Stand, *Namespace…), told apart by a type switch or by Kind.

type ResourceKind

type ResourceKind uint8

ResourceKind is the kind of a resource of the stand, one per level.

const (
	// ResourceKindStand is a Stand: the root, the stand bucket.
	ResourceKindStand ResourceKind = iota + 1
	// ResourceKindNamespace is a Namespace: a namespace of Kubernetes.
	ResourceKindNamespace
	// ResourceKindService is a Service: a service.
	ResourceKindService
	// ResourceKindPod is a Pod: a pod.
	ResourceKindPod
	// ResourceKindContainer is a Container: a container in a pod.
	ResourceKindContainer
	// ResourceKindInstance is an Instance: one start of a process in a container.
	ResourceKindInstance
)

The kinds of the resources.

func (ResourceKind) String

func (k ResourceKind) String() string

String is the name of the kind: SERVICE.

type Sample

type Sample struct {
	// Metric is the metric.
	Metric *MetricDef
	// Count is the count of the values.
	Count int64
	// Sum is the sum of the values.
	Sum int64
	// Min is the least value.
	Min int64
	// Max is the greatest value.
	Max int64
	// Last is the last value.
	Last int64
	// Rejected are the values rejected.
	Rejected int64
	// Severity is the severity of the alert at the end of the interval.
	Severity alert.Severity
	// Warnings are the values beyond a warning threshold.
	Warnings int64
	// Criticals are the values beyond a critical threshold.
	Criticals int64
	// Unassessed are the values not assessed.
	Unassessed int64
	// Limited are the values beyond the limit.
	Limited int64
	// LimitMin is the least value beyond the limit.
	LimitMin int64
	// LimitMax is the greatest value beyond the limit.
	LimitMax int64
	// Histogram are the counts by bucket, empty when the metric has none.
	Histogram []int64
}

Sample is what a metric observed in an interval: the count, the sum, the extremes and the last of its values (in its units times 10^scale), the values it rejected, the verdicts of its alert, the values beyond its limit and its histogram — the counts by bucket, empty when it has none.

type SegmentKey

type SegmentKey struct {
	// Stream is the stream.
	Stream Stream
	// Namespace is the namespace.
	Namespace string
	// Service is the service.
	Service string
	// Pod is the pod.
	Pod string
	// Container is the container.
	Container string
	// Instance is the instance.
	Instance uuid.UUID
	// Begin is the time of the first record, ms of the epoch.
	Begin int64
	// End is the time of the last record.
	End int64
	// Statistics are the counts of the key, in the order of the stream (format.md §2.3).
	Statistics []int64
	// Obj is the object.
	Obj bucket.Obj
}

SegmentKey is a key of a segment taken apart (format.md §2): <stream>/v1/index/all/direct/YYYY/MM/DD/HH/mm/ss/SSS/<namespace>/<service>/<pod>/<container>/<instance>/ <begin>-<end>-<statistics>.<ext>.

func ParseSegmentKey

func ParseSegmentKey(stream Stream, obj bucket.Obj) (SegmentKey, bool)

ParseSegmentKey takes a key of a segment of a stream apart; false if it is not one.

type Service

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

Service is a service of a namespace. Its children are read anew from the tree on every iteration.

func (*Service) Kind

func (s *Service) Kind() ResourceKind

Kind is ResourceKindService.

func (*Service) Name

func (s *Service) Name() string

Name is the name of the service.

func (*Service) Parent

func (s *Service) Parent() *Namespace

Parent is the namespace.

func (*Service) Pod

func (s *Service) Pod(name string) *Pod

Pod is a pod by name, listed or not; one of a name that is not valid (NameValid) reads nothing, its first read gives a *NameError.

func (*Service) Pods

func (s *Service) Pods(ctx context.Context) iter.Seq2[*Pod, error]

Pods are the pods listed in the tree.

func (*Service) Query

func (s *Service) Query() *Query

Query are the queries by time over everything in the service.

func (*Service) String

func (s *Service) String() string

String is the path of names: prod/orders.

type Stand

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

Stand is the stand: the root of the tree of a stand bucket. Every level gives its children and the queries by time over everything beneath it; nothing is cached — every iteration reads the bucket anew.

stand, err := reflector.StandOf("prod", bucket, key)
for namespace, err := range stand.Namespaces(ctx) { … }
for item, err := range stand.Query().EventsAll(ctx, from, to, decoder.OrderReverse, nil).All() { … }

func StandOf

func StandOf(name string, source bucket.Bucket, keys ...*decoder.RecipientKey) (*Stand, error)

StandOf is a stand of a bucket, with the private keys that open its encrypted segments (none — only the open streams read). The name is the one the reader shows next to every item (prod, Production): its items carry it in Origin.Stand; a blank one is a *NameError.

func (*Stand) Attachment

func (s *Stand) Attachment(ctx context.Context, origin *Origin, attachment *api.Attachment) (util.Option[[]byte],
	error)

Attachment is the content of an attachment of an event, read now: a blob or an image the record of the event holds as an *api.Attachment — beyond the budget of its record, kept beside its event in a pack of attachments (attachments/v1/…/<instance>/<pack>.kfb, format.md §10d). Two requests by range: the header of the pack, then the block alone; checked against the size and the SHA-256 of the record. None if it was kept nowhere or the bucket has no pack for it (lost on the way). One that is damaged, of a newer version, that none of the keys opens or that is not the content the event refers to is a *format.Error; an origin that does not name the place of its instance is an error — as Stand.attachment of the Java SDK.

func (*Stand) Code

func (s *Stand) Code(ctx context.Context, build uuid.UUID) (util.Option[*decoder.Code], error)

Code is the code of a build, read anew: the sources it was made of, put by its first instance or by its build (code/v1/<build>.kfc, format.md §10c); None if the bucket has none for the build. One that is damaged, of a newer version or that none of the keys of the stand opens is a *format.Error — as Stand.code of the Java SDK.

func (*Stand) Kind

func (s *Stand) Kind() ResourceKind

Kind is ResourceKindStand.

func (*Stand) Name

func (s *Stand) Name() string

Name is the name of the stand, given when it was made.

func (*Stand) Namespace

func (s *Stand) Namespace(name string) *Namespace

Namespace is a namespace by name, listed or not; one of a name that is not valid (NameValid) reads nothing, its first read gives a *NameError.

func (*Stand) Namespaces

func (s *Stand) Namespaces(ctx context.Context) iter.Seq2[*Namespace, error]

Namespaces are the namespaces listed in the tree.

func (*Stand) Query

func (s *Stand) Query() *Query

Query are the queries by time over the whole stand.

func (*Stand) String

func (s *Stand) String() string

String is "stand".

func (*Stand) Text

func (s *Stand) Text(ctx context.Context, origin *Origin, attachment *api.Attachment) (util.Option[string], error)

Text is the whole of a string argument cut in its event, read now: its UTF-8 in a pack of attachments (the *api.Attachment in the Ref of the argument, format.md §10d), checked as Attachment checks — Stand.text of the Java SDK.

type Start

type Start struct {

	// Environment is the environment of the process, or nil.
	Environment *environment.Environment
	// contains filtered or unexported fields
}

Start is the start of a process: the first record of its events, with its environment — nil when the record holds none.

func (*Start) Key

func (h *Start) Key() ItemKey

Key is the key of the item.

func (*Start) Kind

func (*Start) Kind() ItemKind

Kind is ItemKindStart.

func (*Start) Origin

func (h *Start) Origin() *Origin

Origin is where the item comes from.

func (*Start) Time

func (h *Start) Time() int64

Time is the time of the item, ms of the epoch.

type StatusSnapshot

type StatusSnapshot struct {

	// Status is the status, or nil.
	Status *status.Status
	// contains filtered or unexported fields
}

StatusSnapshot is the state of the process as it knew it (STATUS, decision 87): the last record of every segment of events, its time that of the record before it; nil when the record holds none.

func (*StatusSnapshot) Key

func (h *StatusSnapshot) Key() ItemKey

Key is the key of the item.

func (*StatusSnapshot) Kind

func (*StatusSnapshot) Kind() ItemKind

Kind is ItemKindStatusSnapshot.

func (*StatusSnapshot) Origin

func (h *StatusSnapshot) Origin() *Origin

Origin is where the item comes from.

func (*StatusSnapshot) Time

func (h *StatusSnapshot) Time() int64

Time is the time of the item, ms of the epoch.

type Stream

type Stream uint8

Stream is a stream of segments of a stand bucket (format.md §2), its identifier that of its header (format.Events …): its prefix, its extension and the index of its interval in the start object of an instance.

const (
	// StreamEvents are the events, frames, starts, finishes, usage, changes of health; encrypted when keys are given.
	StreamEvents Stream = format.Events
	// StreamMetrics are the metric intervals; encrypted when keys are given.
	StreamMetrics Stream = format.Metrics
	// StreamAlerts are the assessments of metric thresholds; open.
	StreamAlerts Stream = format.Alerts
	// StreamHealth are the runs of health checks; open.
	StreamHealth Stream = format.Health
	// StreamTraffic are the links of the processes with their peers; open unless the collector encrypts it.
	StreamTraffic Stream = format.Traffic
	// StreamProfiles are the profiles of the processes; encrypted when keys are given.
	StreamProfiles Stream = format.Profiles
	// StreamTracks are the points of the tracks of moving objects; encrypted when keys are given.
	StreamTracks Stream = format.Tracks
)

The streams.

func (Stream) Extension

func (s Stream) Extension() string

Extension is the extension of the objects of the stream: kfe.

func (Stream) Interval

func (s Stream) Interval() int

Interval is the index of the interval of the stream in InstanceInfo.Intervals.

func (Stream) Prefix

func (s Stream) Prefix() string

Prefix is the first part of the keys of the stream: events.

func (Stream) String

func (s Stream) String() string

String is the name of the stream, as Java names its constants: EVENTS.

type Timeline

type Timeline[T Item] struct {
	// contains filtered or unexported fields
}

Timeline are the items of a span of time in an order: decoder.OrderDirect — the time never decreases, decoder.OrderReverse — it never increases. Every iteration reads the bucket anew, nothing is cached; nothing is sorted: segments are read in the order of their keys, items in the order of their segments, instances merged by time. A failure — of the bucket, of a damaged segment — is the last pair of an iteration. What is newer than this reader is passed over, not failed at (decision 89): Newer tells what the last iteration passed over.

for event, err := range query.Events(ctx, from, to, decoder.OrderReverse, nil).All() {
	if err != nil {
		return err
	}
	show(event)
}

func Merge

func Merge[T Item](order decoder.Order, from, to int64, parts ...Timeline[T]) Timeline[T]

Merge merges spans by time into one of an order — of several instances, levels or streams, say: the events of a service with the metrics of its pods (Items), or with items parsed from other logs. A part in the other order is read reversed; at equal times the earlier part comes first. The parts fill the report of the merge.

func TimelineOf

func TimelineOf[T Item](order decoder.Order, from, to int64,
	source func(order decoder.Order) iter.Seq2[T, error]) Timeline[T]

TimelineOf is a span given by a source of iterations per order: a list read anew, a parser of logs, a query of one's own.

func (Timeline[T]) All

func (t Timeline[T]) All() iter.Seq2[T, error]

All iterates the span anew, with a report of its own: the items with no error, or a failure as the last pair.

func (Timeline[T]) Collect

func (t Timeline[T]) Collect() ([]T, error)

Collect collects the items, for small spans.

func (Timeline[T]) From

func (t Timeline[T]) From() int64

From is the beginning of the span, ms of the epoch, inclusive.

func (Timeline[T]) Items

func (t Timeline[T]) Items() Timeline[Item]

Items is the span as one of any items, to merge it with spans of other types.

func (Timeline[T]) Newer

func (t Timeline[T]) Newer() *format.Newer

Newer is what the last iteration passed over as newer than this reader (decision 89): records of a type it does not know, entities of a version it does not know; the report of a merge sums those of its parts. Asked after the iteration ends; a timeline not iterated yet tells nothing.

func (Timeline[T]) Order

func (t Timeline[T]) Order() decoder.Order

Order is the order.

func (Timeline[T]) Reversed

func (t Timeline[T]) Reversed() Timeline[T]

Reversed is the same span in the other order.

func (Timeline[T]) To

func (t Timeline[T]) To() int64

To is the end of the span, ms of the epoch, inclusive.

type Track

type Track struct {
	// Name is the name of the track.
	Name string
	// Points are its points, by the time of their fixes.
	Points []*Position
}

Track is a track — Track of the Java SDK: the points of one name (util.TrackPoint.Track — a moving object or its trip), ordered by the time of their fixes, gathered by Query.Tracks from the stream tracks and from the arguments of events of every instance beneath the query. A point that came twice — the same fix by Track and in an event — is kept once, as the event: its message tells why it is there. A track has a point at least.

func (*Track) At

func (t *Track) At(time int64) *Position

At is the point of a time of a fix (ms of the epoch): the one a map marks for an event whose argument it was; nil when none is.

func (*Track) Begin

func (t *Track) Begin() int64

Begin is the time of the first fix, ms of the epoch.

func (*Track) End

func (t *Track) End() int64

End is the time of the last fix, ms of the epoch.

func (*Track) Length

func (t *Track) Length() float64

Length is the length of the track, metres: the great-circle distances between its points, one after another (haversine, on a sphere of EarthRadius; the altitude is not counted).

func (*Track) Simplified

func (t *Track) Simplified(tolerance float64) (*Track, error)

Simplified is the track simplified for a map (Douglas — Peucker): a point is left out when it is closer than the tolerance (metres) to the line between the points kept around it. The first and the last point are kept, and every point of an event: it has a context. Distances are on the plane tangent at the start of each line — metres, as good as GPS for lines up to a few hundred kilometres. The track itself when nothing is left out; an error for a tolerance below 0 or not finite.

func (*Track) Trips

func (t *Track) Trips(gap int64) ([]*Track, error)

Trips are the trips of the track, by time: it is cut where the next fix is later than the gap (ms) — a courier who rested an hour, a phone off for the night; the track alone if it has no such gap; an error for a gap below 0.

type TrackSummary

type TrackSummary struct {
	// Track is the name of the track.
	Track string
	// Points are its points in the segments read.
	Points int64
	// South, West, North and East are the frame of their places, degrees.
	South, West, North, East float64
	// First and Last are the times of the first and the last fix.
	First, Last int64
}

TrackSummary is a track in a span as the tables of the segments of the stream tracks tell it (Query.TrackSummaries): its points there, the frame of their places (degrees: the least and the largest latitude and longitude) and the span of their fixes (ms of the epoch) — TrackSummary of the Java SDK.

type TrafficInterval

type TrafficInterval struct {

	// End is the end of the interval, ms of the epoch.
	End int64
	// Edges are the links.
	Edges []traffic.Edge
	// contains filtered or unexported fields
}

TrafficInterval is an interval of traffic: from its time to End, the links of the process with its peers.

func (*TrafficInterval) Key

func (h *TrafficInterval) Key() ItemKey

Key is the key of the item.

func (*TrafficInterval) Kind

func (*TrafficInterval) Kind() ItemKind

Kind is ItemKindTrafficInterval.

func (*TrafficInterval) Origin

func (h *TrafficInterval) Origin() *Origin

Origin is where the item comes from.

func (*TrafficInterval) Time

func (h *TrafficInterval) Time() int64

Time is the time of the item, ms of the epoch.

type UsageSnapshot

type UsageSnapshot struct {

	// Usage is the usage, or nil.
	Usage *usage.Usage
	// contains filtered or unexported fields
}

UsageSnapshot is a snapshot of the resources used: nil when the record holds none.

func (*UsageSnapshot) Key

func (h *UsageSnapshot) Key() ItemKey

Key is the key of the item.

func (*UsageSnapshot) Kind

func (*UsageSnapshot) Kind() ItemKind

Kind is ItemKindUsageSnapshot.

func (*UsageSnapshot) Origin

func (h *UsageSnapshot) Origin() *Origin

Origin is where the item comes from.

func (*UsageSnapshot) Time

func (h *UsageSnapshot) Time() int64

Time is the time of the item, ms of the epoch.

type Where

type Where struct {
	// Node is the node of Kubernetes.
	Node util.Option[string]
	// Namespace is the namespace.
	Namespace util.Option[string]
	// Service is the service.
	Service util.Option[string]
	// Pod is the pod.
	Pod util.Option[string]
	// Container is the container.
	Container util.Option[string]
	// Instance is the instance.
	Instance util.Option[uuid.UUID]
	// Version is the version of the application.
	Version util.Option[string]
	// Ref is the branch or the tag.
	Ref util.Option[string]
	// Commit is the commit.
	Commit util.Option[string]
	// Build is the build.
	Build util.Option[uuid.UUID]
	// OS is the operating system: linux.
	OS util.Option[string]
	// Arch is the architecture: amd64, arm64.
	Arch util.Option[string]
	// Variant is the variant of the architecture.
	Variant util.Option[string]
}

Where is what items must come from: fields of their Origin, each None — any; the zero value is any origin. The reader knows them before it reads a segment — the names from the keys of the segments, the rest from the start object of each instance — so an instance that does not match is not read at all.

where := reflector.Where{Service: util.Some("orders"), Version: util.Some("2.3.1"), Arch: util.Some("arm64")}
stand.Query().EventsAll(ctx, from, to, decoder.OrderDirect, where)

func (Where) And

func (w Where) And(match func(item Item) bool) ItemFilter

And is this filter with a test of each item read: instances are chosen by this, items by both.

func (Where) Match

func (w Where) Match(item Item) bool

Match tells whether an item comes from a matching origin.

func (Where) Matches

func (w Where) Matches(origin *Origin) bool

Matches tells whether an origin matches: every field set is that of the origin.

func (Where) Where

func (w Where) Where() Where

Where is this filter: it is all known before reading.