From c08c2484892551487f63b64b9faba90dc19cdd4e Mon Sep 17 00:00:00 2001 From: Lauren Muhlhauser Date: Thu, 23 Jul 2020 18:10:19 -0400 Subject: [PATCH] [core] Close fetch / fetchSeries spans --- .../spotify/heroic/tracing/EndSpanFutureReporter.java | 6 +++--- .../com/spotify/heroic/metric/LocalMetricManager.java | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/heroic-component/src/main/java/com/spotify/heroic/tracing/EndSpanFutureReporter.java b/heroic-component/src/main/java/com/spotify/heroic/tracing/EndSpanFutureReporter.java index 3bb7ffd49..87759d510 100644 --- a/heroic-component/src/main/java/com/spotify/heroic/tracing/EndSpanFutureReporter.java +++ b/heroic-component/src/main/java/com/spotify/heroic/tracing/EndSpanFutureReporter.java @@ -36,7 +36,7 @@ public EndSpanFutureReporter(final Span span) { } @Override - public void failed(final Throwable cause) throws Exception { + public void failed(final Throwable cause) { span.putAttribute("error", booleanAttributeValue(true)); Optional.ofNullable(cause.getMessage()).ifPresent(span::addAnnotation); span.setStatus(Status.INTERNAL); @@ -44,12 +44,12 @@ public void failed(final Throwable cause) throws Exception { } @Override - public void resolved(final Object result) throws Exception { + public void resolved(final Object result) { span.end(); } @Override - public void cancelled() throws Exception { + public void cancelled() { span.putAttribute("error", booleanAttributeValue(true)); span.setStatus(Status.CANCELLED); span.end(); diff --git a/heroic-core/src/main/java/com/spotify/heroic/metric/LocalMetricManager.java b/heroic-core/src/main/java/com/spotify/heroic/metric/LocalMetricManager.java index 469c77460..567f40511 100644 --- a/heroic-core/src/main/java/com/spotify/heroic/metric/LocalMetricManager.java +++ b/heroic-core/src/main/java/com/spotify/heroic/metric/LocalMetricManager.java @@ -79,7 +79,6 @@ import javax.inject.Inject; import javax.inject.Named; import org.apache.commons.lang3.NotImplementedException; -import org.slf4j.Logger; @MetricScope public class LocalMetricManager implements MetricManager { @@ -88,7 +87,6 @@ public class LocalMetricManager implements MetricManager { QueryTrace.identifier(LocalMetricManager.class, "query"); private static final QueryTrace.Identifier FETCH = QueryTrace.identifier(LocalMetricManager.class, "fetch"); - private static final Logger log = org.slf4j.LoggerFactory.getLogger(LocalMetricManager.class); private final OptionalLimit groupLimit; private final OptionalLimit seriesLimit; @@ -231,7 +229,7 @@ private Transform( } @Override - public AsyncFuture transform(final FindSeries result) throws Exception { + public AsyncFuture transform(final FindSeries result) { final Span fetchSpan = tracer.spanBuilderWithExplicitParent( "localMetricsManager.fetch", parentSpan).startSpan(); final ResultLimits limits; @@ -255,8 +253,13 @@ public AsyncFuture transform(final FindSeries result) throws Exceptio limits = ResultLimits.of(); } - /* if empty, there are not time series on this shard */ + /* if empty, there are no time series on this shard */ if (result.isEmpty()) { + + fetchSpan.addAnnotation("There are no time series on this shard"); + fetchSpan.putAttribute("resultEmpty", booleanAttributeValue(true)); + fetchSpan.end(); + return async.resolved(FullQuery.empty(namedWatch.end(), limits)); }