Files
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

84 lines
2.8 KiB
Go

package telemetrystorehook
import (
"context"
datastore "github.com/hanzo-ds/go"
"github.com/hanzoai/o11y/pkg/factory"
"github.com/hanzoai/o11y/pkg/telemetrystore"
"github.com/hanzoai/o11y/pkg/types/ctxtypes"
)
type provider struct {
settings telemetrystore.QuerySettings
}
func NewSettingsFactory() factory.ProviderFactory[telemetrystore.TelemetryStoreHook, telemetrystore.Config] {
return factory.NewProviderFactory(factory.MustNewName("settings"), func(ctx context.Context, providerSettings factory.ProviderSettings, config telemetrystore.Config) (telemetrystore.TelemetryStoreHook, error) {
return NewSettings(ctx, providerSettings, config)
})
}
func NewSettings(ctx context.Context, providerSettings factory.ProviderSettings, config telemetrystore.Config) (telemetrystore.TelemetryStoreHook, error) {
return &provider{
settings: config.Datastore.QuerySettings,
}, nil
}
func (h *provider) BeforeQuery(ctx context.Context, _ *telemetrystore.QueryEvent) context.Context {
settings := datastore.Settings{}
settings["log_comment"] = ctxtypes.CommentFromContext(ctx).String()
if ctx.Value("enforce_max_result_rows") != nil {
settings["max_result_rows"] = h.settings.MaxResultRows
}
if h.settings.MaxBytesToRead != 0 {
settings["max_bytes_to_read"] = h.settings.MaxBytesToRead
}
if h.settings.MaxExecutionTime != 0 {
settings["max_execution_time"] = h.settings.MaxExecutionTime
}
if h.settings.MaxExecutionTimeLeaf != 0 {
settings["max_execution_time_leaf"] = h.settings.MaxExecutionTimeLeaf
}
if h.settings.TimeoutBeforeCheckingExecutionSpeed != 0 {
settings["timeout_before_checking_execution_speed"] = h.settings.TimeoutBeforeCheckingExecutionSpeed
}
if h.settings.IgnoreDataSkippingIndices != "" {
settings["ignore_data_skipping_indices"] = h.settings.IgnoreDataSkippingIndices
}
if ctx.Value("datastore_max_threads") != nil {
if maxThreads, ok := ctx.Value("datastore_max_threads").(int); ok {
settings["max_threads"] = maxThreads
}
}
if ctx.Value("max_result_rows") != nil && ctx.Value("result_overflow_mode") != nil {
if maxResultRows, ok := ctx.Value("max_result_rows").(int); ok {
settings["max_result_rows"] = maxResultRows
}
settings["result_overflow_mode"] = ctx.Value("result_overflow_mode")
}
if ctx.Value("max_rows_to_group_by") != nil && ctx.Value("result_overflow_mode") != nil {
settings["max_rows_to_group_by"] = ctx.Value("max_rows_to_group_by").(int)
settings["result_overflow_mode"] = ctx.Value("result_overflow_mode")
}
// TODO(srikanthccv): enable it when the upstream "Cannot read all data"
// bulk-filtering bug on secondary indices is fixed.
settings["secondary_indices_enable_bulk_filtering"] = false
ctx = datastore.Context(ctx, datastore.WithSettings(settings))
return ctx
}
func (h *provider) AfterQuery(ctx context.Context, event *telemetrystore.QueryEvent) {}