micrometer-metrics / micrometer

An application observability facade for the most popular observability tools. Think SLF4J, but for observability.
https://micrometer.io
Apache License 2.0
4.41k stars 976 forks source link

Test osgi with new Prometheus client #5063

Open shakuzen opened 2 months ago

shakuzen commented 2 months ago

See the description of https://github.com/micrometer-metrics/micrometer/pull/4846.

The OSGi test was failing when the new Prometheus client was used, so it was updated to use the -simpleclient module for now.

We should make sure we're testing with the latest Prometheus client and figure out what the issue is that's causing it to fail.

shakuzen commented 2 months ago

I just tried it locally by changing the dependency in micrometer-osgi-test and fixing the imports. The following is the error output I'm seeing:

> Task :micrometer-osgi-test:resolve FAILED
Resolution failed. Capabilities satisfying the following requirements could not be found:
    [<<INITIAL>>]
      ⇒ osgi.identity: (osgi.identity=micrometer-osgi-test-tests)
          ⇒ [micrometer-osgi-test-tests version=1.13.0.SNAPSHOT]
              ⇒ osgi.wiring.package: (&(osgi.wiring.package=io.micrometer.prometheusmetrics)(version>=1.13.0)(!(version>=2.0.0)))
                  ⇒ [micrometer-registry-prometheus version=1.13.0.SNAPSHOT]
                      ⇒ osgi.wiring.package: (&(osgi.wiring.package=io.prometheus.metrics.core.exemplars)(version>=1.2.0)(!(version>=2.0.0)))
                          ⇒ [io.prometheus.metrics-core version=1.2.1]
                              ⇒ osgi.wiring.package: (&(osgi.wiring.package=io.prometheus.metrics.tracer.initializer)(version>=1.2.0)(!(version>=2.0.0)))
    [io.prometheus.metrics-exposition-formats version=1.2.1]
      ⇒ osgi.wiring.package: (osgi.wiring.package=io.prometheus.metrics.shaded.com_google_protobuf_3_25_3)
The following requirements are optional:
    [junit-platform-commons version=1.10.2]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
    [junit-jupiter-params version=5.10.2]
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin.jvm.internal)
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin)
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
    [micrometer-core version=1.13.0.SNAPSHOT]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.annotation)(version>=3.0.2))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.annotation.meta)(version>=3.0.2))
    [junit-platform-launcher version=1.10.2]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
    [junit-platform-engine version=1.10.2]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
    [micrometer-commons version=1.13.0.SNAPSHOT]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.annotation)(version>=3.0.2))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=javax.annotation.meta)(version>=3.0.2))
    [junit-jupiter-engine version=5.10.2]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
    [junit-jupiter-api version=5.10.2]
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin.jvm.internal)
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin)
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin.collections)
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.apiguardian.api)(version>=1.1.0)(!(version>=2.0.0)))
      ⇒ osgi.wiring.package: (osgi.wiring.package=kotlin.jvm.functions)
    [assertj-core version=3.25.3]
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit.platform.commons.support)(version>=1.10.0)(!(version>=2.0.0)))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit.jupiter.api)(version>=5.10.0)(!(version>=6.0.0)))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.opentest4j)(version>=1.3.0)(!(version>=2.0.0)))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit.jupiter.api.parallel)(version>=5.10.0)(!(version>=6.0.0)))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit.platform.commons.annotation)(version>=1.10.0)(!(version>=2.0.0)))
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.hamcrest)(version>=2.2.0)(!(version>=3.0.0)))
      ⇒ osgi.wiring.package: (osgi.wiring.package=org.junit.runner)
      ⇒ osgi.wiring.package: (osgi.wiring.package=org.junit.rules)
      ⇒ osgi.wiring.package: (osgi.wiring.package=org.junit.runners.model)
      ⇒ osgi.wiring.package: (&(osgi.wiring.package=org.junit.jupiter.api.extension)(version>=5.10.0)(!(version>=6.0.0)))

FAILURE: Build failed with an exception.

@driessamyn do you have any bandwidth to help take a look at this?

driessamyn commented 2 months ago

Sorry for the delayed response. I've been looking into this and I think this is an issue on the prometheus side. io.prometheus.metrics.expositionformats has a dependency on io.prometheus.metrics.shaded.com_google_protobuf_3_21_7 which is not an OSGi bundle 🤔

fstab commented 2 months ago

Thanks for finding this.

@driessamyn I'm the maintainer of the Prometheus Java client library. I'm not an OSGI expert. Your comment sounds like it would be sufficient to add

<packaging>bundle</packaging>

to the pom.xml of the prometheus-metrics-shaded-opentelemetry module (all other modules have that, so it seems to be just an oversight that it's missing).

I'm happy to give it a try, or do you think something else is needed?

driessamyn commented 2 months ago

Thanks for finding this.

@driessamyn I'm the maintainer of the Prometheus Java client library. I'm not an OSGI expert. Your comment sounds like it would be sufficient to add

<packaging>bundle</packaging>

to the pom.xml of the prometheus-metrics-shaded-opentelemetry module (all other modules have that, so it seems to be just an oversight that it's missing).

I'm happy to give it a try, or do you think something else is needed?

Hi @fstab ,

I'm not familiar with the Maven build tooling for OSGi, but that sounds right. When unpacking the produced jar, the metadata should have OSGi exports, similar to this:

image