Documentation
¶
Overview ¶
Package federate provides a fast /federate handler for promxy.
It is a drop-in replacement for the vendored Prometheus federation handler for the common case (text/plain exposition of float samples), avoiding the per-request dto.MetricFamily tree and the encode-time name re-validation that dominate federation CPU/allocations (issue #784). For any other negotiated format (protobuf, OpenMetrics) -- and thus for native histograms, which are only servable over those formats -- it transparently delegates to a fallback handler (the vendored one), so behavior is unchanged outside the fast path.
The query path (selectors, lookback window, merge, staleness handling, sort, external-label attachment) mirrors the vendored handler exactly, and the output is byte-for-byte identical (verified by tests against the vendored handler); only the encoding is replaced with pkg/expfmt.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves /federate. Construct with New and keep external labels current via SetExternalLabels on each config reload.
func New ¶
New returns a federation handler that queries queryable over the given lookback window and delegates non-text formats to fallback.
func (*Handler) SetExternalLabels ¶
SetExternalLabels updates the external labels attached to federated series. It mirrors the vendored handler: the configured global external_labels plus an implicit empty "instance" label when not otherwise set. Safe for concurrent use with ServeHTTP.