snapshot

package module
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package snapshot defines contract for collecting snapshots as well as helper structures

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogBuffer

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

LogBuffer is a buffer for plog.Logs

func NewLogBuffer

func NewLogBuffer(idealSize int) *LogBuffer

NewLogBuffer creates a logBuffer with the ideal size set

func (*LogBuffer) Add

func (l *LogBuffer) Add(ld plog.Logs)

Add adds the new log payload and adjust buffer to keep ideal size

func (*LogBuffer) ConstructPayload

func (l *LogBuffer) ConstructPayload(logsMarshaler plog.Marshaler, searchQuery *string, minimumTimestamp *time.Time, maximumPayloadSize int) ([]byte, error)

ConstructPayload condenses the buffer and serializes to protobuf. Does not compress the payload to be compatible with both the snapshot reporter and the snapshot processor. It ensures that the payload is less than the maximum payload size returning an error if it cannot sample logs within the maximum payload size. Uses an increasing retention approach to sample the logs, starting at 1% and increasing by 25% until we reach the maximum payload size allowed. Clears the buffer if it cannot sample logs within the maximum payload size. This should allow the next snapshot to have a valid payload size.

func (*LogBuffer) Len

func (l *LogBuffer) Len() int

Len counts the number of log records in all Log payloads in buffer

type MetricBuffer

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

MetricBuffer is a buffer for pmetric.Metrics

func NewMetricBuffer

func NewMetricBuffer(idealSize int) *MetricBuffer

NewMetricBuffer creates a metricBuffer with the ideal size set

func (*MetricBuffer) Add

func (l *MetricBuffer) Add(md pmetric.Metrics)

Add adds the new metric payload and adjust buffer to keep ideal size

func (*MetricBuffer) ConstructPayload

func (l *MetricBuffer) ConstructPayload(metricMarshaler pmetric.Marshaler, searchQuery *string, minimumTimestamp *time.Time, maximumPayloadSize int) ([]byte, error)

ConstructPayload condenses the buffer and serializes to protobuf. Does not compress the payload to be compatible with both the snapshot reporter and the snapshot processor. It ensures that the payload is less than the maximum payload size returning an error if it cannot sample metrics within the maximum payload size. Uses an increasing retention approach to sample the metrics, starting at 1% and increasing by 25% until we reach the maximum payload size allowed. Clears the buffer if it cannot sample metrics within the maximum payload size. This should allow the next snapshot to have a valid payload size.

func (*MetricBuffer) Len

func (l *MetricBuffer) Len() int

Len counts the number of data points in all Metric payloads in buffer

type Snapshotter

type Snapshotter interface {
	// SaveLogs saves off logs in a snapshot
	SaveLogs(componentID string, ld plog.Logs)

	// SaveTraces saves off traces in a snapshot
	SaveTraces(componentID string, td ptrace.Traces)

	// SaveMetrics saves off metrics in a snapshot
	SaveMetrics(componentID string, md pmetric.Metrics)
}

Snapshotter represents an interface to save logs, metrics, and traces for snapshots

//go:generate mockery --name Snapshotter --filename mock_snapshotter.go --structname MockSnapshotter No go generate for this as it requires internal otel structures that don't import correctly with mockery. Can uncomment above and run then modify by hand.

type TraceBuffer

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

TraceBuffer is a buffer for ptrace.Traces

func NewTraceBuffer

func NewTraceBuffer(idealSize int) *TraceBuffer

NewTraceBuffer creates a traceBuffer with the ideal size set

func (*TraceBuffer) Add

func (l *TraceBuffer) Add(td ptrace.Traces)

Add adds the new trace payload and adjust buffer to keep ideal size

func (*TraceBuffer) ConstructPayload

func (l *TraceBuffer) ConstructPayload(traceMarshaler ptrace.Marshaler, searchQuery *string, minimumTimestamp *time.Time, maximumPayloadSize int) ([]byte, error)

ConstructPayload condenses the buffer and serializes to protobuf. Does not compress the payload to be compatible with both the snapshot reporter and the snapshot processor. It ensures that the payload is less than the maximum payload size returning an error if it cannot sample traces within the maximum payload size. Uses an increasing retention approach to sample the traces, starting at 1% and increasing by 25% until we reach the maximum payload size allowed. Clears the buffer if it cannot sample traces within the maximum payload size. This should allow the next snapshot to have a valid payload size.

func (*TraceBuffer) Len

func (l *TraceBuffer) Len() int

Len counts the number of spans in all Traces payloads in buffer

Directories

Path Synopsis
Package mocks contains mocks for snapshot interfaces
Package mocks contains mocks for snapshot interfaces

Jump to

Keyboard shortcuts

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