telemetry

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket added in v0.38.0

type Bucket[T any] struct {
	// contains filtered or unexported fields
}

type BucketedBuffer added in v0.38.0

type BucketedBuffer[T any] struct {
	// contains filtered or unexported fields
}

BucketedBuffer groups items by trace id, flushing per bucket.

func NewBucketedBuffer added in v0.38.0

func NewBucketedBuffer[T any](
	category ratelimit.Category,
	capacity int,
	overflowPolicy OverflowPolicy,
	batchSize int,
	timeout time.Duration,
	recorder report.ClientReportRecorder,
) *BucketedBuffer[T]

func (*BucketedBuffer[T]) AcceptedCount added in v0.38.0

func (b *BucketedBuffer[T]) AcceptedCount() int64

func (*BucketedBuffer[T]) Capacity added in v0.38.0

func (b *BucketedBuffer[T]) Capacity() int

func (*BucketedBuffer[T]) Category added in v0.38.0

func (b *BucketedBuffer[T]) Category() ratelimit.Category

func (*BucketedBuffer[T]) Clear added in v0.38.0

func (b *BucketedBuffer[T]) Clear()

func (*BucketedBuffer[T]) Drain added in v0.38.0

func (b *BucketedBuffer[T]) Drain() []T

func (*BucketedBuffer[T]) DropRate added in v0.38.0

func (b *BucketedBuffer[T]) DropRate() float64

func (*BucketedBuffer[T]) DroppedCount added in v0.38.0

func (b *BucketedBuffer[T]) DroppedCount() int64

func (*BucketedBuffer[T]) GetMetrics added in v0.38.0

func (b *BucketedBuffer[T]) GetMetrics() BufferMetrics

func (*BucketedBuffer[T]) IsEmpty added in v0.38.0

func (b *BucketedBuffer[T]) IsEmpty() bool

func (*BucketedBuffer[T]) IsFull added in v0.38.0

func (b *BucketedBuffer[T]) IsFull() bool

func (*BucketedBuffer[T]) IsReadyToFlush added in v0.38.0

func (b *BucketedBuffer[T]) IsReadyToFlush() bool

func (*BucketedBuffer[T]) MarkFlushed added in v0.38.0

func (b *BucketedBuffer[T]) MarkFlushed()

func (*BucketedBuffer[T]) Offer added in v0.38.0

func (b *BucketedBuffer[T]) Offer(item T) bool

func (*BucketedBuffer[T]) OfferedCount added in v0.38.0

func (b *BucketedBuffer[T]) OfferedCount() int64

func (*BucketedBuffer[T]) Peek added in v0.38.0

func (b *BucketedBuffer[T]) Peek() (T, bool)

func (*BucketedBuffer[T]) Poll added in v0.38.0

func (b *BucketedBuffer[T]) Poll() (T, bool)

func (*BucketedBuffer[T]) PollBatch added in v0.38.0

func (b *BucketedBuffer[T]) PollBatch(maxItems int) []T

func (*BucketedBuffer[T]) PollIfReady added in v0.38.0

func (b *BucketedBuffer[T]) PollIfReady() []T

func (*BucketedBuffer[T]) Priority added in v0.38.0

func (b *BucketedBuffer[T]) Priority() ratelimit.Priority

func (*BucketedBuffer[T]) SetDroppedCallback added in v0.38.0

func (b *BucketedBuffer[T]) SetDroppedCallback(callback func(item T, reason string))

func (*BucketedBuffer[T]) Size added in v0.38.0

func (b *BucketedBuffer[T]) Size() int

func (*BucketedBuffer[T]) Utilization added in v0.38.0

func (b *BucketedBuffer[T]) Utilization() float64

type Buffer

type Buffer[T any] interface {
	// Core operations
	Offer(item T) bool
	Poll() (T, bool)
	PollBatch(maxItems int) []T
	PollIfReady() []T
	Drain() []T
	Peek() (T, bool)

	// State queries
	Size() int
	Capacity() int
	IsEmpty() bool
	IsFull() bool
	Utilization() float64

	// Flush management
	IsReadyToFlush() bool
	MarkFlushed()

	// Category/Priority
	Category() ratelimit.Category
	Priority() ratelimit.Priority

	// Metrics
	OfferedCount() int64
	DroppedCount() int64
	AcceptedCount() int64
	DropRate() float64
	GetMetrics() BufferMetrics

	// Configuration
	SetDroppedCallback(callback func(item T, reason string))
	Clear()
}

Buffer defines the common interface for all buffer implementations.

type BufferMetrics

type BufferMetrics struct {
	Category      ratelimit.Category `json:"category"`
	Priority      ratelimit.Priority `json:"priority"`
	Capacity      int                `json:"capacity"`
	Size          int                `json:"size"`
	Utilization   float64            `json:"utilization"`
	OfferedCount  int64              `json:"offered_count"`
	DroppedCount  int64              `json:"dropped_count"`
	AcceptedCount int64              `json:"accepted_count"`
	DropRate      float64            `json:"drop_rate"`
	LastUpdated   time.Time          `json:"last_updated"`
}

type OverflowPolicy

type OverflowPolicy int

OverflowPolicy defines how the ring buffer handles overflow.

const (
	OverflowPolicyDropOldest OverflowPolicy = iota
	OverflowPolicyDropNewest
)

func (OverflowPolicy) String

func (op OverflowPolicy) String() string

type Processor added in v0.42.0

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

Processor is the top-level object that wraps the scheduler and buffers.

func NewProcessor added in v0.42.0

