首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实现普罗米修斯计数器时的NoClassDefFoundError

实现普罗米修斯计数器时的NoClassDefFoundError
EN

Stack Overflow用户
提问于 2020-03-22 21:56:28
回答 1查看 611关注 0票数 1

我实现了一个普罗米修斯计数器来得到。对服务的请求的数量。当我调用服务时,我得到了以下错误。

Exception in thread "HTTP-Listener I/O dispatcher-1" java.lang.NoClassDefFoundError: io/prometheus/client/Counter

我在pom.xml文件中添加了以下依赖项。

代码语言:javascript
复制
      <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient</artifactId>
         <version>0.8.1</version>
     </dependency>
     <!-- Hotspot JVM metrics-->
     <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient_hotspot</artifactId>
         <version>0.8.1</version>
     </dependency>
     <!-- Exposition HTTPServer-->
     <dependency>
         <groupId>io.prometheus</groupId>
         <artifactId>simpleclient_httpserver</artifactId>
         <version>0.8.1</version>
     </dependency>

这是我的java工具。

代码语言:javascript
复制
      private Counter requestsReceived;

      requestsReceived = Counter.build().name("requests_total_Sample").help("Total 
                                                       requests.").register();

      requestsReceived.inc(); 

我该如何解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2021-01-29 04:07:37

你应该始终使用简单客户端的各个部分的一致版本。

代码语言:javascript
复制
<!-- prometheus - core -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- prometheus - Exposition HTTPServer -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_httpserver</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- Hotspot JVM metrics -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_hotspot</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_servlet</artifactId>
    <version>${prometheus.version}</version>
</dependency>

<!-- prometheus - Pushgateway exposition -->
<dependency>
    <groupId>io.prometheus</groupId>
    <artifactId>simpleclient_pushgateway</artifactId>
    <version>${prometheus.version}</version>
</dependency>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60800202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档