Skip to content

Commit

Permalink
Maintenance: add default retry rule for Armeria client (#375)
Browse files Browse the repository at this point in the history
Signed-off-by: qchea <[email protected]>
  • Loading branch information
chenqi0805 authored Oct 6, 2021
1 parent ba0d9f1 commit b3d1ff9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.protobuf.ByteString;
import com.linecorp.armeria.client.Clients;
import com.linecorp.armeria.client.retry.RetryRule;
import com.linecorp.armeria.client.retry.RetryingClient;
import com.linecorp.armeria.internal.shaded.bouncycastle.util.encoders.Hex;
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc;
Expand Down Expand Up @@ -152,8 +154,10 @@ private void refreshIndices(final RestHighLevelClient restHighLevelClient) throw
}

private void sendExportTraceServiceRequestToSource(final int port, final ExportTraceServiceRequest request) {
Clients.newClient(String.format("gproto+http://127.0.0.1:%d/", port),
TraceServiceGrpc.TraceServiceBlockingStub.class).export(request);
TraceServiceGrpc.TraceServiceBlockingStub client = Clients.builder(String.format("gproto+http://127.0.0.1:%d/", port))
.decorator(RetryingClient.newDecorator(RetryRule.failsafe()))
.build(TraceServiceGrpc.TraceServiceBlockingStub.class);
client.export(request);
}

private List<Map<String, Object>> getSourcesFromSearchHits(final SearchHits searchHits) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.stream.Stream;

import com.linecorp.armeria.client.Clients;
import com.linecorp.armeria.client.retry.RetryRule;
import com.linecorp.armeria.client.retry.RetryingClient;
import io.opentelemetry.proto.collector.trace.v1.ExportTraceServiceRequest;
import io.opentelemetry.proto.collector.trace.v1.TraceServiceGrpc;
import io.opentelemetry.proto.common.v1.AnyValue;
Expand Down Expand Up @@ -132,8 +134,10 @@ private void refreshIndices(final RestHighLevelClient restHighLevelClient) throw
}

private void sendExportTraceServiceRequestToSource(final int port, final ExportTraceServiceRequest request) {
Clients.newClient(String.format("gproto+http://127.0.0.1:%d/", port),
TraceServiceGrpc.TraceServiceBlockingStub.class).export(request);
TraceServiceGrpc.TraceServiceBlockingStub client = Clients.builder(String.format("gproto+http://127.0.0.1:%d/", port))
.decorator(RetryingClient.newDecorator(RetryRule.failsafe()))
.build(TraceServiceGrpc.TraceServiceBlockingStub.class);
client.export(request);
}

private List<Map<String, Object>> getSourcesFromIndex(final RestHighLevelClient restHighLevelClient, final String index) throws IOException {
Expand Down

0 comments on commit b3d1ff9

Please sign in to comment.