api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(store *storage.DB, hub *ws.Hub, fwd *forwarder.Forwarder) http.Handler

func NewRouterFull

func NewRouterFull(store *storage.DB, hub *ws.Hub, fwd *forwarder.Forwarder, mfs *coverage.Manifests, settings *SettingsService) http.Handler

NewRouterFull is the canonical constructor. Pass nil for any optional dependency (manifests, settings) to disable the corresponding endpoints.

func NewRouterWithManifests

func NewRouterWithManifests(store *storage.DB, hub *ws.Hub, fwd *forwarder.Forwarder, mfs *coverage.Manifests) http.Handler

NewRouterWithManifests is a back-compat shim — prefer NewRouterFull.

Types

type DiffResult

type DiffResult struct {
	Baseline      DiffSessionInfo `json:"baseline"`
	Compare       DiffSessionInfo `json:"compare"`
	Summary       DiffSummary     `json:"summary"`
	Spans         []DiffSpan      `json:"spans"`
	BaselineSpans []*storage.Span `json:"baseline_spans"`
	CompareSpans  []*storage.Span `json:"compare_spans"`
}

type DiffSessionInfo

type DiffSessionInfo struct {
	SessionID       string `json:"session_id"`
	Label           string `json:"label"`
	TotalDurationNs int64  `json:"total_duration_ns"`
	SpanCount       int    `json:"span_count"`
	DBCalls         int    `json:"db_calls"`
}

type DiffSpan

type DiffSpan struct {
	Name               string  `json:"name"`
	ServiceName        string  `json:"service_name"`
	Status             string  `json:"status"` // added|removed|changed|unchanged
	BaselineDurationNs int64   `json:"baseline_duration_ns"`
	CompareDurationNs  int64   `json:"compare_duration_ns"`
	DeltaPct           float64 `json:"delta_pct"`
	Depth              int     `json:"depth"`
}

type DiffSummary

type DiffSummary struct {
	DurationDeltaNs  int64   `json:"duration_delta_ns"`
	DurationDeltaPct float64 `json:"duration_delta_pct"`
	SpansAdded       int     `json:"spans_added"`
	SpansRemoved     int     `json:"spans_removed"`
	DBCallDelta      int     `json:"db_call_delta"`
}

type MetricSeriesPoint

type MetricSeriesPoint struct {
	TimestampNs int64   `json:"timestamp_ns"`
	Value       float64 `json:"value"`
	Percentile  string  `json:"percentile,omitempty"`
}

MetricSeriesResponse is the shape returned by GET /api/metrics/series. Histogram percentiles arrive bucketed into p50/p95/p99 slices on the client; gauge/counter populate only Value.

type MetricSeriesResponse

type MetricSeriesResponse struct {
	Name        string              `json:"name"`
	ServiceName string              `json:"service_name"`
	Type        string              `json:"type"`
	Unit        string              `json:"unit"`
	Description string              `json:"description"`
	Points      []MetricSeriesPoint `json:"points"`
	// Traces is populated only when ?with_traces=1 is passed. Always
	// materialized as [] (never null) so the frontend type can be
	// non-optional and rendering branches stay flat.
	Traces []*storage.TraceOverlay `json:"traces"`
}

type Router

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

type SettingsResponse

type SettingsResponse struct {
	Port          int      `json:"port"`
	DBPath        string   `json:"db_path"`
	RetentionDays int      `json:"retention_days"`
	MaxSessions   int      `json:"max_sessions"`
	MaxDBSizeMB   int      `json:"max_db_size_mb"`
	OTLPGRPCPort  int      `json:"otlp_grpc_port"`
	OTLPHTTPPort  int      `json:"otlp_http_port"`
	NoBrowser     bool     `json:"no_browser"`
	Forward       []string `json:"forward"`
	BindAddress   string   `json:"bind_address"`
	ForwardSample float64  `json:"forward_sample"`

	Runtime SettingsRuntime `json:"runtime"`
}

SettingsResponse is the JSON shape returned by GET /api/settings. Persistable fields live at the top level; read-only info is under Runtime.

type SettingsRuntime

type SettingsRuntime struct {
	PID          int    `json:"pid"`
	UptimeNs     int64  `json:"uptime_ns"`
	Version      string `json:"version"`
	ConfigPath   string `json:"config_path"`
	OTLPGRPCPort int    `json:"otlp_grpc_port"`
	OTLPHTTPPort int    `json:"otlp_http_port"`
	DBSizeBytes  int64  `json:"db_size_bytes"`
}

SettingsRuntime is everything the UI shows but never writes back.

type SettingsService

type SettingsService struct {
	Viper        *viper.Viper
	ConfigPath   string // path to the file Save() will write
	Version      string
	StartedAt    time.Time
	OTLPGRPCPort int
	OTLPHTTPPort int
}

SettingsService is everything the settings endpoints need that isn't already on the Router (storage, hub, etc.). main.go builds one of these after viper has been bootstrapped and hands it to Router.SetSettingsService.

type SettingsUpdate

type SettingsUpdate struct {
	Port          *int      `json:"port,omitempty"`
	DBPath        *string   `json:"db_path,omitempty"`
	RetentionDays *int      `json:"retention_days,omitempty"`
	MaxSessions   *int      `json:"max_sessions,omitempty"`
	MaxDBSizeMB   *int      `json:"max_db_size_mb,omitempty"`
	OTLPGRPCPort  *int      `json:"otlp_grpc_port,omitempty"`
	OTLPHTTPPort  *int      `json:"otlp_http_port,omitempty"`
	NoBrowser     *bool     `json:"no_browser,omitempty"`
	Forward       *[]string `json:"forward,omitempty"`
	BindAddress   *string   `json:"bind_address,omitempty"`
	ForwardSample *float64  `json:"forward_sample,omitempty"`
}

SettingsUpdate is the writable subset accepted by PUT /api/settings. Pointer fields let clients send partial updates — nil = "leave as-is".

Jump to

Keyboard shortcuts

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