Skip to content

Commit

Permalink
[grid] Add error event-logs when capabilities are not found. (Seleniu…
Browse files Browse the repository at this point in the history
…mHQ#8943)

* [grid] Add error event-logs when capabilites are not found

* [grid] Add span attribute error to AttributeKey enum
  • Loading branch information
pujagani committed Dec 14, 2020
1 parent 6227b66 commit 8996ec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ public Either<SessionNotCreatedException, CreateSessionResponse> 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);
}

Expand Down Expand Up @@ -242,7 +249,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> 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);
Expand All @@ -252,7 +259,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> 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);
Expand Down

0 comments on commit 8996ec2

Please sign in to comment.