Documentation
¶
Overview ¶
Package imbhgo is a Go binding for IMBH — an embeddable observability database — with zero-copy Arrow query results fused onto Go's scheduler via sable. (Binding plan M0: open → SQL → zero-copy rows. Ingest and typed queries land in M1/M2.)
Build with -tags sable_extern_lib so sable's Go package contributes no -lsable of its own; the combined staticlib below (which contains both imbhgo_* and sable_* symbols) is linked instead.
Index ¶
- Constants
- Variables
- func SetMaxInFlight(max uint64)
- type CompactionReport
- type Cursor
- type DB
- func (db *DB) AttrNames(ctx context.Context) ([]string, error)
- func (db *DB) AttrValues(ctx context.Context, key string) ([]string, error)
- func (db *DB) Close()
- func (db *DB) Compact() (CompactionReport, error)
- func (db *DB) CountLogs(ctx context.Context, q LogQuery) (uint64, error)
- func (db *DB) DurableThrough() (uint64, bool, error)
- func (db *DB) Export(table Table, startNs, endNs int64) ([]byte, error)
- func (db *DB) ExportRecords(table Table, startNs, endNs int64) ([]arrow.RecordBatch, error)
- func (db *DB) Flush() error
- func (db *DB) GetTrace(ctx context.Context, traceID string) (*Rows, error)
- func (db *DB) GetTraceForest(ctx context.Context, traceID string) ([]*TraceNode, error)
- func (db *DB) GetTraceSpans(ctx context.Context, traceID string) ([]Span, error)
- func (db *DB) IngestOTLPLogs(otlp []byte) (Receipt, error)
- func (db *DB) IngestOTLPMetrics(otlp []byte) (Receipt, error)
- func (db *DB) IngestOTLPTraces(otlp []byte) (Receipt, error)
- func (db *DB) LogVolume(ctx context.Context, q LogQuery, stepNs int64) ([]VolumeBucket, error)
- func (db *DB) LogVolumeBy(ctx context.Context, q LogQuery, stepNs int64, groupBy []string) ([]VolumeBucket, error)
- func (db *DB) Maintain() (MaintenanceReport, error)
- func (db *DB) MetricCatalog(ctx context.Context) ([]MetricInfo, error)
- func (db *DB) MetricExemplars(ctx context.Context, metric string) ([]Exemplar, error)
- func (db *DB) MetricSeries(ctx context.Context, metric string) ([]string, error)
- func (db *DB) Query(ctx context.Context, sql string) (*Rows, error)
- func (db *DB) QueryLogPage(ctx context.Context, q LogQuery, after Cursor) (*LogPage, error)
- func (db *DB) QueryLogQL(ctx context.Context, query string, start, end, step int64) (*Rows, error)
- func (db *DB) QueryLogQLLines(ctx context.Context, query string, start, end int64, limit int) ([]LogEntry, error)
- func (db *DB) QueryLogQLSeries(ctx context.Context, query string, start, end, step int64) ([]Series, error)
- func (db *DB) QueryLogs(ctx context.Context, q LogQuery) (*Rows, error)
- func (db *DB) QueryLogsTyped(ctx context.Context, q LogQuery) ([]LogEntry, error)
- func (db *DB) QueryMetricInstant(ctx context.Context, q MetricQuery) ([]InstantSample, error)
- func (db *DB) QueryMetricPoints(ctx context.Context, q MetricPointsQuery) (*Rows, error)
- func (db *DB) QueryMetricPointsTyped(ctx context.Context, q MetricPointsQuery) ([]MetricPoint, error)
- func (db *DB) QueryMetrics(ctx context.Context, q MetricQuery) (*Rows, error)
- func (db *DB) QueryMetricsTyped(ctx context.Context, q MetricQuery) (Matrix, error)
- func (db *DB) QueryPromQL(ctx context.Context, query string, start, end, step int64) (*Rows, error)
- func (db *DB) QueryPromQLSeries(ctx context.Context, query string, start, end, step int64) ([]Series, error)
- func (db *DB) QuerySpanMetrics(ctx context.Context, q SpanMetricsQuery) (*Rows, error)
- func (db *DB) QuerySpanMetricsTyped(ctx context.Context, q SpanMetricsQuery) ([]SpanMetricPoint, error)
- func (db *DB) QueryTraceQL(ctx context.Context, query string, start, end int64) (*Rows, error)
- func (db *DB) QueryTraceQLMatches(ctx context.Context, query string, start, end int64) ([]TraceMatch, error)
- func (db *DB) SearchTraces(ctx context.Context, q TraceQuery) ([]TraceSummary, error)
- func (db *DB) SegmentFiles(table Table) ([]string, error)
- func (db *DB) Segments() ([]SegmentRef, error)
- func (db *DB) Snapshot(dir string) (SnapshotInfo, error)
- func (db *DB) Stats() (DbStats, error)
- func (db *DB) TryIngestOTLPLogs(otlp []byte) (Receipt, error)
- func (db *DB) TryIngestOTLPMetrics(otlp []byte) (Receipt, error)
- func (db *DB) TryIngestOTLPTraces(otlp []byte) (Receipt, error)
- type DbOptions
- type DbStats
- type Exemplar
- type InstantSample
- type LogEntry
- type LogPage
- type LogQuery
- type MaintenanceReport
- type Matrix
- type MetricInfo
- type MetricPoint
- type MetricPointsQuery
- type MetricQuery
- type Point
- type QueryStats
- type Receipt
- type Rows
- type SegmentRef
- type Series
- type SnapshotInfo
- type Span
- type SpanMetricPoint
- type SpanMetricsQuery
- type Stats
- type Table
- type TableStats
- type TraceMatch
- type TraceNode
- type TraceQuery
- type TraceSummary
- type VolumeBucket
Constants ¶
const Version = release.Version
Version is the module release this source corresponds to. It is bumped in lockstep with each tagged release, and the prebuilt libimbhgo.a assets on GitHub Releases are named after it. The canonical value lives in internal/release (which is cgo-free so cmd/imbhgo-fetch can share it without depending on the archive); this re-export lets consumers read imbhgo.Version at runtime.
Variables ¶
var ErrBackpressure = sable.ErrBackpressure
ErrBackpressure is returned by the Try* entry points and by Query when the fused runtime is at its in-flight cap (see SetMaxInFlight). No work was admitted; the caller should shed load or retry.
Functions ¶
func SetMaxInFlight ¶
func SetMaxInFlight(max uint64)
SetMaxInFlight caps the number of concurrently in-flight *admitted* operations (0 = unbounded, the default). The cap is process-global (one fused runtime) and applies to every admission-controlled entry point: TryIngestOTLP* and Query — a live Rows holds a slot until Close, so the cap also bounds concurrent open result streams. The blocking IngestOTLP* path is never refused (it still counts toward the in-flight gauge). Observe rejections via RuntimeStats().Rejected.
Types ¶
type CompactionReport ¶
type CompactionReport struct {
SegmentsMerged uint64 `json:"segments_merged"`
SegmentsCreated uint64 `json:"segments_created"`
}
CompactionReport summarizes a compact() pass (imbh: Db::compact).
type Cursor ¶
type Cursor []byte
Cursor is an opaque page-resume token. Obtain it from LogPage.Next and pass it back to QueryLogPage to fetch the following page (reusing the same filters/limit/direction). Treat it as opaque — do not construct or interpret it. The zero (nil) value requests the first page.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a handle to an embedded IMBH database.
func OpenInMemory ¶
OpenInMemory opens an ephemeral, process-local database (great for tests and dev loops).
func OpenReadOnly ¶
OpenReadOnly opens an existing on-disk database at path read-only. It takes no writer lock, so it coexists with the single writer process and with other readers; queries see the writer's segments unioned with its live WAL tail (near-real-time). Every write returns an error.
Rejected if the writer had its WAL disabled (the reader could then get only seal-interval freshness, not near-real-time); use OpenWith with AllowStaleReads to accept that. (imbh: Db::open_read_only.)
func OpenWith ¶
OpenWith opens a durable database configured by opts (imbh: Db::builder(path) + setters).
func (*DB) AttrNames ¶
AttrNames returns every distinct attribute/label key present on any signal (logs, spans, metrics), plus "service.name" when any record carries a service. Sorted.
func (*DB) AttrValues ¶
AttrValues returns the distinct string values for one attribute key across every signal, sorted.
func (*DB) Compact ¶
func (db *DB) Compact() (CompactionReport, error)
Compact merges segments to reduce fragmentation. Writer-only.
func (*DB) CountLogs ¶
CountLogs returns the number of log records matching q — imbh's logs().count(filter), a full count(*) over the filter that ignores q.Limit and q.Backward (they bound/order returned rows, not the total). It scans without materializing rows, so it is cheaper than draining QueryLogs when you only need the tally. Equivalent to SELECT count(*) via Query, but driven by the same typed LogQuery.
func (*DB) DurableThrough ¶
DurableThrough returns the highest LSN durably persisted, or (0, false) if nothing is durable yet (imbh: Db::durable_through).
func (*DB) Export ¶
Export returns the given table's rows over [startNs, endNs) as an Arrow-IPC stream (a self-describing schema + record batches), buffer unioned with segments ordered by time. Pass startNs == endNs == 0 for the whole range. Use ExportRecords to decode. (imbh: Db::export.)
func (*DB) ExportRecords ¶
ExportRecords is Export decoded into Arrow record batches. Each returned batch is Retained and owned by the caller — Release() it when done.
func (*DB) Flush ¶
Flush seals the in-memory buffer into an immutable segment. Not required for queryability (queries see the buffer union segments); use it to bound memory or to exercise the on-disk read path.
func (*DB) GetTrace ¶
GetTrace fetches one trace's spans as zero-copy Arrow rows. traceID is the 32-char hex id — the same form QueryTraceQLMatches returns, so a TraceQL match can be passed straight in.
func (*DB) GetTraceForest ¶
GetTraceForest fetches a trace's spans (via GetTraceSpans) and returns them assembled into a parent→child forest. It is named GetTraceForest rather than GetTrace because DB.GetTrace already exists in lgtm.go and returns zero-copy Arrow *Rows.
func (*DB) GetTraceSpans ¶
GetTraceSpans fetches a trace and decodes its spans into []Span (ordered by start time).
func (*DB) IngestOTLPLogs ¶
IngestOTLPLogs ingests OTLP/HTTP logs export-request protobuf bytes (what a stock OTel exporter sends). Data is queryable immediately, before any Flush.
func (*DB) IngestOTLPMetrics ¶
IngestOTLPMetrics ingests an OTLP metrics export-request.
func (*DB) IngestOTLPTraces ¶
IngestOTLPTraces ingests an OTLP traces export-request.
func (*DB) LogVolume ¶
LogVolume returns log record counts per stepNs-sized time bucket over the filter q. The bucket start is floor(time/stepNs)*stepNs in unix nanos; buckets carry no labels (Labels == "{}").
func (*DB) LogVolumeBy ¶
func (db *DB) LogVolumeBy(ctx context.Context, q LogQuery, stepNs int64, groupBy []string) ([]VolumeBucket, error)
LogVolumeBy is LogVolume broken down by the given attribute keys — counts per (step-bucket, label set), each bucket carrying its Labels as canonical JSON. Empty groupBy is equivalent to LogVolume.
A key may name a record attribute or the service: "service.name" (the OTel resource key) and "service" (the column it is lifted into at ingest) both split per service. Requires imbh 0.3.0 — before that, either spelling silently collapsed the breakdown into one empty-labelled bucket set.
func (*DB) Maintain ¶
func (db *DB) Maintain() (MaintenanceReport, error)
Maintain runs a maintenance pass (seal + retention enforcement). Writer-only; a read-only handle returns an error.
func (*DB) MetricCatalog ¶
func (db *DB) MetricCatalog(ctx context.Context) ([]MetricInfo, error)
MetricCatalog returns the metric catalog — one MetricInfo per stored metric.
func (*DB) MetricExemplars ¶
MetricExemplars returns every exemplar recorded for a metric. Exemplars are carried by histogram/ exponential-histogram (and gauge/sum) points; a metric with none yields an empty slice.
func (*DB) MetricSeries ¶
MetricSeries returns the distinct label sets (series) carrying a metric, each rendered as its canonical JSON object string. Resource-level dimensions like service are separate axes and are not folded in.
func (*DB) Query ¶
Query runs a SQL statement and returns a lazily-streamed, zero-copy result set. The query executes batch-by-batch on IMBH's engine (fused onto Go's scheduler via sable); each Rows.Next pulls one Arrow RecordBatch without copying its buffers. Cancelling ctx aborts a parked Next (interrupting a slow batch) and cancels the query on the IMBH side (releasing its pinned snapshot); after cancellation, Next returns ok=false with ctx.Err().
func (*DB) QueryLogPage ¶
QueryLogPage runs a single page of a log query. Pass a nil Cursor for the first page; pass the returned LogPage.Next (while HasMore) for each subsequent page, keeping the same LogQuery. Rows are materialized into []LogEntry (like QueryLogsTyped); the page's cursor and QueryStats come back alongside. (imbh: logs().query → LogPage, LogQuery::after.)
func (*DB) QueryLogQL ¶
QueryLogQL evaluates a LogQL query over [start, end] at step, returning zero-copy Arrow rows. LogQL has two result shapes (as in Loki): a range aggregation (e.g. count_over_time, rate) yields labeled series (labels|timestamp|value), while a bare selector yields log lines (the logs projection). See QueryLogQLSeries and QueryLogQLLines for the decoded forms.
func (*DB) QueryLogQLLines ¶
func (db *DB) QueryLogQLLines(ctx context.Context, query string, start, end int64, limit int) ([]LogEntry, error)
QueryLogQLLines evaluates a bare LogQL selector (e.g. `{service="checkout"} |= "error"`) and decodes the matching log lines. This is LogQL's `streams` result shape, as opposed to the `matrix` shape a range aggregation produces (see QueryLogQLSeries). limit caps the lines returned (0 = engine default).
func (*DB) QueryLogQLSeries ¶
func (db *DB) QueryLogQLSeries(ctx context.Context, query string, start, end, step int64) ([]Series, error)
QueryLogQLSeries evaluates a LogQL range aggregation and decodes it into labeled series.
func (*DB) QueryLogs ¶
QueryLogs runs a typed log query, returning a zero-copy streamed result set (see Rows).
func (*DB) QueryLogsTyped ¶
QueryLogsTyped runs a typed log query and decodes the result rows into []LogEntry. Convenience over QueryLogs for callers that want Go structs rather than raw Arrow batches. Prefer QueryLogs (+ manual Arrow) for very large results, since this materializes all rows.
func (*DB) QueryMetricInstant ¶
func (db *DB) QueryMetricInstant(ctx context.Context, q MetricQuery) ([]InstantSample, error)
QueryMetricInstant runs an instant metric query (imbh's `metrics().instant`) over the same MetricQuery as QueryMetrics, returning one InstantSample per series (the last point in range).
func (*DB) QueryMetricPoints ¶
QueryMetricPoints returns raw metric samples as zero-copy Arrow rows. Columns: point_time, metric, service, attributes, temporality, is_monotonic, then value (scalar kinds) or explicit_bounds + bucket_counts (histogram).
func (*DB) QueryMetricPointsTyped ¶
func (db *DB) QueryMetricPointsTyped(ctx context.Context, q MetricPointsQuery) ([]MetricPoint, error)
QueryMetricPointsTyped decodes raw scalar (gauge/sum) samples into []MetricPoint. For histogram metrics use QueryMetricPoints and read the bucket columns directly.
func (*DB) QueryMetrics ¶
QueryMetrics runs a typed metric range query, returning a zero-copy streamed result set.
func (*DB) QueryMetricsTyped ¶
QueryMetricsTyped runs a metric range query and decodes it into a Matrix (rows grouped into series by the GroupBy label set). Convenience over QueryMetrics.
func (*DB) QueryPromQL ¶
QueryPromQL evaluates a PromQL query over [start, end] at the given step (all unix nanoseconds), returning the result as zero-copy Arrow rows (columns labels | timestamp | value).
func (*DB) QueryPromQLSeries ¶
func (db *DB) QueryPromQLSeries(ctx context.Context, query string, start, end, step int64) ([]Series, error)
QueryPromQLSeries evaluates a PromQL query and decodes the result into labeled series.
func (*DB) QuerySpanMetrics ¶
QuerySpanMetrics runs a span (RED) metrics query, returning a zero-copy streamed result set with columns bucket, [group labels], calls, errors, p50, p95, p99.
func (*DB) QuerySpanMetricsTyped ¶
func (db *DB) QuerySpanMetricsTyped(ctx context.Context, q SpanMetricsQuery) ([]SpanMetricPoint, error)
QuerySpanMetricsTyped runs a span (RED) metrics query and decodes the rows into []SpanMetricPoint.
func (*DB) QueryTraceQL ¶
QueryTraceQL evaluates a TraceQL query over the trace-start window [start, end] (unix nanoseconds), returning matches as zero-copy Arrow rows (columns trace_id | span_id).
func (*DB) QueryTraceQLMatches ¶
func (db *DB) QueryTraceQLMatches(ctx context.Context, query string, start, end int64) ([]TraceMatch, error)
QueryTraceQLMatches evaluates a TraceQL query and decodes the matches into []TraceMatch.
func (*DB) SearchTraces ¶
func (db *DB) SearchTraces(ctx context.Context, q TraceQuery) ([]TraceSummary, error)
SearchTraces returns the trace summaries matching q, most-recent-first per imbh's ordering.
func (*DB) SegmentFiles ¶
SegmentFiles lists the on-disk file paths backing the given table (imbh: Db::segment_files).
func (*DB) Segments ¶
func (db *DB) Segments() ([]SegmentRef, error)
Segments lists the database's current on-disk segments.
func (*DB) Snapshot ¶
func (db *DB) Snapshot(dir string) (SnapshotInfo, error)
Snapshot writes a consistent copy of the database's segments into dir (created if absent). Writer-only.
func (*DB) Stats ¶
Stats returns a snapshot of storage and ingest counters. Works on readers and writers.
func (*DB) TryIngestOTLPLogs ¶
TryIngestOTLPLogs is IngestOTLPLogs with backpressure: at the in-flight cap it returns ErrBackpressure immediately without ingesting (nothing admitted), so a producer can shed load or retry with backoff instead of piling on unbounded work.
func (*DB) TryIngestOTLPMetrics ¶
TryIngestOTLPMetrics is IngestOTLPMetrics with backpressure.
type DbOptions ¶
type DbOptions struct {
// Path is the on-disk directory (required).
Path string `json:"path"`
// ReadOnly opens as a reader (no writer lock; many may coexist with one writer).
ReadOnly bool `json:"read_only,omitempty"`
// AllowStaleReads lets a read-only open accept seal-interval freshness when the writer's WAL is
// off (otherwise such an open is rejected).
AllowStaleReads bool `json:"allow_stale_reads,omitempty"`
// MemoryBudgetBytes caps the in-memory buffer (0 = imbh default, 128 MiB).
MemoryBudgetBytes uint64 `json:"memory_budget_bytes,omitempty"`
// Compression selects the segment codec: "none", "lz4", or "zstd" (with ZstdLevel). "" = default.
Compression string `json:"compression,omitempty"`
// ZstdLevel is the zstd level used when Compression == "zstd".
ZstdLevel int32 `json:"zstd_level,omitempty"`
// WalMode selects the write-ahead-log mode: "off", "always", or "interval" (with WalIntervalNs).
WalMode string `json:"wal_mode,omitempty"`
// WalIntervalNs is the flush interval when WalMode == "interval".
WalIntervalNs int64 `json:"wal_interval_ns,omitempty"`
// RetentionDays drops data older than N days (0 = keep, unless MaxDiskBytes bounds it).
RetentionDays uint64 `json:"retention_days,omitempty"`
// MaxDiskBytes bounds on-disk segment bytes (0 = unbounded).
MaxDiskBytes uint64 `json:"max_disk_bytes,omitempty"`
// Refresh controls read-only snapshot refresh: "onquery", "manual", or "ttl" (with RefreshTtlNs).
Refresh string `json:"refresh,omitempty"`
// RefreshTtlNs is the refresh TTL when Refresh == "ttl".
RefreshTtlNs int64 `json:"refresh_ttl_ns,omitempty"`
// MaintenanceBackgroundNs runs background maintenance on an owned OS thread every N ns (0 = manual).
// This picks *who* runs the scheduler; Flush picks *when* it seals. imbh's default is manual, so
// with this at 0 nothing seals (and no WAL fsync timer runs) unless you call Flush/Maintain yourself.
MaintenanceBackgroundNs int64 `json:"maintenance_background_ns,omitempty"`
// Flush is imbh's flush-policy spec: comma-separated key=value pairs, or the single word "manual"
// ("off"/"none"/"never" alias it). Keys are interval/every (duration), buffer/bytes (size, or
// "budget"/"off"), rows (count), wal (size), idle (duration), and tick (duration); the triggers OR
// together. E.g. "interval=5s,wal=64MiB". Unlike the other string tags, a malformed spec fails the
// open rather than falling back to a default. "" leaves imbh's own default, which seals on the
// MaintenanceBackgroundNs tick and at the memory-budget-derived byte threshold. (imbh 0.2.0:
// DbBuilder::flush.)
Flush string `json:"flush,omitempty"`
// Duplicates picks what happens when two metric datapoints share a series *and* a timestamp — a
// pair PromQL has no meaning for, since series identity is service + __name__ + the string
// attributes. "" (or "error_on_read") keeps imbh's historical behavior: ingest takes both and any
// PromQL query touching that series fails, naming the metric, labels and instant. "last_wins"
// collapses the duplicated instant at read time, degrading one point instead of the whole metric —
// the only remedy for points already written. "reject" drops the repeat at ingest and counts it in
// Receipt.Rejected and DbStats.IngestRejected; it costs a fixed ~13 MiB guard and takes an optional
// lookback, "reject,recent=N" (default 262144 points). The guard is process-local, best-effort, and
// never rejects out-of-order or late points — only an exact (series, timestamp) repeat. Like Flush,
// a malformed spec fails the open rather than falling back. (imbh 0.5.0: DbBuilder::duplicates.)
Duplicates string `json:"duplicates,omitempty"`
// PromoteKeys promotes the given attribute keys to dedicated columns. Reserved names (including
// "service") are dropped by imbh, and "service.name" needs no promotion: since imbh 0.3.0 both
// spellings resolve to the built-in service column in every group-by and attribute predicate.
PromoteKeys []string `json:"promote_keys,omitempty"`
}
DbOptions configures a durable open, mirroring imbh's DbBuilder. The zero value opens with imbh's defaults (equivalent to Open). Only set fields take effect; unrecognized string tags are ignored (leaving the default). The host-runtime option variants (async ingest, runtime-driven maintenance), which need an explicit tokio runtime handle, are intentionally not exposed here.
type DbStats ¶
type DbStats struct {
Tables []TableStats `json:"tables"`
BufferBytes uint64 `json:"buffer_bytes"`
WalBytes uint64 `json:"wal_bytes"`
DurableLSN *uint64 `json:"durable_lsn"`
IngestQueueDepth uint64 `json:"ingest_queue_depth"`
IngestDropped uint64 `json:"ingest_dropped"`
IngestErrors uint64 `json:"ingest_errors"`
// IngestRejected counts metric points dropped at ingest because their (series, timestamp) was
// already accepted. Non-zero only under DbOptions.Duplicates == "reject"; every other policy
// takes duplicates and resolves them (or fails) at read time. (imbh 0.5.0.)
IngestRejected uint64 `json:"ingest_rejected"`
}
DbStats is a snapshot of the database's storage and ingest counters (imbh: Db::stats).
type Exemplar ¶
Exemplar is one OTLP exemplar surfaced from a metric point — the trace link for metric→trace drill-down. TraceID/SpanID are "" when the exemplar carries none. Attributes is the exemplar's filtered attributes as canonical JSON ("" when none).
type InstantSample ¶
InstantSample is one series' instant value: the last sample of that series over the query range (Vector semantics — exactly one sample per series). Labels is the canonical JSON label-set string; Time is unix nanoseconds.
type LogEntry ¶
type LogEntry struct {
Time int64 // event time, unix nanoseconds
Service string // service.name (may be "")
Severity uint8 // OTLP severity number
SeverityText string
Body string
Attributes string // attributes as a JSON object string
TraceID []byte // 16 bytes, or nil
SpanID []byte // 8 bytes, or nil
}
LogEntry is a decoded log record (a curated subset of IMBH's logs columns).
type LogPage ¶
type LogPage struct {
Entries []LogEntry
Next Cursor
Stats QueryStats
}
LogPage is one page of a paged log query: the decoded rows, a resume cursor (empty when the page was short, i.e. no more rows), and the scan statistics.
type LogQuery ¶
type LogQuery struct {
Service string `json:"service,omitempty"` // exact service.name match
Match string `json:"match,omitempty"` // full-text match on the log body
AttrEq map[string]string `json:"attr_eq,omitempty"` // attribute equality filters (AND)
Start int64 `json:"start,omitempty"` // time range start (unix nanos, inclusive)
End int64 `json:"end,omitempty"` // time range end (unix nanos)
Limit int `json:"limit,omitempty"` // max rows (0 = engine default)
Backward bool `json:"backward,omitempty"` // newest-first (default is oldest-first)
// Trace correlation: filter logs down to a single trace or span.
TraceID string `json:"trace_id,omitempty"` // hex trace id (32 hex chars); correlate logs to a trace
SpanID string `json:"span_id,omitempty"` // hex span id (16 hex chars); correlate to a single span
// Severity + attribute predicates (all AND-combined with the above).
SeverityAtLeast int `json:"severity_at_least,omitempty"` // minimum OTEL severity number (1-24); 0 = unset
AttrExists []string `json:"attr_exists,omitempty"` // keys that must be present
AttrMatches map[string]string `json:"attr_matches,omitempty"` // key → full-text term match on that attribute
AttrIn map[string][]string `json:"attr_in,omitempty"` // key → allowed value set
AttrNotIn map[string][]string `json:"attr_not_in,omitempty"` // key → excluded value set
AttrGt map[string]float64 `json:"attr_gt,omitempty"` // key → value must be > n
AttrGe map[string]float64 `json:"attr_ge,omitempty"` // key → value must be >= n
AttrLt map[string]float64 `json:"attr_lt,omitempty"` // key → value must be < n
AttrLe map[string]float64 `json:"attr_le,omitempty"` // key → value must be <= n
AttrRegex map[string]string `json:"attr_regex,omitempty"` // key → RE2 pattern the value must match
}
LogQuery is an endpoint-shaped log query (mirrors IMBH's LogQuery builder; a curated subset). The zero value matches all logs. Times are Unix nanoseconds; 0 means unset.
type MaintenanceReport ¶
type MaintenanceReport struct {
Sealed bool `json:"sealed"`
SegmentsDropped uint64 `json:"segments_dropped"`
BytesFreed uint64 `json:"bytes_freed"`
}
MaintenanceReport summarizes a maintain() pass (imbh: Db::maintain).
type Matrix ¶
type Matrix struct {
Series []Series
}
Matrix is the result of a metric range query — one series per distinct group-by label set.
type MetricInfo ¶
MetricInfo is one metric's catalog entry: its name, unit, temporality ("" when the kind carries none, e.g. summaries), and kind ("gauge" | "sum" | "histogram" | ...).
type MetricPoint ¶
type MetricPoint struct {
Time int64 // unix nanoseconds
Metric string
Service string
Attributes string // JSON object string
Value float64
}
MetricPoint is one decoded raw metric sample (scalar kinds: gauge / sum).
type MetricPointsQuery ¶
type MetricPointsQuery struct {
Metric string `json:"metric"`
Kind string `json:"kind,omitempty"`
Filters map[string]string `json:"filters,omitempty"` // attribute equality filters (AND)
Start int64 `json:"start,omitempty"`
End int64 `json:"end,omitempty"`
Limit int `json:"limit,omitempty"`
}
MetricPointsQuery selects raw (unaggregated) metric samples — the counterpart to MetricQuery, which resamples into a range. Kind is "gauge" (default), "sum", or "histogram". Times are Unix nanoseconds.
type MetricQuery ¶
type MetricQuery struct {
Metric string `json:"metric"` // metric name
Sum bool `json:"sum,omitempty"` // false = gauge (default), true = sum
Step int64 `json:"step,omitempty"` // resample step (nanos)
Start int64 `json:"start,omitempty"` // range start (unix nanos)
End int64 `json:"end,omitempty"` // range end (unix nanos)
GroupBy []string `json:"group_by,omitempty"` // attribute keys to split series on
}
MetricQuery is a metric range query over a scalar metric (gauge or sum). Times are Unix nanoseconds; Step is the resampling interval in nanoseconds. GroupBy names attribute keys to split series on — a record attribute, or the service under either spelling ("service.name" / "service"), which imbh 0.3.0 resolves to the built-in service column (earlier versions merged every service into one empty-labelled series). The same holds for LogQuery's attribute predicates and SpanMetricsQuery.
type QueryStats ¶
type QueryStats struct {
SegmentsScanned uint64 `json:"segments_scanned"`
SegmentsPruned uint64 `json:"segments_pruned"`
RowsScanned uint64 `json:"rows_scanned"`
RowsReturned uint64 `json:"rows_returned"`
BytesScanned uint64 `json:"bytes_scanned"`
ElapsedNs uint64 `json:"elapsed_ns"`
UsedIndex bool `json:"used_index"`
}
QueryStats reports what a query scanned. Complete only for a fully drained query (which QueryLogPage always does). Mirrors imbh's QueryStats.
type Receipt ¶
Receipt is the outcome of an ingest call. When Queued is true (async ingest), LSN/Durable carry no information yet.
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is a streaming, zero-copy query result. Iterate with Next until it returns ok=false, then check Err (or Close). Not safe for concurrent use: iterate from one goroutine. Each returned RecordBatch is owned by the caller — call its Release() when done.
ZERO-COPY CAVEAT: a batch's Arrow buffers are IMBH-owned and freed by Release(). Scalar values read from a batch — especially strings/[]byte via arrow-go, which alias the buffer without copying — are only valid until that batch's Release(). Copy anything you need to outlive the batch (e.g. strings.Clone for strings; QueryLogsTyped does this for you).
func (*Rows) Close ¶
func (r *Rows) Close()
Close releases the cursor (and cancels the query if not fully drained). Idempotent.
Abandoning a stream before end-of-stream means finish never runs, and finish is what clears this query's Rust-side error slot — so Close does it instead. Without that, a query that had already recorded a terminal error (a plan error, say, which is stored the moment the handler starts) holds that entry until the process exits: a slow leak for any long-lived program that abandons streams. See TestAbandonedStreamClearsErrorSlot.
One window remains open by design: if the handler records an error *after* this fetch — it is still running, and only a send failure makes it stop without storing — that entry is never claimed. The Rust-side fix would be to skip storing once the consumer is gone (`tx.is_closed()`), at every store site; the pending-error count in TestNoLeak is the tripwire if it ever matters in practice.
func (*Rows) Err ¶
Err returns the terminal error after Next has returned ok=false: nil (clean end), a query error, or context.Canceled/DeadlineExceeded. Meaningless before iteration ends.
func (*Rows) Next ¶
func (r *Rows) Next() (rec arrow.RecordBatch, ok bool, err error)
Next pulls the next result batch. ok=false marks the end of iteration; then Err reports whether it ended cleanly (nil), on a query error, or on context cancellation. On ok=true the RecordBatch wraps IMBH-allocated Arrow buffers zero-copy; the caller must Release() it.
type SegmentRef ¶
type SegmentRef struct {
RelativePath string `json:"relative_path"`
MinTimeUnixNano int64 `json:"min_time_unix_nano"`
MaxTimeUnixNano int64 `json:"max_time_unix_nano"`
Rows uint64 `json:"rows"`
}
SegmentRef identifies one on-disk segment and its covered time range (imbh: Db::segments).
type SnapshotInfo ¶
SnapshotInfo describes a snapshot written by Snapshot (imbh: Db::snapshot).
type Span ¶
type Span struct {
TraceID []byte
SpanID []byte
ParentSpanID []byte
Name string
Kind string
StartTime int64 // unix nanoseconds
DurationNs int64
StatusCode string
StatusMessage string
Service string
Attributes string // JSON object string
}
Span is one decoded span of a trace.
type SpanMetricPoint ¶
type SpanMetricPoint struct {
Bucket int64 // bucket start, unix nanoseconds
Labels map[string]string
Calls uint64
Errors uint64
P50 float64 // latency percentiles, nanoseconds
P95 float64
P99 float64
}
SpanMetricPoint is one bucket of RED span metrics for a label set.
type SpanMetricsQuery ¶
type SpanMetricsQuery struct {
Service string `json:"service,omitempty"`
Name string `json:"name,omitempty"` // span name
Kind string `json:"kind,omitempty"` // span kind
Status string `json:"status,omitempty"` // status code filter
GroupBy []string `json:"group_by,omitempty"` // attribute keys to split on
Step int64 `json:"step,omitempty"` // bucket width (nanos)
Start int64 `json:"start,omitempty"`
End int64 `json:"end,omitempty"`
}
SpanMetricsQuery is a span (RED) metrics query: calls / errors / latency percentiles over spans, bucketed by Step (nanos) and optionally split by GroupBy attribute keys.
type Stats ¶
Stats is a snapshot of the fused runtime's counters.
func RuntimeStats ¶
func RuntimeStats() Stats
RuntimeStats returns a snapshot of runtime counters (InFlight, Rejected, MaxInFlight, …) for backpressure tuning and observability.
type Table ¶
type Table string
Table names one of imbh's storage tables (logs, spans, and the five metric families). The string values match imbh's Table::as_str form used on the wire.
type TableStats ¶
type TableStats struct {
Table string `json:"table"`
SegmentCount uint64 `json:"segment_count"`
SegmentRows uint64 `json:"segment_rows"`
BufferRows uint64 `json:"buffer_rows"`
MinTimeUnixNano *int64 `json:"min_time_unix_nano"`
MaxTimeUnixNano *int64 `json:"max_time_unix_nano"`
}
TableStats is per-table storage accounting within DbStats.
type TraceMatch ¶
TraceMatch is a TraceQL match: a trace and the span ids its spanset selected.
type TraceNode ¶
TraceNode is one span in an assembled trace tree. It embeds the decoded Span and holds the spans whose ParentSpanID names this span's SpanID.
func AssembleTrace ¶
AssembleTrace rebuilds the parent→child forest from a flat span slice and returns the roots.
A span becomes a root when its ParentSpanID is empty OR when its parent's SpanID is not present in the input (an orphan is surfaced as a root so no span is ever dropped). Every other span is attached under the node whose SpanID equals its ParentSpanID. Spans are keyed by string(SpanID); on a duplicate SpanID the first occurrence wins and later ones are discarded.
The input slice is not mutated: nodes are built from copies of the Span values. Children of each node, and the returned roots, are sorted by StartTime then by string(SpanID) so the output is stable regardless of input order. An empty or nil input returns nil.
type TraceQuery ¶
type TraceQuery struct {
Service string `json:"service,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`
Kind string `json:"kind,omitempty"`
MinDurationNs int64 `json:"min_duration_ns,omitempty"`
MaxDurationNs int64 `json:"max_duration_ns,omitempty"`
AttrEq map[string]string `json:"attr_eq,omitempty"`
// Attribute predicates (parity with LogQuery; all AND-combined with the above).
AttrExists []string `json:"attr_exists,omitempty"` // keys that must be present
AttrMatches map[string]string `json:"attr_matches,omitempty"` // key → full-text term match on that attribute
AttrIn map[string][]string `json:"attr_in,omitempty"` // key → allowed value set
AttrNotIn map[string][]string `json:"attr_not_in,omitempty"` // key → excluded value set
AttrGt map[string]float64 `json:"attr_gt,omitempty"` // key → value must be > n
AttrGe map[string]float64 `json:"attr_ge,omitempty"` // key → value must be >= n
AttrLt map[string]float64 `json:"attr_lt,omitempty"` // key → value must be < n
AttrLe map[string]float64 `json:"attr_le,omitempty"` // key → value must be <= n
AttrRegex map[string]string `json:"attr_regex,omitempty"` // key → RE2 pattern the value must match
Start int64 `json:"start,omitempty"`
End int64 `json:"end,omitempty"`
Limit int64 `json:"limit,omitempty"`
}
TraceQuery selects traces for SearchTraces. All fields are optional: a field is applied only when non-empty/non-zero, so a zero TraceQuery matches everything (up to the server's default limit). The JSON tags match the Rust `TraceQueryWire`.
type TraceSummary ¶
type TraceSummary struct {
TraceID string
RootService string
RootName string
StartTime int64
DurationNs int64
SpanCount int64
Error bool
}
TraceSummary is one matched trace's summary row. RootService/RootName are "" when the root span carries none (SQL-NULL upstream). StartTime is unix nanoseconds; DurationNs is the trace's wall duration in nanoseconds.
type VolumeBucket ¶
VolumeBucket is one time bucket of a log-volume query: the bucket start (unix nanos), the label set identifying this bucket's series as canonical JSON ("{}" when un-grouped), and the record count.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
imbhgo-fetch
command
Command imbhgo-fetch downloads the prebuilt combined static library (libimbhgo.a) for the current platform so a consumer can build github.com/moriyoshi/imbh-go WITHOUT building the Rust side.
|
Command imbhgo-fetch downloads the prebuilt combined static library (libimbhgo.a) for the current platform so a consumer can build github.com/moriyoshi/imbh-go WITHOUT building the Rust side. |
|
internal
|
|
|
release
Package release holds the release coordinates for the prebuilt libimbhgo.a archives: the version this source corresponds to and the naming/URL scheme for the assets published on GitHub Releases.
|
Package release holds the release coordinates for the prebuilt libimbhgo.a archives: the version this source corresponds to and the naming/URL scheme for the assets published on GitHub Releases. |