Skip to content

Commit

Permalink
Fixes ThrottledStorageComponent not passing through health check (#2632)
Browse files Browse the repository at this point in the history
  • Loading branch information
lambcode authored and adriancole committed Jun 23, 2019
1 parent 8a58c6f commit da7482f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ final class ZipkinHealthIndicator extends CompositeHealthIndicator {
}

void addComponent(Component component) {
String healthName = component.getClass().getSimpleName();
healthName = healthName.replace("AutoValue_", "");
String healthName = component.toString();
addHealthIndicator(healthName, new ComponentHealthIndicator(component));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import zipkin2.Call;
import zipkin2.CheckResult;
import zipkin2.Span;
import zipkin2.storage.SpanConsumer;
import zipkin2.storage.SpanStore;
Expand Down Expand Up @@ -97,8 +98,12 @@ public ThrottledStorageComponent(StorageComponent delegate, MeterRegistry regist
delegate.close();
}

@Override public CheckResult check() {
return delegate.check();
}

@Override public String toString() {
return "Throttled(" + delegate + ")";
return "Throttled(" + delegate.toString() + ")";
}

static final class ThrottledSpanConsumer implements SpanConsumer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ package zipkin2.server.internal.throttle
import com.linecorp.armeria.common.metric.NoopMeterRegistry
import org.assertj.core.api.Assertions.assertThat
import org.junit.Test
import org.mockito.Mockito.mock
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import zipkin2.storage.InMemoryStorage
import zipkin2.storage.StorageComponent

class ThrottledStorageComponentTest {
val delegate = InMemoryStorage.newBuilder().build()
Expand All @@ -43,6 +47,12 @@ class ThrottledStorageComponentTest {

@Test fun niceToString() {
assertThat(ThrottledStorageComponent(delegate, registry, 1, 2, 1))
.hasToString("Throttled(InMemoryStorage{traceCount=0})");
.hasToString("Throttled(InMemoryStorage{traceCount=0})")
}

@Test fun delegatesCheck() {
val mock = mock(StorageComponent::class.java)
ThrottledStorageComponent(mock, registry, 1, 2, 1).check()
verify(mock, times(1)).check()
}
}

0 comments on commit da7482f

Please sign in to comment.