This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.matez.client; | |
import static org.junit.Assert.fail; | |
import static org.mockito.Matchers.any; | |
import static org.mockito.Mockito.times; | |
import static org.mockito.Mockito.verify; | |
import static org.mockito.Mockito.when; | |
import java.io.IOException; | |
import java.net.UnknownHostException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.prometheus.client.CollectorRegistry; | |
import io.prometheus.client.dropwizard.DropwizardExports; | |
import io.prometheus.client.hotspot.ClassLoadingExports; | |
import io.prometheus.client.hotspot.GarbageCollectorExports; | |
import io.prometheus.client.hotspot.MemoryPoolsExports; | |
import io.prometheus.client.hotspot.ThreadExports; | |
import io.prometheus.client.hotspot.VersionInfoExports; | |
import javax.enterprise.context.ApplicationScoped; | |
import javax.enterprise.context.Destroyed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> | |
<welcome-file-list> | |
<welcome-file>/index.html</welcome-file> | |
</welcome-file-list> | |
<!-- --> | |
<servlet> | |
<servlet-name>prometheusMetrics</servlet-name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>io.astefanutti.metrics.cdi</groupId> | |
<artifactId>metrics-cdi</artifactId> | |
<version>1.3.6</version> | |
</dependency> | |
<dependency> | |
<groupId>io.prometheus</groupId> | |
<artifactId>simpleclient</artifactId> | |
<version>0.0.23</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scrape_configs: | |
- job_name: 'jaxrs' | |
metrics_path: /prometheusMetrics/ | |
# Override the global default and scrape targets from this job every 5 seconds. | |
scrape_interval: 5s | |
static_configs: | |
- targets: ['www.example.com:80'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MetricRegistry metricRegistry = new MetricRegistry(); | |
final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS) | |
.convertDurationsTo(TimeUnit.MILLISECONDS).build(); | |
GitHub github = Feign.builder().invocationHandlerFactory( | |
// instrumenting feign | |
new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry)) | |
// instrumenting ok http | |
.client(new OkHttpClient(InstrumentedOkHttpClients.create(metricRegistry))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MetricRegistry metricRegistry = new MetricRegistry(); | |
final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS) | |
.convertDurationsTo(TimeUnit.MILLISECONDS).build(); | |
GitHub github = Feign.builder().invocationHandlerFactory( | |
// instrument feign | |
new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry)).client( | |
// setting an instrumented httpclient | |
new ApacheHttpClient(InstrumentedHttpClients |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Gauges ---------------------------------------------------------------------- | |
okhttp3.OkHttpClient.connection-pool-idle-count | |
value = 1 | |
okhttp3.OkHttpClient.connection-pool-total-count | |
value = 1 | |
-- Counters -------------------------------------------------------------------- | |
okhttp3.OkHttpClient.network-requests-running | |
count = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Gauges ---------------------------------------------------------------------- | |
org.apache.http.conn.HttpClientConnectionManager.available-connections | |
value = 1 | |
org.apache.http.conn.HttpClientConnectionManager.leased-connections | |
value = 0 | |
org.apache.http.conn.HttpClientConnectionManager.max-connections | |
value = 20 | |
org.apache.http.conn.HttpClientConnectionManager.pending-connections | |
value = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/example") | |
@Produces(MediaType.TEXT_PLAIN) | |
public class ExampleResource { | |
@GET | |
@Timed | |
@Metered | |
@ExceptionMetered | |
public String show() { | |
return "yay"; | |
} |
OlderNewer