Documentation
¶
Index ¶
- Variables
- func BuildOTLPPayload(name string, duration time.Duration, attrs ...Attribute) ([]byte, error)
- func ClearMetrics() error
- func ContainerName(engine Engine) string
- func DiscoverOTEL(runtime string) map[string]string
- func ExportSpan(name string, duration time.Duration, attrs ...Attribute)
- func Flush()
- func InjectJSONFlag(args []string) []string
- func IsGoTestCmd(args []string) bool
- func NudgeIfSlow(event string, duration, threshold time.Duration, jsonMode bool)
- func ProvisionDashboard() error
- func RecordEvent(event string, duration time.Duration, attrs ...Attribute)
- func RunGoTestWithTelemetry(args []string, dir string, stdout io.Writer, stderr io.Writer) (int, error)
- func SpawnArgs(engine Engine, runtime, persistDir string) ([]string, engineConfig, error)
- type Attribute
- type Engine
- type GoTestEvent
- type MetricEntry
Constants ¶
This section is empty.
Variables ¶
var SupportedEngines = []Engine{EngineJaeger, EngineGrafana}
SupportedEngines lists all valid engine names for user-facing help text.
Functions ¶
func BuildOTLPPayload ¶ added in v0.29.0
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 ¶
ContainerName returns the deterministic container name for a given engine.
func DiscoverOTEL ¶
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
ExportSpan posts a single span to the local OTLP/HTTP endpoint. Fire-and-forget: silently no-ops if the backend is unreachable.
func Flush ¶ added in v0.30.0
func Flush()
Flush waits up to 100ms for pending OTLP exports to complete. Call this before exiting the CLI to ensure telemetry spans aren't dropped.
func InjectJSONFlag ¶ added in v0.30.0
InjectJSONFlag returns a copy of args with -json inserted after "test" if not already present. It returns the original args if -json exists.
func IsGoTestCmd ¶ added in v0.30.0
IsGoTestCmd returns true if the command is "go test".
func NudgeIfSlow ¶ added in v0.29.0
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
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.
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.
type GoTestEvent ¶ added in v0.30.0
type GoTestEvent struct {
Time time.Time `json:"Time"`
Action string `json:"Action"`
Package string `json:"Package"`
Test string `json:"Test"`
Elapsed float64 `json:"Elapsed"` // in seconds
Output string `json:"Output"`
}
GoTestEvent mirrors the test2json output schema.
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.