mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
Every logs query answered 500 "failed to get logs keys". The metadata step ahead of each one reads SHOW CREATE TABLE through hanzo-ds/sqlparser, and event.log carries `el Tuple(label String, ...)` — a NAMED tuple, which only parsed in its unnamed form, so the parse stopped at the first element's type and the whole query failed. event.span carries the same column, so traces read back now too. sqlparser v0.4.17 routes the named form to the column-list grammar its parseNestedType already read. The test here is over this plane's own schema shape, because that is the invariant worth holding: a table this service defines must be one it can read.
27 lines
1.2 KiB
Go
27 lines
1.2 KiB
Go
package telemetrymetadata
|
|
|
|
import "testing"
|
|
|
|
// TestNamedTupleSchemaReadsBack pins that the plane's OWN log table can be read
|
|
// back by the metadata step every logs query runs first.
|
|
//
|
|
// event.log and event.span each carry `el`, a NAMED tuple. The parser read only
|
|
// the unnamed form, so SHOW CREATE TABLE stopped at the first element's type and
|
|
// getLogsKeys answered ErrFailedToGetLogsKeys — which surfaced as HTTP 500
|
|
// "failed to get logs keys" on EVERY logs query, against a table holding 122M
|
|
// rows a day. A schema this service defines has to be one this service can read.
|
|
func TestNamedTupleSchemaReadsBack(t *testing.T) {
|
|
const ddl = "CREATE TABLE event.log (" +
|
|
"`org` LowCardinality(String), " +
|
|
"`time` DateTime64(9) CODEC(DoubleDelta, ZSTD(1)), " +
|
|
"`attributes` Map(LowCardinality(String), String) CODEC(ZSTD(1)), " +
|
|
"`el` Tuple(label String, role LowCardinality(String), path Array(String)) CODEC(ZSTD(1)), " +
|
|
"`service` LowCardinality(String), " +
|
|
"`ts_bucket_start` UInt64 MATERIALIZED intDiv(toUnixTimestamp(time), 1800) * 1800" +
|
|
") ENGINE = ReplacingMergeTree ORDER BY (org, service, time)"
|
|
|
|
if _, err := ExtractFieldKeysFromTblStatement(ddl); err != nil {
|
|
t.Fatalf("the plane's own log schema does not read back: %v", err)
|
|
}
|
|
}
|