Documentation
¶
Overview ¶
Package telemetry defines the canonical, storage-independent rows emitted by the OTLP decoder. These are the only telemetry write contracts in Pitot.
Index ¶
- Constants
- Variables
- func FirstPositiveNanos(values ...int64) int64
- func IsBatchCorrupt(err error) bool
- func MetricSeriesID(m Metric) uint64
- func NormalizeNamespace(namespace string) string
- func NormalizeSeverity(text string, number int32) string
- func SeverityAliases() map[string]string
- func SeverityFromText(text string) string
- func SeverityRank(band string) (int, bool)
- func ValidateBatchID(id string) error
- func ValidatePublishedBatch(dir string) (err error)
- func ValueBytes(value any) int
- type BatchMetadata
- type BatchVerifier
- type Column
- type CorruptBatchError
- type Event
- type Exemplar
- type Field
- type Histogram
- type IndexedSpan
- type Link
- type Log
- type Metric
- type Order
- type ParquetMergeStats
- type ParquetStats
- type ParquetStore
- func (p *ParquetStore) BatchMetadata() []BatchMetadata
- func (p *ParquetStore) BatchPath(id string) string
- func (p *ParquetStore) BatchesDir() string
- func (p *ParquetStore) Close() error
- func (p *ParquetStore) CollectRetired() (int, error)
- func (p *ParquetStore) CommitBatch(ctx context.Context, metadata *BatchMetadata, spans []Span, logs []Log, ...) error
- func (p *ParquetStore) CompactionDebt() int
- func (p *ParquetStore) Dir() string
- func (p *ParquetStore) Generation0BatchCount() int
- func (p *ParquetStore) MergeParquet(ctx context.Context, signal string, inputs []string, output string) (ParquetMergeStats, error)
- func (p *ParquetStore) Pattern(signal string) string
- func (p *ParquetStore) Pin() SnapshotPin
- func (p *ParquetStore) PrepareReplacement(dir string, metadata BatchMetadata) error
- func (p *ParquetStore) PruneBefore(cutoff int64, maxBatches int, publish func(func(context.Context) error) error) (int, error)
- func (p *ParquetStore) PublishReplacement(stage string, metadata BatchMetadata, inputs []string, ...) error
- func (p *ParquetStore) RetirementWaiting(pin SnapshotPin) bool
- func (p *ParquetStore) RetiringBatches() int
- func (p *ParquetStore) RowCount() uint64
- func (p *ParquetStore) StagingPath(id string) string
- func (p *ParquetStore) Stats() (map[string]ParquetStats, error)
- func (p *ParquetStore) Trace(ctx context.Context, query TraceQuery) ([]IndexedSpan, TraceTotals, error)
- func (p *ParquetStore) TraceDetail(ctx context.Context, query TraceQuery) (TraceDetail, error)
- func (p *ParquetStore) TraceLogs(ctx context.Context, query TraceQuery) ([]TraceLog, error)
- func (p *ParquetStore) TraceSummaries(ctx context.Context, ids []TraceIdentity, start, end int64) ([]TraceTotals, error)
- func (p *ParquetStore) Unpin(pin SnapshotPin)
- func (p *ParquetStore) WaitForCompactionLimit(ctx context.Context) error
- type Part
- type Signal
- type SnapshotPin
- type Span
- type TimeRange
- type TraceDetail
- type TraceIdentity
- type TraceLog
- type TraceQuery
- type TraceTotals
- type Type
Constants ¶
const ( CompactionMaxRows = 25_000_000 // The slowest measured merge with six busy cores sustained over 400k // rows/s. Four million rows retire pressured debt in about ten seconds; // unpressured and higher-generation merges retain the normal ceiling. CompactionPressureMaxRows = 4_000_000 CompactionBatchLimit = 128 CompactionDebtLimit = 1024 // CompactionWindow bounds what one merge may combine by ingest time. Span // files sort by trace, so each row group covers its file's whole time // range and a narrow query decodes the entire file: file size, not window // size, sets its cost. An hour of pico-rate ingest is about 325,000 spans. CompactionWindow = time.Hour )
const ( BatchSuffix = ".batch" SchemaBatch = "_schema" + BatchSuffix )
Variables ¶
var ErrUnsupportedBatchFormat = errors.New("unsupported telemetry batch format")
var Logs = &Signal{ Name: "logs", Time: "log_time", Order: Order{{Column: "log_time", Bucket: int64(5 * time.Minute)}, {Column: "namespace"}, {Column: "service"}, {Column: "log_time"}}, Columns: append([]Column{ str("namespace", func(r *Log) string { return r.Namespace }).dict(), ts("log_time", func(r *Log) int64 { return FirstPositiveNanos(r.EventUnixNanos, r.TimeUnixNanos, r.ObservedTimeNanos, r.IngestedAt) }).as("time"), ts("observed_time", func(r *Log) int64 { return FirstPositiveNanos(r.ObservedTimeNanos, r.EventUnixNanos, r.TimeUnixNanos, r.IngestedAt) }), nanos("time_unix_nano", func(r *Log) int64 { return r.TimeUnixNanos }), nanos("observed_time_unix_nano", func(r *Log) int64 { return r.ObservedTimeNanos }), str("severity", func(r *Log) string { return r.Severity }).dict(), i64("severity_number", func(r *Log) int64 { return int64(r.SeverityNumber) }), str("body", func(r *Log) string { return r.Body }), str("service", func(r *Log) string { return r.ServiceName }).dict(), str("trace_id", func(r *Log) string { return r.TraceID }), str("span_id", func(r *Log) string { return r.SpanID }), i64("flags", func(r *Log) int64 { return int64(r.Flags) }), object("resource", func(r *Log) map[string]any { return r.Resource }, resourceShred), object("attributes", func(r *Log) map[string]any { return r.Attributes }, attributeShred), str("scope_name", func(r *Log) string { return r.ScopeName }).dict(), str("scope_version", func(r *Log) string { return r.ScopeVersion }).dict(), ts("ingested_at", func(r *Log) int64 { return r.IngestedAt }), nanos("ingested_unix_nano", func(r *Log) int64 { return r.IngestedAt }), str("body_template", func(r *Log) string { return r.BodyTemplate }).dict(), }, dedicated(semconv.Resource)...), }
var Metrics = &Signal{ Name: "metrics", Time: "metric_time", Order: Order{{Column: "namespace"}, {Column: "service"}, {Column: "name"}, {Column: "metric_time", Bucket: int64(time.Hour)}, {Column: "series_id"}, {Column: "metric_time"}}, Columns: append([]Column{ u64("series_id", func(r *Metric) uint64 { return r.SeriesID }), str("namespace", func(r *Metric) string { return r.Namespace }).dict(), ts("metric_time", func(r *Metric) int64 { return FirstPositiveNanos(r.EventUnixNanos, r.TimeUnixNanos, r.IngestedAt) }).as("time"), nanos("time_unix_nano", func(r *Metric) int64 { return r.TimeUnixNanos }), str("name", func(r *Metric) string { return r.Name }).dict(), str("description", func(r *Metric) string { return r.Description }).dict(), str("unit", func(r *Metric) string { return r.Unit }).dict(), str("type", func(r *Metric) string { return r.Type }).dict(), nullable("temporality", String, func(r *Metric) (string, bool) { return r.Temporality, r.Temporality != "" }).dict(), nanos("start_time_unix_nano", func(r *Metric) int64 { return r.StartTimeUnixNanos }).view(Field{Name: "start_time", Type: Time, Expr: `CASE WHEN start_time_unix_nano=0 THEN NULL ELSE TRY(make_timestamp_ns(start_time_unix_nano)::TIMESTAMPTZ_NS) END`}), str("service", func(r *Metric) string { return r.ServiceName }).dict(), column("flags", Uint32, func(r *Metric) uint32 { return r.Flags }), nullable("value", Float64, func(r *Metric) (float64, bool) { return r.Value, r.Type != "histogram" && r.Type != "summary" && r.Flags&metricNoRecordedValue == 0 }), nullable("hist_count", Uint64, func(r *Metric) (uint64, bool) { return r.Count, r.Type == "histogram" || r.Type == "summary" }), nullable("hist_sum", Float64, func(r *Metric) (float64, bool) { return r.Sum, r.HasSum }), nullable("hist_min", Float64, func(r *Metric) (float64, bool) { return r.Min, r.HasMin }), nullable("hist_max", Float64, func(r *Metric) (float64, bool) { return r.Max, r.HasMax }), list("hist_bounds", Float64, func(r *Metric, b []float64) ([]float64, bool) { return append(b, r.Bounds...), r.Type == "histogram" && !r.Exponential }).dict(), list("hist_counts", Uint64, func(r *Metric, b []uint64) ([]uint64, bool) { return append(b, r.Counts...), r.Type == "histogram" && !r.Exponential }).dense(), nullable("exp_scale", Int32, func(r *Metric) (int32, bool) { return r.Scale, r.Exponential }), nullable("exp_zero_count", Uint64, func(r *Metric) (uint64, bool) { return r.ZeroCount, r.Exponential }), nullable("exp_zero_threshold", Float64, func(r *Metric) (float64, bool) { return r.ZeroThreshold, r.Exponential }), nullable("exp_positive_offset", Int32, func(r *Metric) (int32, bool) { return r.PositiveOffset, r.Exponential }), list("exp_positive_counts", Uint64, func(r *Metric, b []uint64) ([]uint64, bool) { return append(b, r.PositiveCounts...), r.Exponential }).dense(), nullable("exp_negative_offset", Int32, func(r *Metric) (int32, bool) { return r.NegativeOffset, r.Exponential }), list("exp_negative_counts", Uint64, func(r *Metric, b []uint64) ([]uint64, bool) { return append(b, r.NegativeCounts...), r.Exponential }).dense(), list("quantiles", Float64, func(r *Metric, b []float64) ([]float64, bool) { return append(b, r.Quantiles...), r.Type == "summary" }).parallel("quantiles").dict(), list("quantile_values", Float64, func(r *Metric, b []float64) ([]float64, bool) { return append(b, r.QuantileValues...), r.Type == "summary" }).parallel("quantiles"), list("exemplar_times", Time, func(r *Metric, b []int64) ([]int64, bool) { for _, e := range r.Exemplars { b = append(b, e.TimeUnixNanos) } return b, r.Type != "summary" }).parallel("exemplars"), list("exemplar_values", Float64, func(r *Metric, b []float64) ([]float64, bool) { for _, e := range r.Exemplars { b = append(b, e.Value) } return b, r.Type != "summary" }).parallel("exemplars"), list("exemplar_trace_ids", String, func(r *Metric, b []string) ([]string, bool) { for _, e := range r.Exemplars { b = append(b, e.TraceID) } return b, r.Type != "summary" }).parallel("exemplars"), list("exemplar_span_ids", String, func(r *Metric, b []string) ([]string, bool) { for _, e := range r.Exemplars { b = append(b, e.SpanID) } return b, r.Type != "summary" }).parallel("exemplars"), list("exemplar_attributes", Variant, func(r *Metric, b []map[string]any) ([]map[string]any, bool) { for _, e := range r.Exemplars { b = append(b, e.Attributes) } return b, r.Type != "summary" }).parallel("exemplars"), object("attributes", func(r *Metric) map[string]any { return r.Attributes }, attributeShred), object("resource", func(r *Metric) map[string]any { return r.Resource }, resourceShred), str("scope_name", func(r *Metric) string { return r.ScopeName }).dict(), str("scope_version", func(r *Metric) string { return r.ScopeVersion }).dict(), ts("ingested_at", func(r *Metric) int64 { return r.IngestedAt }), nanos("ingested_unix_nano", func(r *Metric) int64 { return r.IngestedAt }), }, dedicated(semconv.Resource)...), }
Metric columns follow the ClickHouse exporter's point layout. A column that does not apply to a point's kind is NULL.
var SeverityBands = [...]string{"TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL"}
SeverityBands lists the six standard severity bands in ascending rank.
var Signals = []*Signal{Spans, Logs, Metrics}
Signals lists every signal in file order.
var Spans = &Signal{ Name: "spans", Time: "start_time", Order: Order{{Column: "_trace_hash"}, {Column: "start_unix_nano"}, {Column: "span_id"}}, Traces: true, Columns: append([]Column{ str("namespace", func(r *Span) string { return r.Namespace }), str("trace_id", func(r *Span) string { return r.TraceID }), u64("_trace_hash", func(r *Span) uint64 { return xxh3.HashString(r.TraceID) }).private(), str("span_id", func(r *Span) string { return r.SpanID }), str("parent_span_id", func(r *Span) string { return r.ParentSpanID }), str("service", func(r *Span) string { return r.ServiceName }), str("operation", func(r *Span) string { return r.Name }), str("kind", func(r *Span) string { return r.Kind }).dict(), ts("start_time", func(r *Span) int64 { return r.StartUnixNanos }), ts("end_time", func(r *Span) int64 { return r.EndUnixNanos }), nanos("start_unix_nano", func(r *Span) int64 { return r.StartUnixNanos }), nanos("end_unix_nano", func(r *Span) int64 { return r.EndUnixNanos }), f64("duration_ms", func(r *Span) float64 { return r.DurationMS }), str("status", func(r *Span) string { return r.StatusCode }).dict(), str("status_message", func(r *Span) string { return r.StatusMsg }), object("resource", func(r *Span) map[string]any { return r.Resource }, resourceShred), object("attributes", func(r *Span) map[string]any { return r.Attributes }, attributeShred), list("event_times", Time, func(r *Span, b []int64) ([]int64, bool) { for _, e := range r.Events { b = append(b, e.TimeUnixNanos) } return b, true }).parallel("events"), list("event_names", String, func(r *Span, b []string) ([]string, bool) { for _, e := range r.Events { b = append(b, e.Name) } return b, true }).parallel("events").dict(), list("event_attributes", Variant, func(r *Span, b []map[string]any) ([]map[string]any, bool) { for _, e := range r.Events { b = append(b, e.Attributes) } return b, true }).parallel("events"), list("link_trace_ids", String, func(r *Span, b []string) ([]string, bool) { for _, l := range r.Links { b = append(b, l.TraceID) } return b, true }).parallel("links"), list("link_span_ids", String, func(r *Span, b []string) ([]string, bool) { for _, l := range r.Links { b = append(b, l.SpanID) } return b, true }).parallel("links"), list("link_trace_states", String, func(r *Span, b []string) ([]string, bool) { for _, l := range r.Links { b = append(b, l.TraceState) } return b, true }).parallel("links").dict(), list("link_attributes", Variant, func(r *Span, b []map[string]any) ([]map[string]any, bool) { for _, l := range r.Links { b = append(b, l.Attributes) } return b, true }).parallel("links"), str("trace_state", func(r *Span) string { return r.TraceState }).dict(), i64("flags", func(r *Span) int64 { return int64(r.Flags) }), str("scope_name", func(r *Span) string { return r.ScopeName }).dict(), str("scope_version", func(r *Span) string { return r.ScopeVersion }).dict(), ts("ingested_at", func(r *Span) int64 { return r.IngestedAt }), nanos("ingested_unix_nano", func(r *Span) int64 { return r.IngestedAt }), str("rpc_service", func(r *Span) string { return r.RPCService }).dict(), str("peer_service", func(r *Span) string { return r.PeerService }).dict(), str("exception_type", func(r *Span) string { return r.ExceptionType }).dict(), str("exception_message", func(r *Span) string { return r.ExceptionMessage }), derived("messaging_system", String, "TRY_CAST(attributes['messaging.system'] AS VARCHAR)"), derived("messaging_destination", String, "TRY_CAST(attributes['messaging.destination.name'] AS VARCHAR)"), }, dedicated(semconv.Span, semconv.Resource)...), }
Spans keep trace locality, which the trace index depends on. Logs and metrics follow the OpenTelemetry Collector's ClickHouse exporter, with namespace before service: a coarse time bucket or the series identity first, and time last, so row-group statistics separate time ranges, services and metric names.
Functions ¶
func FirstPositiveNanos ¶
FirstPositiveNanos returns the first usable timestamp in priority order.
func IsBatchCorrupt ¶
func MetricSeriesID ¶
MetricSeriesID hashes the OTLP series identity, independent of point value, kind, temporality and time. Call after decoding the complete identity. Ingest hashes every point, so the encoding is built on the stack.
func NormalizeNamespace ¶
func NormalizeSeverity ¶
NormalizeSeverity maps a record onto the six OTel severity names, so that a search for ERROR finds every error however its emitter spelled it.
Passing SeverityText through unchanged is what produced a store holding INFO, INFORMATION and "" for the same level: .NET writes "Information", Envoy's access logs carry no severity at all, and each spelling then answered a different query. severity_number is preferred because the specification makes it the authoritative field and the text the display form, and a record that carries neither is stored as UNSPECIFIED rather than as an empty string — the log-bucket query already labels that case UNSPECIFIED, and a level you can see in the chart should be one you can filter on.
func SeverityAliases ¶
SeverityAliases returns a copy of the lowercase synonym-to-band table.
func SeverityFromText ¶
SeverityFromText canonicalizes the spellings emitters use when they send no severity_number: OTel's own numbered short names (INFO2, WARN3), the syslog names, and the long forms favoured by .NET and Python.
func SeverityRank ¶
SeverityRank returns a standard band's ascending rank; unknown bands have none.
func ValidateBatchID ¶
ValidateBatchID is the one grammar for identifiers that become directory names under the storage root. It is exported because the store package validates marker-supplied IDs against the same rule before joining them to a path; a second copy there could drift and leave the two gates disagreeing about what is a safe name.
func ValidatePublishedBatch ¶
ValidatePublishedBatch deeply decodes a single batch and checks its schema, row counts, complete trace ordering and exact trace-index ranges.
func ValueBytes ¶
ValueBytes accounts for owned attribute payloads and container overhead without allocating another serialized copy while ingest is backpressured.
Types ¶
type BatchMetadata ¶
type BatchMetadata struct {
Version uint32 `json:"version"`
ID string `json:"id"`
MinIngestedNanos int64 `json:"min_ingested_nanos"`
MaxIngestedNanos int64 `json:"max_ingested_nanos"`
MinSpanStartNanos int64 `json:"min_span_start_nanos"`
MaxSpanStartNanos int64 `json:"max_span_start_nanos"`
Generation uint32 `json:"generation"`
Spans int `json:"spans"`
Logs int `json:"logs"`
Metrics int `json:"metrics"`
// Bytes is the batch's on-disk size, derived rather than persisted: it is
// measured when a batch is loaded, from stats the load already performs.
// Zero means not measured.
Bytes int64 `json:"-"`
// Event times come from fixed-schema Parquet footer statistics, not ingest
// timestamps. They are derived on publication/load and never change the persisted format.
SpanTime TimeRange `json:"-"`
LogTime TimeRange `json:"-"`
MetricTime TimeRange `json:"-"`
}
type BatchVerifier ¶
type BatchVerifier struct {
// contains filtered or unexported fields
}
BatchVerifier reuses one bounded native engine for an offline batch walk. It creates no catalog, spill files, or downloaded extensions.
func NewBatchVerifier ¶
func NewBatchVerifier(ctx context.Context, directory string) (*BatchVerifier, error)
func (*BatchVerifier) Close ¶
func (v *BatchVerifier) Close() error
type Column ¶
type Column struct {
Name string
Type Type
Null bool // nullable; an absent value is NULL
List bool // a nullable LIST of Type elements
Dict bool // dictionary-encoded; see the encoding note below
Delta bool // DELTA_BINARY_PACKED: an integer instant or count of nanoseconds
Dense bool // compressed with parquetDenseCodec
Shred []string // VARIANT object keys also stored as typed columns
Expr string // raw-relation expression over stored columns
Private bool // part of the file layout only; no relation exposes it
Key *semconv.Key // dedicated column of a standard attribute key
Parallel string // lists of one group hold one element per item: events, links or exemplars
View Field // clean-view column; the zero Field leaves it out
// contains filtered or unexported fields
}
Column is one column of a signal. The writer fills a stored column from the canonical row; a column with Expr is computed by the raw relation instead.
Accessors take the row and return its value: func(*R) T for a required scalar, func(*R) (T, bool) for a nullable one, where false is NULL, and func(*R, []T) ([]T, bool) for a list, which appends the row's elements to the buffer it is given. A dedicated column has no accessor: the writer copies Key's value out of the attributes or resource map.
type CorruptBatchError ¶
type CorruptBatchError struct{ Err error }
CorruptBatchError denotes evidence of malformed authoritative data. A failed verifier (permissions, engine limits or cancellation) is not such evidence.
func (*CorruptBatchError) Error ¶
func (e *CorruptBatchError) Error() string
func (*CorruptBatchError) Unwrap ¶
func (e *CorruptBatchError) Unwrap() error
type Exemplar ¶
type Exemplar struct {
TimeUnixNanos int64
Value float64 // integers become doubles
TraceID string
SpanID string
Attributes map[string]any
}
Exemplar is a sampled measurement with its typed filtered attributes.
type Field ¶
type Field struct {
Name string
Type Type
List bool
Expr string // over the raw relation; empty reads the column itself
}
Field is a column of a signal's clean view.
type Histogram ¶
type Histogram struct {
Count uint64
Sum float64
Min float64
Max float64
HasSum bool
HasMin bool
HasMax bool
Bounds []float64 // explicit bucket upper bounds
Counts []uint64 // explicit bucket counts, one more than Bounds
Exponential bool
Scale int32
ZeroCount uint64
ZeroThreshold float64
PositiveOffset int32
PositiveCounts []uint64
NegativeOffset int32
NegativeCounts []uint64
Quantiles []float64 // summary quantiles in [0, 1]
QuantileValues []float64
}
Histogram holds the aggregate of a histogram or summary point.
type IndexedSpan ¶
type IndexedSpan struct {
Namespace string
TraceID string
SpanID string
ParentSpanID string
ServiceName string
Name string
Kind string
StartUnixNanos int64
DurationMS float64
StatusCode string
StatusMsg string
}
IndexedSpan is the narrow projection needed by trace-detail queries. The complete authoritative span remains in Parquet and is available through SQL; keeping this narrow projection small avoids decoding large attribute columns.
type Log ¶
type Log struct {
Namespace string
EventUnixNanos int64
TimeUnixNanos int64
ObservedTimeNanos int64
Severity string
SeverityNumber int32
Body string
ServiceName string
TraceID string
SpanID string
Flags uint32
Resource map[string]any
Attributes map[string]any
ScopeName string
ScopeVersion string
IngestedAt int64
BodyTemplate string
}
type Metric ¶
type Metric struct {
SeriesID uint64
Namespace string
EventUnixNanos int64
TimeUnixNanos int64
Name string
Description string
Unit string
Type string
Temporality string // cumulative or delta; empty for gauges and summaries
StartTimeUnixNanos int64
ServiceName string
Flags uint32
Value float64 // gauge and sum points; integers become doubles
Histogram
Exemplars []Exemplar
Attributes map[string]any
Resource map[string]any
ScopeName string
ScopeVersion string
IngestedAt int64
}
Metric is one OTLP data point. Type is the user-visible kind: gauge, counter, updown, histogram (explicit or exponential) or summary.
type Order ¶
type Order []Part
Order is a signal's row order. Ingest sorts each batch by it, compaction merges sorted inputs by it, and offline verification checks it. Ties keep their input order.
type ParquetMergeStats ¶
ParquetMergeStats records row counts and the existing span metadata bounds without decoding the completed output a second time.
type ParquetStats ¶
type ParquetStore ¶
type ParquetStore struct {
// contains filtered or unexported fields
}
func OpenParquetStore ¶
func OpenParquetStore(dir string) (*ParquetStore, error)
func (*ParquetStore) BatchMetadata ¶
func (p *ParquetStore) BatchMetadata() []BatchMetadata
BatchMetadata returns the installed batches in canonical order: generation, then earliest ingest time, then ID. The result is a shared, immutable snapshot republished on every catalog mutation, so this call takes no lock and allocates nothing. Callers MUST NOT mutate it — no sorting, appending in place, or assigning elements; clone it first (slices.Clone) if they need to.
func (*ParquetStore) BatchPath ¶
func (p *ParquetStore) BatchPath(id string) string
func (*ParquetStore) BatchesDir ¶
func (p *ParquetStore) BatchesDir() string
func (*ParquetStore) Close ¶
func (p *ParquetStore) Close() error
Close releases the footer cache's open files.
func (*ParquetStore) CollectRetired ¶
func (p *ParquetStore) CollectRetired() (int, error)
CollectRetired deletes retired batch directories no pinned reader can still open. Retirements are deleted in publication order and the pass stops at the first failure, so a compacted batch is never removed before the inputs its replaces list retires. Removals are made durable before a batch carrying a replaces list is removed, so a filesystem that reorders directory operations cannot keep an input after losing the output that retired it. Each directory leaves the batch namespace with one rename before it is removed, so a partial removal is never mistaken for a published batch. Callers serialize this with compaction and retention.
func (*ParquetStore) CommitBatch ¶
func (p *ParquetStore) CommitBatch(ctx context.Context, metadata *BatchMetadata, spans []Span, logs []Log, metrics []Metric) error
CommitBatch publishes one atomic batch directory. Preparation is allowed to finish; only the final publish-gate wait is capped. A stalled publication therefore cannot hang ingest, while a large valid encode does not consume the gate budget before it starts waiting. On success metadata is replaced with the actual published metadata, including an adopted earlier attempt.
func (*ParquetStore) CompactionDebt ¶
func (p *ParquetStore) CompactionDebt() int
CompactionDebt returns the reclaimable generation-0 backlog, excluding batches that the compaction policy cannot yet merge. No metadata scan.
func (*ParquetStore) Dir ¶
func (p *ParquetStore) Dir() string
func (*ParquetStore) Generation0BatchCount ¶
func (p *ParquetStore) Generation0BatchCount() int
Generation0BatchCount is the exact live ingest-batch inventory, including terminal oversized batches and underfilled day groups. The cached count lets metrics read it without waiting for the catalog lock or a metadata scan.
func (*ParquetStore) MergeParquet ¶
func (p *ParquetStore) MergeParquet(ctx context.Context, signal string, inputs []string, output string) (ParquetMergeStats, error)
MergeParquet rewrites immutable files into one native Parquet output. Span rows retain the index order required by trace.fidx and build that sidecar as they are copied; the other signals keep their input order. Re-encoding also consolidates tiny ingest row groups. A logs output gets logs.fidx, derived from the merged file as a commit's is rather than remapped from the inputs' postings.
func (*ParquetStore) Pattern ¶
func (p *ParquetStore) Pattern(signal string) string
func (*ParquetStore) Pin ¶
func (p *ParquetStore) Pin() SnapshotPin
Pin admits a reader to the current catalog. It never waits: publication swaps the catalog atomically and defers deleting what it replaced.
func (*ParquetStore) PrepareReplacement ¶
func (p *ParquetStore) PrepareReplacement(dir string, metadata BatchMetadata) error
PrepareReplacement durably records metadata after all signal merges and the streaming trace index have completed. Span bounds come from the merge.
func (*ParquetStore) PruneBefore ¶
func (p *ParquetStore) PruneBefore(cutoff int64, maxBatches int, publish func(func(context.Context) error) error) (int, error)
PruneBefore removes complete batches from the catalog in one swap. Readers never wait: directories stay in place until CollectRetired finds no reader that could still open them. Each batch is durably marked pruned before the swap, so a crash before deletion retires it at the next open instead of republishing it. Callers serialize this with compaction, so the candidates stay in the catalog until the swap; if the swap fails, marked batches stay listed until the next pass prunes them.
func (*ParquetStore) PublishReplacement ¶
func (p *ParquetStore) PublishReplacement(stage string, metadata BatchMetadata, inputs []string, publish func(func(context.Context) error) error) error
PublishReplacement validates a prepared compacted batch and swaps it for its inputs. The output's rename commits the replacement: its replaces list retires the inputs, whose directories stay in place for readers that captured the old catalog until CollectRetired deletes them. No reader is excluded or waited for.
func (*ParquetStore) RetirementWaiting ¶
func (p *ParquetStore) RetirementWaiting(pin SnapshotPin) bool
RetirementWaiting reports whether deleting a retired batch waits for pin, so a resumable reader can release its snapshot at a convenient boundary.
func (*ParquetStore) RetiringBatches ¶
func (p *ParquetStore) RetiringBatches() int
RetiringBatches is the number of retired batch directories not yet deleted.
func (*ParquetStore) RowCount ¶
func (p *ParquetStore) RowCount() uint64
func (*ParquetStore) StagingPath ¶
func (p *ParquetStore) StagingPath(id string) string
func (*ParquetStore) Stats ¶
func (p *ParquetStore) Stats() (map[string]ParquetStats, error)
func (*ParquetStore) Trace ¶
func (p *ParquetStore) Trace(ctx context.Context, query TraceQuery) ([]IndexedSpan, TraceTotals, error)
Trace reads only ranges selected by the persistent hash index. Scope filters and the limit are applied while decoding so a pathological trace cannot grow request memory without bound. The totals it returns describe the whole trace, not the page the limit admitted.
func (*ParquetStore) TraceDetail ¶
func (p *ParquetStore) TraceDetail(ctx context.Context, query TraceQuery) (TraceDetail, error)
TraceDetail reads a trace's spans and logs from one capture of the catalog, so a publication between the two reads cannot pair the spans of one catalog with the logs of another. Both reads take query.Limit.
func (*ParquetStore) TraceLogs ¶
func (p *ParquetStore) TraceLogs(ctx context.Context, query TraceQuery) ([]TraceLog, error)
TraceLogs reads one trace's logs through each batch's log index: a probe per batch whose log times meet the window, then only the posted rows. It keeps the first Limit rows by (time, service, span ID, batch, row), a total order that refines time order.
func (*ParquetStore) TraceSummaries ¶
func (p *ParquetStore) TraceSummaries(ctx context.Context, ids []TraceIdentity, start, end int64) ([]TraceTotals, error)
TraceSummaries reads bounded identities in one batch pass, opening each index and matching span file once. Hash collisions are resolved by exact identity.
func (*ParquetStore) Unpin ¶
func (p *ParquetStore) Unpin(pin SnapshotPin)
Unpin releases a reader. Releasing a zero pin is a no-op.
func (*ParquetStore) WaitForCompactionLimit ¶
func (p *ParquetStore) WaitForCompactionLimit(ctx context.Context) error
WaitForCompactionLimit wakes higher-generation work when ingest needs the compactor. Registration and the threshold check share the catalog lock, so debt cannot cross the limit between the check and subscribing. No lock is held while waiting, and caller cancellation releases the waiter.
type Part ¶
Part is one component of a sort key: a stored column's value or, with Bucket, that integer value floored to a multiple of Bucket. Buckets let the order name time buckets that no column stores.
type Signal ¶
type Signal struct {
Name string // file stem and relation name
Time string // event-time column whose footer statistics bound a file
Order Order // row order of every file
Traces bool // files carry trace.fidx, built from an order led by _trace_hash
Columns []Column
// contains filtered or unexported fields
}
Signal is the layout of one signal's Parquet files and its relations.
func LookupSignal ¶
LookupSignal returns the signal with this name.
func (*Signal) Dedicated ¶
Dedicated returns the standard key whose dedicated column holds the typed values of key in this signal's attributes or resource map.
type SnapshotPin ¶
type SnapshotPin struct {
// contains filtered or unexported fields
}
SnapshotPin records the catalog epoch a reader entered at. A reader pins before it captures BatchMetadata and unpins when it no longer opens files.
type Span ¶
type Span struct {
Namespace string
TraceID string
SpanID string
ParentSpanID string
ServiceName string
Name string
Kind string
StartUnixNanos int64
EndUnixNanos int64
DurationMS float64
StatusCode string
StatusMsg string
Resource map[string]any
Attributes map[string]any
Events []Event
Links []Link
TraceState string
Flags uint32
ScopeName string
ScopeVersion string
IngestedAt int64
RPCService string
PeerService string
ExceptionType string
ExceptionMessage string
}
type TraceDetail ¶
type TraceDetail struct {
Spans []IndexedSpan
Totals TraceTotals
Logs []TraceLog
}
TraceDetail is one trace's span page, its whole-trace totals and its log page.
type TraceIdentity ¶
type TraceIdentity struct{ Namespace, TraceID string }
TraceIdentity keeps equal trace IDs in different namespaces separate.
type TraceLog ¶
type TraceLog struct {
Namespace string
ServiceName string
TraceID string
SpanID string
Severity string
Body string
TimeUnixNanos int64
// contains filtered or unexported fields
}
TraceLog is the narrow projection of a log row that trace detail shows.
type TraceQuery ¶
type TraceTotals ¶
type TraceTotals struct {
// Root prefers a parentless span, then start time and span ID, across all
// matching indexed ranges, independently of the detail page limit.
Root *IndexedSpan
Spans int
Services int
DurationMS float64
HasError bool
MinStartNano int64
MaxEndNano int64
}
TraceTotals describes the whole trace, not the page a limit admitted.
These come free: readIndexedTrace already decodes every row of the trace and applies the same predicates a separate aggregate would, and only the heap is bounded by Limit. Deriving them here removes a second pass over every batch file -- the thing that made trace_detail pay for its own correctness.