metrics

package
v0.63.1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package metrics provides a set of functions to Marshal and Unmarshal metric events.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Events

type Events struct {
	EventsArr []*event.Event
	Hostname  string
}

Events represents a list of events ready to be serialize

func (Events) CreateMarshalersBySourceType

func (events Events) CreateMarshalersBySourceType() []marshaler.StreamJSONMarshaler

CreateMarshalersBySourceType creates a collection of marshaler.StreamJSONMarshaler. Each StreamJSONMarshaler is composed of all events for a specific source type name.

func (Events) CreateSingleMarshaler

func (events Events) CreateSingleMarshaler() marshaler.StreamJSONMarshaler

CreateSingleMarshaler creates marshaler.StreamJSONMarshaler where each item is composed of all events for a specific source type name.

func (Events) Marshal

func (events Events) Marshal() ([]byte, error)

Marshal serialize events using agent-payload definition

func (Events) MarshalJSON

func (events Events) MarshalJSON() ([]byte, error)

MarshalJSON serializes events to JSON so it can be sent to the Agent 5 intake (we don't use the v1 event endpoint because it only supports 1 event per payload) FIXME(olivier): to be removed when v2 endpoints are available

func (Events) SplitPayload

func (events Events) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into times number of pieces

type IterableSeries

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

IterableSeries is a serializer for metrics.IterableSeries

func CreateIterableSeries

func CreateIterableSeries(source metrics.SerieSource) *IterableSeries

CreateIterableSeries creates a new instance of *IterableSeries

func (*IterableSeries) DescribeCurrentItem

func (series *IterableSeries) DescribeCurrentItem() string

DescribeCurrentItem returns a text description for logs

func (*IterableSeries) GetCurrentItemPointCount

func (series *IterableSeries) GetCurrentItemPointCount() int

GetCurrentItemPointCount gets the number of points in the current serie

func (*IterableSeries) MarshalJSON

func (series *IterableSeries) MarshalJSON() ([]byte, error)

MarshalJSON serializes timeseries to JSON so it can be sent to V1 endpoints FIXME(maxime): to be removed when v2 endpoints are available

func (*IterableSeries) MarshalSplitCompress

func (series *IterableSeries) MarshalSplitCompress(bufferContext *marshaler.BufferContext, config config.Component, strategy compression.Component) (transaction.BytesPayloads, error)

MarshalSplitCompress uses the stream compressor to marshal and compress series payloads. If a compressed payload is larger than the max, a new payload will be generated. This method returns a slice of compressed protobuf marshaled MetricPayload objects.

func (*IterableSeries) MarshalSplitCompressMultiple added in v0.56.0

func (series *IterableSeries) MarshalSplitCompressMultiple(config config.Component, strategy compression.Component, filterFuncForMRF func(s *metrics.Serie) bool, filterFuncForAutoscaling func(s *metrics.Serie) bool) (transaction.BytesPayloads, transaction.BytesPayloads, transaction.BytesPayloads, error)

MarshalSplitCompressMultiple uses the stream compressor to marshal and compress one series into three sets of payloads. One set of payloads contains all metrics, The seond contains only those that pass the provided MRF filter function. The third contains only those that pass the provided autoscaling local failover filter function. This function exists because we need a way to build both payloads in a single pass over the input data, which cannot be iterated over twice.

func (*IterableSeries) MoveNext

func (series *IterableSeries) MoveNext() bool

MoveNext moves to the next item. This function skips the series when `NoIndex` is set at true as `NoIndex` is only supported by `MarshalSplitCompress`.

func (*IterableSeries) NewPayloadsBuilder added in v0.56.0

func (series *IterableSeries) NewPayloadsBuilder(bufferContext *marshaler.BufferContext, config config.Component, strategy compression.Component) (PayloadsBuilder, error)

NewPayloadsBuilder initializes a new PayloadsBuilder to be used for serializing series into a set of output payloads.

func (*IterableSeries) SplitPayload

func (series *IterableSeries) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into, at least, "times" number of pieces

func (*IterableSeries) WriteCurrentItem

func (series *IterableSeries) WriteCurrentItem(stream *jsoniter.Stream) error

WriteCurrentItem writes the json representation of an item

func (*IterableSeries) WriteFooter

func (series *IterableSeries) WriteFooter(stream *jsoniter.Stream) error

WriteFooter writes the payload footer for this type

func (*IterableSeries) WriteHeader

func (series *IterableSeries) WriteHeader(stream *jsoniter.Stream) error

WriteHeader writes the payload header for this type

type PayloadsBuilder added in v0.56.0

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

PayloadsBuilder represents an in-progress serialization of a series into potentially multiple payloads.

type Series

type Series []*metrics.Serie

Series represents a list of metrics.Serie ready to be serialize

func (Series) MarshalJSON

func (series Series) MarshalJSON() ([]byte, error)

MarshalJSON serializes timeseries to JSON so it can be sent to V1 endpoints FIXME(maxime): to be removed when v2 endpoints are available

func (Series) SplitPayload

func (series Series) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into, at least, "times" number of pieces

type ServiceChecks

type ServiceChecks []*servicecheck.ServiceCheck

ServiceChecks represents a list of service checks ready to be serialize

func (ServiceChecks) DescribeItem

func (sc ServiceChecks) DescribeItem(i int) string

DescribeItem returns a text description for logs

func (ServiceChecks) Len

func (sc ServiceChecks) Len() int

Len returns the number of items to marshal

func (ServiceChecks) MarshalJSON

func (sc ServiceChecks) MarshalJSON() ([]byte, error)

MarshalJSON serializes service checks to JSON so it can be sent to V1 endpoints FIXME(olivier): to be removed when v2 endpoints are available

func (ServiceChecks) SplitPayload

func (sc ServiceChecks) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into times number of pieces

func (ServiceChecks) WriteFooter

func (sc ServiceChecks) WriteFooter(stream *jsoniter.Stream) error

WriteFooter writes the payload footer for this type

func (ServiceChecks) WriteHeader

func (sc ServiceChecks) WriteHeader(stream *jsoniter.Stream) error

WriteHeader writes the payload header for this type

func (ServiceChecks) WriteItem

func (sc ServiceChecks) WriteItem(stream *jsoniter.Stream, i int) error

WriteItem writes the json representation of an item

type SketchSeriesList

type SketchSeriesList struct {
	metrics.SketchesSource
}

A SketchSeriesList implements marshaler.Marshaler

func (SketchSeriesList) Marshal

func (sl SketchSeriesList) Marshal() ([]byte, error)

Marshal encodes this series list.

func (SketchSeriesList) MarshalSplitCompress

func (sl SketchSeriesList) MarshalSplitCompress(bufferContext *marshaler.BufferContext, config config.Component, strategy compression.Component) (transaction.BytesPayloads, error)

MarshalSplitCompress uses the stream compressor to marshal and compress sketch series payloads. If a compressed payload is larger than the max, a new payload will be generated. This method returns a slice of compressed protobuf marshaled gogen.SketchPayload objects. gogen.SketchPayload is not directly marshaled - instead it's contents are marshaled individually, packed with the appropriate protobuf metadata, and compressed in stream. The resulting payloads (when decompressed) are binary equal to the result of marshaling the whole object at once.

func (SketchSeriesList) MarshalSplitCompressMultiple added in v0.56.0

func (sl SketchSeriesList) MarshalSplitCompressMultiple(config config.Component, strategy compression.Component, filterFunc func(ss *metrics.SketchSeries) bool) (transaction.BytesPayloads, transaction.BytesPayloads, error)

MarshalSplitCompressMultiple uses the stream compressor to marshal and compress one sketch list into two sets of payloads. One set of payloads contains all metrics, and the other contains only those that pass the provided filter function. This function exists because we need a way to build both payloads in a single pass over the input data, which cannot be iterated over twice.

func (SketchSeriesList) SplitPayload

func (sl SketchSeriesList) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into times number of pieces

type SketchSeriesSlice

type SketchSeriesSlice []*metrics.SketchSeries

func (SketchSeriesSlice) SplitPayload

func (sl SketchSeriesSlice) SplitPayload(times int) ([]marshaler.AbstractMarshaler, error)

SplitPayload breaks the payload into times number of pieces

Jump to

Keyboard shortcuts

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