Skip to content

Instantly share code, notes, and snippets.

@mwiede
Created November 7, 2017 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwiede/30864cabac831ca25e528d35ec76cb69 to your computer and use it in GitHub Desktop.
Save mwiede/30864cabac831ca25e528d35ec76cb69 to your computer and use it in GitHub Desktop.
example shjowing apache http client instrumentation
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
.createDefault(metricRegistry, HttpClientMetricNameStrategies.HOST_AND_METHOD)))
.decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com");
execute...
reporter.report();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment