Documentation
¶
Overview ¶
Package ateomstats holds the usage telemetry both ateom runtimes share: the attribution an ateom retains for each actor, the per-activation state behind every sample, the sampler, and the ate.actor.usage_sampled records. The per-runtime measurement reads live with their runtimes (the cgroup read is only meaningful inside the gVisor worker's cgroup namespace, the guest-agent read only over the micro-VM's vsock).
Index ¶
- func ActorAttributionFromRequest(req attributionSource) resources.ActorAttribution
- func NewStdoutHandler(w io.Writer) *actorevent.AsyncHandler
- func StartSampler(ctx context.Context, interval time.Duration, sweep func(context.Context)) (stop func())
- func StatsSourceLabel(s ateompb.StatsSource) string
- func UsageAttrs(pool Pool, kind string, s *ateompb.WorkloadStatsSample) []slog.Attr
- type Activation
- func (a *Activation) Epoch() int64
- func (a *Activation) Final(write func(measured *ateompb.WorkloadStatsSample))
- func (a *Activation) Initial(s *ateompb.WorkloadStatsSample, write func())
- func (a *Activation) Latest() *ateompb.WorkloadStatsSample
- func (a *Activation) Measure(ctx context.Context, ...) (*ateompb.WorkloadStatsSample, error)
- func (a *Activation) Periodic(s *ateompb.WorkloadStatsSample, write func())
- func (a *Activation) Sampling() bool
- func (a *Activation) Store(s *ateompb.WorkloadStatsSample)
- func (a *Activation) WithEpoch(s *ateompb.WorkloadStatsSample) *ateompb.WorkloadStatsSample
- type Pool
- type UsageEmitter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActorAttributionFromRequest ¶
func ActorAttributionFromRequest(req attributionSource) resources.ActorAttribution
ActorAttributionFromRequest extracts the attribution an ateom should retain for the workload req starts: nothing later in the run, checkpoint, or restore paths carries it, and GetWorkloadStats needs it.
func NewStdoutHandler ¶ added in v0.4.0
func NewStdoutHandler(w io.Writer) *actorevent.AsyncHandler
NewStdoutHandler writes the stdout form of the usage records to w in the ateom's JSON format, at a fixed level so --log-level does not silence it, and off the caller's goroutine.
func StartSampler ¶ added in v0.4.0
func StartSampler(ctx context.Context, interval time.Duration, sweep func(context.Context)) (stop func())
StartSampler calls sweep every interval on its own goroutine and returns a function that stops it and waits for the sweep in flight. Defer the stop after the stdout handler's Close and the LoggerProvider's shutdown, so it runs before them.
func StatsSourceLabel ¶ added in v0.4.0
func StatsSourceLabel(s ateompb.StatsSource) string
StatsSourceLabel maps the wire enum to the ate.stats.source values.
func UsageAttrs ¶ added in v0.4.0
UsageAttrs is the attribute set of ate.actor.usage_sampled for s. The measurements are absent while s has no source, and the peak also when the source reports none.
Types ¶
type Activation ¶ added in v0.4.0
type Activation struct {
// contains filtered or unexported fields
}
Activation is the usage state of one activation of an actor: one Run or Restore. An ateom creates one each time it hosts an actor, so a re-hosted actor starts a new one.
It is safe for concurrent use: the stats reads, the sampler, and the lifecycle records touch it with no lifecycle lock held.
func NewActivation ¶ added in v0.4.0
func NewActivation(now time.Time, resumesCounters bool) *Activation
NewActivation starts an activation at now. resumesCounters is true when the source's CPU counters survive into this activation, as guest-agent counters do in a restored guest; CPU then counts from the first reading. When false the counters start at zero with the activation and count in full.
func (*Activation) Epoch ¶ added in v0.4.0
func (a *Activation) Epoch() int64
Epoch is the unix-nano time the activation began.
func (*Activation) Final ¶ added in v0.4.0
func (a *Activation) Final(write func(measured *ateompb.WorkloadStatsSample))
Final marks the activation ended and runs write with the newest measured sample, or nil when there is none, once: a later call does nothing. write runs under the activation's lock and must not block or call into a.
func (*Activation) Initial ¶ added in v0.4.0
func (a *Activation) Initial(s *ateompb.WorkloadStatsSample, write func())
Initial ends the wait for the initial reading, once: a later call does nothing. With a reading s it stores s and runs write, unless the final record was written first; nil s means the reading failed, and periodic records start without an initial one. write runs under the activation's lock and must not block or call into a.
func (*Activation) Latest ¶ added in v0.4.0
func (a *Activation) Latest() *ateompb.WorkloadStatsSample
Latest is the last stored sample, or nil before the first. Callers must not modify it.
func (*Activation) Measure ¶ added in v0.4.0
func (a *Activation) Measure(ctx context.Context, read func() (*ateompb.WorkloadStatsSample, map[string]uint64, error)) (*ateompb.WorkloadStatsSample, error)
Measure takes a reading with read and returns its sample with the epoch set and the raw CPU replaced by the CPU used in this activation.
read returns the sample and, for a source that sums several counters, each counter's raw CPU by name; nil means the sample's own CPU is the one counter. A counter missing from a reading, as when its read failed, keeps its last value. A counter that decreased restarted, so its new value counts. A counter not seen before, in the first reading or a later one, counts in full only when the activation's counters start at zero. Waiting for another reading to finish ends with ctx.
func (*Activation) Periodic ¶ added in v0.4.0
func (a *Activation) Periodic(s *ateompb.WorkloadStatsSample, write func())
Periodic stores s and runs write if the activation is still between its initial reading and its final record, which a sweep that read s may have raced. write runs under the activation's lock and must not block or call into a.
func (*Activation) Sampling ¶ added in v0.4.0
func (a *Activation) Sampling() bool
Sampling reports whether a sweep should take a periodic reading: after the initial reading and before the final record.
func (*Activation) Store ¶ added in v0.4.0
func (a *Activation) Store(s *ateompb.WorkloadStatsSample)
Store records s as the latest sample, and as the newest measured one when it has numbers, each unless a newer one is already there.
func (*Activation) WithEpoch ¶ added in v0.4.0
func (a *Activation) WithEpoch(s *ateompb.WorkloadStatsSample) *ateompb.WorkloadStatsSample
WithEpoch sets the epoch on s, a sample with no CPU reading, and returns it.
type UsageEmitter ¶ added in v0.4.0
type UsageEmitter struct {
// contains filtered or unexported fields
}
UsageEmitter writes ate.actor.usage_sampled records. A nil *UsageEmitter writes nothing.
func NewUsageEmitter ¶ added in v0.4.0
func NewUsageEmitter(lp *sdklog.LoggerProvider, stdout slog.Handler, pool Pool) *UsageEmitter
NewUsageEmitter writes the records over OTLP through lp, the provider InitLogging returned, or through stdout when lp is nil; with console, both.
func (*UsageEmitter) Emit ¶ added in v0.4.0
func (e *UsageEmitter) Emit(ctx context.Context, kind string, s *ateompb.WorkloadStatsSample)
Emit writes one record for s, dated when s was read. kind is one of the ateattr.StatsKind values.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ateomstatstest records the usage records an ateom writes, for tests.
|
Package ateomstatstest records the usage records an ateom writes, for tests. |