telemetry

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedEngines = []Engine{EngineJaeger, EngineGrafana}

SupportedEngines lists all valid engine names for user-facing help text.

Functions

func BuildOTLPPayload added in v0.29.0

func BuildOTLPPayload(name string, duration time.Duration, attrs ...Attribute) ([]byte, error)

BuildOTLPPayload is exported for testing — constructs the OTLP JSON payload without actually sending it.

func ClearMetrics added in v0.29.0

func ClearMetrics() error

ClearMetrics truncates the local metrics file.

func ContainerName

func ContainerName(engine Engine) string

ContainerName returns the deterministic container name for a given engine.

func DiscoverOTEL

func DiscoverOTEL(runtime string) map[string]string

DiscoverOTEL scans running containers for any devx-managed telemetry backend. It returns the environment variable map to inject into devx shell, including OTEL_EXPORTER_OTLP_ENDPOINT and standard exporter wiring.

func ExportSpan added in v0.29.0

func ExportSpan(name string, duration time.Duration, attrs ...Attribute)

ExportSpan posts a single span to the local OTLP/HTTP endpoint. Fire-and-forget: silently no-ops if the backend is unreachable.

func NudgeIfSlow added in v0.29.0

func NudgeIfSlow(event string, duration, threshold time.Duration, jsonMode bool)

NudgeIfSlow prints an actionable tip to stderr if duration exceeds threshold. Suppressed when jsonMode is true (for --json flag compliance).

func ProvisionDashboard added in v0.29.0

func ProvisionDashboard() error

ProvisionDashboard auto-installs the "devx Build Metrics" dashboard into a running Grafana instance. Fire-and-forget: warns on error but never fatals.

func RecordEvent added in v0.29.0

func RecordEvent(event string, duration time.Duration, attrs ...Attribute)

RecordEvent appends a timestamped duration entry to ~/.devx/metrics.json and opportunistically exports an OTel span to localhost:4318 if a backend is running. Safe for concurrent use (file-level flock). Silently no-ops on any I/O error.

func SpawnArgs

func SpawnArgs(engine Engine, runtime, persistDir string) ([]string, engineConfig, error)

SpawnArgs constructs the container run arguments for the given engine. If persistDir is non-empty, the host directory is bind-mounted into the container to preserve data across restarts.

Types

type Attribute added in v0.29.0

type Attribute struct {
	Key   string
	Value interface{}
}

Attribute is a key-value pair attached to an OTel span.

func Attr added in v0.29.0

func Attr(key string, value interface{}) Attribute

Attr is a convenience constructor for Attribute.

type Engine

type Engine string

Engine represents a supported local telemetry backend.

const (
	EngineJaeger  Engine = "jaeger"
	EngineGrafana Engine = "grafana"
)

type MetricEntry added in v0.29.0

type MetricEntry struct {
	Event      string `json:"event"`
	DurationMs int64  `json:"duration_ms"`
	Timestamp  string `json:"timestamp"`
}

MetricEntry is a single recorded event.

func LoadMetrics added in v0.29.0

func LoadMetrics() []MetricEntry

LoadMetrics reads all metric entries from the local metrics file. Returns an empty slice (not nil) if the file is missing or corrupted.

Jump to

Keyboard shortcuts

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