Files
o11y/pkg/telemetrystore/telemetrystore.go
zeekayandHanzo Dev 2965c80547 An address is measured from a root this package owns
The five claim verbs need the address an operation will answer at, which is a
root joined with a path. They used to ask the target for its prefix through a
struct written to answer with one — and that struct existed for a second reason
that has since gone: an operation with no declared id took a shape-derived one
qualified by the prefix of the occurrence it answered under, so a plain group
would have renamed every undeclared id. All 319 operations state their own id
now, so a declared id survives composition verbatim and the group is just a
group.

The roots are this package's own constants, so each group carries the one it was
made with and nothing can disagree about the address. The escape hatches name
their whole address and register through Raw, which says which method each one
answers.

The test that measured the gap reached zero and said so; it now holds the
property from the other side, that no operation goes undeclared.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-17 06:15:44 -07:00

44 lines
1.3 KiB
Go

package telemetrystore
import (
"context"
datastore "github.com/hanzo-ds/go"
"github.com/hanzoai/o11y/pkg/types/telemetrystoretypes"
)
type TelemetryStore interface {
// Datastore returns the datastore connection, which can also EXPLAIN.
Datastore() datastore.Conn
// Cluster returns the cluster name.
Cluster() string
// Estimate returns the per-table scan estimate from EXPLAIN ESTIMATE.
Estimate(ctx context.Context, stmt string, args ...any) ([]telemetrystoretypes.EstimateEntry, error)
// Plan runs EXPLAIN PLAN to check stmt parses and binds.
Plan(ctx context.Context, stmt string, args ...any) error
// Indexes returns the granule-skip breakdown from EXPLAIN json = 1, indexes = 1.
Indexes(ctx context.Context, stmt string, args ...any) (telemetrystoretypes.Granules, bool, error)
}
type TelemetryStoreHook interface {
BeforeQuery(ctx context.Context, event *QueryEvent) context.Context
AfterQuery(ctx context.Context, event *QueryEvent)
}
func WrapBeforeQuery(hooks []TelemetryStoreHook, ctx context.Context, event *QueryEvent) context.Context {
for _, hook := range hooks {
ctx = hook.BeforeQuery(ctx, event)
}
return ctx
}
func WrapAfterQuery(hooks []TelemetryStoreHook, ctx context.Context, event *QueryEvent) {
for i := len(hooks) - 1; i >= 0; i-- {
hooks[i].AfterQuery(ctx, event)
}
}