diagnostics

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceAgent   = "agent"
	SourceDesktop = "desktop"

	TraceHeader   = "X-Redeven-Debug-Trace-ID"
	EnabledHeader = "X-Redeven-Debug-Console-Enabled"

	ScopeDesktopHTTP      = "desktop_http"
	ScopeDesktopLifecycle = "desktop_lifecycle"
	ScopeLocalUIHTTP      = "localui_http"
	ScopeLocalAPI         = "local_api"
	ScopeDirectSession    = "direct_session"
	ScopeCodexBridge      = "codex_bridge"
)

Variables

This section is empty.

Functions

func EnabledForLogLevel

func EnabledForLogLevel(level string) bool

func EventKey

func EventKey(event Event) string

func NewTraceID

func NewTraceID() string

func ShouldMarkSlow

func ShouldMarkSlow(scope string, kind string, durationMs int64) bool

func TraceIDFromContext

func TraceIDFromContext(ctx context.Context) string

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

Types

type Event

type Event struct {
	CreatedAt  string         `json:"created_at"`
	Source     string         `json:"source,omitempty"`
	Scope      string         `json:"scope"`
	Kind       string         `json:"kind"`
	TraceID    string         `json:"trace_id,omitempty"`
	Method     string         `json:"method,omitempty"`
	Path       string         `json:"path,omitempty"`
	StatusCode int            `json:"status_code,omitempty"`
	DurationMs int64          `json:"duration_ms,omitempty"`
	Slow       bool           `json:"slow,omitempty"`
	Message    string         `json:"message,omitempty"`
	Detail     map[string]any `json:"detail,omitempty"`
}

func ListSource

func ListSource(stateDir string, source string, limit int) ([]Event, error)

func MergeEvents

func MergeEvents(limit int, sources ...[]Event) []Event

type Options

type Options struct {
	Logger     *slog.Logger
	StateDir   string
	Source     string
	MaxBytes   int64
	MaxBackups int
	Disabled   bool
}

type Snapshot

type Snapshot struct {
	RecentEvents []Event       `json:"recent_events"`
	SlowSummary  []SummaryItem `json:"slow_summary"`
	Stats        Stats         `json:"stats"`
}

func BuildSnapshot

func BuildSnapshot(recentLimit int, summaryLimit int, sources ...[]Event) Snapshot

type Stats

type Stats struct {
	TotalEvents   int `json:"total_events"`
	AgentEvents   int `json:"agent_events"`
	DesktopEvents int `json:"desktop_events"`
	SlowEvents    int `json:"slow_events"`
	TraceCount    int `json:"trace_count"`
}

func BuildStats

func BuildStats(events []Event) Stats

type StatusWriter

type StatusWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewStatusWriter

func NewStatusWriter(w http.ResponseWriter) *StatusWriter

func (*StatusWriter) Flush

func (w *StatusWriter) Flush()

func (*StatusWriter) Hijack

func (w *StatusWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*StatusWriter) Push

func (w *StatusWriter) Push(target string, opts *http.PushOptions) error

func (*StatusWriter) ReadFrom

func (w *StatusWriter) ReadFrom(r io.Reader) (int64, error)

func (*StatusWriter) StatusCode

func (w *StatusWriter) StatusCode() int

func (*StatusWriter) Unwrap

func (w *StatusWriter) Unwrap() http.ResponseWriter

func (*StatusWriter) Write

func (w *StatusWriter) Write(body []byte) (int, error)

func (*StatusWriter) WriteHeader

func (w *StatusWriter) WriteHeader(statusCode int)

type Store

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

func New

func New(opts Options) (*Store, error)

func (*Store) Append

func (s *Store) Append(e Event)

func (*Store) Enabled

func (s *Store) Enabled() bool

func (*Store) List

func (s *Store) List(limit int) ([]Event, error)

func (*Store) SetEnabled

func (s *Store) SetEnabled(enabled bool)

type SummaryItem

type SummaryItem struct {
	Scope          string `json:"scope"`
	Kind           string `json:"kind,omitempty"`
	Method         string `json:"method,omitempty"`
	Path           string `json:"path,omitempty"`
	Count          int    `json:"count"`
	SlowCount      int    `json:"slow_count"`
	MaxDurationMs  int64  `json:"max_duration_ms"`
	AvgDurationMs  int64  `json:"avg_duration_ms"`
	LastStatusCode int    `json:"last_status_code,omitempty"`
	LastSeenAt     string `json:"last_seen_at,omitempty"`
}

func BuildSlowSummary

func BuildSlowSummary(events []Event, limit int) []SummaryItem

Jump to

Keyboard shortcuts

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