telemetry

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactSecret

func RedactSecret(value string) string

RedactSecret sanitizes strings containing potential tokens or sensitive key material.

Types

type Event

type Event struct {
	Timestamp string         `json:"time"`
	Level     Level          `json:"level"`
	Event     string         `json:"event"`
	Message   string         `json:"message,omitempty"`
	Fields    map[string]any `json:"fields,omitempty"`
}

Event is a structured log entry emitted by r1s daemon or client. Secret fields (keys, tokens, identities) are strictly redacted before emission.

type Level

type Level string

Level represents log severity level.

const (
	LevelDebug Level = "DEBUG"
	LevelInfo  Level = "INFO"
	LevelWarn  Level = "WARN"
	LevelError Level = "ERROR"
)

type Logger

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

Logger formats and outputs structured events in JSON or logfmt-style lines.

func NewLogger

func NewLogger(output io.Writer, asJSON bool) *Logger

NewLogger constructs a structured logger writing to output.

func (*Logger) Error

func (l *Logger) Error(event, message string, fields map[string]any)

Error logs an ERROR level event.

func (*Logger) Info

func (l *Logger) Info(event, message string, fields map[string]any)

Info logs an INFO level event.

func (*Logger) IsJSON

func (l *Logger) IsJSON() bool

IsJSON reports whether this logger outputs in JSON format.

func (*Logger) Log

func (l *Logger) Log(level Level, event, message string, fields map[string]any)

Log emits a structured log event with redacted fields.

func (*Logger) Warn

func (l *Logger) Warn(event, message string, fields map[string]any)

Warn logs a WARN level event.

type Metrics

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

Metrics manages the Prometheus registry and metric collectors for an r1s allocator. Label values are strictly bounded to prevent cardinality explosion:

  • resource_class: operator-configured resource classes (e.g. "default", "gpu") plus the allocator's fixed "__unconfigured__" fallback
  • phase: protocol execution phases (e.g. "running", "completed", "failed")
  • reason: categorical rejection/error codes (e.g. "CAPACITY", "INCOMPATIBLE", "ADMISSION", "UNAUTHORIZED", "NOT_FOUND", "EXPIRED", "CONFLICT")

Dynamic runtime IDs, message IDs, hashes, join tokens, and container output are NEVER used as labels.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics constructs and registers allocator metrics on a dedicated Prometheus registry.

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler returns an http.Handler that serves the registered metrics in Prometheus exposition format.

func (*Metrics) ObserveDispatchLatency

func (m *Metrics) ObserveDispatchLatency(command string, duration time.Duration)

ObserveDispatchLatency records the duration of command dispatch handling.

func (*Metrics) ObserveExecutionTerminal

func (m *Metrics) ObserveExecutionTerminal(resourceClass, phase string, duration time.Duration)

ObserveExecutionTerminal records an execution transitioning to a terminal phase.

func (*Metrics) ObserveInboundEnvelope

func (m *Metrics) ObserveInboundEnvelope(bytes int)

ObserveInboundEnvelope records an inbound RNS envelope and payload size.

func (*Metrics) ObserveLeaseEviction

func (m *Metrics) ObserveLeaseEviction()

ObserveLeaseEviction records an execution evicted due to lease expiry.

func (*Metrics) ObserveOffer

func (m *Metrics) ObserveOffer(resourceClass string)

ObserveOffer records an issued offer for a resource class.

func (*Metrics) ObserveOutboundEnvelope

func (m *Metrics) ObserveOutboundEnvelope(bytes int)

ObserveOutboundEnvelope records an outbound RNS envelope and payload size.

func (*Metrics) ObserveRejection

func (m *Metrics) ObserveRejection(reason string)

ObserveRejection records a command rejection categorized by reason code.

func (*Metrics) ObserveRequest

func (m *Metrics) ObserveRequest(resourceClass string)

ObserveRequest records an incoming execution request for a resource class.

func (*Metrics) Registry

func (m *Metrics) Registry() *prometheus.Registry

Registry returns the underlying prometheus Registry.

func (*Metrics) SetActiveExecutions

func (m *Metrics) SetActiveExecutions(class string, count int)

SetActiveExecutions updates the current number of non-terminal executions for a class.

func (*Metrics) UpdateCapacity

func (m *Metrics) UpdateCapacity(class string, total, available uint32)

UpdateCapacity gauges sets the configured total and available slots per class.

type Server

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

Server serves Prometheus metrics over HTTP. Failure or disconnection of this server never impacts allocator operation or workload execution.

func StartServer

func StartServer(address string, metrics *Metrics) (*Server, error)

StartServer starts an HTTP metrics exporter on address listening at /metrics. An empty address disables the metrics server and returns nil.

func (*Server) Address

func (s *Server) Address() string

Address returns the listener's network address, useful when listening on :0.

func (*Server) Close

func (s *Server) Close() error

Close stops the HTTP metrics server gracefully.

Jump to

Keyboard shortcuts

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