Skip to content

expositionformats.internal is imported by exposition-textformats but exported by nothing, breaking OSGi resolution #2395

Description

@anjeongkyun

Summary

In 1.8.0, prometheus-metrics-exposition-textformats imports io.prometheus.metrics.expositionformats.internal, but no artifact exports it. The classes exist in prometheus-metrics-exposition-formats, which keeps them unexported, so the two bundles cannot be wired together and any OSGi container fails to resolve io.prometheus.metrics.expositionformats.

Evidence

From the published 1.8.0 manifests:

prometheus-metrics-exposition-textformats-1.8.0.jar
  Export-Package: io.prometheus.metrics.expositionformats
  Import-Package: io.prometheus.metrics.expositionformats.internal      <- nothing provides this

prometheus-metrics-exposition-formats-1.8.0.jar
  Export-Package: io.prometheus.metrics.expositionformats.generated
                  io.prometheus.metrics.expositionformats.generated.com_google_protobuf_4_35_0
  Import-Package: io.prometheus.metrics.expositionformats

The implementation classes are in the second jar but not exported from it:

$ unzip -l prometheus-metrics-exposition-formats-1.8.0.jar | grep expositionformats/internal
  io/prometheus/metrics/expositionformats/internal/PrometheusProtobufWriterImpl.class
  io/prometheus/metrics/expositionformats/internal/ProtobufUtil.class

prometheus-metrics-exposition-textformats-1.8.0.jar contains none of them, so the import is not satisfiable from within its own bundle either.

How I hit it

Micrometer has an OSGi test that is still pinned to the old simpleclient because of an earlier failure (micrometer-metrics/micrometer#5063). Switching it to the current client, the bnd resolution now stops here:

micrometer-osgi-test-tests cannot be resolved
  ⇒ Import-Package io.micrometer.prometheusmetrics could not be provided
    ⇒ Import-Package io.prometheus.metrics.expositionformats;version=[1.8.0,2.0.0) could not be provided
      ⇒ Import-Package io.prometheus.metrics.expositionformats.internal could not be provided

The blocker reported back in 2024 (the shaded protobuf module not being a bundle) is gone, this is what is left.

Possible fixes

Either export io.prometheus.metrics.expositionformats.internal from prometheus-metrics-exposition-formats, or move the two classes so the package does not have to cross a bundle boundary. The first is a one line manifest change but does publish an internal package; the second is cleaner if you would rather not.

I saw #989 was closed as not planned, though that was about prometheus-metrics-shaded-protobuf, which no longer exists in 1.8.0. This one is a metadata inconsistency between two shipped artifacts rather than a request for OSGi support, so I thought it was worth reporting separately. Happy to send a PR for whichever direction you prefer.

Environment

  • io.prometheus:* 1.8.0
  • bnd resolution via Micrometer's micrometer-osgi-test (Felix framework)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions