Skip to content

fix: mark tracer initializer OSGi import optional - #2528

Merged
zeitlinger merged 1 commit into
prometheus:mainfrom
kalayciburak:fix/optional-tracer-initializer-osgi-import
Oct 6, 2026
Merged

zeitlinger merged 1 commit into
prometheus:mainfrom
kalayciburak:fix/optional-tracer-initializer-osgi-import

Conversation

@kalayciburak

Copy link
Copy Markdown
Contributor

Problem

prometheus-metrics-core references SpanContextSupplier, so bnd adds a required OSGi import of io.prometheus.metrics.tracer.initializer. An OSGi runtime that leaves out prometheus-metrics-tracer-initializer cannot resolve the bundle. Micrometer excludes that artifact and supplies its own supplier.

Fix

Mark that import resolution:=optional, the same way prometheus-metrics-exposition-textformats treats expositionformats.internal. Automatic-Module-Name is kept. Other imports are unchanged.

Fixes #2516

How tested

JAVA_HOME=25 ./mvnw test -pl prometheus-metrics-core -am -Dtest=OsgiBundleManifestTest -Dsurefire.failIfNoSpecifiedTests=false -Dcoverage.skip=true

Before the instruction, the generated clause was io.prometheus.metrics.tracer.initializer and the test failed because it did not contain resolution:=optional. After the instruction, that test passed.

Same reactor command with -Dtest='!OsgiBundleManifestTest' also passed, including 175 tests in prometheus-metrics-core.

prometheus-metrics-core referenced SpanContextSupplier, so bnd required io.prometheus.metrics.tracer.initializer even when Micrometer excludes that artifact. Mark the import optional, the same way exposition-textformats treats its internal package.

Fixes prometheus#2516

Signed-off-by: kalayciburak <kalayciburak1996@gmail.com>

@zeitlinger zeitlinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the PI!

@zeitlinger
zeitlinger enabled auto-merge (squash) October 6, 2026 11:33
@zeitlinger
zeitlinger merged commit fc5d0ba into prometheus:main Oct 6, 2026
23 checks passed
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.

prometheus-metrics-core makes io.prometheus.metrics.tracer.initializer a mandatory OSGi import although the code supports its absence

2 participants