Help us shape the future of Go! Take the 2026 Go Developer Survey

prometheus

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package prometheus forwards original OTLP metrics and queries a single-tenant Prometheus server. Prometheus owns translation, durable storage and PromQL.

Index

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.

func NewError

func NewError(status int, kind, message string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

func NewClient

func NewClient(cfg Config) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Export

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 (c *Client) MaxQueryBytes() int

func (*Client) MaxQueryRange

func (c *Client) MaxQueryRange() time.Duration

func (*Client) MaxResponseBytes

func (c *Client) MaxResponseBytes() int64

func (*Client) MetricNames

func (c *Client) MetricNames(ctx context.Context, params url.Values) (json.RawMessage, error)

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

func (c *Client) Ready(ctx context.Context) error

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

func (c *Client) SupportsTenant(ctx context.Context) bool

SupportsTenant follows the existing bound-principal precedence. It does not introduce authentication: missing tenant context still means "default".

func (*Client) TenantID

func (c *Client) TenantID() string

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.

Jump to

Keyboard shortcuts

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