query

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildValues added in v1.5.0

func BuildValues(predefined map[string]string, cols []ColumnDef, rawAttrs []dash0api.KeyValue) map[string]string

BuildValues merges predefined values with attribute lookups for arbitrary columns.

func CSVHeader added in v1.5.0

func CSVHeader(cols []ColumnDef) []string

CSVHeader returns the CSV header row for the given columns using canonical keys.

func CSVRow added in v1.5.0

func CSVRow(cols []ColumnDef, values map[string]string) []string

CSVRow returns a CSV data row for the given columns and values.

func FormatTimestamp added in v1.4.0

func FormatTimestamp(nanoStr string) string

FormatTimestamp converts a nanosecond Unix timestamp string to a human-readable format.

func NormalizeTimestamp

func NormalizeTimestamp(s string) string

NormalizeTimestamp normalizes an absolute timestamp to the format required by the Dash0 API (RFC 3339 with millisecond precision). Relative expressions like "now" and "now-1h" are returned as-is.

func ParseFilter

func ParseFilter(s string) (dash0api.AttributeFilter, error)

ParseFilter parses a single filter string into an AttributeFilter.

Format: key [operator] value

  • If key starts with single quote, consume until closing quote
  • Next token is checked against known operators
  • If it matches: use that operator, rest is value
  • If no match: implicit "is" operator, rest (from that token) is value
  • is_set/is_not_set expect no value
  • is_one_of/is_not_one_of split value on whitespace (single-quoted tokens may contain spaces)

func ParseFilters

func ParseFilters(filterStrings []string) (*dash0api.FilterCriteria, error)

ParseFilters parses a list of filter strings into FilterCriteria.

func RenderTable added in v1.5.0

func RenderTable(w io.Writer, cols []ColumnDef, rows []map[string]string, skipHeader bool)

RenderTable buffers all rows, computes optimal column widths (using Width as an upper bound), and renders the complete table. For each non-zero-width column, the effective width is min(maxWidth, max(headerLen, maxValueLen)). When skipHeader is true, header length is excluded from the computation. Width 0 (unlimited, typically the last column) stays unlimited.

func ValidateColumnFormat added in v1.5.0

func ValidateColumnFormat(columns []string, outputFormat string) error

ValidateColumnFormat rejects --column with JSON output.

func WriteCSVHeader added in v1.5.0

func WriteCSVHeader(w *csv.Writer, cols []ColumnDef) error

WriteCSVHeader writes the CSV header row.

func WriteCSVRow added in v1.5.0

func WriteCSVRow(w *csv.Writer, cols []ColumnDef, values map[string]string) error

WriteCSVRow writes a CSV data row.

Types

type ColumnDef added in v1.5.0

type ColumnDef struct {
	Key     string                   // canonical attribute key, e.g. "otel.log.time"
	Aliases []string                 // short aliases, e.g. ["timestamp", "time"]; case-insensitive
	Header  string                   // table header, e.g. "TIMESTAMP"
	Width   int                      // max width for table (upper bound); 0 = unlimited (last col)
	ColorFn func(string, int) string // optional color+pad formatter: (value, width) → styled string
}

ColumnDef defines a single output column.

func ResolveColumns added in v1.5.0

func ResolveColumns(specs []ColumnSpec, defaults []ColumnDef) []ColumnDef

ResolveColumns resolves user-provided column specs against the default column definitions. Each spec is matched by alias (case-insensitive) or by canonical key (case-sensitive). Unknown keys become arbitrary attribute columns.

type ColumnSpec added in v1.5.0

type ColumnSpec struct {
	Key string // user-provided key (alias or attribute key)
}

ColumnSpec represents a user-provided column specification from --column.

func ParseColumns added in v1.5.0

func ParseColumns(specs []string) ([]ColumnSpec, error)

ParseColumns parses a list of --column flag values into a list of ColumnSpec. Each value is a single column specification: an alias or attribute key.

Jump to

Keyboard shortcuts

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