Documentation
¶
Overview ¶
Package runtimeobs resolves durable Session identity to provider-owned Runtime observations. It is telemetry only and never owns Runtime lifecycle decisions.
Index ¶
- Variables
- type CollectionSource
- type ExportOptions
- type ExportRecord
- type Exporter
- type HistoryObserver
- type Instance
- type Mode
- type Observation
- type OwnershipChecker
- type PageOptions
- type Sample
- type Sampler
- type SamplerOptions
- type Service
- func (s *Service) Close(ctx context.Context) error
- func (s *Service) ObserveSession(ctx context.Context, tenantID, sessionID string) (Observation, error)
- func (s *Service) ObserveSessionForHistory(ctx context.Context, tenantID, sessionID string, owner OwnershipChecker, ...) (Observation, error)
- func (s *Service) ObserveSessions(ctx context.Context, sessions []SessionIdentity, options PageOptions) ([]Observation, []error)
- func (s *Service) ObserveSessionsForHistory(ctx context.Context, sessions []SessionIdentity, owner OwnershipChecker, ...) ([]Observation, []error)
- type ServiceOption
- type SessionIdentity
- type SessionLister
- type SessionPage
- type Source
- type Status
- type SweepResult
- type Target
- type TargetResolver
- type TokenUsage
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotRunning = errors.New("Runtime is not running") )
Functions ¶
This section is empty.
Types ¶
type CollectionSource ¶
type CollectionSource string
const ( CollectionSourceOnRead CollectionSource = "on_read" CollectionSourcePeriodic CollectionSource = "periodic" )
type ExportOptions ¶
type ExportRecord ¶
type ExportRecord struct {
TenantID string
SessionID string
EnvironmentID string
AllocationID string
Mode Mode
ProviderType string
Status Status
Reason string
CollectionSource CollectionSource
ResolvedAt time.Time
SourceDuration time.Duration
Sample *Sample
TokenUsage *TokenUsage
}
ExportRecord is the provider-neutral, sanitized history handoff produced after Runtime identity and a current observation result have been validated. It intentionally excludes provider receipts, native identifiers, and raw provider errors.
type Exporter ¶
type Exporter interface {
Export(context.Context, ExportRecord) error
}
Exporter persists or forwards sanitized Runtime observation records. Core invokes exporters only through a bounded asynchronous dispatcher, so an exporter outage cannot fail or block the current-observation request path.
type HistoryObserver ¶
type HistoryObserver interface {
ObserveSessionsForHistory(context.Context, []SessionIdentity, OwnershipChecker, PageOptions) ([]Observation, []error)
}
HistoryObserver reads one listed page with bounded concurrency.
type Instance ¶
type Instance struct {
AllocationID string
ProviderKey string
DeviceID string
ConnectionGeneration string
AllocationState string
AllocationCreatedAt time.Time
ComputePhase string
// ProviderState is the provider-owned, persisted compute receipt. It is
// internal-only and lets an observation source verify the exact current
// incarnation without accepting provider identifiers from the caller.
ProviderState json.RawMessage
}
Instance is one provider-owned Runtime incarnation. AllocationID is present for managed compute. DeviceID and ConnectionGeneration are reserved for a future authenticated self-hosted telemetry source.
type Observation ¶
type OwnershipChecker ¶
type PageOptions ¶
type PageOptions struct {
// Concurrency bounds identity resolution and per-target provider reads.
Concurrency int
// SourceTimeout bounds each provider read.
SourceTimeout time.Duration
}
PageOptions bounds one page of current reads.
type Sample ¶
type Sample struct {
ObservedAt time.Time
StartedAt *time.Time
CPUUsageSecondsTotal *float64
CPUCapacityCores *float64
// CPUUtilizationRatio is a provider-reported share of CPUCapacityCores, for
// providers such as E2B that report a current rate instead of cumulative time.
// Newer fields are omitted when absent: node frames carry Sample, and an
// older Core decodes them with unknown fields disallowed.
CPUUtilizationRatio *float64 `json:",omitempty"`
MemoryUsageBytes *uint64
MemoryLimitBytes *uint64
// Disk values are current usage and capacity of the Runtime's disk, when
// the provider reports them (E2B). They are not part of the /v1 projection.
DiskUsageBytes *uint64 `json:",omitempty"`
DiskLimitBytes *uint64 `json:",omitempty"`
}
Sample contains provider-neutral cumulative counters and current gauges. Pointer fields distinguish an observed zero from an unavailable measurement.
type Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
func NewSampler ¶
func NewSampler(lister SessionLister, observer HistoryObserver, owner OwnershipChecker, options SamplerOptions) (*Sampler, error)
type SamplerOptions ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(resolver TargetResolver, source func(context.Context) (Source, string, error), options ...ServiceOption) (*Service, error)
NewService reads managed Runtimes through source, which returns the Sandbox Provider of the deployment's current selection and its registered kind, or ErrUnavailable while none is selected.
func (*Service) Close ¶
Close drains pending history handoffs within ctx. Current-observation callers may keep using a Service without an exporter; Close is then a no-op.
func (*Service) ObserveSession ¶
func (*Service) ObserveSessionForHistory ¶
func (s *Service) ObserveSessionForHistory(ctx context.Context, tenantID, sessionID string, owner OwnershipChecker, sourceTimeout time.Duration) (Observation, error)
ObserveSessionForHistory performs the same provider-neutral current read, but marks its export as deployment-periodic so coverage queries can distinguish it from user-triggered API reads. It has no lifecycle side effects.
func (*Service) ObserveSessions ¶
func (s *Service) ObserveSessions(ctx context.Context, sessions []SessionIdentity, options PageOptions) ([]Observation, []error)
ObserveSessions observes one page of Sessions, reading each running target exactly as ObserveSession reads it. Results and errors are aligned with sessions.
func (*Service) ObserveSessionsForHistory ¶
func (s *Service) ObserveSessionsForHistory(ctx context.Context, sessions []SessionIdentity, owner OwnershipChecker, options PageOptions) ([]Observation, []error)
ObserveSessionsForHistory is the periodic-collection form of ObserveSessions.
type ServiceOption ¶
type ServiceOption func(*serviceOptions) error
func WithExporter ¶
func WithExporter(exporter Exporter, options ExportOptions) ServiceOption
WithExporter enables best-effort history export. Queue saturation drops the newest handoff; it never changes the Runtime observation result.
type SessionIdentity ¶
type SessionIdentity struct {
TenantID, SessionID string
}
type SessionLister ¶
type SessionPage ¶
type SessionPage struct {
Sessions []SessionIdentity
NextCursor string
}
type Source ¶
type Source interface {
providercontract.Declared
Observe(context.Context, Target) (Sample, error)
}
Source is the observation half of a Sandbox Provider, which services/core/internal/sandbox/sandbox_provider.go defines.
type SweepResult ¶
type SweepResult struct {
StartedAt, CompletedAt time.Time
Listed, Observed, Failed int
Complete bool
}
SweepResult is deliberately low-cardinality. It reports collection coverage without exposing tenant, Session, allocation, provider-native, or error text.
type Target ¶
type Target struct {
TenantID, SessionID, EnvironmentID string
Mode Mode
Instance Instance
// TokenUsage is the latest measured Core Session usage: every recorded
// root Turn snapshot, active Turns included. Unlike public Session usage it
// is not withheld until every Turn ends. It is Session-scoped and
// deliberately independent of the provider Runtime.
TokenUsage *TokenUsage
}
Target binds telemetry to durable Core identity. A Session is not itself a process or sandbox, so callers must retain the complete binding.
type TargetResolver ¶
type TokenUsage ¶
TokenUsage contains cumulative measured Session counters. Missing native measurements remain nil at the Target level and are never treated as zero.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package otlpexporter sends sanitized Runtime observation records to an operator-configured OTLP/HTTP metrics endpoint.
|
Package otlpexporter sends sanitized Runtime observation records to an operator-configured OTLP/HTTP metrics endpoint. |