trace

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package trace implements trace-specific vectorized query operators: the two-phase pull pipeline that resolves trace IDs (Phase 1) and materializes spans grouped per trace (Phase 2).

Index

Constants

View Source
const (
	Phase1ColumnNameKey      = "key"
	Phase1ColumnNameSeriesID = "seriesID"
	Phase1ColumnNamePartID   = "partID"
	Phase1ColumnNamePayload  = "payload"
	Phase1ColumnNameTraceID  = "traceID"
)

Phase-1 column names.

Variables

This section is empty.

Functions

func IncrQueryCount

func IncrQueryCount()

IncrQueryCount increments the process-wide vectorized trace query counter. Called by banyand/trace when the vectorized path is taken.

func NewPhase1Schema

func NewPhase1Schema() *vectorized.BatchSchema

NewPhase1Schema returns the thin trace-ID resolution batch schema.

func QueryCount

func QueryCount() int64

QueryCount returns the cumulative number of vectorized trace queries successfully started by this process.

Types

type DistinctTraceID

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

DistinctTraceID carries ordered trace IDs, part hints, and keys into Phase 2.

func NewDistinctTraceID

func NewDistinctTraceID(schema *vectorized.BatchSchema) *DistinctTraceID

NewDistinctTraceID constructs the Phase-1 carry-forward fusible.

func (*DistinctTraceID) Close

func (d *DistinctTraceID) Close() error

Close is idempotent and a no-op.

func (*DistinctTraceID) Init

Init resets carry-forward state.

func (*DistinctTraceID) Keys

func (d *DistinctTraceID) Keys() map[string]int64

Keys returns the traceID to sort-key mapping collected so far.

func (*DistinctTraceID) Order

func (d *DistinctTraceID) Order() []string

Order returns trace IDs in Phase-1 arrival order.

func (*DistinctTraceID) OutputSchema

func (d *DistinctTraceID) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the unchanged input schema.

func (*DistinctTraceID) Process

Process records active rows without rewriting the selection vector.

func (*DistinctTraceID) TraceIDsByPart

func (d *DistinctTraceID) TraceIDsByPart() map[int64][]string

TraceIDsByPart returns the part-hint mapping collected so far.

type IDDecode

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

IDDecode decodes idFormatV1 trace-ID payloads into the traceID column.

func NewIDDecode

func NewIDDecode(schema *vectorized.BatchSchema) *IDDecode

NewIDDecode constructs a trace-ID decode fusible.

func (*IDDecode) Close

func (d *IDDecode) Close() error

Close is idempotent and a no-op.

func (*IDDecode) Init

func (d *IDDecode) Init(context.Context) error

Init is a no-op.

func (*IDDecode) OutputSchema

func (d *IDDecode) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the unchanged input schema.

func (*IDDecode) Process

func (d *IDDecode) Process(_ context.Context, batch *vectorized.RecordBatch) error

Process decodes every active row's payload into traceID.

type Limit

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

Limit applies MaxTraceSize to the ordered Phase-1 stream.

func NewLimit

func NewLimit(schema *vectorized.BatchSchema, maxRows uint32) *Limit

NewLimit constructs a trace Phase-1 limit fusible.

func (*Limit) Close

func (l *Limit) Close() error

Close is idempotent and a no-op.

func (*Limit) Init

func (l *Limit) Init(context.Context) error

Init is a no-op.

func (*Limit) OutputSchema

func (l *Limit) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the unchanged input schema.

func (*Limit) Process

func (l *Limit) Process(_ context.Context, batch *vectorized.RecordBatch) error

Process rewrites selection to keep only the first max active rows.

type LimitedDistinctTraceID

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

LimitedDistinctTraceID applies MaxTraceSize while carrying kept rows.

func NewLimitedDistinctTraceID

func NewLimitedDistinctTraceID(schema *vectorized.BatchSchema, maxRows uint32) *LimitedDistinctTraceID

NewLimitedDistinctTraceID constructs the Phase-1 limit and carry fusible.

func (*LimitedDistinctTraceID) Carry

Carry returns the embedded carry-forward state.

func (*LimitedDistinctTraceID) Close

func (l *LimitedDistinctTraceID) Close() error

Close is idempotent and closes the embedded carry operator.

func (*LimitedDistinctTraceID) Init

Init resets carry-forward state.

func (*LimitedDistinctTraceID) OutputSchema

func (l *LimitedDistinctTraceID) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the unchanged input schema.

func (*LimitedDistinctTraceID) Process

Process rewrites selection to kept rows and records only those rows.

type MergeItem

type MergeItem struct {
	TraceID  string
	Payload  []byte
	Key      int64
	SeriesID int64
	PartID   int64
	// contains filtered or unexported fields
}

MergeItem is one sorted Phase-1 trace candidate consumed by SortedMerge.

func NewMergeItem

func NewMergeItem(key, seriesID, partID int64, payload []byte) *MergeItem

NewMergeItem builds a merge item whose SortedField preserves numeric int64 order.

func (*MergeItem) SortedField

func (m *MergeItem) SortedField() []byte

