Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simpleclient_servlet duplicates classes from simpleclient.jar starting in 0.12 #771

Closed
twbecker opened this issue Mar 30, 2022 · 4 comments · Fixed by #789
Closed

simpleclient_servlet duplicates classes from simpleclient.jar starting in 0.12 #771

twbecker opened this issue Mar 30, 2022 · 4 comments · Fixed by #789

Comments

@twbecker
Copy link

Starting with release 0.12, the simpleclient_servlet jar now contains duplicates of most (all?) classes from the core client. The dependency from the servlet module on the main module still exists, so I can only assume this is unintentional.

@fstab
Copy link
Member

fstab commented Mar 30, 2022

Hi, I assume you mean that these dependencies are both, in simpleclient_servlet/pom.xml and in simpleclient_servlet_common/pom.xml?

        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.15.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_common</artifactId>
            <version>0.15.1-SNAPSHOT</version>
        </dependency>

Good point, I'll remove them from simpleclient_servlet/pom.xml. However, this should not cause any problems either, or does it?

@skuroda
Copy link

skuroda commented Mar 30, 2022

A project I'm working on flags when duplicate class files exist, so are hitting this issue as well. Thinking all the dependencies might be bundled, we tried excluding simpleclient (as it is a transitive dependency) in our build script. However, doing so results in

java.lang.NoClassDefFoundError: io/prometheus/client/exemplars/ExemplarConfig
  at io.prometheus.client.Counter$Child.sampleNextExemplar(Counter.java:272)
  at io.prometheus.client.Counter$Child.updateExemplar(Counter.java:255)
  at io.prometheus.client.Counter$Child.incWithExemplar(Counter.java:240)
  at io.prometheus.client.Counter$Child.inc(Counter.java:215)
  at io.prometheus.client.Counter.inc(Counter.java:329)
  at io.prometheus.client.Counter.inc(Counter.java:306)

So it seems like removing the dependencies would leave things in a non functional state.

Is it possible to either produce an artifact that contains the client completely embedded, or completely separate so we can resolve the dependency?

@twbecker
Copy link
Author

@fstab I'm not talking about the dependencies in the pom. I'm saying the classes are actually duplicated inside the JAR files. In version 0.11.0 the contents of simpleclient_servlet.jar was this:

META-INF/MANIFEST.MF
META-INF/
META-INF/maven/
META-INF/maven/io.prometheus/
META-INF/maven/io.prometheus/simpleclient_servlet/
META-INF/maven/io.prometheus/simpleclient_servlet/pom.properties
META-INF/maven/io.prometheus/simpleclient_servlet/pom.xml
io/
io/prometheus/
io/prometheus/client/
io/prometheus/client/exporter/
io/prometheus/client/exporter/MetricsServlet.class
io/prometheus/client/filter/
io/prometheus/client/filter/MetricsFilter.class

Starting in 0.12.0, it's this:

