Documentation
¶
Index ¶
- Constants
- func AddExplorerURL(wrapper map[string]any, explorerURL string) map[string]any
- 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 ParsePrecision(value string, timeRange dash0api.TimeReferenceRange) (*dash0api.Sampling, error)
- func PrintExplorerURL(w io.Writer, label, explorerURL string)
- 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 ¶
const ( AliasTimestamp = "timestamp" AliasTime = "time" AliasValue = "value" )
Common column alias constants shared across query commands.
const ( ExplorerLabelQuery = "Open this query in Dash0:" ExplorerLabelTrace = "Open this trace in Dash0:" )
Labels introducing a deep link in human-readable output.
const ExplorerURLKey = "dash0ExplorerUrl"
ExplorerURLKey is the JSON key under which query commands report the Dash0 explorer deep link alongside their results.
The key is prefixed with "dash0" because it is a Dash0 extension to payloads that are otherwise OTLP/JSON: an unprefixed name risks colliding with a field OTLP itself may introduce later.
const PrecisionFlagDescription = `` /* 301-byte string literal not displayed */
PrecisionFlagDescription is the help text for the `--precision` flag. It is shared by every query command that accepts the flag.
Variables ¶
This section is empty.
Functions ¶
func AddExplorerURL ¶ added in v1.21.0
AddExplorerURL sets the deep link on a JSON result wrapper under ExplorerURLKey, and returns the wrapper for chaining. It leaves the wrapper untouched when explorerURL is empty, so a consumer can treat the key's presence as "a link is available" rather than having to test for "".
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. Each string can be either a text expression ("key [operator] value") or a JSON value. A JSON array of filter objects expands into multiple filters; a single JSON object is treated as one filter. This allows users to paste the output of the Dash0 UI "copy filter criteria" feature directly into --filter.
func ParsePrecision ¶ added in v1.14.0
func ParsePrecision(value string, timeRange dash0api.TimeReferenceRange) (*dash0api.Sampling, error)
ParsePrecision turns the raw value of the `--precision` flag into a sampling spec for the API request. The empty string means "use the server default" and returns nil so the request omits the field.
func PrintExplorerURL ¶ added in v1.21.0
PrintExplorerURL writes a Dash0 explorer deep link for human consumption, introduced by label. It is a no-op when explorerURL is empty, which is what the URL builders return when the API URL is unset or cannot be parsed.
Callers pass os.Stderr so the link stays out of the piped result stream: the link is commentary about the query, not part of its results.
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.