// Package metrics contains decision metric query contracts. The capacity
// planner's own Prometheus metrics live in pkg/runtime/metrics.
package metrics

import (
	"context"
	"time"

	"github.com/tidbcloud/cluster-service-ng/internal/capacity-planner/pkg/target"
)

const (
	// Canonical TSDB labels written by the metrics scrapers.
	LabelNamespace = "namespace"
	LabelPod       = "pod"
	LabelContainer = "container"
)

// Provider evaluates one or more selector-only PromQL expressions. Results
// correspond to promQLs by index. A query with no matching series has an empty
// Metrics value at the same index.
type Provider interface {
	Query(ctx context.Context, target target.Target, promQLs ...string) ([]Metrics, error)
}

// Metrics contains every time series selected by one PromQL expression.
type Metrics struct {
	Series []TimeSeries
}

// TimeSeries is one TSDB series. Ref is nil for external metrics.
type TimeSeries struct {
	Ref     *Reference
	Samples []Sample
}

// Reference identifies the Pod associated with a time series.
type Reference struct {
	Name string
}

// Sample is one float sample stored in the embedded TSDB.
type Sample struct {
	Timestamp time.Time
	Value     float64
}