META-INF/MANIFEST.MF
META-INF/
META-INF/maven/
META-INF/maven/io.prometheus/
META-INF/maven/io.prometheus/simpleclient_servlet/
META-INF/maven/io.prometheus/simpleclient_servlet/pom.properties
META-INF/maven/io.prometheus/simpleclient_servlet/pom.xml
io/
io/prometheus/
io/prometheus/client/
io/prometheus/client/Adapter$1.class
io/prometheus/client/Adapter$FilterConfigAdapterImpl.class
io/prometheus/client/Adapter$HttpServletRequestAdapterImpl.class
io/prometheus/client/Adapter$HttpServletResponseAdapterImpl.class
io/prometheus/client/Adapter$ServletConfigAdapterImpl.class
io/prometheus/client/Adapter.class
io/prometheus/client/CKMSQuantiles$Item.class
io/prometheus/client/CKMSQuantiles$Quantile.class
io/prometheus/client/CKMSQuantiles.class
io/prometheus/client/Collector$1.class
io/prometheus/client/Collector$Describable.class
io/prometheus/client/Collector$MetricFamilySamples$Sample.class
io/prometheus/client/Collector$MetricFamilySamples.class
io/prometheus/client/Collector$Type.class
io/prometheus/client/Collector.class
io/prometheus/client/CollectorRegistry$MetricFamilySamplesEnumeration.class
io/prometheus/client/CollectorRegistry.class
io/prometheus/client/Counter$Builder.class
io/prometheus/client/Counter$Child.class
io/prometheus/client/Counter.class
io/prometheus/client/CounterMetricFamily.class
io/prometheus/client/DoubleAdder.class
io/prometheus/client/Enumeration$1.class
io/prometheus/client/Enumeration$Builder.class
io/prometheus/client/Enumeration$Child.class
io/prometheus/client/Enumeration.class
io/prometheus/client/Gauge$1.class
io/prometheus/client/Gauge$Builder.class
io/prometheus/client/Gauge$Child.class
io/prometheus/client/Gauge$TimeProvider.class
io/prometheus/client/Gauge$Timer.class
io/prometheus/client/Gauge.class
io/prometheus/client/GaugeMetricFamily.class
io/prometheus/client/Histogram$1.class
io/prometheus/client/Histogram$Builder.class
io/prometheus/client/Histogram$Child$Value.class
io/prometheus/client/Histogram$Child.class
io/prometheus/client/Histogram$Timer.class
io/prometheus/client/Histogram.class
io/prometheus/client/Info$1.class
io/prometheus/client/Info$Builder.class
io/prometheus/client/Info$Child.class
io/prometheus/client/Info.class
io/prometheus/client/Predicate.class
io/prometheus/client/SampleNameFilter$1.class
io/prometheus/client/SampleNameFilter$AllowAll.class
io/prometheus/client/SampleNameFilter$Builder.class
io/prometheus/client/SampleNameFilter.class
io/prometheus/client/SimpleCollector$Builder.class
io/prometheus/client/SimpleCollector.class
io/prometheus/client/SimpleTimer$TimeProvider.class
io/prometheus/client/SimpleTimer.class
io/prometheus/client/Striped64$Cell.class
io/prometheus/client/Striped64.class
io/prometheus/client/Summary$1.class
io/prometheus/client/Summary$Builder.class
io/prometheus/client/Summary$Child$Value.class
io/prometheus/client/Summary$Child.class
io/prometheus/client/Summary$Timer.class
io/prometheus/client/Summary.class
io/prometheus/client/SummaryMetricFamily.class
io/prometheus/client/Supplier.class
io/prometheus/client/TimeWindowQuantiles.class
io/prometheus/client/exporter/
io/prometheus/client/exporter/MetricsServlet.class
io/prometheus/client/filter/
io/prometheus/client/filter/MetricsFilter.class

For most setups I guess this duplication doesn't break anything, but anyone checking for duplicate classes will find it, and it seems pretty clear it should not be this way.

@fstab
Copy link
Member

fstab commented Apr 4, 2022

Thanks a lot for the explanation. It seem that this is related to <packaging>bundle</packaging>. If you remove <packaging>bundle</packaging> from simpleclient_servlet/pom.xml the additional classes will not be part of the JAR.

Unfortunately it's not clear why this happens. <packaging>bundle</packaging> was already there in version 0.11, except that the parent module was different. So it seems this is caused by a combination of the packaging and how the parent modules are structured.

Moreover, the packaging was introduced on purpose because some users use client_java modules via OSGI, and for that the OSGI packaging is needed, see for example #678.

I have never used OSGI myself and I'm not an expert on what exactly <packaging>bundle</packaging> does and why it behaves differently depending on what is the parent of the module. I'm hesitant to remove the packaging because this might break OSGI for some people.

Is there anyone reading this with a bit more OSGI knowledge who could give some advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants