Documentation
¶
Index ¶
- func BuildValues(predefined map[string]string, cols []ColumnDef, rawAttrs []dash0api.KeyValue) map[string]string
- func CSVHeader(cols []ColumnDef) []string
- func CSVRow(cols []ColumnDef, values map[string]string) []string
- func FormatTimestamp(nanoStr string) string
- func NormalizeTimestamp(s string) string
- func ParseFilter(s string) (dash0api.AttributeFilter, error)
- func ParseFilters(filterStrings []string) (*dash0api.FilterCriteria, error)
- func RenderTable(w io.Writer, cols []ColumnDef, rows []map[string]string, skipHeader bool)
- func ValidateColumnFormat(columns []string, outputFormat string) error
- func WriteCSVHeader(w *csv.Writer, cols []ColumnDef) error
- func WriteCSVRow(w *csv.Writer, cols []ColumnDef, values map[string]string) error
- type ColumnDef
- type ColumnSpec
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
CSVHeader returns the CSV header row for the given columns using canonical keys.
func FormatTimestamp ¶ added in v1.4.0
FormatTimestamp converts a nanosecond Unix timestamp string to a human-readable format.
func NormalizeTimestamp ¶
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
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
ValidateColumnFormat rejects --column with JSON output.
func WriteCSVHeader ¶ added in v1.5.0
WriteCSVHeader writes the CSV header 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.