mirror of
https://github.com/hanzoai/o11y.git
synced 2026-11-02 09:37:36 +00:00
HIP-0132 unified o11y_logs, o11y_traces and o11y_metrics into one `event`
database and dropped them. The commit that restored the reads repointed
three files and said so; it was thirty. The rest went on naming databases
that no longer exist, so trace funnels, the Kafka and queue panels, the
v3/v4 logs and traces builders and the PromQL adapter each answered
Code: 81 UNKNOWN_DATABASE, and the golden tests agreed with them because
they pinned the same dead SQL.
pkg/telemetryplane is the one address for the name, imports nothing, and
is reachable from every depth that needs it. Its test walks the tree and
fails the build on a literal that names a dropped database, tests
included — a golden encoding broken SQL is a second vote for the bug, not
coverage.
Two service views turned a failed read into an offer to instrument an
already-instrumented application. A failure now shows the failure, and
onboarding is offered on a successful empty read.
Cherry-picked from salvage/blue-wt-o11y-readers 83ecbec03c.
100 lines
4.2 KiB
Go
100 lines
4.2 KiB
Go
package v3
|
|
|
|
import (
|
|
"testing"
|
|
|
|
v3 "github.com/hanzoai/o11y/pkg/query-service/model/v3"
|
|
)
|
|
|
|
func TestPanelTableForDelta(t *testing.T) {
|
|
cases := []struct {
|
|
name string
|
|
query *v3.BuilderQuery
|
|
expected string
|
|
}{
|
|
{
|
|
name: "request rate",
|
|
query: &v3.BuilderQuery{
|
|
QueryName: "A",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateOperator: v3.AggregateOperatorSumRate,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: "o11y_latency_count",
|
|
},
|
|
Temporality: v3.Delta,
|
|
Filters: &v3.FilterSet{
|
|
Items: []v3.FilterItem{
|
|
{
|
|
Key: v3.AttributeKey{Key: "service_name"},
|
|
Operator: v3.FilterOperatorIn,
|
|
Value: []interface{}{"frontend"},
|
|
},
|
|
{
|
|
Key: v3.AttributeKey{Key: "operation"},
|
|
Operator: v3.FilterOperatorIn,
|
|
Value: []interface{}{"HTTP GET /dispatch"},
|
|
},
|
|
},
|
|
},
|
|
Expression: "A",
|
|
},
|
|
expected: "SELECT toStartOfHour(now()) as ts, sum(value)/1800 as value FROM event.metric INNER JOIN (SELECT DISTINCT fingerprint FROM event.series WHERE metric_name IN ['o11y_latency_count'] AND temporality = 'Delta' AND __normalized = false AND unix_milli >= 1689253200000 AND unix_milli < 1689257640000 AND JSONExtractString(labels, 'service_name') IN ['frontend'] AND JSONExtractString(labels, 'operation') IN ['HTTP GET /dispatch']) as filtered_time_series USING fingerprint WHERE metric_name IN ['o11y_latency_count'] AND unix_milli >= 1689255866000 AND unix_milli <= 1689257640000 GROUP BY ts ORDER BY ts",
|
|
},
|
|
{
|
|
name: "latency p50",
|
|
query: &v3.BuilderQuery{
|
|
QueryName: "A",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateOperator: v3.AggregateOperatorHistQuant50,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: "o11y_latency_bucket",
|
|
},
|
|
Temporality: v3.Delta,
|
|
Filters: &v3.FilterSet{
|
|
Items: []v3.FilterItem{
|
|
{
|
|
Key: v3.AttributeKey{Key: "service_name"},
|
|
Operator: v3.FilterOperatorEqual,
|
|
Value: "frontend",
|
|
},
|
|
},
|
|
},
|
|
Expression: "A",
|
|
},
|
|
expected: "SELECT ts, histogramQuantile(arrayMap(x -> toFloat64(x), groupArray(le)), groupArray(value), 0.500) as value FROM (SELECT le, toStartOfHour(now()) as ts, sum(value)/1800 as value FROM event.metric INNER JOIN (SELECT DISTINCT fingerprint FROM event.series WHERE metric_name IN ['o11y_latency_bucket'] AND temporality = 'Delta' AND __normalized = false AND unix_milli >= 1689253200000 AND unix_milli < 1689257640000 AND JSONExtractString(labels, 'service_name') = 'frontend') as filtered_time_series USING fingerprint WHERE metric_name IN ['o11y_latency_bucket'] AND unix_milli >= 1689255866000 AND unix_milli <= 1689257640000 GROUP BY le,ts ORDER BY le ASC, ts) GROUP BY ts ORDER BY ts",
|
|
},
|
|
{
|
|
name: "latency p99 with group by",
|
|
query: &v3.BuilderQuery{
|
|
QueryName: "A",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateOperator: v3.AggregateOperatorHistQuant99,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: "o11y_latency_bucket",
|
|
},
|
|
Temporality: v3.Delta,
|
|
GroupBy: []v3.AttributeKey{
|
|
{
|
|
Key: "service_name",
|
|
},
|
|
},
|
|
Expression: "A",
|
|
},
|
|
expected: "SELECT service_name, ts, histogramQuantile(arrayMap(x -> toFloat64(x), groupArray(le)), groupArray(value), 0.990) as value FROM (SELECT service_name,le, toStartOfHour(now()) as ts, sum(value)/1800 as value FROM event.metric INNER JOIN (SELECT DISTINCT JSONExtractString(labels, 'service_name') as service_name, fingerprint FROM event.series WHERE metric_name IN ['o11y_latency_bucket'] AND temporality = 'Delta' AND __normalized = false AND unix_milli >= 1689253200000 AND unix_milli < 1689257640000) as filtered_time_series USING fingerprint WHERE metric_name IN ['o11y_latency_bucket'] AND unix_milli >= 1689255866000 AND unix_milli <= 1689257640000 GROUP BY service_name,le,ts ORDER BY service_name ASC,le ASC, ts) GROUP BY service_name,ts ORDER BY service_name ASC, ts",
|
|
},
|
|
}
|
|
|
|
for _, c := range cases {
|
|
t.Run(c.name, func(t *testing.T) {
|
|
query, err := buildDeltaMetricQueryForTable(1689255866000, 1689257640000, 1800, c.query)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
if query != c.expected {
|
|
t.Fatalf("expected: %s, got: %s", c.expected, query)
|
|
}
|
|
})
|
|
}
|
|
}
|