readpath

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoV2Data = errors.New("no v2 data ingested for tenant")

Functions

func Query

func Query[Req, Resp any](
	ctx context.Context,
	router *Router,
	req *connect.Request[Req],
	sanitize func(a, b *Req),
	aggregate func(a, b *Resp) (*Resp, error),
) (*connect.Response[Resp], error)

Query routes a query to the appropriate query frontend. Before the call to the frontend is made, the requests are sanitized: any of the arguments can be nil, but not both. If the query was split, the responses are aggregated.

Types

type Config

type Config struct {
	EnableQueryBackend     bool             `yaml:"enable_query_backend" json:"enable_query_backend" doc:"hidden"`
	EnableQueryBackendFrom QueryBackendFrom `yaml:"enable_query_backend_from" json:"enable_query_backend_from" doc:"hidden"`
	QueryTreeEnabled       bool             `yaml:"query_tree_enabled" json:"query_tree_enabled" doc:"hidden"`
}

func (*Config) RegisterFlags

func (o *Config) RegisterFlags(f *flag.FlagSet)

type MetastoreSplitTimeResolver added in v1.20.0

type MetastoreSplitTimeResolver struct {
	// contains filtered or unexported fields
}

MetastoreSplitTimeResolver resolves the split time for "auto" mode by querying the metastore for each tenant's oldest profile time. Results are cached per tenant to avoid calling the metastore on every query.

func NewMetastoreSplitTimeResolver added in v1.20.0

func NewMetastoreSplitTimeResolver(client TenantServiceClient, ttl time.Duration) *MetastoreSplitTimeResolver

func (*MetastoreSplitTimeResolver) OldestProfileTime added in v1.20.0

func (r *MetastoreSplitTimeResolver) OldestProfileTime(ctx context.Context, tenantID string) (time.Time, error)

type Overrides

type Overrides interface {
	ReadPathOverrides(tenantID string) Config
}

type QueryBackendFrom added in v1.20.0

type QueryBackendFrom struct {
	Auto bool
	Time time.Time
}

QueryBackendFrom is a flag/config type that accepts either an RFC3339 timestamp or the special value "auto". When set to "auto", the split point is resolved at query time by looking up the tenant's oldest profile time in the metastore.

func (QueryBackendFrom) IsZero added in v1.20.0

func (q QueryBackendFrom) IsZero() bool

func (QueryBackendFrom) MarshalJSON added in v1.20.0

func (q QueryBackendFrom) MarshalJSON() ([]byte, error)

func (QueryBackendFrom) MarshalText added in v1.20.0

func (q QueryBackendFrom) MarshalText() ([]byte, error)

func (QueryBackendFrom) MarshalYAML added in v1.20.0

func (q QueryBackendFrom) MarshalYAML() (interface{}, error)

func (*QueryBackendFrom) Set added in v1.20.0

func (q *QueryBackendFrom) Set(s string) error

Set implements flag.Value.

func (QueryBackendFrom) SplitTime added in v1.20.0

func (q QueryBackendFrom) SplitTime(tenantOldestProfileTime func() (time.Time, error)) (time.Time, error)

SplitTime returns the split timestamp for routing queries. For a fixed timestamp, it returns the time directly. For "auto" mode, it queries the metastore for the tenant's oldest profile time. Returns zero time if the split cannot be determined.

func (QueryBackendFrom) String added in v1.20.0

func (q QueryBackendFrom) String() string

String implements flag.Value.

func (*QueryBackendFrom) UnmarshalJSON added in v1.20.0

func (q *QueryBackendFrom) UnmarshalJSON(data []byte) error

func (*QueryBackendFrom) UnmarshalText added in v1.20.0

func (q *QueryBackendFrom) UnmarshalText(data []byte) error

func (*QueryBackendFrom) UnmarshalYAML added in v1.20.0

func (q *QueryBackendFrom) UnmarshalYAML(value *yaml.Node) error

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a proxy that routes queries to the query frontend.

If the query backend is enabled, it routes queries to the new query frontend, otherwise it routes queries to the old query frontend.

If the query targets a time range that spans the enablement of the new query backend, it splits the query into two parts and sends them to the old and new query frontends.

func NewRouter

func NewRouter(
	logger log.Logger,
	overrides Overrides,
	resolver SplitTimeResolver,
	oldFrontend querierv1connect.QuerierServiceClient,
	newFrontend querierv1connect.QuerierServiceClient,
) *Router

func (*Router) SelectHeatmap added in v1.19.0

type SplitTimeResolver added in v1.20.0

type SplitTimeResolver interface {
	OldestProfileTime(ctx context.Context, tenantID string) (time.Time, error)
}

SplitTimeResolver resolves the split time for a tenant in "auto" mode. It returns the oldest profile time known for the tenant in the v2 storage.

type TenantServiceClient added in v1.20.0

type TenantServiceClient interface {
	GetTenant(ctx context.Context, in *metastorev1.GetTenantRequest, opts ...grpc.CallOption) (*metastorev1.GetTenantResponse, error)
}

TenantServiceClient is the subset of the metastore client needed to resolve the oldest profile time for a tenant.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL