Skip to content

Add stable Metrics class to decouple consumers from protobuf version - #1873

Merged
zeitlinger merged 1 commit into
mainfrom
metrics-class-name
Feb 13, 2026
Merged

Add stable Metrics class to decouple consumers from protobuf version#1873
zeitlinger merged 1 commit into
mainfrom
metrics-class-name

Conversation

@zeitlinger

Copy link
Copy Markdown
Member

Summary

  • Introduce a stable Metrics.java in the version-free ...generated package that extends the versioned generated class, so consumer code no longer needs import updates on protobuf upgrades.
  • Update generate-protobuf.sh to make the generated class extensible (final removed, constructor protected) and read the old package from the stable class's extends clause.
  • Update all consumer imports to use the stable package, with @SuppressWarnings("NonCanonicalType") for Error Prone compatibility.

Test plan

  • mise run build passes (all 54 modules)
  • mise run test -pl prometheus-metrics-exposition-formats passes (47 tests)
  • mise run lint:super-linter passes
The generated protobuf Metrics.java lives in a versioned package that
changes every protobuf release, requiring import updates in all consumer
files. Introduce a stable extending class in the version-free package
so consumers import from a single stable location. On protobuf upgrades
only the extends clause in the stable class changes, handled
automatically by generate-protobuf.sh.

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger

Copy link
Copy Markdown
Member Author

approved by @dhoard

@zeitlinger
zeitlinger merged commit 229e2e0 into main Feb 13, 2026
14 checks passed
@zeitlinger
zeitlinger deleted the metrics-class-name branch February 13, 2026 16:35
zeitlinger added a commit that referenced this pull request Jun 3, 2026
Follow-up to #2167 ([review
comment](#2167 (comment))):
switches the JMX Exporter compatibility job to the **quick test**
configuration and fixes the gaps that surfaced.

**Changes**

- **Quick test config** (`jmx_exporter_compat.py`): build the full
reactor (`clean install`) so `integration_test_suite` actually runs,
pinned to a single Java + Prometheus distribution. The pins are read
from the checked-out jmx_exporter's `run-quick-test.sh` so they stay
aligned with upstream; `-Dparamixel.parallelism` set to CPU count.
- **Test `main`, not the release**: the integration suite only compiles
against current `client_java` when jmx_exporter imports the stable
`expositionformats.generated.Metrics` class (#1873). Release 1.5.0
imports the version-stamped `com_google_protobuf_4_32_0` package
directly, which breaks on protobuf bumps (now 4.35.0); `main` uses the
stable class. Tracked by #2179 — switch the ref back to a pinned release
once one ships the fix.
- **Renovate guard** (`renovate.json5`): block major JDK bumps for the
jmx-exporter and micrometer compat env files (they pin an LTS JDK the
upstream release supports). This supersedes #2173-style bumps.

**Local validation**: `mise run lint:fix`; image-pin regex verified
against `prometheus/jmx_exporter@main`. Full integration run is
validated by CI (needs Docker + JDK 21).

---------

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
jaydeluca pushed a commit that referenced this pull request Jun 4, 2026
Follow-up to #2167 ([review
comment](#2167 (comment))):
switches the JMX Exporter compatibility job to the **quick test**
configuration and fixes the gaps that surfaced.

**Changes**

- **Quick test config** (`jmx_exporter_compat.py`): build the full
reactor (`clean install`) so `integration_test_suite` actually runs,
pinned to a single Java + Prometheus distribution. The pins are read
from the checked-out jmx_exporter's `run-quick-test.sh` so they stay
aligned with upstream; `-Dparamixel.parallelism` set to CPU count.
- **Test `main`, not the release**: the integration suite only compiles
against current `client_java` when jmx_exporter imports the stable
`expositionformats.generated.Metrics` class (#1873). Release 1.5.0
imports the version-stamped `com_google_protobuf_4_32_0` package
directly, which breaks on protobuf bumps (now 4.35.0); `main` uses the
stable class. Tracked by #2179 — switch the ref back to a pinned release
once one ships the fix.
- **Renovate guard** (`renovate.json5`): block major JDK bumps for the
jmx-exporter and micrometer compat env files (they pin an LTS JDK the
upstream release supports). This supersedes #2173-style bumps.

**Local validation**: `mise run lint:fix`; image-pin regex verified
against `prometheus/jmx_exporter@main`. Full integration run is
validated by CI (needs Docker + JDK 21).

---------

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant