Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public byte[] getResponseMessage() {
}

private static byte[] getResponseMessageBytes(byte[] bodyBytes) throws IOException {
if (bodyBytes.length > 5) {
if (bodyBytes.length >= 5) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurit notes that for a typical case where an OTLP receiver returns an empty payload, this results in IOException("Invalid response"). Added in #8046.

This error didn't show up in our build logs because it results in a log at level FINE.

ByteArrayInputStream bodyStream = new ByteArrayInputStream(bodyBytes);
bodyStream.skip(5);
if (bodyBytes[0] == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private static void onError(Throwable e) {
}
}

private static Sampler updateSampler(SamplingStrategyResponse response) {
private static Sampler updateSampler(SamplingStrategyResponse response) throws IOException {
SamplingStrategyResponse.PerOperationSamplingStrategies operationSampling =
response.perOperationSamplingStrategies;
if (operationSampling.strategies.size() > 0) {
Expand All @@ -156,9 +156,9 @@ private static Sampler updateSampler(SamplingStrategyResponse response) {
return Sampler.parentBased(
new RateLimitingSampler(response.rateLimitingSamplingStrategy.maxTracesPerSecond));
case UNRECOGNIZED:
throw new AssertionError("unrecognized sampler type");
throw new IOException("unrecognized sampler type");
}
throw new AssertionError("unrecognized sampler type");
throw new IOException("unrecognized sampler type");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,26 @@ void pollingInterval_duration() {
}
}

@Test
void emptyResponse() {
Sampling.SamplingStrategyResponse response =
Sampling.SamplingStrategyResponse.newBuilder().build();
responses.add(response);

try (JaegerRemoteSampler sampler =
JaegerRemoteSampler.builder()
.setEndpoint(server.httpUri().toString())
.setServiceName(SERVICE_NAME)
// Make sure only polls once.
.setPollingInterval(500, TimeUnit.SECONDS)
.build()) {
assertThat(sampler).extracting("grpcSender").isInstanceOf(OkHttpGrpcSender.class);

// Empty response results in an unmarshaling exception which is handled by logging a warning
await().untilAsserted(() -> logs.assertContains("Failed to unmarshal strategy response"));
}
}

@Test
void perOperationSampling() {
Sampling.SamplingStrategyResponse response =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,26 @@ void pollingInterval_duration() {
}
}

@Test
void emptyResponse() {
Sampling.SamplingStrategyResponse response =
Sampling.SamplingStrategyResponse.newBuilder().build();
responses.add(response);

try (JaegerRemoteSampler sampler =
JaegerRemoteSampler.builder()
.setChannel(managedChannel())
.setServiceName(SERVICE_NAME)
// Make sure only polls once.
.setPollingInterval(500, TimeUnit.SECONDS)
.build()) {
assertThat(sampler).extracting("grpcSender").isInstanceOf(UpstreamGrpcSender.class);

// Empty response results in an unmarshaling exception which is handled by logging a warning
await().untilAsserted(() -> logs.assertContains("Failed to unmarshal strategy response"));
}
}

@Test
void perOperationSampling() {
Sampling.SamplingStrategyResponse response =
Expand Down
Loading