kandi background
Explore Kits

client_java | Prometheus instrumentation library for JVM applications | Monitoring library

 by   prometheus Java Version: parent-0.15.0 License: Apache-2.0

 by   prometheus Java Version: parent-0.15.0 License: Apache-2.0

Download this library from

kandi X-RAY | client_java Summary

client_java is a Java library typically used in Performance Management, Monitoring, Prometheus applications. client_java has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub, Maven.
[Per Metric Exemplar Samplers](#per-metric-exemplar-samplers). [Built-in Support for Tracing Systems](#built-in-support-for-tracing-systems). [Exporting to a Pushgateway](#exporting-to-a-pushgateway).
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • client_java has a medium active ecosystem.
  • It has 1693 star(s) with 658 fork(s). There are 71 watchers for this library.
  • There were 4 major release(s) in the last 12 months.
  • There are 45 open issues and 272 have been closed. On average issues are closed in 86 days. There are 18 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of client_java is parent-0.15.0
client_java Support
Best in #Monitoring
Average in #Monitoring
client_java Support
Best in #Monitoring
Average in #Monitoring

quality kandi Quality

  • client_java has 0 bugs and 0 code smells.
client_java Quality
Best in #Monitoring
Average in #Monitoring
client_java Quality
Best in #Monitoring
Average in #Monitoring

securitySecurity

  • client_java has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • client_java code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
client_java Security
Best in #Monitoring
Average in #Monitoring
client_java Security
Best in #Monitoring
Average in #Monitoring

license License

  • client_java is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
client_java License
Best in #Monitoring
Average in #Monitoring
client_java License
Best in #Monitoring
Average in #Monitoring

buildReuse

  • client_java releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
  • It has 17879 lines of code, 1295 functions and 219 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
client_java Reuse
Best in #Monitoring
Average in #Monitoring
client_java Reuse
Best in #Monitoring
Average in #Monitoring
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

client_java Key Features

[Using](#using)

[Assets](#assets)

[Javadocs](#javadocs)

[Instrumenting](#instrumenting)

[Counter](#counter)

[Gauge](#gauge)

[Summary](#summary)

[Histogram](#histogram)

[Labels](#labels)

[Registering Metrics](#registering-metrics)

[Exemplars](#exemplars)

[Global Exemplar Samplers](#global-exemplar-samplers)

[Per Metric Exemplar Samplers](#per-metric-exemplar-samplers)

[Per Observation Exemplars](#per-observation-exemplars)

[Built-in Support for Tracing Systems](#built-in-support-for-tracing-systems)

[Included Collectors](#included-collectors)

[Logging](#logging)

[Caches](#caches)

[Hibernate](#hibernate)

[Jetty](#jetty)

[Exporting](#exporting)

[HTTP](#http)

[Exporting to a Pushgateway](#exporting-to-a-pushgateway)

[Bridges](#bridges)

[Graphite](#graphite)

[Custom Collectors](#custom-collectors)

[Contact](#contact)

Assets

copy iconCopydownload iconDownload
<!-- The client -->
<dependency>
  <groupId>io.prometheus</groupId>
  <artifactId>simpleclient</artifactId>
  <version>0.15.0</version>
</dependency>
<!-- Hotspot JVM metrics-->
<dependency>
  <groupId>io.prometheus</groupId>
  <artifactId>simpleclient_hotspot</artifactId>
  <version>0.15.0</version>
</dependency>
<!-- Exposition HTTPServer-->
<dependency>
  <groupId>io.prometheus</groupId>
  <artifactId>simpleclient_httpserver</artifactId>
  <version>0.15.0</version>
</dependency>
<!-- Pushgateway exposition-->
<dependency>
  <groupId>io.prometheus</groupId>
  <artifactId>simpleclient_pushgateway</artifactId>
  <version>0.15.0</version>
</dependency>

Counter

copy iconCopydownload iconDownload
import io.prometheus.client.Counter;
class YourClass {
  static final Counter requests = Counter.build()
     .name("requests_total").help("Total requests.").register();

  void processRequest() {
    requests.inc();
    // Your code here.
  }
}

Gauge

copy iconCopydownload iconDownload
class YourClass {
  static final Gauge inprogressRequests = Gauge.build()
     .name("inprogress_requests").help("Inprogress requests.").register();

  void processRequest() {
    inprogressRequests.inc();
    // Your code here.
    inprogressRequests.dec();
  }
}

Summary

copy iconCopydownload iconDownload
class YourClass {

  private static final Summary requestLatency = Summary.build()
      .name("requests_latency_seconds")
      .help("request latency in seconds")
      .register();

  private static final Summary receivedBytes = Summary.build()
      .name("requests_size_bytes")
      .help("request size in bytes")
      .register();

  public void processRequest(Request req) {
    Summary.Timer requestTimer = requestLatency.startTimer();
    try {
      // Your code here.
    } finally {
      requestTimer.observeDuration();
      receivedBytes.observe(req.size());
    }
  }
}

Histogram

copy iconCopydownload iconDownload
class YourClass {
  static final Histogram requestLatency = Histogram.build()
     .name("requests_latency_seconds").help("Request latency in seconds.").register();

  void processRequest(Request req) {
    Histogram.Timer requestTimer = requestLatency.startTimer();
    try {
      // Your code here.
    } finally {
      requestTimer.observeDuration();
    }
  }
}

Labels

copy iconCopydownload iconDownload
class YourClass {
  static final Counter requests = Counter.build()
     .name("my_library_requests_total").help("Total requests.")
     .labelNames("method").register();

  void processGetRequest() {
    requests.labels("get").inc();
    // Your code here.
  }
}

Registering Metrics

copy iconCopydownload iconDownload
static final Counter requests = Counter.build()
   .name("my_library_requests_total").help("Total requests.").labelNames("path").register();

Exemplars

copy iconCopydownload iconDownload
curl -H 'Accept: application/openmetrics-text; version=1.0.0; charset=utf-8' http://localhost:8080/metrics

Global Exemplar Samplers

copy iconCopydownload iconDownload
ExemplarConfig.disableExemplars();

Per Metric Exemplar Samplers

copy iconCopydownload iconDownload
Counter myCounter = Counter.build()
    .name("number_of_events_total")
    .help("help")
    .withExemplars()
    ...
    .register();

Per Observation Exemplars

copy iconCopydownload iconDownload
myCounter.incWithExemplar("span_id", "abcdef", "trace_id", "123456");

Included Collectors

copy iconCopydownload iconDownload
DefaultExports.initialize();

Logging

copy iconCopydownload iconDownload
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>

    <appender name="METRICS" class="io.prometheus.client.logback.InstrumentedAppender" />

    <root level="INFO">
        <appender-ref ref="METRICS" />
    </root>

</configuration>

Caches

copy iconCopydownload iconDownload
CacheMetricsCollector cacheMetrics = new CacheMetricsCollector().register();

Cache<String, String> cache = CacheBuilder.newBuilder().recordStats().build();
cacheMetrics.addCache("myCacheLabel", cache);

Hibernate

copy iconCopydownload iconDownload
new HibernateStatisticsCollector(sessionFactory, "myapp").register();

Jetty

copy iconCopydownload iconDownload
// Configure StatisticsHandler.
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler());
server.setHandler(stats);
// Register collector.
new JettyStatisticsCollector(stats).register();

HTTP

copy iconCopydownload iconDownload
HTTPServer server = new HTTPServer.Builder()
    .withPort(1234)
    .build();

Exporting to a Pushgateway

copy iconCopydownload iconDownload
void executeBatchJob() throws Exception {
  CollectorRegistry registry = new CollectorRegistry();
  Gauge duration = Gauge.build()
     .name("my_batch_job_duration_seconds").help("Duration of my batch job in seconds.").register(registry);
  Gauge.Timer durationTimer = duration.startTimer();
  try {
    // Your code here.

    // This is only added to the registry after success,
    // so that a previous success in the Pushgateway isn't overwritten on failure.
    Gauge lastSuccess = Gauge.build()
       .name("my_batch_job_last_success").help("Last time my batch job succeeded, in unixtime.").register(registry);
    lastSuccess.setToCurrentTime();
  } finally {
    durationTimer.setDuration();
    PushGateway pg = new PushGateway("127.0.0.1:9091");
    pg.pushAdd(registry, "my_batch_job");
  }
}
 ```

A separate registry is used, as the default registry may contain other metrics
such as those from the Process Collector. See the
[Pushgateway documentation](https://github.com/prometheus/pushgateway/blob/master/README.md)
for more information.


#### with Basic Auth
```java
PushGateway pushgateway = new PushGateway("127.0.0.1:9091");
pushgateway.setConnectionFactory(new BasicAuthHttpConnectionFactory("my_user", "my_password"));

Graphite

copy iconCopydownload iconDownload
Graphite g = new Graphite("localhost", 2003);
// Push the default registry once.
g.push(CollectorRegistry.defaultRegistry);

// Push the default registry every 60 seconds.
Thread thread = g.start(CollectorRegistry.defaultRegistry, 60);
// Stop pushing.
thread.interrupt();
thread.join();

Custom Collectors

copy iconCopydownload iconDownload
class YourCustomCollector extends Collector {
  public List<MetricFamilySamples> collect() {
    List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>();
    // With no labels.
    mfs.add(new GaugeMetricFamily("my_gauge", "help", 42));
    // With labels
    GaugeMetricFamily labeledGauge = new GaugeMetricFamily("my_other_gauge", "help", Arrays.asList("labelname"));
    labeledGauge.addMetric(Arrays.asList("foo"), 4);
    labeledGauge.addMetric(Arrays.asList("bar"), 5);
    mfs.add(labeledGauge);
    return mfs;
  }
}

// Registration
static final YourCustomCollector requests = new YourCustomCollector().register()

DropwizardExports Collector

copy iconCopydownload iconDownload
// Dropwizard MetricRegistry
MetricRegistry metricRegistry = new MetricRegistry();
new DropwizardExports(metricRegistry).register();

Why is SpringBoot upgrade from 2.3.0 to 2.5.0 failing to start tomcat with Prometheus exceptions?

copy iconCopydownload iconDownload
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-spring-legacy</artifactId>
    <version>1.5.1</version>
</dependency>

Community Discussions

Trending Discussions on client_java
  • Prometheus java client and Prometheus server compatiblity
  • Why is SpringBoot upgrade from 2.3.0 to 2.5.0 failing to start tomcat with Prometheus exceptions?
Trending Discussions on client_java

QUESTION

Prometheus java client and Prometheus server compatiblity

Asked 2020-Aug-22 at 18:47

Current latest version of Prometheus Java client is 0.9.0 and the latest version of Prometheus Server is 2.20.1. I was wondering if there is a compatibility matrix of client and server versions which I could not find via basic google search. If someone is aware of it, can you please share?

It can contain something like the earliest supported version of server for the latest client and also vice-versa, the earliest supported version of client for the latest server.

ANSWER

Answered 2020-Aug-22 at 18:47

Practically speaking, everything should work with everything.

The current v0.0.4 Prometheus text format has been around for 5+ years, you'd probably have to dig back to before the Java simpleclient existed to find something incompatible.

Source https://stackoverflow.com/questions/63521927

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install client_java

You can download it from GitHub, Maven.
You can use client_java like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the client_java component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

Support

The DefaultExemplarSampler detects if a tracing library is found on startup, and provides exemplars for that tracing library by default. Currently, only [OpenTelemetry tracing](https://github.com/open-telemetry/opentelemetry-java) is supported. If you are a tracing vendor, feel free to open a PR and add support for your tracing library.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Reuse Pre-built Kits with client_java
Consider Popular Monitoring Libraries
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.