metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package metrics provides performance tracking for Nebula

Index

Constants

This section is empty.

Variables

View Source
var (
	// RecordsProcessed tracks total records processed
	RecordsProcessed = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: "nebula_records_processed_total",
			Help: "Total number of records processed",
		},
		[]string{"source", "destination", "status"},
	)

	// ProcessingLatency tracks processing latency in nanoseconds
	ProcessingLatency = promauto.NewHistogramVec(
		prometheus.HistogramOpts{
			Name: "nebula_processing_latency_nanoseconds",
			Help: "Processing latency in nanoseconds",
			Buckets: []float64{
				100,
				1000,
				10000,
				100000,
				1e6,
				1e7,
				1e8,
				1e9,
			},
		},
		[]string{"operation", "source", "destination"},
	)

	// MemoryAllocated tracks memory allocations
	MemoryAllocated = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "nebula_memory_allocated_bytes",
			Help: "Memory allocated in bytes",
		},
		[]string{"component"},
	)

	// ActiveConnections tracks active connections
	ActiveConnections = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "nebula_active_connections",
			Help: "Number of active connections",
		},
		[]string{"type", "destination"},
	)

	// QueueDepth tracks queue depths
	QueueDepth = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "nebula_queue_depth",
			Help: "Current queue depth",
		},
		[]string{"queue_name"},
	)

	// GCPauseDuration tracks GC pause durations
	GCPauseDuration = promauto.NewHistogram(
		prometheus.HistogramOpts{
			Name: "nebula_gc_pause_duration_nanoseconds",
			Help: "GC pause duration in nanoseconds",
			Buckets: []float64{
				1e3,
				1e4,
				1e5,
				1e6,
				1e7,
				1e8,
			},
		},
	)

	// Throughput tracks records per second
	Throughput = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: "nebula_throughput_records_per_second",
			Help: "Current throughput in records per second",
		},
		[]string{"source", "destination"},
	)

	// AllocationRate tracks memory allocation rate
	AllocationRate = promauto.NewGauge(
		prometheus.GaugeOpts{
			Name: "nebula_memory_allocation_rate_bytes_per_second",
			Help: "Memory allocation rate in bytes per second",
		},
	)
)

Functions

This section is empty.

Types

type Collector

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

Collector is a metrics collector interface

func NewCollector

func NewCollector(name string) *Collector

NewCollector creates a new metrics collector for a component

func (*Collector) GetAll

func (c *Collector) GetAll() map[string]interface{}

GetAll returns all current metric values

func (*Collector) Record

func (c *Collector) Record(name string, value interface{})

Record records a metric value

func (*Collector) RecordCounter

func (c *Collector) RecordCounter(name string, value float64, labels ...string)

RecordCounter records a counter metric

func (*Collector) RecordGauge

func (c *Collector) RecordGauge(name string, value float64, labels ...string)

RecordGauge records a gauge metric

func (*Collector) RecordHistogram

func (c *Collector) RecordHistogram(name string, value float64, labels ...string)

RecordHistogram records a histogram metric

func (*Collector) StartTime

func (c *Collector) StartTime() time.Time

StartTime returns when the collector was created

type LatencyTracker

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

LatencyTracker provides percentile tracking

func NewLatencyTracker

func NewLatencyTracker(maxSize int) *LatencyTracker

NewLatencyTracker creates a new latency tracker

func (*LatencyTracker) GetPercentile

func (l *LatencyTracker) GetPercentile(p float64) time.Duration

GetPercentile returns the percentile value (0-100)

func (*LatencyTracker) Record

func (l *LatencyTracker) Record(d time.Duration)

Record records a latency value

type ThroughputTracker

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

ThroughputTracker tracks throughput over time

func NewThroughputTracker

func NewThroughputTracker(source, destination string) *ThroughputTracker

NewThroughputTracker creates a new throughput tracker

func (*ThroughputTracker) GetAndReset

func (t *ThroughputTracker) GetAndReset() float64

GetAndReset returns the current throughput and resets the counter

func (*ThroughputTracker) Increment

func (t *ThroughputTracker) Increment(n int64)

Increment increments the counter

type Timer

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

Timer provides a simple timing mechanism

func NewTimer

func NewTimer(name string) *Timer

NewTimer creates a new timer

func (*Timer) Stop

func (t *Timer) Stop() time.Duration

Stop stops the timer and records the duration

Jump to

Keyboard shortcuts

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