[ 
https://issues.apache.org/jira/browse/SLING-12013?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Robert Munteanu updated SLING-12013:
------------------------------------
    Description: 
The commons.thread bundle exports its JMX attributes as Gauges via the 
[ThreadPoolMetricGauges 
class|https://github.com/apache/sling-org-apache-sling-commons-threads/blob/master/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolMetricsGauges.java].
 In particular, it also exports the 'Pid' attribute.

This attribute does not make sense as a Gauge value ( it's a static, 
non-numeric, value ) and when exported ends up null. 

When used with the [prometheus bundle from the 
whiteboard|https://github.com/apache/sling-whiteboard/tree/master/metrics-prometheus]
 it breaks the Prometheus metrics servlet, causing no metrics to be returned. 
Note that this is the code provided by the Prometheus SimpleClient bundle, we 
can't influence how it behaves. I tried.

{noformat}
29.08.2023 17:42:16.461 *ERROR* [FelixLogListener] 
LogService.org.apache.felix.http.jetty Exception while processing request to 
/metrics (java.lang.NullPointerException: Cannot invoke "Object.getClass()" 
because "obj" is null)
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "obj" 
is null
        at 
io.prometheus.client.dropwizard.DropwizardExports.fromGauge(DropwizardExports.java:55)
 [io.prometheus.simpleclient_dropwizard:0.0.23]
        at 
io.prometheus.client.dropwizard.DropwizardExports.collect(DropwizardExports.java:133)
 [io.prometheus.simpleclient_dropwizard:0.0.23]
        at 
io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:180)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.<init>(CollectorRegistry.java:144)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.CollectorRegistry.filteredMetricFamilySamples(CollectorRegistry.java:131)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.exporter.MetricsServlet.doGet(MetricsServlet.java:43) 
[io.prometheus.simpleclient_servlet:0.0.23]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) 
[org.apache.felix.http.servlet-api:1.2.0]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) 
[org.apache.felix.http.servlet-api:1.2.0]
{noformat}

  was:
The commons.thread bundle exports its JMX attributes as Gauges via the 
[ThreadPoolMetricGauges 
class](https://github.com/apache/sling-org-apache-sling-commons-threads/blob/master/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolMetricsGauges.java).
 In particular, it also exports the 'Pid' attribute.

This attribute does not make sense as a Gauge value ( it's a static, 
non-numeric, value ) and when exported ends up null. 

When used with the [prometheus bundle from the 
whiteboard](https://github.com/apache/sling-whiteboard/tree/master/metrics-prometheus)
 it breaks the Prometheus metric servlet, causing no metrics to be returned. 
Note that this is the code provided by the Prometheus SimpleClient bundle, we 
can't influence how it behaves. I tried.

{noformat}
29.08.2023 17:42:16.461 *ERROR* [FelixLogListener] 
LogService.org.apache.felix.http.jetty Exception while processing request to 
/metrics (java.lang.NullPointerException: Cannot invoke "Object.getClass()" 
because "obj" is null)
java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "obj" 
is null
        at 
io.prometheus.client.dropwizard.DropwizardExports.fromGauge(DropwizardExports.java:55)
 [io.prometheus.simpleclient_dropwizard:0.0.23]
        at 
io.prometheus.client.dropwizard.DropwizardExports.collect(DropwizardExports.java:133)
 [io.prometheus.simpleclient_dropwizard:0.0.23]
        at 
io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:180)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.<init>(CollectorRegistry.java:144)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.CollectorRegistry.filteredMetricFamilySamples(CollectorRegistry.java:131)
 [io.prometheus.simpleclient:0.0.23]
        at 
io.prometheus.client.exporter.MetricsServlet.doGet(MetricsServlet.java:43) 
[io.prometheus.simpleclient_servlet:0.0.23]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) 
[org.apache.felix.http.servlet-api:1.2.0]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) 
[org.apache.felix.http.servlet-api:1.2.0]
{noformat}


> Commons Threads exports invalid 'Pid' attribute as gauge
> --------------------------------------------------------
>
>                 Key: SLING-12013
>                 URL: https://issues.apache.org/jira/browse/SLING-12013
>             Project: Sling
>          Issue Type: Bug
>          Components: Commons
>            Reporter: Robert Munteanu
>            Assignee: Robert Munteanu
>            Priority: Major
>             Fix For: Commons Threads 3.3.0
>
>
> The commons.thread bundle exports its JMX attributes as Gauges via the 
> [ThreadPoolMetricGauges 
> class|https://github.com/apache/sling-org-apache-sling-commons-threads/blob/master/src/main/java/org/apache/sling/commons/threads/impl/ThreadPoolMetricsGauges.java].
>  In particular, it also exports the 'Pid' attribute.
> This attribute does not make sense as a Gauge value ( it's a static, 
> non-numeric, value ) and when exported ends up null. 
> When used with the [prometheus bundle from the 
> whiteboard|https://github.com/apache/sling-whiteboard/tree/master/metrics-prometheus]
>  it breaks the Prometheus metrics servlet, causing no metrics to be returned. 
> Note that this is the code provided by the Prometheus SimpleClient bundle, we 
> can't influence how it behaves. I tried.
> {noformat}
> 29.08.2023 17:42:16.461 *ERROR* [FelixLogListener] 
> LogService.org.apache.felix.http.jetty Exception while processing request to 
> /metrics (java.lang.NullPointerException: Cannot invoke "Object.getClass()" 
> because "obj" is null)
> java.lang.NullPointerException: Cannot invoke "Object.getClass()" because 
> "obj" is null
>       at 
> io.prometheus.client.dropwizard.DropwizardExports.fromGauge(DropwizardExports.java:55)
>  [io.prometheus.simpleclient_dropwizard:0.0.23]
>       at 
> io.prometheus.client.dropwizard.DropwizardExports.collect(DropwizardExports.java:133)
>  [io.prometheus.simpleclient_dropwizard:0.0.23]
>       at 
> io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.findNextElement(CollectorRegistry.java:180)
>  [io.prometheus.simpleclient:0.0.23]
>       at 
> io.prometheus.client.CollectorRegistry$MetricFamilySamplesEnumeration.<init>(CollectorRegistry.java:144)
>  [io.prometheus.simpleclient:0.0.23]
>       at 
> io.prometheus.client.CollectorRegistry.filteredMetricFamilySamples(CollectorRegistry.java:131)
>  [io.prometheus.simpleclient:0.0.23]
>       at 
> io.prometheus.client.exporter.MetricsServlet.doGet(MetricsServlet.java:43) 
> [io.prometheus.simpleclient_servlet:0.0.23]
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) 
> [org.apache.felix.http.servlet-api:1.2.0]
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) 
> [org.apache.felix.http.servlet-api:1.2.0]
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to