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 @@ -68,16 +68,17 @@ public CompletableResultCode export(Marshaler exportRequest, int numItems) {

grpcSender.send(
exportRequest.toBinaryMessageWriter(),
grpcResponse -> onResponse(result, metricRecording, grpcResponse),
throwable -> onError(result, metricRecording, throwable));
grpcResponse -> onResponse(result, metricRecording, grpcResponse, numItems),
throwable -> onError(result, metricRecording, numItems, throwable));

return result;
}

private void onResponse(
CompletableResultCode result,
ExporterInstrumentation.Recording metricRecording,
GrpcResponse grpcResponse) {
GrpcResponse grpcResponse,
int numItems) {
GrpcStatusCode statusCode = grpcResponse.getStatusCode();

metricRecording.setGrpcStatusCode(statusCode);
Expand All @@ -100,6 +101,8 @@ private void onResponse(
logger.log(
Level.SEVERE,
"Failed to export "
+ numItems
+ " "
+ type
+ "s. Server is UNAVAILABLE. "
+ "Make sure your collector is running and reachable from this network. "
Expand All @@ -110,6 +113,8 @@ private void onResponse(
logger.log(
Level.WARNING,
"Failed to export "
+ numItems
+ " "
+ type
+ "s. Server responded with gRPC status code "
+ statusCode.getValue()
Expand All @@ -123,12 +128,16 @@ private void onResponse(
private void onError(
CompletableResultCode result,
ExporterInstrumentation.Recording metricRecording,
int numItems,
Throwable e) {
metricRecording.finishFailed(e);
logger.log(
Level.SEVERE, "Failed to export " + type + "s. The request could not be executed.", e);
Level.SEVERE,
"Failed to export " + numItems + " " + type + "s. The request could not be executed.",
e);
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Failed to export " + type + "s. Details follow:", e);
logger.log(
Level.FINEST, "Failed to export " + numItems + " " + type + "s. Details follow:", e);
}
result.failExceptionally(FailedExportException.grpcFailedExceptionally(e));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ public CompletableResultCode export(Marshaler exportRequest, int numItems) {

httpSender.send(
messageWriter,
httpResponse -> onResponse(result, metricRecording, httpResponse),
throwable -> onError(result, metricRecording, throwable));
httpResponse -> onResponse(result, metricRecording, httpResponse, numItems),
throwable -> onError(result, metricRecording, numItems, throwable));

return result;
}

private void onResponse(
CompletableResultCode result,
ExporterInstrumentation.Recording metricRecording,
HttpResponse httpResponse) {
HttpResponse httpResponse,
int numItems) {
int statusCode = httpResponse.getStatusCode();

metricRecording.setHttpStatusCode(statusCode);
Expand All @@ -104,6 +105,8 @@ private void onResponse(
logger.log(
Level.WARNING,
"Failed to export "
+ numItems
+ " "
+ type
+ "s. Server responded with HTTP status code "
+ statusCode
Expand All @@ -116,10 +119,13 @@ private void onResponse(
private void onError(
CompletableResultCode result,
ExporterInstrumentation.Recording metricRecording,
int numItems,
Throwable e) {
metricRecording.finishFailed(e);
logger.log(
Level.SEVERE, "Failed to export " + type + "s. The request could not be executed.", e);
Level.SEVERE,
"Failed to export " + numItems + " " + type + "s. The request could not be executed.",
e);
result.failExceptionally(FailedExportException.httpFailedExceptionally(e));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ void error() {

LoggingEvent log =
logs.assertContains(
"Failed to export "
"Failed to export 1 "
+ type
+ "s. Server responded with gRPC status code 13. Error message:");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
Expand Down Expand Up @@ -870,7 +870,7 @@ void errorWithMessage() {
.isFalse();
LoggingEvent log =
logs.assertContains(
"Failed to export "
"Failed to export 1 "
+ type
+ "s. Server responded with gRPC status code 8. Error message: out of quota");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
Expand All @@ -891,7 +891,7 @@ void errorWithEscapedMessage() {
.isFalse();
LoggingEvent log =
logs.assertContains(
"Failed to export "
"Failed to export 1 "
+ type
+ "s. Server responded with gRPC status code 5. Error message: クマ🐻");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
Expand All @@ -912,7 +912,7 @@ void testExport_Unavailable() {
.isFalse();
LoggingEvent log =
logs.assertContains(
"Failed to export "
"Failed to export 1 "
+ type
+ "s. Server is UNAVAILABLE. "
+ "Make sure your collector is running and reachable from this network.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void error() {

LoggingEvent log =
logs.assertContains(
"Failed to export "
"Failed to export 1 "
+ type
+ "s. Server responded with HTTP status code 500. Error message:");
assertThat(log.getLevel()).isEqualTo(Level.WARN);
Expand Down
Loading