Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dropwizard version to 4.0.0 #370

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
<artifactId>metrics-healthchecks</artifactId>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jmx</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/
package com.hotels.styx.metrics.reporting.jmx;

import com.codahale.metrics.JmxReporter;
import com.codahale.metrics.jmx.JmxReporter;
import com.codahale.metrics.MetricRegistry;
import com.hotels.styx.api.extension.service.spi.StyxService;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -21,8 +21,10 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import org.testng.annotations.Test;

import static com.hotels.styx.support.matchers.RegExMatcher.matchesRegex;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.regex.Pattern.quote;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

Expand All @@ -42,18 +44,20 @@ public void supportsModules() {

JsonSupplier supplier = JsonSupplier.create(() -> metricsRegistry, new MetricsModule(SECONDS, MILLISECONDS, false));

assertThat(supplier.get(), is("{\"version\":\"3.1.3\",\"gauges\":{\"gauge\":{\"value\":\"foo\"}},\"counters\":{\"counter\":{\"count\":7}},\"histograms\":{},\"meters\":{},\"timers\":{}}"));
assertThat(supplier.get(), matchesRegex(quote("{\"version\":\"") +
"\\d+\\.\\d+\\.\\d+" +
quote("\",\"gauges\":{\"gauge\":{\"value\":\"foo\"}},\"counters\":{\"counter\":{\"count\":7}},\"histograms\":{},\"meters\":{},\"timers\":{}}")));
}

private Gauge<String> gauge(String value) {
private static Gauge<String> gauge(String value) {
return () -> value;
}

private static class Convertible {
private final String string;
private final int integer;

public Convertible(String string, int integer) {
Convertible(String string, int integer) {
this.string = string;
this.integer = integer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,9 @@
import static com.hotels.styx.api.HttpResponseStatus.NOT_FOUND;
import static com.hotels.styx.api.HttpResponseStatus.OK;
import static com.hotels.styx.support.api.BlockingObservables.waitForResponse;
import static com.hotels.styx.support.matchers.RegExMatcher.matchesRegex;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.regex.Pattern.quote;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

Expand All @@ -53,7 +55,9 @@ public void respondsToRequestWithJsonResponse() {
public void exposesRegisteredMetrics() {
metricRegistry.counter("foo").inc();
HttpResponse response = waitForResponse(handler.handle(get("/admin/metrics").build(), HttpInterceptorContext.create()));
assertThat(response.bodyAs(UTF_8), is("{\"version\":\"3.1.3\",\"gauges\":{},\"counters\":{\"foo\":{\"count\":1}},\"histograms\":{},\"meters\":{},\"timers\":{}}"));
assertThat(response.bodyAs(UTF_8), matchesRegex(quote("{\"version\":\"") +
"\\d+\\.\\d+\\.\\d+" +
quote("\",\"gauges\":{},\"counters\":{\"foo\":{\"count\":1}},\"histograms\":{},\"meters\":{},\"timers\":{}}")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2013-2018 Expedia Inc.
Copyright (C) 2013-2019 Expedia Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -22,8 +22,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.testng.annotations.Test;

import static com.hotels.styx.support.matchers.RegExMatcher.matchesRegex;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.regex.Pattern.quote;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

Expand Down Expand Up @@ -85,7 +87,7 @@ public void createsMetricsJsonCorrectly() throws JsonProcessingException {

String after = JsonReformatter.reformat(before);

assertThat(after, is("{\n" +
assertThat(after, matchesRegex(quote("{\n" +
" \"counters\":{\n" +
" \"foo.bar.count\":4,\n" +
" \"styx\":{\n" +
Expand All @@ -106,8 +108,10 @@ public void createsMetricsJsonCorrectly() throws JsonProcessingException {
" \"timers\":{\n" +
"\n" +
" },\n" +
" \"version\":\"3.1.3\"\n" +
"}"));
" \"version\":\"") +
"\\d+\\.\\d+\\.\\d+" +
quote("\"\n" +
"}")));
}

private static String removeWhiteSpace(String text) {
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
<jackson.version>2.9.7</jackson.version>
<jackson.dataformat.version>2.5.1</jackson.dataformat.version>
<jackson.module.scala.version>2.9.7</jackson.module.scala.version>
<metrics.version>3.2.6</metrics.version>
<metrics.version>4.0.0</metrics.version>
<antlr.version>4.5.1-1</antlr.version>
<netty.version>4.1.15.Final</netty.version>
<netty-tcnative.version>2.0.6.Final</netty-tcnative.version>
Expand Down Expand Up @@ -335,6 +335,12 @@
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jmx</artifactId>
<version>${metrics.version}</version>
</dependency>

<dependency>
<groupId>org.hdrhistogram</groupId>
<artifactId>HdrHistogram</artifactId>
Expand Down