Skip to content

Stop preloading per-adapter Prometheus label values - #134

Merged
zwl-williamzha merged 1 commit into
msp-2506from
no-adapter-metric-preload
Aug 24, 2026
Merged

Stop preloading per-adapter Prometheus label values#134
zwl-williamzha merged 1 commit into
msp-2506from
no-adapter-metric-preload

Conversation

@zwl-williamzha

Copy link
Copy Markdown

Why

preloadLabelValues walks CoreBidderNames() and calls .With() on every adapter metric, so all ~340 bidders compiled into the binary (263 in the core list + 77 aliases registered at config load) get a full series set created at zero and exported forever — whether or not they ever see a request.

Measured against a real msp-prod registry:

before:  per-pod series=9429  adapter-labeled=9180  (97.4%)
after:   per-pod series=249   adapter-labeled=0

Times 16–140 replicas depending on deployment. Only 39 bidders are referenced anywhere in our stored requests. SRE is currently carrying 792,360 series and this is very nearly all of it.

Worth noting: adapters.<x>.disabled: true does not help. Preload never consults BidderInfos, so enabled and disabled bidders are preloaded alike.

Commented, not deleted

So a rebase onto upstream keeps the blocks visible and one edit puts them back. Along with them go the four locals that only fed adapter preloads (adapterValues, adapterErrorValues, bidTypeValues, cookieValues), the openrtb_ext import behind CoreBidderNames(), and the three metricsDisabled.Adapter* wrappers that would otherwise be no-op conditionals around nothing.

What this gives up

The zero baseline — and the baseline was allocated backwards. It existed for the ~340 upstream bidders nobody calls, and was missing for every msp_* bidder, because those were never in CoreBidderNames(). So we're dropping a property we only had where it was worthless.

After this, a bidder that is configured but never called reads as no data rather than 0. Bidders that actually serve get their series lazily on first use, exactly as ours always did. sum(rate(...)) is unaffected. Worth a skim of the adapter dashboards for panels that assume a series exists.

Test

TestMetricCountGatekeeping divided adapter cardinality by the bidder count, so with nothing preloaded it would pass on a count of zero and guard nothing. Replaced with an assertion that nothing per-adapter is preloaded, which fails loudly if a block is switched back on. Verified it bites: temporarily re-enabling the adapter_panics preload fails with "Adapter metrics should not be preloaded".

go build ./... and go vet ./... clean; ./validate.sh --nofmt passes except a pre-existing local ./exchange failure (msp_nova: builder not registered — plugin builders aren't registered under plain go test; fails identically with this change stashed).

Follow-up

The parent msp repo needs a submodule pointer bump to pick this up, then a canary → promote deploy. This also makes ParticleMedia/msp#3077 (a scrape-time relabel doing the same job at ingest) redundant — closing that in favor of this.

🤖 Generated with Claude Code

preloadLabelValues walked CoreBidderNames() and called .With() on every
adapter metric, so all ~340 bidders compiled into the binary -- 263 in the
core list plus 77 aliases registered at config load -- got a full series set
created at zero and exported forever, whether or not they ever saw a request.

Measured against a real msp-prod registry that is 9,180 of 9,429 series per
pod, 97.4%, times 16-140 replicas depending on the deployment. Only 39
bidders are referenced anywhere in our stored requests. SRE is carrying
792,360 series and this is very nearly all of it.

Note that disabling the unused adapters in config does not help: preload
never consults BidderInfos, so enabled and disabled bidders are preloaded
alike.

Commented out rather than deleted so a rebase onto upstream keeps the blocks
visible and one edit puts them back. The four locals that only fed adapter
preloads, and the openrtb_ext import behind CoreBidderNames(), go with them,
as do the three metricsDisabled.Adapter* wrappers that would otherwise be
no-op conditionals around nothing.

What this gives up is the zero baseline, and it is worth being clear that
the baseline was allocated backwards: it existed for the ~340 upstream
bidders nobody calls and was missing for every msp_* bidder, because those
were never in CoreBidderNames(). A bidder that is configured but never
called now reads as no data instead of 0. Adapter series for bidders that
actually serve are created lazily on first use, as they always were for ours.

TestMetricCountGatekeeping divided adapter cardinality by the bidder count,
so with nothing preloaded it would pass on zero and guard nothing. Replaced
with an assertion that nothing per-adapter is preloaded, which fails if a
block is switched back on. Verified it fails by re-enabling adapter_panics.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@zwl-williamzha
zwl-williamzha merged commit cc05e1b into msp-2506 Aug 24, 2026
@zwl-williamzha
zwl-williamzha deleted the no-adapter-metric-preload branch August 24, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants