View JschExec.java
class JschExec { | |
private static String runCommand(Session session, String command, String... input) throws JSchException, IOException { | |
ChannelExec channel = (ChannelExec) session.openChannel("exec"); | |
try { | |
channel.setCommand(command); | |
logger.debug("running command: {}", command); | |
final InputStream in = channel.getInputStream(); | |
final InputStream errStream = channel.getErrStream(); |
View WebserviceFactory.java
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Proxy; | |
import io.github.resilience4j.retry.Retry; | |
public final class WebserviceFactory{ | |
static <T> T decorateWithRetryer(final T service, Retry retry) { | |
InvocationHandler invocationHandler = (proxy, method, args) -> retry.executeCheckedSupplier(() -> method.invoke(service, args)); |
View Example.java
@Timed | |
@Metered | |
@ExceptionMetered | |
interface GitHub { | |
@RequestLine("GET /repos/{owner}/{repo}/contributors") | |
List<Contributor> contributors(@Param("owner") String owner, @Param("repo") String repo); | |
} | |
static class Contributor { | |
String login; |
View ExampleResource.java
@Path("/example") | |
@Produces(MediaType.TEXT_PLAIN) | |
public class ExampleResource { | |
@GET | |
@Timed | |
@Metered | |
@ExceptionMetered | |
public String show() { | |
return "yay"; | |
} |
View gist:7e2f494ff4b221bd4c7d703a7dfcde88
-- 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 |
View gist:c082106651eccacb3b720a8b83ba5109
-- 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 |
View HttpClientExample.java
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 |
View OkHttpExample.java
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))) |
View prometheus.yml
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'] | |
View pom.xml
<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> |
NewerOlder