monitoring

package
v0.10.1 Latest Latest
Warning

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

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

Documentation

Overview

Package monitoring provides OpenTelemetry-based observability for Aquarium Fish

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool `json:"enabled"`          // Enable/disable monitoring
	EnableLogs      bool `json:"enable_logs"`      // Enable logs
	EnableMetrics   bool `json:"enable_metrics"`   // Enable metrics
	EnableProfiling bool `json:"enable_profiling"` // Enable profiling
	EnableTracing   bool `json:"enable_tracing"`   // Enable tracing

	OTLPEndpoint   string `json:"otlp_endpoint"`    // OTLP endpoint for traces, metrics, logs
	PyroscopeURL   string `json:"pyroscope_url"`    // Pyroscope URL for profiling
	FileExportPath string `json:"file_export_path"` // Path to export telemetry data to files (when no remote endpoints configured)

	SampleRate        float64       `json:"sample_rate"`        // Trace sampling rate (0.0 to 1.0)
	MetricsInterval   util.Duration `json:"metrics_interval"`   // Metrics collection interval
	ProfilingInterval util.Duration `json:"profiling_interval"` // Profiling file export interval

	// Will be set automatically from fish
	ServiceName    string `json:"service_name"`    // Service name for telemetry
	ServiceVersion string `json:"service_version"` // Service version

	NodeUID      string `json:"node_uid"`      // Node UID for resource attributes
	NodeName     string `json:"node_name"`     // Node name for resource attributes
	NodeLocation string `json:"node_location"` // Node location for resource attributes
}

Config defines monitoring configuration

func (*Config) InitDefaults

func (c *Config) InitDefaults()

DefaultConfig returns default monitoring configuration

type FileLogExporter

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

FileLogExporter implements a file-based log exporter

func NewFileLogExporter

func NewFileLogExporter(filename string) (*FileLogExporter, error)

NewFileLogExporter creates a new file-based log exporter

func (*FileLogExporter) Export

func (f *FileLogExporter) Export(_ context.Context, records []otellog.Record) error

Export exports logs to the file

func (*FileLogExporter) ForceFlush

func (f *FileLogExporter) ForceFlush(_ context.Context) error

ForceFlush forces a flush of the log exporter

func (*FileLogExporter) Shutdown

func (f *FileLogExporter) Shutdown(_ context.Context) error

Shutdown closes the file

type FileMetricExporter

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

FileMetricExporter implements a file-based metric exporter

func NewFileMetricExporter

func NewFileMetricExporter(filename string) (*FileMetricExporter, error)

NewFileMetricExporter creates a new file-based metric exporter

func (*FileMetricExporter) Shutdown

func (f *FileMetricExporter) Shutdown(_ context.Context) error

Shutdown closes the file

func (*FileMetricExporter) WriteMetrics

func (f *FileMetricExporter) WriteMetrics(metricsData map[string]any) error

WriteMetrics writes metrics data to the file

type FileTraceExporter

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

FileTraceExporter implements a file-based trace exporter

func NewFileTraceExporter

func NewFileTraceExporter(filename string) (*FileTraceExporter, error)

NewFileTraceExporter creates a new file-based trace exporter

func (*FileTraceExporter) ExportSpans

func (f *FileTraceExporter) ExportSpans(_ context.Context, spans []trace.ReadOnlySpan) error

ExportSpans exports spans to the file

func (*FileTraceExporter) Shutdown

func (f *FileTraceExporter) Shutdown(_ context.Context) error

Shutdown closes the file

type Metrics

type Metrics struct {

	// New metrics
	RPCRequestDuration        metric.Float64Histogram
	RPCRequestCount           metric.Int64Counter
	RPCRequestErrors          metric.Int64Counter
	RPCActiveRequests         metric.Int64UpDownCounter
	ApplicationStateChanges   metric.Int64Counter
	ApplicationCreations      metric.Int64Counter
	ApplicationDeallocations  metric.Int64Counter
	ApplicationsByState       metric.Int64Gauge
	ApplicationProcessingTime metric.Float64Histogram
	DatabaseOperationDuration metric.Float64Histogram
	DatabaseOperationCount    metric.Int64Counter
	DatabaseErrors            metric.Int64Counter
	DatabaseActiveConnections metric.Int64UpDownCounter
	SystemCPUUsage            metric.Float64Gauge
	SystemMemoryUsage         metric.Float64Gauge
	SystemDiskUsage           metric.Float64Gauge
	SystemNetworkRxBytes      metric.Int64Counter
	SystemNetworkTxBytes      metric.Int64Counter
	GoGoroutines              metric.Int64Gauge
	GoMemoryHeap              metric.Int64Gauge
	GoMemoryStack             metric.Int64Gauge
	GoGCCycles                metric.Int64Counter
	// contains filtered or unexported fields
}

Metrics holds all monitoring metrics for Aquarium Fish

func NewMetrics

func NewMetrics(meter metric.Meter) (*Metrics, error)

NewMetrics creates a new metrics collection

func (*Metrics) CollectRuntimeMetrics

func (m *Metrics) CollectRuntimeMetrics(ctx context.Context)

CollectRuntimeMetrics collects and records Go runtime metrics

func (*Metrics) CollectSystemMetrics

func (m *Metrics) CollectSystemMetrics(ctx context.Context)

CollectSystemMetrics collects and records system metrics

func (*Metrics) RecordAPIRequest

func (m *Metrics) RecordAPIRequest(ctx context.Context, method, endpoint, status string, duration time.Duration)

RecordAPIRequest records an API request

func (*Metrics) RecordAllocation

func (m *Metrics) RecordAllocation(ctx context.Context, driver, status string)

RecordAllocation records an application allocation

func (*Metrics) RecordApplicationCreation

func (m *Metrics) RecordApplicationCreation(ctx context.Context, appUID, labelUID, userID string)

RecordApplicationCreation records application creation

func (*Metrics) RecordApplicationDeallocation

func (m *Metrics) RecordApplicationDeallocation(ctx context.Context, appUID, userID string)

RecordApplicationDeallocation records application deallocation

func (*Metrics) RecordApplicationProcessingTime

func (m *Metrics) RecordApplicationProcessingTime(ctx context.Context, appUID string, fromState, toState typesv2.ApplicationState_Status, duration time.Duration)

RecordApplicationProcessingTime records how long it takes to process applications through states

func (*Metrics) RecordApplicationStateChange

func (m *Metrics) RecordApplicationStateChange(ctx context.Context, appUID string, fromState, toState typesv2.ApplicationState_Status, userID string)

RecordApplicationStateChange records application state changes

func (*Metrics) RecordApplicationsByState

func (m *Metrics) RecordApplicationsByState(ctx context.Context, state typesv2.ApplicationState_Status, count int64)

RecordApplicationsByState records the current count of applications by state

func (*Metrics) RecordDatabaseActiveConnections

func (m *Metrics) RecordDatabaseActiveConnections(ctx context.Context, delta int64)

RecordDatabaseActiveConnections tracks active database connections

func (*Metrics) RecordDatabaseCompaction

func (m *Metrics) RecordDatabaseCompaction(ctx context.Context)

RecordDatabaseCompaction records a database compaction

func (*Metrics) RecordDatabaseOperation

func (m *Metrics) RecordDatabaseOperation(ctx context.Context, operation, status string, duration time.Duration)

RecordDatabaseOperation records a database operation

func (*Metrics) RecordDeallocation

func (m *Metrics) RecordDeallocation(ctx context.Context, driver string)

RecordDeallocation records an application deallocation

func (*Metrics) RecordDriverOperation

func (m *Metrics) RecordDriverOperation(ctx context.Context, driver, operation, status string)

