From 8996ec2376ca1dec7844bce1974ffa4384f09e56 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Mon, 14 Dec 2020 15:40:22 +0530 Subject: [PATCH] [grid] Add error event-logs when capabilities are not found. (#8943) * [grid] Add error event-logs when capabilites are not found * [grid] Add span attribute error to AttributeKey enum --- .../openqa/selenium/remote/tracing/AttributeKey.java | 2 ++ .../openqa/selenium/grid/distributor/Distributor.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/java/client/src/org/openqa/selenium/remote/tracing/AttributeKey.java b/java/client/src/org/openqa/selenium/remote/tracing/AttributeKey.java index d7873fff5fc52..72bdc513a2e4a 100644 --- a/java/client/src/org/openqa/selenium/remote/tracing/AttributeKey.java +++ b/java/client/src/org/openqa/selenium/remote/tracing/AttributeKey.java @@ -42,6 +42,8 @@ public enum AttributeKey { HTTP_SCHEME(SemanticAttributes.HTTP_SCHEME.getKey()), HTTP_FLAVOR(SemanticAttributes.HTTP_FLAVOR.getKey()), + ERROR("error"), + LOGGER_CLASS("logger"), DRIVER_RESPONSE("driver.response"), diff --git a/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java b/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java index 765f4e2fa69d7..0364bac8212ca 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java +++ b/java/server/src/org/openqa/selenium/grid/distributor/Distributor.java @@ -202,6 +202,13 @@ public Either newSession( "No host supports the capabilities required: %s", payload.stream().map(Capabilities::toString).collect(Collectors.joining(", "))); SessionNotCreatedException exception = new SessionNotCreatedException(errorMessage); + span.setAttribute(AttributeKey.ERROR.getKey(), true); + span.setStatus(Status.ABORTED); + + EXCEPTION.accept(attributeMap, exception); + attributeMap.put(AttributeKey.EXCEPTION_MESSAGE.getKey(), + EventAttribute.setValue("Unable to create session: " + exception.getMessage())); + span.addEvent(AttributeKey.EXCEPTION_EVENT.getKey(), attributeMap); return Either.left(exception); } @@ -242,7 +249,7 @@ public Either newSession( return Either.left(exception); } } catch (SessionNotCreatedException e) { - span.setAttribute("error", true); + span.setAttribute(AttributeKey.ERROR.getKey(), true); span.setStatus(Status.ABORTED); EXCEPTION.accept(attributeMap, e); @@ -252,7 +259,7 @@ public Either newSession( SessionNotCreatedException exception = new RetrySessionRequestException(e.getMessage()); return Either.left(exception); } catch (IOException e) { - span.setAttribute("error", true); + span.setAttribute(AttributeKey.ERROR.getKey(), true); span.setStatus(Status.UNKNOWN); EXCEPTION.accept(attributeMap, e);