Documentation
¶
Index ¶
- Constants
- Variables
- func BuildBootstrap(header BootstrapHeader, signals []BootstrapSignal) ([]byte, int64, error)
- func DecodeBootstrap(r io.Reader, onHeader func(BootstrapHeader) error, consume func([]byte) error) (BootstrapHeader, BootstrapTerminal, error)
- func IsCleanMiss(err error) bool
- func SanitizeTitle(title string) string
- func VerifyClosure(roots []string, load func(string) (*callpbv1.Call, error)) (map[string]*callpbv1.Call, error)
- func WriteBootstrapFrame(w io.Writer, kind BootstrapFrameKind, payload []byte) error
- type AgentRevision
- type Bootstrap
- type BootstrapBatch
- type BootstrapFrameKind
- type BootstrapHeader
- type BootstrapResult
- type BootstrapSignal
- type BootstrapTerminal
- type Client
- func (c *Client) Bootstrap(ctx context.Context, traceID string, ...) (BootstrapResult, error)
- func (c *Client) List(ctx context.Context, opts ListOptions) (Page, error)
- func (c *Client) ListAll(ctx context.Context, opts ListOptions) ([]Manifest, error)
- func (c *Client) Logs(ctx context.Context, traceID string, opts StreamOptions, ...) (int64, error)
- func (c *Client) Metrics(ctx context.Context, traceID string, opts StreamOptions, ...) (int64, error)
- func (c *Client) Traces(ctx context.Context, traceID string, opts StreamOptions, ...) (int64, error)
- func (c *Client) Unsealed(ctx context.Context, traceID string) (UnsealedArchive, error)
- type Completion
- type Config
- type ErrorKind
- type Failure
- type FailureKind
- type FinalizeInput
- type HTTPDoer
- type HighWater
- type ListOptions
- type Manager
- func (m *Manager) BeginFinalizing(traceID string) error
- func (m *Manager) BootstrapPath(traceID string) string
- func (m *Manager) Finalize(traceID string, in FinalizeInput) (Manifest, error)
- func (m *Manager) GC() (overage int64, err error)
- func (m *Manager) KeepSet() map[string]bool
- func (m *Manager) List(after, excludeTraceID string, limit int) Page
- func (m *Manager) Manifest(traceID string) (Manifest, error)
- func (m *Manager) MarkIncomplete(traceID string, cause error) error
- func (m *Manager) Register(traceID, mainClientID string) (Manifest, error)
- func (m *Manager) SetTitle(traceID, title string) error
- type Manifest
- type Page
- type RequestError
- type State
- type StreamOptions
- type SubscriptionRevision
- type UnsealedArchive
Constants ¶
const ( DefaultTTL = 7 * 24 * time.Hour DefaultQuota = int64(10 << 30) )
const AgentBootstrapResource = "agent-bootstrap"
AgentBootstrapResource names the agent-restore bootstrap within an archive. It is agent-specific: final agent/subscription control records plus the recipe closure of their snapshots. The OTLP signal streams alongside it are generic telemetry resources.
const BootstrapContentType = "application/vnd.dagger.telemetry.bootstrap"
const ManifestVersion = 4
const MaxBootstrapPayloadSize = 64 << 20
MaxBootstrapPayloadSize bounds the encoded payload of each bootstrap frame.
const MaxTitleRunes = 120
MaxTitleRunes bounds an archive title. Titles come from trace records any session producer can emit, and listings print them to a terminal.
Variables ¶
var ( ErrCleanMiss = errors.New("engine archive clean miss") ErrState = errors.New("engine archive state failure") ErrCorrupt = errors.New("engine archive corruption") ErrTransient = errors.New("engine archive transient failure") )
var ErrBootstrapIncomplete = errors.New("bootstrap stream ended before terminal frame")
ErrBootstrapIncomplete identifies a finite bootstrap response that ended before its terminal frame.
Functions ¶
func BuildBootstrap ¶
func BuildBootstrap(header BootstrapHeader, signals []BootstrapSignal) ([]byte, int64, error)
func DecodeBootstrap ¶
func DecodeBootstrap(r io.Reader, onHeader func(BootstrapHeader) error, consume func([]byte) error) (BootstrapHeader, BootstrapTerminal, error)
DecodeBootstrap requires a header first and a terminal last, rejects trailing bytes, verifies the terminal checksum, calls onHeader before reading any logs frame, and calls consume with each logs frame's payload. EOF before the terminal is an interruption, never a successful finite response.
func IsCleanMiss ¶
IsCleanMiss reports whether the connected engine definitively has no usable archive and a caller may try another source.
func SanitizeTitle ¶
SanitizeTitle reduces a trace-derived title to one bounded, printable line: control and format characters (including bidi overrides) are dropped or turned into spaces, whitespace runs collapse, and long titles are cut with an ellipsis.
func VerifyClosure ¶
func VerifyClosure(roots []string, load func(string) (*callpbv1.Call, error)) (map[string]*callpbv1.Call, error)
VerifyClosure loads the recipe closure of the anchors without evaluating any recipe, failing on a missing or cyclic dependency. The returned payloads are exactly the dependency closure of the anchors.
func WriteBootstrapFrame ¶
func WriteBootstrapFrame(w io.Writer, kind BootstrapFrameKind, payload []byte) error
Types ¶
type AgentRevision ¶
type AgentRevision struct {
Key agentcontrol.Key
Revision int64
}
type BootstrapBatch ¶
type BootstrapBatch struct {
Logs *collogspb.ExportLogsServiceRequest
}
BootstrapBatch is one decoded OTLP logs batch from a bootstrap response.
type BootstrapFrameKind ¶
type BootstrapFrameKind byte
const ( BootstrapFrameHeader BootstrapFrameKind = 1 BootstrapFrameLogs BootstrapFrameKind = 3 BootstrapFrameTerminal BootstrapFrameKind = 4 )
func ReadBootstrapFrame ¶
func ReadBootstrapFrame(r io.Reader) (BootstrapFrameKind, []byte, error)
type BootstrapHeader ¶
type BootstrapHeader struct {
Version int `json:"version"`
TraceID string `json:"traceID"`
SealAt string `json:"sealAt"`
HighWater HighWater `json:"highWater"`
Completion Completion `json:"completion"`
}
type BootstrapResult ¶
type BootstrapResult struct {
Header BootstrapHeader
Terminal BootstrapTerminal
}
BootstrapResult is the immutable cut described by a bootstrap.
type BootstrapSignal ¶
BootstrapSignal is one encoded OTLP logs batch of Records log records.
type BootstrapTerminal ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client reads telemetry archives through a connected engine's HTTP transport.
func NewClientWithURL ¶
NewClientWithURL creates an archive client with an explicit base URL. It is useful for HTTP proxies and tests; connected engine clients should use NewClient.
func (*Client) Bootstrap ¶
func (c *Client) Bootstrap(ctx context.Context, traceID string, consume func(BootstrapHeader, BootstrapBatch) error) (BootstrapResult, error)
Bootstrap buffers the complete raw bootstrap and checks its header and terminal checksum before invoking consume, so a truncated or corrupt bootstrap never applies part of itself. Consumers may then apply the batches and wait for their frontend barrier, without loading unrelated historical telemetry. The engine verified the roster and recipe closure when it built the bootstrap.
func (*Client) Logs ¶
func (c *Client) Logs(ctx context.Context, traceID string, opts StreamOptions, consume func(int64, *collogspb.ExportLogsServiceRequest) error) (int64, error)
Logs reads a finite framed log stream. It returns the last safe resume cursor.
func (*Client) Metrics ¶
func (c *Client) Metrics(ctx context.Context, traceID string, opts StreamOptions, consume func(int64, *colmetricspb.ExportMetricsServiceRequest) error) (int64, error)
Metrics reads a finite framed metric stream. It returns the last safe resume cursor.
func (*Client) Traces ¶
func (c *Client) Traces(ctx context.Context, traceID string, opts StreamOptions, consume func(int64, *coltracepb.ExportTraceServiceRequest) error) (int64, error)
Traces reads a finite framed trace stream. It returns the last safe resume cursor.
type Completion ¶
type Completion struct {
Agents []AgentRevision `json:"agents"`
Subscriptions []SubscriptionRevision `json:"subscriptions"`
}
Completion is the final roster the producer witnessed when the archive was sealed: the agents and subscriptions a restore installs from the bootstrap.
func Witness ¶
func Witness(want agentcontrol.Expectation) Completion
type Config ¶
type Config struct {
Root string
TTL time.Duration
QuotaBytes int64
Now func() time.Time
RemoveStore func(string) (bool, error)
// StoreSize reports the on-disk size of a main client's telemetry store.
// It sizes archives that end unsealed, so they count toward the quota.
StoreSize func(clientID string) (int64, error)
}
type ErrorKind ¶
type ErrorKind string
ErrorKind groups archive failures by the recovery decision a caller should make.
type Failure ¶
type Failure struct {
Kind FailureKind `json:"kind"`
State State `json:"state,omitempty"`
Err error `json:"-"`
}
type FailureKind ¶
type FailureKind string
const ( FailureNotFound FailureKind = "not_found" FailureState FailureKind = "state" FailureCorrupt FailureKind = "corrupt" FailureIO FailureKind = "io" )
type FinalizeInput ¶
type FinalizeInput struct {
HighWater HighWater
SealAt time.Time
StoreSizeBytes int64
BootstrapBytes []byte
BootstrapRecords int64
}
FinalizeInput is the sealed cut. The caller built and verified the bootstrap for exactly this cut.
type HTTPDoer ¶
HTTPDoer is the transport required by the archive client. engine/client's DirectConn implements this interface and carries the connected session's authentication and routing metadata.
type ListOptions ¶
ListOptions controls one archive list page. The engine also excludes the archive currently being captured for this connected session. ExcludeTraceID can omit one additional archive client-side.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) BeginFinalizing ¶
func (*Manager) BootstrapPath ¶
BootstrapPath is where a sealed archive's agent bootstrap is stored.
func (*Manager) Finalize ¶
func (m *Manager) Finalize(traceID string, in FinalizeInput) (Manifest, error)
func (*Manager) GC ¶
GC deletes expired archives, then the oldest ended archives (closed or unsealed) until the retained ones fit the quota. The newest ended archive is kept even when it alone exceeds the quota; overage reports by how much. An archive whose store is still open is left in place and retried by the next GC.
func (*Manager) MarkIncomplete ¶
func (*Manager) Register ¶
Register creates the active archive for a trace. The first session to register a trace owns its archive; a later registration for the same trace (e.g. a nested session that inherited TRACEPARENT) fails.
func (*Manager) SetTitle ¶
SetTitle records the session title the main client published into an active archive's trace. It is persisted immediately, so an archive recovered after an engine crash keeps it, and the sealed manifest inherits it. The title is sanitized first; an unchanged or empty title writes nothing.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
TraceID string `json:"traceID"`
MainClientID string `json:"mainClientID"`
State State `json:"state"`
Title string `json:"title,omitempty"`
StartedAt time.Time `json:"startedAt"`
ClosedAt *time.Time `json:"closedAt,omitempty"`
ExpiresAt time.Time `json:"expiresAt"`
SealAt *time.Time `json:"sealAt,omitempty"`
SizeBytes int64 `json:"sizeBytes"`
Bootstrap Bootstrap `json:"bootstrap,omitempty"`
HighWater HighWater `json:"highWater"`
Failure string `json:"failure,omitempty"`
}
Manifest describes one archive. An archive is identified by its trace ID alone: the first session to register a trace owns its archive.
type RequestError ¶
type RequestError struct {
Kind ErrorKind
Failure FailureKind
State State
StatusCode int
Err error
}
RequestError is a typed archive transport or protocol failure.
func (*RequestError) Error ¶
func (e *RequestError) Error() string
func (*RequestError) Is ¶
func (e *RequestError) Is(target error) bool
func (*RequestError) Unwrap ¶
func (e *RequestError) Unwrap() error
type StreamOptions ¶
StreamOptions fixes one finite signal read to a high-water cursor. Cursor is the last batch successfully acknowledged by the caller. Unsealed reads an interrupted or incomplete archive at the cut returned by Unsealed; its log stream then includes agent control records.
type SubscriptionRevision ¶
type SubscriptionRevision struct {
Key agentcontrol.EdgeKey
Revision int64
}
type UnsealedArchive ¶
type UnsealedArchive struct {
Cut HighWater
}
UnsealedArchive is an archive whose session ended without a seal. It has no bootstrap; stream it with StreamOptions.Unsealed at Cut.