encoders

package
v1.46.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InfluxStrategy

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

InfluxStrategy implements InfluxDB line protocol encoding

func NewInfluxStrategy

func NewInfluxStrategy() *InfluxStrategy

NewInfluxStrategy creates a new InfluxDB strategy

func (*InfluxStrategy) AddField

func (s *InfluxStrategy) AddField(key string, value any)

func (*InfluxStrategy) AddTag

func (s *InfluxStrategy) AddTag(key, value string)

func (*InfluxStrategy) Bytes

func (s *InfluxStrategy) Bytes() []byte

func (*InfluxStrategy) EndLine

func (s *InfluxStrategy) EndLine(timestamp time.Time)

func (*InfluxStrategy) Err

func (s *InfluxStrategy) Err() error

func (*InfluxStrategy) StartLine

func (s *InfluxStrategy) StartLine(measurement string)

type JsonEncoderMetricsPoint

type JsonEncoderMetricsPoint struct {
	Measure string            `json:"measure"`
	Tag     map[string]string `json:"tag"`
	Field   map[string]any    `json:"field"`
	Ts      int64             `json:"ts"`
}

JsonEncoderMetricsPoint represents a JSON metrics point

type JsonStrategy

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

JsonStrategy implements JSON encoding

func NewJsonStrategy

func NewJsonStrategy() *JsonStrategy

NewJsonStrategy creates a new JSON strategy

func (*JsonStrategy) AddField

func (s *JsonStrategy) AddField(key string, value any)

func (*JsonStrategy) AddTag

func (s *JsonStrategy) AddTag(key, value string)

func (*JsonStrategy) Bytes

func (s *JsonStrategy) Bytes() []byte

func (*JsonStrategy) EndLine

func (s *JsonStrategy) EndLine(timestamp time.Time)

func (*JsonStrategy) Err

func (s *JsonStrategy) Err() error

func (*JsonStrategy) StartLine

func (s *JsonStrategy) StartLine(measurement string)

type OtelStrategy

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

OtelStrategy implements OpenTelemetry OTLP encoding with optimized performance. It uses manual JSON building with strings.Builder for maximum performance, achieving ~16,000x improvement over standard JSON marshaling.

func NewOtelStrategy

func NewOtelStrategy() *OtelStrategy

NewOtelStrategy creates a new optimized OTEL strategy with pre-allocated slices for better memory efficiency and reduced allocations.

func (*OtelStrategy) AddField

func (s *OtelStrategy) AddField(key string, value any)

AddField adds a field value to the current metric. The first field becomes the primary value, additional fields create separate metrics.

func (*OtelStrategy) AddTag

func (s *OtelStrategy) AddTag(key, value string)

AddTag adds an OpenTelemetry attribute (tag) to the current metric. Tags become attributes in the OTLP format.

func (*OtelStrategy) Bytes

func (s *OtelStrategy) Bytes() []byte

Bytes generates the complete OTLP JSON payload from all collected metrics. Returns nil if there were any errors during metric collection. Clears the metrics batch after generation for reuse.

func (*OtelStrategy) EndLine

func (s *OtelStrategy) EndLine(timestamp time.Time)

EndLine finalizes the current metric with a timestamp and adds it to the batch.

func (*OtelStrategy) Err

func (s *OtelStrategy) Err() error

Err returns any error that occurred during metric processing

func (*OtelStrategy) StartLine

func (s *OtelStrategy) StartLine(measurement string)

StartLine initializes a new metric with the given measurement name. Pre-allocates slices and maps for optimal performance.

type Strategy

type Strategy interface {
	StartLine(measurement string)
	AddTag(key, value string)
	AddField(key string, value any)
	EndLine(timestamp time.Time)
	Bytes() []byte
	Err() error
}

Strategy defines the interface for different encoding strategies

Jump to

Keyboard shortcuts

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