Created
November 7, 2017 09:55
-
-
Save mwiede/09dde211a9bf5f3813ca11cbf2be184f to your computer and use it in GitHub Desktop.
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
@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; | |
int contributions; | |
} | |
public static void main(String... args) { | |
MetricRegistry metricRegistry = new MetricRegistry(); | |
final ConsoleReporter reporter = ConsoleReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS) | |
.convertDurationsTo(TimeUnit.MILLISECONDS).build(); | |
GitHub github = Feign.builder().invocationHandlerFactory( | |
new FeignOutboundMetricsDecorator(new InvocationHandlerFactory.Default(), metricRegistry)) | |
.decoder(new GsonDecoder()).target(GitHub.class, "https://api.github.com"); | |
// Fetch and print a list of the contributors to this library. | |
List<Contributor> contributors = github.contributors("mwiede", "metrics-feign"); | |
for (Contributor contributor : contributors) { | |
System.out.println(contributor.login + " (" + contributor.contributions + ")"); | |
} | |
reporter.report(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment