You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zipkin.apache.org by ad...@apache.org on 2019/06/13 12:43:52 UTC
[incubator-zipkin] 01/01: Updates to Armeria 0.87 and addresses
deprecation
This is an automated email from the ASF dual-hosted git repository.
adriancole pushed a commit to branch armeria-0.87
in repository https://gitbox.apache.org/repos/asf/incubator-zipkin.git
commit 99f418939eb7040b7ef1749c8beb29ec34879a34
Author: Adrian Cole <ac...@pivotal.io>
AuthorDate: Thu Jun 13 20:43:41 2019 +0800
Updates to Armeria 0.87 and addresses deprecation
---
pom.xml | 4 +--
.../server/internal/MetricsHealthController.java | 2 +-
.../server/internal/ZipkinHealthIndicator.java | 10 ++++----
.../server/internal/ZipkinHttpCollector.java | 6 ++---
.../zipkin2/server/internal/ZipkinQueryApiV2.java | 30 +++++++++++-----------
.../internal/brave/TracingStorageComponent.java | 6 ++---
.../ZipkinPrometheusMetricsConfiguration.java | 5 ++--
.../server/internal/ui/ZipkinUiConfiguration.java | 10 ++++----
8 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3b2c3cd..7672c96 100755
--- a/pom.xml
+++ b/pom.xml
@@ -48,9 +48,9 @@
<main.basedir>${project.basedir}</main.basedir>
- <armeria.version>0.86.0</armeria.version>
+ <armeria.version>0.87.0</armeria.version>
<!-- This is from armeria, but be careful to avoid >= v20 apis -->
- <guava.version>27.1-jre</guava.version>
+ <guava.version>28.0-jre</guava.version>
<!-- only used for proto interop testing -->
<wire.version>3.0.0-alpha01</wire.version>
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/MetricsHealthController.java b/zipkin-server/src/main/java/zipkin2/server/internal/MetricsHealthController.java
index 1906b47..6bdce4f 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/MetricsHealthController.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/MetricsHealthController.java
@@ -96,6 +96,6 @@ public class MetricsHealthController {
ResponseHeaders headers = ResponseHeaders.builder(statusMapper.mapStatus(health.getStatus()))
.contentType(MediaType.JSON)
.setInt(HttpHeaderNames.CONTENT_LENGTH, body.length).build();
- return HttpResponse.of(headers, HttpData.of(body));
+ return HttpResponse.of(headers, HttpData.wrap(body));
}
}
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHealthIndicator.java b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHealthIndicator.java
index 9a1569d..782faa3 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHealthIndicator.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHealthIndicator.java
@@ -17,19 +17,20 @@ import org.springframework.boot.actuate.health.CompositeHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.HealthIndicator;
+import org.springframework.boot.actuate.health.HealthIndicatorRegistry;
import zipkin2.CheckResult;
import zipkin2.Component;
final class ZipkinHealthIndicator extends CompositeHealthIndicator {
- ZipkinHealthIndicator(HealthAggregator healthAggregator) {
- super(healthAggregator);
+ ZipkinHealthIndicator(HealthAggregator healthAggregator, HealthIndicatorRegistry registry) {
+ super(healthAggregator, registry);
}
void addComponent(Component component) {
String healthName = component.getClass().getSimpleName();
healthName = healthName.replace("AutoValue_", "");
- addHealthIndicator(healthName, new ComponentHealthIndicator(component));
+ getRegistry().register(healthName, new ComponentHealthIndicator(component));
}
static final class ComponentHealthIndicator implements HealthIndicator {
@@ -40,8 +41,7 @@ final class ZipkinHealthIndicator extends CompositeHealthIndicator {
}
/** synchronized to prevent overlapping requests to a storage backend */
- @Override
- public synchronized Health health() {
+ @Override public synchronized Health health() {
CheckResult result = component.check();
return result.ok() ? Health.up().build() : Health.down((Exception) result.error()).build();
}
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
index d538d16..6afe779 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinHttpCollector.java
@@ -14,7 +14,7 @@
package zipkin2.server.internal;
import com.linecorp.armeria.client.encoding.GzipStreamDecoderFactory;
-import com.linecorp.armeria.common.AggregatedHttpMessage;
+import com.linecorp.armeria.common.AggregatedHttpRequest;
import com.linecorp.armeria.common.HttpData;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpRequest;
@@ -170,7 +170,7 @@ public class ZipkinHttpCollector {
return HttpResponse.from(result);
}
- static void maybeLog(String prefix, ServiceRequestContext ctx, AggregatedHttpMessage request) {
+ static void maybeLog(String prefix, ServiceRequestContext ctx, AggregatedHttpRequest request) {
if (!LOGGER.isDebugEnabled()) return;
LOGGER.debug("{} sent by clientAddress->{}, userAgent->{}",
prefix, ctx.clientAddress(), request.headers().get(HttpHeaderNames.USER_AGENT)
@@ -205,7 +205,7 @@ final class CompletableCallback extends CompletableFuture<HttpResponse>
final class UnzippingBytesRequestConverter {
static final GzipStreamDecoderFactory GZIP_DECODER_FACTORY = new GzipStreamDecoderFactory();
- static HttpData convertRequest(ServiceRequestContext ctx, AggregatedHttpMessage request) {
+ static HttpData convertRequest(ServiceRequestContext ctx, AggregatedHttpRequest request) {
ZipkinHttpCollector.metrics.incrementMessages();
String encoding = request.headers().get(HttpHeaderNames.CONTENT_ENCODING);
HttpData content = request.content();
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinQueryApiV2.java b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinQueryApiV2.java
index 4cd0b47..4f7c2b6 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinQueryApiV2.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/ZipkinQueryApiV2.java
@@ -13,7 +13,7 @@
*/
package zipkin2.server.internal;
-import com.linecorp.armeria.common.AggregatedHttpMessage;
+import com.linecorp.armeria.common.AggregatedHttpResponse;
import com.linecorp.armeria.common.HttpData;
import com.linecorp.armeria.common.HttpHeaderNames;
import com.linecorp.armeria.common.HttpStatus;
@@ -70,7 +70,7 @@ public class ZipkinQueryApiV2 {
}
@Get("/api/v2/dependencies")
- public AggregatedHttpMessage getDependencies(
+ public AggregatedHttpResponse getDependencies(
@Param("endTs") long endTs,
@Param("lookback") Optional<Long> lookback) throws IOException {
Call<List<DependencyLink>> call =
@@ -79,20 +79,20 @@ public class ZipkinQueryApiV2 {
}
@Get("/api/v2/services")
- public AggregatedHttpMessage getServiceNames() throws IOException {
+ public AggregatedHttpResponse getServiceNames() throws IOException {
List<String> serviceNames = storage.serviceAndSpanNames().getServiceNames().execute();
serviceCount = serviceNames.size();
return maybeCacheNames(serviceCount > 3, serviceNames);
}
@Get("/api/v2/spans")
- public AggregatedHttpMessage getSpanNames(@Param("serviceName") String serviceName) throws IOException {
+ public AggregatedHttpResponse getSpanNames(@Param("serviceName") String serviceName) throws IOException {
List<String> spanNames = storage.serviceAndSpanNames().getSpanNames(serviceName).execute();
return maybeCacheNames(serviceCount > 3, spanNames);
}
@Get("/api/v2/remoteServices")
- public AggregatedHttpMessage getRemoteServiceNames(@Param("serviceName") String serviceName)
+ public AggregatedHttpResponse getRemoteServiceNames(@Param("serviceName") String serviceName)
throws IOException {
List<String> remoteServiceNames =
storage.serviceAndSpanNames().getRemoteServiceNames(serviceName).execute();
@@ -100,7 +100,7 @@ public class ZipkinQueryApiV2 {
}
@Get("/api/v2/traces")
- public AggregatedHttpMessage getTraces(
+ public AggregatedHttpResponse getTraces(
@Param("serviceName") Optional<String> serviceName,
@Param("remoteServiceName") Optional<String> remoteServiceName,
@Param("spanName") Optional<String> spanName,
@@ -129,19 +129,19 @@ public class ZipkinQueryApiV2 {
}
@Get("/api/v2/trace/{traceIdHex}")
- public AggregatedHttpMessage getTrace(@Param("traceIdHex") String traceIdHex) throws IOException {
+ public AggregatedHttpResponse getTrace(@Param("traceIdHex") String traceIdHex) throws IOException {
List<Span> trace = storage.spanStore().getTrace(traceIdHex).execute();
if (trace == null) {
- return AggregatedHttpMessage.of(HttpStatus.NOT_FOUND, MediaType.PLAIN_TEXT_UTF_8,
+ return AggregatedHttpResponse.of(HttpStatus.NOT_FOUND, MediaType.PLAIN_TEXT_UTF_8,
traceIdHex + " not found");
}
return jsonResponse(SpanBytesEncoder.JSON_V2.encodeList(trace));
}
- static AggregatedHttpMessage jsonResponse(byte[] body) {
- return AggregatedHttpMessage.of(ResponseHeaders.builder(200)
+ static AggregatedHttpResponse jsonResponse(byte[] body) {
+ return AggregatedHttpResponse.of(ResponseHeaders.builder(200)
.contentType(MediaType.JSON)
- .setInt(HttpHeaderNames.CONTENT_LENGTH, body.length).build(), HttpData.of(body));
+ .setInt(HttpHeaderNames.CONTENT_LENGTH, body.length).build(), HttpData.wrap(body));
}
static final WriteBuffer.Writer<String> QUOTED_STRING_WRITER = new WriteBuffer.Writer<String>() {
@@ -157,12 +157,12 @@ public class ZipkinQueryApiV2 {
};
@Get("/api/v2/autocompleteKeys")
- public AggregatedHttpMessage getAutocompleteKeys() {
+ public AggregatedHttpResponse getAutocompleteKeys() {
return maybeCacheNames(true, autocompleteKeys);
}
@Get("/api/v2/autocompleteValues")
- public AggregatedHttpMessage getAutocompleteValues(@Param("key") String key) throws IOException {
+ public AggregatedHttpResponse getAutocompleteValues(@Param("key") String key) throws IOException {
List<String> values = storage.autocompleteTags().getValues(key).execute();
return maybeCacheNames(values.size() > 3, values);
}
@@ -172,7 +172,7 @@ public class ZipkinQueryApiV2 {
* empty results, users have more questions. We assume caching becomes a concern when zipkin is in
* active use, and active use usually implies more than 3 services.
*/
- AggregatedHttpMessage maybeCacheNames(boolean shouldCacheControl, List<String> values) {
+ AggregatedHttpResponse maybeCacheNames(boolean shouldCacheControl, List<String> values) {
Collections.sort(values);
byte[] body = JsonCodec.writeList(QUOTED_STRING_WRITER, values);
ResponseHeadersBuilder headers = ResponseHeaders.builder(200)
@@ -184,7 +184,7 @@ public class ZipkinQueryApiV2 {
CacheControl.maxAge(namesMaxAge, TimeUnit.SECONDS).mustRevalidate().getHeaderValue()
);
}
- return AggregatedHttpMessage.of(headers.build(), HttpData.of(body));
+ return AggregatedHttpResponse.of(headers.build(), HttpData.wrap(body));
}
// This is inlined here as there isn't enough re-use to warrant it being in the zipkin2 library
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/brave/TracingStorageComponent.java b/zipkin-server/src/main/java/zipkin2/server/internal/brave/TracingStorageComponent.java
index 81b4b63..b736f18 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/brave/TracingStorageComponent.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/brave/TracingStorageComponent.java
@@ -73,13 +73,11 @@ public final class TracingStorageComponent extends StorageComponent {
return new TracedCall<>(tracer, delegate.getTrace(traceId), "get-trace");
}
- @Override
- public Call<List<String>> getServiceNames() {
+ @Override @Deprecated public Call<List<String>> getServiceNames() {
return new TracedCall<>(tracer, delegate.getServiceNames(), "get-service-names");
}
- @Override
- public Call<List<String>> getSpanNames(String serviceName) {
+ @Override @Deprecated public Call<List<String>> getSpanNames(String serviceName) {
return new TracedCall<>(tracer, delegate.getSpanNames(serviceName), "get-span-names");
}
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/prometheus/ZipkinPrometheusMetricsConfiguration.java b/zipkin-server/src/main/java/zipkin2/server/internal/prometheus/ZipkinPrometheusMetricsConfiguration.java
index 7356870..aa44951 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/prometheus/ZipkinPrometheusMetricsConfiguration.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/prometheus/ZipkinPrometheusMetricsConfiguration.java
@@ -20,7 +20,7 @@ import com.linecorp.armeria.common.RequestContext;
import com.linecorp.armeria.common.Response;
import com.linecorp.armeria.common.logging.RequestLog;
import com.linecorp.armeria.common.logging.RequestLogAvailability;
-import com.linecorp.armeria.server.PathMapping;
+import com.linecorp.armeria.server.Route;
import com.linecorp.armeria.server.Service;
import com.linecorp.armeria.server.ServiceRequestContext;
import com.linecorp.armeria.server.SimpleDecoratingService;
@@ -73,7 +73,8 @@ public class ZipkinPrometheusMetricsConfiguration {
@Order(1)
ArmeriaServerConfigurator notFoundMetricCollector() {
// Use glob instead of catch-all to avoid adding it to the trie router.
- return sb -> sb.service(PathMapping.ofGlob("/**"), (ctx, req) -> HttpResponse.of(HttpStatus.NOT_FOUND));
+ return sb -> sb.service(Route.builder().glob("/**").build(),
+ (ctx, req) -> HttpResponse.of(HttpStatus.NOT_FOUND));
}
static final class MetricCollectingService<I extends Request, O extends Response>
diff --git a/zipkin-server/src/main/java/zipkin2/server/internal/ui/ZipkinUiConfiguration.java b/zipkin-server/src/main/java/zipkin2/server/internal/ui/ZipkinUiConfiguration.java
index 28f01aa..f507467 100644
--- a/zipkin-server/src/main/java/zipkin2/server/internal/ui/ZipkinUiConfiguration.java
+++ b/zipkin-server/src/main/java/zipkin2/server/internal/ui/ZipkinUiConfiguration.java
@@ -21,11 +21,11 @@ import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.common.HttpStatus;
import com.linecorp.armeria.common.MediaType;
+import com.linecorp.armeria.common.ServerCacheControl;
+import com.linecorp.armeria.common.ServerCacheControlBuilder;
import com.linecorp.armeria.server.AbstractHttpService;
import com.linecorp.armeria.server.HttpService;
import com.linecorp.armeria.server.RedirectService;
-import com.linecorp.armeria.server.ServerCacheControl;
-import com.linecorp.armeria.server.ServerCacheControlBuilder;
import com.linecorp.armeria.server.Service;
import com.linecorp.armeria.server.ServiceRequestContext;
import com.linecorp.armeria.server.encoding.HttpEncodingService;
@@ -126,8 +126,8 @@ public class ZipkinUiConfiguration {
legacyIndex = HttpFileBuilder.ofResource("zipkin-ui/index.html");
lensIndex = HttpFileBuilder.ofResource("zipkin-lens/index.html");
} else {
- legacyIndex = HttpFileBuilder.of(HttpData.of(processedIndexHtml().getBytes(UTF_8)));
- lensIndex = HttpFileBuilder.of(HttpData.of(processedLensIndexHtml().getBytes(UTF_8)));
+ legacyIndex = HttpFileBuilder.of(HttpData.wrap(processedIndexHtml().getBytes(UTF_8)));
+ lensIndex = HttpFileBuilder.of(HttpData.wrap(processedLensIndexHtml().getBytes(UTF_8)));
}
ServerCacheControl maxAgeMinute = new ServerCacheControlBuilder().maxAgeSeconds(60).build();
@@ -153,7 +153,7 @@ public class ZipkinUiConfiguration {
byte[] config = new ObjectMapper().writeValueAsBytes(ui);
return sb -> {
- sb.service("/zipkin/config.json", HttpFileBuilder.of(HttpData.of(config))
+ sb.service("/zipkin/config.json", HttpFileBuilder.of(HttpData.wrap(config))
.cacheControl(new ServerCacheControlBuilder().maxAgeSeconds(600).build())
.contentType(MediaType.JSON_UTF_8)
.build()