RecordDriverOperation records a driver operation

func (*Metrics) RecordElectionRound

func (m *Metrics) RecordElectionRound(ctx context.Context, outcome string)

RecordElectionRound records an election round

func (*Metrics) RecordRPCActiveRequest

func (m *Metrics) RecordRPCActiveRequest(ctx context.Context, method string, delta int64)

RecordRPCActiveRequest tracks active requests

func (*Metrics) RecordRPCRequest

func (m *Metrics) RecordRPCRequest(ctx context.Context, method string, duration time.Duration, success bool, userID string)

RecordRPCRequest records metrics for an RPC request

func (*Metrics) StartCollection

func (m *Metrics) StartCollection(ctx context.Context, interval time.Duration)

StartCollection starts automatic metrics collection

func (*Metrics) StopCollection

func (m *Metrics) StopCollection()

StopCollection stops automatic metrics collection

func (*Metrics) UpdateAWSInstanceMetrics

func (m *Metrics) UpdateAWSInstanceMetrics(ctx context.Context, instanceID string, cpuPercent, diskPercent float64, networkBytes int64)

UpdateAWSInstanceMetrics updates AWS instance metrics

func (*Metrics) UpdateAWSPoolMetrics

func (m *Metrics) UpdateAWSPoolMetrics(ctx context.Context, poolName string, size, usage int64)

UpdateAWSPoolMetrics updates AWS pool metrics

func (*Metrics) UpdateCertificateDirectory

func (m *Metrics) UpdateCertificateDirectory(ctx context.Context, certDir string)

UpdateCertificateDirectory scans a directory for certificates and updates expiry metrics

func (*Metrics) UpdateCertificateExpiry

func (m *Metrics) UpdateCertificateExpiry(ctx context.Context, certType, certPath string)

UpdateCertificateExpiry updates certificate expiry metrics

func (*Metrics) UpdateDatabaseStats

func (m *Metrics) UpdateDatabaseStats(ctx context.Context, size, keys int64)

UpdateDatabaseStats updates database statistics

func (*Metrics) UpdateRPCChannelLoad

func (m *Metrics) UpdateRPCChannelLoad(ctx context.Context, channelName string, load int64)

UpdateRPCChannelLoad updates RPC channel load metrics

func (*Metrics) UpdateRPCConnections

func (m *Metrics) UpdateRPCConnections(ctx context.Context, connections int64)

UpdateRPCConnections updates RPC connection count

func (*Metrics) UpdateStreamingClients

func (m *Metrics) UpdateStreamingClients(ctx context.Context, clients int64)

UpdateStreamingClients updates streaming client count

type Monitor

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

Monitor represents the monitoring system

func Initialize

func Initialize(ctx context.Context, config *Config) (*Monitor, error)

Initialize sets up OpenTelemetry monitoring

func (*Monitor) GetMeter

func (m *Monitor) GetMeter() otelmetric.Meter

GetMeter returns the OpenTelemetry meter

func (*Monitor) GetMetrics

func (m *Monitor) GetMetrics() *Metrics

GetMetrics returns the metrics collection

func (*Monitor) GetPrometheusHandler

func (m *Monitor) GetPrometheusHandler() *prometheus.Exporter

GetPrometheusHandler returns the Prometheus HTTP handler

func (*Monitor) GetTracer

func (m *Monitor) GetTracer() oteltrace.Tracer

GetTracer returns the OpenTelemetry tracer

func (*Monitor) IsEnabled

func (m *Monitor) IsEnabled() bool

IsEnabled returns whether monitoring is enabled

func (*Monitor) RecordMetric

func (m *Monitor) RecordMetric(_ context.Context, _ string, _ float64, _ ...attribute.KeyValue)

RecordMetric records a metric value

func (*Monitor) Shutdown

func (m *Monitor) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the monitoring system

Jump to

Keyboard shortcuts

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