SortedField returns the order-preserving encoded key for itersort.

type Phase1Plan

type Phase1Plan struct {
	Pipeline *vectorized.Pipeline
	Carry    *DistinctTraceID
}

Phase1Plan holds the executable Phase-1 pipeline and its carry-forward operator.

func BuildMergePhase1

func BuildMergePhase1(iters []itersort.Iterator[*MergeItem], desc bool, maxTraceSize uint32, batchSize int) (*Phase1Plan, error)

BuildMergePhase1 builds the ordered sidx Phase-1 pipeline.

func BuildStaticPhase1

func BuildStaticPhase1(traceIDs []string, keys map[string]int64, maxTraceSize uint32, batchSize int) (*Phase1Plan, error)

BuildStaticPhase1 builds the traceID lookup Phase-1 pipeline.

type SidxResponseIterator

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

SidxResponseIterator adapts ordered sidx row batches to merge items.

func NewSidxResponseIterator

func NewSidxResponseIterator(responses []*SidxRowBatch) *SidxResponseIterator

NewSidxResponseIterator constructs a merge iterator over sidx row batches.

func (*SidxResponseIterator) Close

func (i *SidxResponseIterator) Close() error

Close marks the iterator closed.

func (*SidxResponseIterator) Error

func (i *SidxResponseIterator) Error() error

Error returns the first response or shape error observed by Next.

func (*SidxResponseIterator) Next

func (i *SidxResponseIterator) Next() bool

Next advances to the next well-formed row.

func (*SidxResponseIterator) Val

func (i *SidxResponseIterator) Val() *MergeItem

Val returns the current merge item.

type SidxRowBatch

type SidxRowBatch struct {
	Error   error
	Keys    []int64
	Data    [][]byte
	SIDs    []int64
	PartIDs []int64
}

SidxRowBatch is the sidx row shape consumed by vectorized trace Phase 1.

func (*SidxRowBatch) Len

func (b *SidxRowBatch) Len() int

Len returns the number of rows in the batch.

type SortedMerge

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

SortedMerge lazily merges sorted trace candidate iterators and deduplicates payloads.

func NewSortedMerge

func NewSortedMerge(iters []itersort.Iterator[*MergeItem], desc bool, batchSize int) *SortedMerge

NewSortedMerge returns a streaming pull operator backed by itersort.NewItemIter.

func (*SortedMerge) Close

func (s *SortedMerge) Close() error

Close releases the source iterators through the underlying merger.

func (*SortedMerge) Init

func (s *SortedMerge) Init(context.Context) error

Init initializes the merge heap and output pool.

func (*SortedMerge) NextBatch

func (s *SortedMerge) NextBatch(ctx context.Context) (*vectorized.RecordBatch, error)

NextBatch returns the next demand-bounded merged batch.

func (*SortedMerge) OutputSchema

func (s *SortedMerge) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the Phase-1 schema.

type StaticTraceIDSource

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

StaticTraceIDSource emits Phase-1 rows for direct trace-ID lookup mode.

func NewStaticTraceIDSource

func NewStaticTraceIDSource(traceIDs []string, keys map[string]int64, batchSize int) *StaticTraceIDSource

NewStaticTraceIDSource constructs a static lookup source.

func (*StaticTraceIDSource) Close

func (s *StaticTraceIDSource) Close() error

Close is idempotent and a no-op.

func (*StaticTraceIDSource) Init

Init initializes the output pool.

func (*StaticTraceIDSource) NextBatch

NextBatch emits the next static lookup batch.

func (*StaticTraceIDSource) OutputSchema

func (s *StaticTraceIDSource) OutputSchema() *vectorized.BatchSchema

OutputSchema returns the Phase-1 schema.

type VectorizedConfig

type VectorizedConfig struct {
	BatchSize int
	// QueryMemoryMiB is a soft span-loading threshold: it caps the cumulative
	// uncompressed span bytes fetched from disk per query. SIDX responses, tags,
	// record-batch overhead, and other per-query allocations are not counted.
	// The first block always loads regardless of the budget (first-block exception),
	// so a single oversized block may exceed this value.
	QueryMemoryMiB int
	Enabled        bool
}

VectorizedConfig controls the v1 vectorized Trace query path.

func DefaultConfig

func DefaultConfig() VectorizedConfig

DefaultConfig returns the default trace vectorized configuration — enabled, with the shared default batch size and a 256 MiB per-query memory budget.

Enabled also selects the liaison<->data wire format: a flag-on distributed data node emits the native columnar frame instead of protobuf. A liaison decodes both (it dispatches on the frame magic byte per message), but an older liaison has no frame decoder at all, so a cluster must upgrade liaison nodes BEFORE data nodes. See docs/operation/upgrade.md.

To roll back the vec path entirely, pass --trace-vectorized-enabled=false on the standalone or data-node command line and restart; the row path resumes immediately.

func (VectorizedConfig) Validate

func (c VectorizedConfig) Validate() error

Validate rejects invalid trace vectorized configurations.

Jump to

Keyboard shortcuts

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