Documentation
¶
Index ¶
- Constants
- func AppendLogsRequestPB(b []byte, rows []Log) ([]byte, error)
- func AppendTraceRequestPB(b []byte, rows []Span) ([]byte, error)
- func CallPayloadBody(row Log) (*callpbv1.Call, error)
- func DecodeLogRecord(row Log) (sdklog.Record, error)
- func Dump(ctx context.Context, root, clientID, selection string, out io.Writer) error
- func LogsToPB(dbLog []Log) []*otlplogsv1.ResourceLogs
- func LogsToPBWithRowIDs(dbLog []Log) []*otlplogsv1.ResourceLogs
- func MarshalEventList(events []sdktrace.Event) ([]byte, error)
- func MarshalKeyValueList(attrs []attribute.KeyValue, skip attribute.Key) ([]byte, error)
- func MarshalProtoList[T proto.Message](protos []T) ([]byte, error)
- func MetricsToPB(dbMetrics []Metric) []*otlpmetricsv1.ResourceMetrics
- func NamedMetricsToPB(dbMetrics []Metric, names map[string]bool) []*otlpmetricsv1.ResourceMetrics
- func SpansToPB(rows []Span) []*otlptracev1.ResourceSpans
- func UnmarshalProtoList[T proto.Message](pb []byte, base T, out *[]T) error
- type AppendStats
- type CallFrame
- type DB
- func (s *DB) AgentControlRows(ctx context.Context) ([]Log, error)
- func (s *DB) AgentSpanIDs() map[string]struct{}
- func (s *DB) AncestorClosure(ids map[string]struct{}) map[string]struct{}
- func (s *DB) AppendLogs(rows []Log) (AppendStats, error)
- func (s *DB) AppendMetrics(rows []Metric) (AppendStats, error)
- func (s *DB) AppendSpans(rows []Span) (AppendStats, error)
- func (s *DB) CallClosure(ctx context.Context, traceID string, roots, known []string, cut HighWater) ([]Log, []string, error)
- func (s *DB) CallDigests() map[string]struct{}
- func (s *DB) CallPayload(ctx context.Context, traceID, digest string, cut HighWater) (Log, error)
- func (s *DB) CausalChildren(spanID string) []string
- func (s *DB) CheckTestSpanIDs() (checks, tests map[string]struct{})
- func (s *DB) Checkpoint(ctx context.Context) (HighWater, error)
- func (s *DB) ChildSpanIDs(spanID string) map[string]struct{}
- func (s *DB) Close() error
- func (s *DB) ControlRows(ctx context.Context, traceID string, through int64, ...) ([]Log, error)
- func (s *DB) FlushLogs(ctx context.Context) error
- func (s *DB) FlushSpans(ctx context.Context) error
- func (s *DB) HasDescendants(spanID string) bool
- func (s *DB) HasSpan(spanID string) bool
- func (s *DB) HighWater() HighWater
- func (s *DB) ImportTrace(ctx context.Context, id string, load func(*DB) error) (*DB, error)
- func (s *DB) InspectionStores() []*DB
- func (s *DB) LiveLogScope(spans []archive.LogSpan) *LogQueryScope
- func (s *DB) LogRowIDsForSpans(ids map[string]struct{}) []int64
- func (s *DB) Read() *DB
- func (s *DB) ReadDisplayLogs(ctx context.Context, p SelectLogsRangeParams, traceID string, ...) (rows []Log, next int64, n int, err error)
- func (s *DB) SearchLogs(ctx context.Context, search archive.LogSearch, throughID int64, traceID string, ...) (archive.LogSearchResult, error)
- func (s *DB) SelectCallFrames(ctx context.Context, digests map[string]struct{}) ([]CallFrame, error)
- func (s *DB) SelectDisplayLogs(ctx context.Context, p SelectLogsRangeParams, traceID string, ...) ([]Log, int64, error)
- func (s *DB) SelectLogRows(ctx context.Context, rowIDs []int64) ([]Log, error)
- func (s *DB) SelectLogsBeneathSpan(ctx context.Context, arg SelectLogsBeneathSpanParams) ([]Log, error)
- func (s *DB) SelectLogsForSpans(ctx context.Context, ids map[string]struct{}, perSpanTail int) ([]Log, error)
- func (s *DB) SelectLogsRange(ctx context.Context, p SelectLogsRangeParams) ([]Log, error)
- func (s *DB) SelectLogsRangeMatching(ctx context.Context, p SelectLogsRangeParams, traceID string, ...) ([]Log, int64, error)
- func (s *DB) SelectLogsSince(ctx context.Context, arg SelectLogsSinceParams) ([]Log, error)
- func (s *DB) SelectLogsWithoutDisplay(ctx context.Context, p SelectLogsRangeParams, seen *LogPresenceSet) ([]Log, []LogPresence, int64, error)
- func (s *DB) SelectMetricsRange(ctx context.Context, p SelectMetricsRangeParams) ([]Metric, error)
- func (s *DB) SelectMetricsSince(ctx context.Context, arg SelectMetricsSinceParams) ([]Metric, error)
- func (s *DB) SelectSpan(ctx context.Context, arg SelectSpanParams) (Span, error)
- func (s *DB) SelectSpansLatest(ctx context.Context, ids map[string]struct{}) ([]Span, error)
- func (s *DB) SelectSpansRange(ctx context.Context, p SelectSpansRangeParams) ([]Span, error)
- func (s *DB) SelectSpansSince(ctx context.Context, arg SelectSpansSinceParams) ([]Span, error)
- func (s *DB) SizeBytes() (int64, error)
- func (s *DB) SpanIDs() map[string]struct{}
- func (s *DB) SpanLogScope(spanID string) map[string]struct{}
- func (s *DB) SpanParentSubtree(spanID string) map[string]struct{}
- func (s *DB) SpanViewAt(ctx context.Context, traceID string, cut HighWater, sel *archive.SpanSelection) (*SpanView, error)
- type DBs
- func (r *DBs) Close() error
- func (r *DBs) GC(keep map[string]bool) error
- func (r *DBs) Open(ctx context.Context, clientID string) (*DB, error)
- func (r *DBs) OpenForAppend(ctx context.Context, clientID string) (*DB, error)
- func (r *DBs) OpenHeld(ctx context.Context, clientID string) (*DB, error)
- func (r *DBs) OpenStats() OpenStats
- func (r *DBs) Remove(clientID string) (bool, error)
- func (r *DBs) Retire(clientID string) error
- func (r *DBs) StoreSize(clientID string) (int64, error)
- func (r *DBs) Sweep(keep map[string]bool) error
- type HighWater
- type Log
- type LogPresence
- type LogPresenceSet
- type LogQueryScope
- type Metric
- type OpenStats
- type SelectLogsBeneathSpanParams
- type SelectLogsRangeParams
- type SelectLogsSinceParams
- type SelectMetricsRangeParams
- type SelectMetricsSinceParams
- type SelectSpanParams
- type SelectSpansRangeParams
- type SelectSpansSinceParams
- type Span
- type SpanView
Constants ¶
const ( DumpAll = "all" DumpSpans = "spans" DumpLogs = "logs" DumpMetrics = "metrics" )
const ( DefaultIdleHold = 90 * time.Second DefaultMaxIdleHolds = 8 )
Defaults for OpenHeld: how long a reader-only store stays open after its last use, and how many such stores may be held at once.
const CollectGarbageAfter = time.Hour
CollectGarbageAfter is the time after which a store is considered garbage.
Variables ¶
This section is empty.
Functions ¶
func AppendLogsRequestPB ¶
AppendLogsRequestPB appends the binary encoding of the OTLP logs export request carrying rows: byte for byte what proto.Marshal makes of ExportLogsServiceRequest{ResourceLogs: LogsToPB(rows)}, without building its messages. It drops the rows LogsToPB drops. A row's body and attributes were encoded with proto.Marshal from valid UTF-8 when it was stored, so they are written as stored: the body after its field's tag, and each element of the attribute list after its tag. Only a body or attribute damaged after it was stored, which LogsToPB would drop, is written as is. Resources and scopes are decoded and encoded again as LogsToPB makes them, each distinct one once per call. Every record's size is worked out first, so the request is written once, into room made for all of it.
func AppendTraceRequestPB ¶
AppendTraceRequestPB appends the binary encoding of the OTLP trace export request carrying rows: byte for byte what proto.Marshal makes of ExportTraceServiceRequest{ResourceSpans: SpansToPB(rows)}, without building its messages, except that each span's links are written as they were stored. A row's stored attribute, event and link lists are already their elements' encodings, each with its length in front, so each element is written after its field's tag. SpansToPB's links go through SDK links, which drop a link's trace state, flags and dropped attribute count; the links a client decodes through SDK links are the same either way. Resources and scopes are encoded as SpansToPB makes them, each distinct one once per call. Every span's size is worked out first, so the request is written once, into room made for all of it.
func CallPayloadBody ¶
CallPayloadBody decodes the call frame a call-payload log record carries.
func DecodeLogRecord ¶
DecodeLogRecord is strict for restore-critical data; the display conversion intentionally skips malformed rows and must not be used for verification.
func Dump ¶
Dump writes the selected persisted stream rows as JSON lines. It opens files read-only and is intended for a closed store, whose tails have been flushed.
func LogsToPB ¶ added in v0.13.1
func LogsToPB(dbLog []Log) []*otlplogsv1.ResourceLogs
LogsToPB converts log rows to OTLP, grouped by resource and instrumentation scope, each group in the order its first row comes. Each distinct resource and scope is decoded once per call, as in SpansToPB.
func LogsToPBWithRowIDs ¶
func LogsToPBWithRowIDs(dbLog []Log) []*otlplogsv1.ResourceLogs
LogsToPBWithRowIDs is LogsToPB with each record carrying its row's ID (telemetryattrs.LogRowAttr) after its stored attributes, for the rows that have one (ID > 0): on-demand log queries send it, so a reader can tell a row it holds already from a new one.
func MarshalEventList ¶
MarshalEventList encodes events as MarshalProtoList encodes telemetry.SpanEventsToPB(events), byte for byte, straight from the SDK values. Like proto.Marshal, it fails on a string that isn't valid UTF-8.
func MarshalKeyValueList ¶
MarshalKeyValueList encodes attrs as MarshalProtoList encodes telemetry.KeyValues(attrs), byte for byte, straight from the SDK values, leaving out the attributes whose key is skip when it isn't empty. Like proto.Marshal, it fails on a string that isn't valid UTF-8. The list is written into a pooled buffer and returned as a copy of exactly its size: lists are kept as long as their rows, and grew past any size guessed up front.
func MarshalProtoList ¶
MarshalProtoList encodes protos as a sequence of length-delimited binary protobuf messages, the store's form for attribute, event and link lists. Binary rather than JSON: encoding and decoding these lists was a large share of the engine's CPU in builds with many execs.
func MetricsToPB ¶ added in v0.13.6
func MetricsToPB(dbMetrics []Metric) []*otlpmetricsv1.ResourceMetrics
func NamedMetricsToPB ¶
func NamedMetricsToPB(dbMetrics []Metric, names map[string]bool) []*otlpmetricsv1.ResourceMetrics
NamedMetricsToPB is MetricsToPB keeping only the metrics whose names are in names; nil keeps every metric. A row whose encoding holds none of the names' bytes is skipped without decoding it: an archive's metric stream is mostly per-exec resource metrics a name selection leaves out.
func SpansToPB ¶
func SpansToPB(rows []Span) []*otlptracev1.ResourceSpans
SpansToPB converts span rows to OTLP, as telemetry.SpansToPB does for their ReadOnly views, without decoding each row into SDK values and encoding it back. A row's attributes and events were encoded from SDK values, so their OTLP form is passed through as stored. Each distinct resource and instrumentation scope is decoded once per call.
Types ¶
type AppendStats ¶
type AppendStats struct {
LastID int64
CapWaitDuration time.Duration
SpillLagRows int
SpillLagBytes int64
}
AppendStats describes the append-side work and the stream backlog visible when an append returns. CapWaitDuration is non-zero only when the hard memory cap applied backpressure to the caller.
type CallFrame ¶
CallFrame is where the store holds one call's frame: the newest snapshot of the span that carries it as dagger.io/dag.call, and/or the call-payload log record that carries it. A frame delivered by both transports has both; the log record is the cheaper one to decode (the span's attributes hold everything else about the span too).
type DB ¶ added in v0.19.7
type DB struct {
// contains filtered or unexported fields
}
DB is one client's standalone append-only telemetry store.
func (*DB) AgentControlRows ¶
AgentControlRows returns the newest control record of every agent the store has seen, across all of its traces, in append order. Unlike ControlRows it verifies nothing and skips what it cannot read: it serves display (what state an agent was last observed in), never restore.
func (*DB) AgentSpanIDs ¶
AgentSpanIDs returns the spans whose attributes carry an agent ID -- agent loop spans, the seed for an agent roster -- answered from the span index.
func (*DB) AncestorClosure ¶
AncestorClosure returns ids plus every member's ancestor chain up to its trace root. A scoped span load includes it so that no loaded span's parent pointer resolves to an unreceived placeholder — dagui would otherwise mistake a placeholder for a root and lose the chain's UI flags.
func (*DB) AppendLogs ¶
func (s *DB) AppendLogs(rows []Log) (AppendStats, error)
func (*DB) AppendMetrics ¶
func (s *DB) AppendMetrics(rows []Metric) (AppendStats, error)
func (*DB) AppendSpans ¶
func (s *DB) AppendSpans(rows []Span) (AppendStats, error)
func (*DB) CallClosure ¶
func (s *DB) CallClosure(ctx context.Context, traceID string, roots, known []string, cut HighWater) ([]Log, []string, error)
CallClosure returns the call-payload rows (as CallPayload returns them) of the recipe closures of roots, within the cut and traceID, each once. Unlike a bootstrap's verified closure it is best-effort: a frame the store does not hold is skipped along with what only it references, and missing reports those digests. A frame that fails to decode is skipped likewise. The closures of known calls, which the caller holds, are neither returned nor walked.
func (*DB) CallDigests ¶
CallDigests returns every call digest the store holds a frame for, on either transport -- the seed for a session-wide call search, sized by the number of distinct calls. The returned map is a fresh snapshot the caller owns.
func (*DB) CallPayload ¶
CallPayload returns a call-payload log row carrying digest's frame, as long as it lies within the cut and belongs to traceID.
A frame reaches the store on one of two carriers (see callLookup): a call-payload log record, or — for a call with a recording span of its own — the span's dagger.io/dag.call attribute, which is then the frame's only delivery. The log row is preferred. A frame that only rode its span is returned as a payload row synthesized from the span row, in exactly the shape the producer emits (core/dag_call_telemetry.go), so bootstrap packing and every reader stay oblivious to the carrier. A synthesized row has no log row ID (0).
The span side is indexed by its newest snapshot. Every snapshot of a call span carries the same frame, and a sealed cut is taken after the session's telemetry shut down, so the newest snapshot lies within it.
func (*DB) CausalChildren ¶
CausalChildren returns the span IDs that cause-link to the given span — e.g. a service's long-lived exec span cause-links to the API spans that installed the Service value (Container.asService and friends).
func (*DB) CheckTestSpanIDs ¶
CheckTestSpanIDs returns the spans marked as named checks and as test cases or suites, answered from the span index. This is the seed for resolving a check/test NAME to a span: load these spans (plus ancestors, for the test view's containment walks) into a throwaway dagui.DB and match names there, instead of retaining a whole-session DB just to answer name lookups.
func (*DB) Checkpoint ¶
Checkpoint is a persistence barrier, not merely an in-memory high water. Producers must be quiesced to use the returned cut for finalization.
func (*DB) ChildSpanIDs ¶
ChildSpanIDs returns the spans one edge beneath spanID, over the same edges as the log queries: parent→child plus cause-purpose links. Answered from the index alone, so a caller can load a span's immediate surroundings without materializing its whole subtree.
func (*DB) ControlRows ¶
func (s *DB) ControlRows(ctx context.Context, traceID string, through int64, want agentcontrol.Expectation) ([]Log, error)
ControlRows selects only final received projections. Verification compares them with a separately supplied, quiesced producer witness.
func (*DB) FlushLogs ¶
FlushLogs writes the in-memory log tail to its file without fsyncing, so restore-critical rows survive the engine process being killed. Session end still Checkpoints for real durability.
func (*DB) FlushSpans ¶
FlushSpans is FlushLogs for the span tail: a spanned call's frame rides its call span alone, so an unsealed restore needs those rows on file too.
func (*DB) HasDescendants ¶
HasDescendants reports whether any span is nested beneath spanID, following the same edges as the log queries: parent→child plus cause-purpose links.
It answers purely from the in-memory span index -- no stream reads, no subtree materialization -- so it is cheap enough to use as a pre-filter (e.g. "did this tool call produce any child telemetry worth rendering?").
func (*DB) HighWater ¶
HighWater reports the current end of each stream without a persistence barrier. Use it only for a store no producer writes to anymore, such as an archive whose session ended without sealing.
func (*DB) ImportTrace ¶
ImportTrace publishes a complete snapshot exactly once. Failed/canceled downloads remain invisible and may be retried. The caller must retain s while using the returned store, and must not close the returned store.
func (*DB) InspectionStores ¶
InspectionStores returns the live store followed by imported snapshots in trace ID order. Retain s while using them; do not close the borrowed stores.
func (*DB) LiveLogScope ¶
func (s *DB) LiveLogScope(spans []archive.LogSpan) *LogQueryScope
LiveLogScope resolves spans against the store's current span index. Spans placed later are found as their rows are read: a row of a span outside the resolved tree matches when the span is now beneath a descendant selection (it, its parent or its cause link arrived later), or when the store has no snapshot of it yet (its position is unknown, so the reader decides).
func (*DB) LogRowIDsForSpans ¶
LogRowIDsForSpans returns the row IDs of every log row attributed to a span in ids, ascending -- a snapshot of a capture's rows, answered from the log index alone. A caller that pages through a large capture resolves its rows once with this and reads them in batches with SelectLogRows, rather than re-resolving the scope per page.
func (*DB) Read ¶
Read mirrors the current DB handle seam. The append-only store needs no separate read pool, so selectors are bound to the same immutable streams.
func (*DB) ReadDisplayLogs ¶
func (s *DB) ReadDisplayLogs(ctx context.Context, p SelectLogsRangeParams, traceID string, scope *LogQueryScope) (rows []Log, next int64, n int, err error)
ReadDisplayLogs is SelectDisplayLogs for a one-shot read of (p.AfterID, p.ThroughID], one call per batch with p.ThroughID fixed: it reads the same rows. Its first call gathers the rows from the row indexes (the scope's spans and every span now beneath its tree, spans with no snapshot yet when it has a tree, and its digests), and later calls page through them, so a read costs what it returns rather than the size of the store, and a batch holds at most p.Limit rows instead of covering p.Limit rows. A live scope with a tree places the spans that arrive during the read and merges their rows after its cursor, as the scan places them as it goes. next is the last row the batch covers, matched or not: the end of the read once no row is left. n is the batch's size in the units of p.Limit: the rows returned, or the rows scanned when the read fell back to a scan (see displayIndexMaxShare).
func (*DB) SearchLogs ¶
func (s *DB) SearchLogs(ctx context.Context, search archive.LogSearch, throughID int64, traceID string, scope *LogQueryScope) (archive.LogSearchResult, error)
SearchLogs matches display text in (search.After, throughID] line by line. scope nil searches every span; traceID "" every trace. It stops at the search's match limit or its scan budget, reporting More.
func (*DB) SelectCallFrames ¶
func (s *DB) SelectCallFrames(ctx context.Context, digests map[string]struct{}) ([]CallFrame, error)
SelectCallFrames returns the frames the store holds for digests, in ascending digest order, skipping digests it holds no frame for. Answered through the call index, so a recipe rebuild that follows a chain's references loads a row per frame rather than scanning either stream.
func (*DB) SelectDisplayLogs ¶
func (s *DB) SelectDisplayLogs(ctx context.Context, p SelectLogsRangeParams, traceID string, scope *LogQueryScope) ([]Log, int64, error)
SelectDisplayLogs reads the display text rows (see logFlags.display) of scope in (p.AfterID, p.ThroughID], scanning at most p.Limit rows. traceID "" matches every trace. next advances across unmatched rows too.
func (*DB) SelectLogRows ¶
SelectLogRows reads the given log rows, which must be ascending (as the log index returns them), in that order.
func (*DB) SelectLogsBeneathSpan ¶
func (s *DB) SelectLogsBeneathSpan(ctx context.Context, arg SelectLogsBeneathSpanParams) ([]Log, error)
SelectLogsBeneathSpan returns the log rows of the capture rooted at arg.SpanID — the rows attributed to any span in its log scope (the span itself, its cause-link targets, and both sets' subtrees; see SpanLogScope) — in append order, starting after cursor arg.ID, up to arg.Limit rows. The root's own rows are part of the capture: a span's directly-attributed output (e.g. the service stdio records routed to an install span) is exactly what a reader asking about that span wants.
Resolved through the per-span log index: the row IDs come straight from the scope's index entries, so the cost scales with the capture, not with the session — the previous implementation scanned the whole log stream past the cursor, linear in session size, on a path that runs per LLM tool call.
func (*DB) SelectLogsForSpans ¶
func (s *DB) SelectLogsForSpans(ctx context.Context, ids map[string]struct{}, perSpanTail int) ([]Log, error)
SelectLogsForSpans returns the log rows attributed to any span in ids, in append order — the log half of a scoped load. perSpanTail > 0 bounds each span to its newest perSpanTail rows; renderers bound every span's log output to a tail anyway, and the cap keeps one pathological span (e.g. a service that streamed millions of lines) from ballooning the load.
func (*DB) SelectLogsRange ¶
func (*DB) SelectLogsRangeMatching ¶
func (s *DB) SelectLogsRangeMatching(ctx context.Context, p SelectLogsRangeParams, traceID string, scope map[string]bool, sel *archive.LogSelection, includeControl bool) ([]Log, int64, error)
SelectLogsRangeMatching scans a bounded metadata window and reads only matching bodies. next advances across filtered rows too, so terminal and resume cursors still refer to the immutable underlying stream, not a filter. Agent control records are skipped unless includeControl is set (an unsealed archive, which has no bootstrap to supply them).
func (*DB) SelectLogsSince ¶
func (*DB) SelectLogsWithoutDisplay ¶
func (s *DB) SelectLogsWithoutDisplay(ctx context.Context, p SelectLogsRangeParams, seen *LogPresenceSet) ([]Log, []LogPresence, int64, error)
SelectLogsWithoutDisplay reads every row in (p.AfterID, p.ThroughID], scanning at most p.Limit rows, except display text, which it reports as presence instead: once per (trace, span, digest) not yet in seen. It is the live push for a frontend that reads display text on demand.
func (*DB) SelectMetricsRange ¶
func (*DB) SelectMetricsSince ¶
func (*DB) SelectSpan ¶
func (*DB) SelectSpansLatest ¶
SelectSpansLatest returns the newest snapshot row of every span in ids, in append order. A span's snapshots are cumulative, so its newest row alone reconstructs the state that full sequential processing would end with — this is the span half of a scoped load, sized by the scope instead of the session.
func (*DB) SelectSpansRange ¶
func (*DB) SelectSpansSince ¶
func (*DB) SpanIDs ¶
SpanIDs returns every span ID the store has seen a snapshot of -- the seed for a session-wide scoped load (e.g. a name search), sized by the span count rather than by the snapshot stream. The returned map is a fresh snapshot the caller owns.
func (*DB) SpanLogScope ¶
SpanLogScope returns the set of span IDs whose log rows belong to a capture rooted at spanID — the same walk SelectLogsBeneathSpan scopes its logs to: the span itself, the spans it cause-links to (e.g. the install spans a service exec span links, which carry the service's stdio records), and everything beneath either over child edges and cause-purpose link edges. The returned map is a fresh snapshot the caller owns; the set only ever grows as spans arrive.
func (*DB) SpanParentSubtree ¶
SpanParentSubtree returns spanID plus every span beneath it over parent→child edges alone, answered from the span index. Unlike SpanLogScope it follows no cause links. The returned map is a fresh snapshot the caller owns.
func (*DB) SpanViewAt ¶
func (s *DB) SpanViewAt(ctx context.Context, traceID string, cut HighWater, sel *archive.SpanSelection) (*SpanView, error)
SpanViewAt returns the span view of traceID at cut, with sel applied. The topology is built once per (trace, cut) on this store and shared; only the selection is computed per call.
type DBs ¶
type DBs struct {
Root string
// IdleHold and MaxIdleHolds configure OpenHeld. Set them before use.
IdleHold time.Duration
MaxIdleHolds int
// contains filtered or unexported fields
}
DBs owns the refcounted set of open per-client telemetry stores. Live client runtimes and readers retain references; the final Close releases the streams.
A store whose last reference closes is reopened when telemetry for its client arrives late, for example from the session's shutdown flush after the client's runtime was reclaimed. DBs remembers where each closed store's streams ended, so such a reopen appends without scanning the store; see OpenForAppend.
Readers of ended sessions (archive requests) open stores with OpenHeld, which keeps the store open for an idle period after use, so that a burst of requests does not replay the whole store from disk per request. Such an idle hold is a reference of its own, but it never blocks Remove, GC or Close: each of those releases the hold first.
func (*DBs) Close ¶
Close prevents new stores from opening, waits for in-flight opens, and releases idle holds. Actively referenced stores remain usable and close their streams when their final handle is released.
func (*DBs) GC ¶
GC removes complete client stores whose newest stream (or transitional SQLite sidecar) is older than CollectGarbageAfter. Grouping files by client keeps a recently active stream from being separated from an older sibling.
func (*DBs) Open ¶
Open returns a reference to the client's store, with its indexes built over every row it holds. Close the reference when done with it.
func (*DBs) OpenForAppend ¶
OpenForAppend returns a reference to the client's store for appending telemetry, or for reading its rows in order. Unlike Open it doesn't build the store's indexes, so reopening a closed store this way reads none of its rows; the selectors that answer from the indexes must not be used through it. Close the reference when done with it.
func (*DBs) OpenHeld ¶
OpenHeld opens clientID like Open, and additionally keeps the store open until it has gone unused for IdleHold; every OpenHeld refreshes that deadline. Use it for readers of stores no live session holds, such as archive requests, which otherwise reopen (and replay) the store per request. At most MaxIdleHolds stores are held; the least recently used hold beyond that is released. The caller still closes the returned handle.
func (*DBs) Remove ¶
Remove deletes a store only when no live writer or reader holds a reference. An idle hold (see OpenHeld) is released first rather than blocking removal. The same per-store lock serializes reopening, so GC cannot unlink a newly reopened archive stream.
func (*DBs) Retire ¶
Retire deletes a client's store once nothing can read it any more: now if nothing holds it, or when its last reference closes. From then on the store can't be reopened, so a late writer can't recreate it. A session retires its clients' stores when it ends.
type HighWater ¶
type HighWater struct{ Spans, Logs, Metrics int64 }
HighWater is a fixed inclusive cursor; zero denotes an empty stream.
type Log ¶
type Log struct {
ID int64
TraceID sql.NullString
SpanID sql.NullString
Timestamp int64
SeverityNumber int64
SeverityText string
Body []byte
Attributes []byte
InstrumentationScope []byte
Resource []byte
ResourceSchemaURL string
}
func SpanCallPayloadLog ¶
SpanCallPayloadLog synthesizes the call-payload log row for the frame a call span row carries as dagger.io/dag.call: a bytes body holding the encoded call, tagged with the call payload content type and digest, attributed to the span. The frame must carry digest.
type LogPresence ¶
type LogPresence struct {
// Row is the first such row's ID.
Row int64
Timestamp int64
TraceID string
SpanID string
Digest string
// contains filtered or unexported fields
}
LogPresence announces that a span has display text without carrying it: the first display row of each (trace, span, digest) in a push stream.
type LogPresenceSet ¶
type LogPresenceSet struct {
// contains filtered or unexported fields
}
LogPresenceSet remembers the (trace, span, digest) triples a push stream has announced. It belongs to one stream.
func NewLogPresenceSet ¶
func NewLogPresenceSet() *LogPresenceSet
func (*LogPresenceSet) Forget ¶
func (s *LogPresenceSet) Forget(presence []LogPresence)
Forget unannounces presence a stream did not deliver after all (e.g. a batch it discarded to refetch a smaller one), so it is reported again.
type LogQueryScope ¶
type LogQueryScope struct {
// contains filtered or unexported fields
}
LogQueryScope is a resolved archive.LogQuery: the spans whose own rows match, and the dag.digest values whose rows match wherever they were emitted. A live scope also follows spans that arrive after it was resolved. A scope belongs to one reader, which keeps what it decided about each span and digest across its reads; it is not safe for concurrent use.
type OpenStats ¶
OpenStats is a measured snapshot of currently open telemetry stores. Each referenced store owns exactly three stream handles.
type SelectLogsBeneathSpanParams ¶ added in v0.19.0
type SelectLogsBeneathSpanParams struct {
SpanID sql.NullString
ID int64
Limit int64
}
type SelectLogsRangeParams ¶
type SelectLogsRangeParams struct{ AfterID, ThroughID, Limit int64 }
type SelectLogsSinceParams ¶
type SelectMetricsRangeParams ¶
type SelectMetricsRangeParams struct{ AfterID, ThroughID, Limit int64 }
type SelectMetricsSinceParams ¶ added in v0.13.6
type SelectSpanParams ¶ added in v0.19.0
type SelectSpansRangeParams ¶
type SelectSpansRangeParams struct{ AfterID, ThroughID, Limit int64 }
type SelectSpansSinceParams ¶
type Span ¶
type Span struct {
ID int64
TraceID string
SpanID string
TraceState string
ParentSpanID sql.NullString
Flags int64
Name string
Kind string
StartTime int64
EndTime sql.NullInt64
Attributes []byte
DroppedAttributesCount int64
Events []byte
DroppedEventsCount int64
Links []byte
DroppedLinksCount int64
StatusCode int64
StatusMessage string
InstrumentationScope []byte
Resource []byte
ResourceSchemaURL string
}
func (*Span) ReadOnly ¶
func (span *Span) ReadOnly() sdktrace.ReadOnlySpan
type SpanView ¶
type SpanView struct {
// contains filtered or unexported fields
}
SpanView is one request's view of a trace's span topology at precisely one span/log cut: the shared, immutable topology plus the request's own selection. It stores only the last row ID and view metadata, never full spans or log bodies.
func (*SpanView) Attributes ¶
Attributes are the dagui view annotations for spanID: its child count, whether it has logs, and whether the selection left spans out.
func (*SpanView) LogQueryScope ¶
func (v *SpanView) LogQueryScope(spans []archive.LogSpan) *LogQueryScope
LogQueryScope resolves spans at the view's fixed cut.