mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +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.
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package rules
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/hanzoai/o11y/pkg/types/metrictypes"
|
|
)
|
|
|
|
// GenerateMetricQueryCHArgs generates query arguments for metric queries used in tests.
|
|
// It calculates the time range, builds time series CTE args, temporal aggregation args,
|
|
// and spatial aggregation args to match the actual query builder behavior.
|
|
func GenerateMetricQueryCHArgs(
|
|
evalTime time.Time,
|
|
evalWindow time.Duration,
|
|
evalDelay time.Duration,
|
|
metricName string,
|
|
temporality metrictypes.Temporality,
|
|
) []interface{} {
|
|
// Calculate time range
|
|
startTime := evalTime.Add(-evalWindow)
|
|
endTime := evalTime
|
|
|
|
startMs := startTime.UnixMilli()
|
|
endMs := endTime.UnixMilli()
|
|
|
|
// Apply eval delay if present
|
|
if evalDelay > 0 {
|
|
startMs = startMs - int64(evalDelay.Milliseconds())
|
|
endMs = endMs - int64(evalDelay.Milliseconds())
|
|
}
|
|
|
|
// Round to nearest minute
|
|
startMs = startMs - (startMs % (60 * 1000))
|
|
endMs = endMs - (endMs % (60 * 1000))
|
|
|
|
start := uint64(startMs)
|
|
end := uint64(endMs)
|
|
|
|
// Step1: Build time series CTE args
|
|
|
|
// Adjust start time to nearest hour
|
|
oneHourInMilliseconds := uint64(time.Hour.Milliseconds())
|
|
// start time for filtering event.series with start time
|
|
timeSeriesCTEStartTime := start - (start % oneHourInMilliseconds)
|
|
|
|
queryArgs := []interface{}{
|
|
metricName,
|
|
timeSeriesCTEStartTime,
|
|
end,
|
|
}
|
|
|
|
// Add temporality if specified
|
|
if temporality == metrictypes.Unknown {
|
|
temporality = metrictypes.Unspecified
|
|
}
|
|
if temporality != metrictypes.Unknown {
|
|
queryArgs = append(queryArgs, temporality.StringValue())
|
|
}
|
|
|
|
// Add normalized flag
|
|
queryArgs = append(queryArgs, false)
|
|
|
|
// Step2: Add temporal aggregation args
|
|
// build args for filtering the event.metric table
|
|
temporalAggArgs := []interface{}{
|
|
metricName,
|
|
start,
|
|
end,
|
|
}
|
|
queryArgs = append(queryArgs, temporalAggArgs...)
|
|
|
|
// Add spatial aggregation args
|
|
spatialAggArgs := []interface{}{
|
|
0, // isNaN check
|
|
}
|
|
queryArgs = append(queryArgs, spatialAggArgs...)
|
|
|
|
return queryArgs
|
|
}
|