prometheus/discovery/azure
Julien Pivotto 5040dd9e68 discovery/azure: keep SD clients from defeating dead-code elimination
The azureClient struct held the armcompute and armnetwork SDK clients as
concrete fields while satisfying the client interface. Once such a client is
reachable through an interface, Go's linker conservatively retains every
exported method of the concrete type plus the entire (de)serializer graph those
operations drag in, even though discovery calls only a handful of them.

Wrap each SDK client in a small adapter that captures only the operations
discovery uses as method-value closures, and box the adapters instead of the raw
clients. The concrete clients then live only inside closure contexts, which
reflection cannot traverse, so dead-code elimination drops the unused
operations.

This drops the retained operations per client from ~60 down to the 2-3 actually
used (UsedInIface markers go from 244+66 to 0), shrinking both the prometheus
and promtool binaries by ~3.2 MB each. No functional or API change.

Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
2026-05-29 16:17:59 +02:00
..
azure.go discovery/azure: keep SD clients from defeating dead-code elimination 2026-05-29 16:17:59 +02:00
azure_test.go discovery/azure: keep SD clients from defeating dead-code elimination 2026-05-29 16:17:59 +02:00
metrics.go Remove copyright date from headers (#17785) 2026-01-05 13:46:21 +01:00