Skip to content

Commit b9fd0f6

Browse files
calohmnKai Hudalla
authored and
Kai Hudalla
committed
Fix OpenTracing span potentially not getting finished; improve logging.
Signed-off-by: Carsten Lohmann <[email protected]>
1 parent 76ffbbd commit b9fd0f6

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

client/src/main/java/org/eclipse/hono/client/impl/GatewayMapperImpl.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public Future<String> getMappedGatewayDevice(final String tenantId, final String
8383

8484
return registrationClientFactory.getOrCreateRegistrationClient(tenantId).compose(client -> {
8585
return client.assertRegistration(deviceId, null, span.context());
86+
}).recover(t -> {
87+
LOG.debug("Error getting registration assertion", t);
88+
return Future.failedFuture(t);
8689
}).compose(registrationAssertionJson -> {
8790
final Future<String> mappedGatewayFuture = Future.future();
8891
final Object viaObject = registrationAssertionJson.getValue(RegistrationConstants.FIELD_VIA);
@@ -136,12 +139,12 @@ public Future<String> getMappedGatewayDevice(final String tenantId, final String
136139
span.setTag(MessageHelper.APP_PROPERTY_GATEWAY_ID, result);
137140
span.finish();
138141
return result;
139-
}).recover(t -> {
140-
TracingHelper.logError(span, t);
141-
Tags.HTTP_STATUS.set(span, ServiceInvocationException.extractStatusCode(t));
142-
span.finish();
143-
return Future.failedFuture(t);
144142
});
143+
}).recover(t -> {
144+
TracingHelper.logError(span, t);
145+
Tags.HTTP_STATUS.set(span, ServiceInvocationException.extractStatusCode(t));
146+
span.finish();
147+
return Future.failedFuture(t);
145148
});
146149
}
147150

client/src/main/java/org/eclipse/hono/client/impl/GatewayMappingCommandHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void handle(final CommandContext originalCommandContext) {
9191
TracingHelper.logError(originalCommandContext.getCurrentSpan(),
9292
"no mapped gateway set for device " + originalDeviceId);
9393
} else {
94-
LOG.error("error getting mapped gateway for device {}", originalDeviceId, mappedGatewayResult.cause());
94+
LOG.debug("error getting mapped gateway for device {}", originalDeviceId, mappedGatewayResult.cause());
9595
TracingHelper.logError(originalCommandContext.getCurrentSpan(),
9696
"error getting mapped gateway for device: " + mappedGatewayResult.cause());
9797
}

0 commit comments

Comments
 (0)