Skip to content

Commit

Permalink
Fix OpenTracing span potentially not getting finished; improve logging.
Browse files Browse the repository at this point in the history
Signed-off-by: Carsten Lohmann <carsten.lohmann@bosch-si.com>
  • Loading branch information
calohmn authored and Kai Hudalla committed Nov 7, 2019
1 parent 76ffbbd commit b9fd0f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public Future<String> getMappedGatewayDevice(final String tenantId, final String

return registrationClientFactory.getOrCreateRegistrationClient(tenantId).compose(client -> {
return client.assertRegistration(deviceId, null, span.context());
}).recover(t -> {
LOG.debug("Error getting registration assertion", t);
return Future.failedFuture(t);
}).compose(registrationAssertionJson -> {
final Future<String> mappedGatewayFuture = Future.future();
final Object viaObject = registrationAssertionJson.getValue(RegistrationConstants.FIELD_VIA);
Expand Down Expand Up @@ -136,12 +139,12 @@ public Future<String> getMappedGatewayDevice(final String tenantId, final String
span.setTag(MessageHelper.APP_PROPERTY_GATEWAY_ID, result);
span.finish();
return result;
}).recover(t -> {
TracingHelper.logError(span, t);
Tags.HTTP_STATUS.set(span, ServiceInvocationException.extractStatusCode(t));
span.finish();
return Future.failedFuture(t);
});
}).recover(t -> {
TracingHelper.logError(span, t);
Tags.HTTP_STATUS.set(span, ServiceInvocationException.extractStatusCode(t));
span.finish();
return Future.failedFuture(t);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void handle(final CommandContext originalCommandContext) {
TracingHelper.logError(originalCommandContext.getCurrentSpan(),
"no mapped gateway set for device " + originalDeviceId);
} else {
LOG.error("error getting mapped gateway for device {}", originalDeviceId, mappedGatewayResult.cause());
LOG.debug("error getting mapped gateway for device {}", originalDeviceId, mappedGatewayResult.cause());
TracingHelper.logError(originalCommandContext.getCurrentSpan(),
"error getting mapped gateway for device: " + mappedGatewayResult.cause());
}
Expand Down

0 comments on commit b9fd0f6

Please sign in to comment.