diagnostics

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package diagnostics provides bounded, native-free application measurements.

Index

Constants

View Source
const SchemaVersion = 1

Variables

This section is empty.

Functions

func ErrorCode

func ErrorCode(err error) string

func SourceState

func SourceState() string

SourceState reports build-time VCS evidence, never the current working tree. An unknown result means the binary contains no vcs.modified build setting.

Types

type Capture

type Capture struct {
	SchemaVersion   int        `json:"schemaVersion"`
	ID              string     `json:"id"`
	Name            string     `json:"name"`
	Workload        string     `json:"workload"`
	Status          string     `json:"status"`
	Identity        Identity   `json:"identity"`
	StartedAt       time.Time  `json:"startedAt"`
	EndedAt         time.Time  `json:"endedAt"`
	DurationSeconds int        `json:"durationSeconds"`
	ElapsedSeconds  float64    `json:"elapsedSeconds"`
	Samples         []Snapshot `json:"samples"`
	Coverage        Health     `json:"coverage"`
	Error           string     `json:"error"`
}

type CaptureRequest

type CaptureRequest struct {
	Name            string `json:"name"`
	DurationSeconds int    `json:"durationSeconds"`
	Workload        string `json:"workload"`
}

type CaptureSummary

type CaptureSummary struct {
	SchemaVersion   int       `json:"schemaVersion"`
	ID              string    `json:"id"`
	Name            string    `json:"name"`
	Workload        string    `json:"workload"`
	Status          string    `json:"status"`
	Identity        Identity  `json:"identity"`
	StartedAt       time.Time `json:"startedAt"`
	EndedAt         time.Time `json:"endedAt"`
	DurationSeconds int       `json:"durationSeconds"`
	ElapsedSeconds  float64   `json:"elapsedSeconds"`
	SampleCount     int       `json:"sampleCount"`
	Coverage        Health    `json:"coverage"`
	Error           string    `json:"error"`
}

CaptureSummary is the bounded polling/list representation. Samples are fetched only by GetCapture.

type Catalog

type Catalog struct {
	SchemaVersion int                `json:"schemaVersion"`
	Identity      Identity           `json:"identity"`
	Metrics       []MetricDescriptor `json:"metrics"`
	Limits        Limits             `json:"limits"`
}

type Client

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

func DiscoverClient

func DiscoverClient(ctx context.Context, options HTTPOptions) (*Client, error)

DiscoverClient verifies private files, process lifetime, profile and authenticated identity.

func NewClient

func NewClient(identity EndpointIdentity, token []byte) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, result any) error

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, input, result any) error

type Comparison

type Comparison struct {
	Baseline   string             `json:"baseline"`
	Candidate  string             `json:"candidate"`
	Compatible bool               `json:"compatible"`
	Warnings   []string           `json:"warnings"`
	Metrics    []MetricComparison `json:"metrics"`
}

type EndpointIdentity

type EndpointIdentity struct {
	SchemaVersion int                         `json:"schemaVersion"`
	WorkspaceID   string                      `json:"workspaceId"`
	InstanceID    string                      `json:"instanceId"`
	Generation    string                      `json:"generation"`
	StateRoot     string                      `json:"stateRoot"`
	Endpoint      string                      `json:"endpoint"`
	Process       devcontract.ProcessIdentity `json:"process"`
	Capabilities  []string                    `json:"capabilities"`
}

EndpointIdentity is public identity proof; it contains no credential references.

type Error

type Error struct {
	Code    string
	Message string
}

Error carries a bounded public category without exposing private storage paths.

func (*Error) Error

func (e *Error) Error() string

type HTTPOptions

type HTTPOptions struct{ RuntimeDirectory, WorkspaceID, StateRoot, Source string }

HTTPOptions selects one profile. Diagnostics never writes control discovery.

type HTTPServer

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

func StartHTTP

func StartHTTP(ctx context.Context, service *Service, options HTTPOptions) (*HTTPServer, error)

StartHTTP starts diagnostics in desktop and development builds alike.

func (*HTTPServer) Close

func (s *HTTPServer) Close() error

func (*HTTPServer) ServeHTTP

func (s *HTTPServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Health

type Health struct {
	Errors        uint64 `json:"errors"`
	Dropped       uint64 `json:"dropped"`
	Gaps          uint64 `json:"gaps"`
	LastError     string `json:"lastError"`
	Complete      bool   `json:"complete"`
	RemoteErrors  uint64 `json:"remoteErrors"`
	RemoteDropped uint64 `json:"remoteDropped"`
}

type History

type History struct {
	Samples []Snapshot `json:"samples"`
	Health  Health     `json:"health"`
}

type Identity

type Identity struct {
	InstanceID string `json:"instanceID"`
	Version    string `json:"version"`
	Revision   string `json:"revision"`
	ConfigID   string `json:"configID"`
	// SessionID identifies one process launch; InstanceID identifies its stable profile.
	SessionID  string `json:"sessionID"`
	Generation string `json:"generation"`
	// SourceState is clean, modified, or unknown. Revision alone is not a source fingerprint.
	SourceState string `json:"sourceState"`
	BuildDate   string `json:"buildDate"`
	// ConfigScope describes exactly which settings ConfigID covers.
	ConfigScope string `json:"configScope"`
}

type Limits

type Limits struct {
	HistorySamples     int   `json:"historySamples"`
	CaptureCount       int   `json:"captureCount"`
	CaptureSeconds     int   `json:"captureSeconds"`
	ConcurrentCaptures int   `json:"concurrentCaptures"`
	DiskBytes          int64 `json:"diskBytes"`
	Metrics            int   `json:"metrics"`
	SeriesPerMetric    int   `json:"seriesPerMetric"`
	SampleBytes        int   `json:"sampleBytes"`
	CaptureBytes       int   `json:"captureBytes"`
}

type Metric

type Metric struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Unit        string  `json:"unit"`
	Kind        string  `json:"kind"`
	Points      []Point `json:"points"`
}

type MetricComparison

type MetricComparison struct {
	Name       string            `json:"name"`
	Unit       string            `json:"unit"`
	Kind       string            `json:"kind"`
	Attributes map[string]string `json:"attributes"`
	Baseline   float64           `json:"baseline"`
	Candidate  float64           `json:"candidate"`
	Delta      float64           `json:"delta"`
	Semantics  string            `json:"semantics"`
	Valid      bool              `json:"valid"`
	Warning    string            `json:"warning"`
}

type MetricDescriptor

type MetricDescriptor struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Unit        string `json:"unit"`
	Kind        string `json:"kind"`
}

MetricDescriptor describes an instrument without copying its collected points.

type Options

type Options struct {
	Directory      string
	Identity       Identity
	Interval       time.Duration
	RemoteInterval time.Duration
	HistoryLimit   int
}

type Point

type Point struct {
	Attributes   map[string]string `json:"attributes"`
	Value        float64           `json:"value"`
	Count        uint64            `json:"count"`
	Sum          float64           `json:"sum"`
	Bounds       []float64         `json:"bounds"`
	BucketCounts []uint64          `json:"bucketCounts"`
	StartTime    time.Time         `json:"startTime"`
}

type Service

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

func New

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

func (*Service) Aggregation

func (*Service) CancelCapture

func (s *Service) CancelCapture(id string) (Capture, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) CompareCaptures

func (s *Service) CompareCaptures(baseline, candidate string) (Comparison, error)

func (*Service) DeleteCapture

func (s *Service) DeleteCapture(id string) error

DeleteCapture removes a finished capture from memory and disk so its slot and storage can be reused. Running captures must be canceled first.

func (*Service) Export

func (s *Service) Export(ctx context.Context, data *metricdata.ResourceMetrics) error

func (*Service) ForceFlush

func (s *Service) ForceFlush(ctx context.Context) error

func (*Service) Fresh

func (s *Service) Fresh() bool

Fresh reports whether collection is current, so scrapes can fail instead of republishing cached values under new scrape timestamps.

func (*Service) GetCapture

func (s *Service) GetCapture(id string) (Capture, error)

func (*Service) GetCatalog

func (s *Service) GetCatalog() Catalog

func (*Service) GetHistory

func (s *Service) GetHistory() History

func (*Service) GetSnapshot

func (s *Service) GetSnapshot() Snapshot

func (*Service) ListCaptures

func (s *Service) ListCaptures() []CaptureSummary

func (*Service) Prometheus

func (s *Service) Prometheus() string

func (*Service) SetConfigID

func (s *Service) SetConfigID(id string)

func (*Service) SetRemote

func (s *Service) SetRemote(exp sdkmetric.Exporter)

func (*Service) SetRemoteEnabled

func (s *Service) SetRemoteEnabled(enabled bool)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

func (*Service) StartCapture

func (s *Service) StartCapture(r CaptureRequest) (Capture, error)

func (*Service) Temporality

type Snapshot

type Snapshot struct {
	SchemaVersion  int       `json:"schemaVersion"`
	Identity       Identity  `json:"identity"`
	Sequence       uint64    `json:"sequence"`
	Timestamp      time.Time `json:"timestamp"`
	ElapsedSeconds float64   `json:"elapsedSeconds"`
	Metrics        []Metric  `json:"metrics"`
	Health         Health    `json:"health"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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