func NewProcessor(
	buffers map[ratelimit.Category]Buffer[protocol.TelemetryItem],
	transport protocol.TelemetryTransport,
	dsn *protocol.Dsn,
	sdkInfo func() *protocol.SdkInfo,
	recorder report.ClientReportRecorder,
) *Processor

NewProcessor creates a new Processor with the given configuration.

func (*Processor) Add added in v0.42.0

func (b *Processor) Add(item protocol.TelemetryItem) bool

Add adds a TelemetryItem to the appropriate buffer based on its category.

The processor should call MakeSerializationSafe to eliminate any race on user mutable fields, since the serialization happens on a background goroutine.

func (*Processor) Close added in v0.42.0

func (b *Processor) Close(timeout time.Duration)

Close stops the buffer, flushes remaining data, and releases resources.

func (*Processor) Flush added in v0.42.0

func (b *Processor) Flush(timeout time.Duration) bool

Flush forces all buffers to flush within the given timeout.

func (*Processor) FlushWithContext added in v0.42.0

func (b *Processor) FlushWithContext(ctx context.Context) bool

FlushWithContext flushes with a custom context for cancellation.

type RingBuffer added in v0.38.0

type RingBuffer[T any] struct {
	// contains filtered or unexported fields
}

RingBuffer is a thread-safe ring buffer with overflow policies.

func NewRingBuffer added in v0.38.0

func NewRingBuffer[T any](category ratelimit.Category, capacity int, overflowPolicy OverflowPolicy, batchSize int, timeout time.Duration, recorder report.ClientReportRecorder) *RingBuffer[T]

func (*RingBuffer[T]) AcceptedCount added in v0.38.0

func (b *RingBuffer[T]) AcceptedCount() int64

func (*RingBuffer[T]) Capacity added in v0.38.0

func (b *RingBuffer[T]) Capacity() int

func (*RingBuffer[T]) Category added in v0.38.0

func (b *RingBuffer[T]) Category() ratelimit.Category

func (*RingBuffer[T]) Clear added in v0.38.0

func (b *RingBuffer[T]) Clear()

func (*RingBuffer[T]) Drain added in v0.38.0

func (b *RingBuffer[T]) Drain() []T

func (*RingBuffer[T]) DropRate added in v0.38.0

func (b *RingBuffer[T]) DropRate() float64

func (*RingBuffer[T]) DroppedCount added in v0.38.0

func (b *RingBuffer[T]) DroppedCount() int64

func (*RingBuffer[T]) GetMetrics added in v0.38.0

func (b *RingBuffer[T]) GetMetrics() BufferMetrics

func (*RingBuffer[T]) IsEmpty added in v0.38.0

func (b *RingBuffer[T]) IsEmpty() bool

func (*RingBuffer[T]) IsFull added in v0.38.0

func (b *RingBuffer[T]) IsFull() bool

func (*RingBuffer[T]) IsReadyToFlush added in v0.38.0

func (b *RingBuffer[T]) IsReadyToFlush() bool

func (*RingBuffer[T]) MarkFlushed added in v0.38.0

func (b *RingBuffer[T]) MarkFlushed()

func (*RingBuffer[T]) Offer added in v0.38.0

func (b *RingBuffer[T]) Offer(item T) bool

func (*RingBuffer[T]) OfferedCount added in v0.38.0

func (b *RingBuffer[T]) OfferedCount() int64

func (*RingBuffer[T]) Peek added in v0.38.0

func (b *RingBuffer[T]) Peek() (T, bool)

func (*RingBuffer[T]) Poll added in v0.38.0

func (b *RingBuffer[T]) Poll() (T, bool)

func (*RingBuffer[T]) PollBatch added in v0.38.0

func (b *RingBuffer[T]) PollBatch(maxItems int) []T

func (*RingBuffer[T]) PollIfReady added in v0.38.0

func (b *RingBuffer[T]) PollIfReady() []T

func (*RingBuffer[T]) Priority added in v0.38.0

func (b *RingBuffer[T]) Priority() ratelimit.Priority

func (*RingBuffer[T]) SetDroppedCallback added in v0.38.0

func (b *RingBuffer[T]) SetDroppedCallback(callback func(item T, reason string))

func (*RingBuffer[T]) Size added in v0.38.0

func (b *RingBuffer[T]) Size() int

func (*RingBuffer[T]) Utilization added in v0.38.0

func (b *RingBuffer[T]) Utilization() float64

type Scheduler added in v0.38.0

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

Scheduler implements a weighted round-robin scheduler for processing buffered events.

func NewScheduler added in v0.38.0

func NewScheduler(
	buffers map[ratelimit.Category]Buffer[protocol.TelemetryItem],
	transport protocol.TelemetryTransport,
	dsn *protocol.Dsn,
	sdkInfo func() *protocol.SdkInfo,
	recorder report.ClientReportRecorder,
) *Scheduler

func (*Scheduler) Add added in v0.38.0

func (s *Scheduler) Add(item protocol.TelemetryItem) bool

func (*Scheduler) Flush added in v0.38.0

func (s *Scheduler) Flush(timeout time.Duration) bool

func (*Scheduler) FlushWithContext added in v0.38.0

func (s *Scheduler) FlushWithContext(ctx context.Context) bool

func (*Scheduler) Signal added in v0.38.0

func (s *Scheduler) Signal()

func (*Scheduler) Start added in v0.38.0

func (s *Scheduler) Start()

func (*Scheduler) Stop added in v0.38.0

func (s *Scheduler) Stop(timeout time.Duration)

type TraceAware added in v0.38.0

type TraceAware interface {
	GetTraceID() (string, bool)
}

TraceAware is implemented by items that can expose a trace ID. BucketedBuffer uses this to group items by trace.

Jump to

Keyboard shortcuts

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