Documentation
¶
Overview ¶
Package prometheus forwards original OTLP metrics and queries a single-tenant Prometheus server. Prometheus owns translation, durable storage and PromQL.
Index ¶
- func ErrorResponse(err error) (int, json.RawMessage)
- type APIError
- type Client
- func (c *Client) Close()
- func (c *Client) Export(ctx context.Context, req *colmetricspb.ExportMetricsServiceRequest) (*colmetricspb.ExportMetricsServiceResponse, error)
- func (c *Client) MaxQueryBytes() int
- func (c *Client) MaxQueryRange() time.Duration
- func (c *Client) MaxResponseBytes() int64
- func (c *Client) MetricNames(ctx context.Context, params url.Values) (json.RawMessage, error)
- func (c *Client) Query(ctx context.Context, params url.Values, rangeQuery bool) (json.RawMessage, error)
- func (c *Client) Ready(ctx context.Context) error
- func (c *Client) SupportsTenant(ctx context.Context) bool
- func (c *Client) TenantID() string
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorResponse ¶
func ErrorResponse(err error) (int, json.RawMessage)
ErrorResponse is shared by HTTP adapters; callers can also errors.As APIError.
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
ErrorType string
Message string
Body json.RawMessage
}
APIError retains the upstream envelope, including warnings and partial data. Local transport/limit errors use the same public Prometheus error shape.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Export ¶
func (c *Client) Export(ctx context.Context, req *colmetricspb.ExportMetricsServiceRequest) (*colmetricspb.ExportMetricsServiceResponse, error)
Export sends the original resource/scope/metric protobuf without converting names, units, temporality, histograms, exemplars, flags or attributes. Ingest must resolve and select resource tenants before calling Export.
func (*Client) MaxQueryBytes ¶
func (*Client) MaxQueryRange ¶
func (*Client) MaxResponseBytes ¶
func (*Client) MetricNames ¶
MetricNames discovers retained series through Prometheus's label API. The caller supplies bounded start/end and optional match[] selectors.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, params url.Values, rangeQuery bool) (json.RawMessage, error)
Query returns the complete Prometheus response envelope on success AND on an upstream API error. It does not parse, rewrite or restrict PromQL expressions.
func (*Client) Ready ¶
Ready probes the configured backend independently of queries and ingest. The caller should supply a short readiness deadline. It proves reachability and Prometheus readiness, not the retention configuration or OTLP enablement.
func (*Client) SupportsTenant ¶
SupportsTenant follows the existing bound-principal precedence. It does not introduce authentication: missing tenant context still means "default".
type Config ¶
type Config struct {
URL string
TenantID string
Timeout time.Duration
MaxConcurrent int
MaxIngestConcurrent int
MaxIngestWaiters int
MaxRequestBytes int64
MaxResponseBytes int64
MaxQueryBytes int
MaxQueryRange time.Duration
MaxSeries int
// MaxIngestBytes bounds the sum of proto.Size across active and waiting
// exports. Zero selects 128 MiB, leaving headroom on a 4 GiB app for decoded
// objects, active encoded copies and other work. This is a protobuf wire-size
// budget, not a Go heap/RSS limit; inbound network decoding precedes Export
// and is not covered. Decoded objects can be much larger than proto.Size.
MaxIngestBytes int64
}
Config bounds requests and shared ingest admission. Zero values select defaults; negative values fail construction. URL is operator configuration, never taken from a request.