Skip to content

Commit bcbd009

Browse files
committed
[java] Adding logging to track session creation and deletion
[skip ci]
1 parent da9f04f commit bcbd009

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

‎java/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
487487
EventAttribute.setValue(getClass().getName()));
488488

489489
attributeMap.put("request.payload", EventAttribute.setValue(request.getDesiredCapabilities().toString()));
490-
String sessionReceivedMessage = "Session request received by the distributor";
490+
String sessionReceivedMessage = "Session request received by the Distributor";
491491
span.addEvent(sessionReceivedMessage, attributeMap);
492492
LOG.info(String.format("%s: \n %s", sessionReceivedMessage, request.getDesiredCapabilities()));
493493

@@ -519,7 +519,7 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
519519
SlotId selectedSlot = reserveSlot(request.getRequestId(), caps);
520520
if (selectedSlot == null) {
521521
LOG.info(
522-
String.format("Unable to find a free slot for request %s. %s ",
522+
String.format("Unable to find a free slot for request %s. \n %s ",
523523
request.getRequestId(),
524524
caps));
525525
retry = true;
@@ -546,9 +546,10 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Sess
546546
span.setAttribute(SESSION_URI.getKey(), sessionUri);
547547
attributeMap.put(SESSION_URI.getKey(), EventAttribute.setValue(sessionUri));
548548

549-
String sessionCreatedMessage = "Session created by the distributor";
549+
String sessionCreatedMessage = "Session created by the Distributor";
550550
span.addEvent(sessionCreatedMessage, attributeMap);
551-
LOG.info(String.format("%s. Id: %s, Caps: %s", sessionCreatedMessage, sessionId, sessionCaps));
551+
LOG.info(
552+
String.format("%s. Id: %s \n Caps: %s", sessionCreatedMessage, sessionId, sessionCaps));
552553

553554
return Either.right(response);
554555
} catch (SessionNotCreatedException e) {

‎java/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ private LocalNode(
167167
.removalListener((RemovalListener<SessionId, SessionSlot>) notification -> {
168168
if (notification.getKey() != null && notification.getValue() != null) {
169169
// Attempt to stop the session
170-
LOG.log(Debug.getDebugLogLevel(), "Stopping session {0}",
171-
notification.getKey().toString());
172170
SessionSlot slot = notification.getValue();
173171
if (!slot.isAvailable()) {
174172
slot.stop();
@@ -374,6 +372,10 @@ public Either<WebDriverException, CreateSessionResponse> newSession(CreateSessio
374372
externalUri,
375373
slotToUse.isSupportingCdp(),
376374
sessionRequest.getDesiredCapabilities());
375+
376+
String sessionCreatedMessage = "Session created by the Node";
377+
LOG.info(String.format("%s. Id: %s, Caps: %s", sessionCreatedMessage, sessionId, caps));
378+
377379
return Either.right(new CreateSessionResponse(
378380
externalSession,
379381
getEncoder(session.getDownstreamDialect()).apply(externalSession)));

‎java/src/org/openqa/selenium/grid/node/local/SessionSlot.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public void stop() {
113113
currentSession = null;
114114
release();
115115
bus.fire(new SessionClosedEvent(id));
116+
LOG.info(String.format("Stopping session %s", id));
116117
}
117118

118119
@Override

‎java/src/org/openqa/selenium/grid/sessionmap/local/LocalSessionMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public LocalSessionMap(Tracer tracer, EventBus bus) {
6767
SESSION_ID.accept(span, id);
6868
SESSION_ID_EVENT.accept(attributeMap, id);
6969
knownSessions.remove(id);
70-
String sessionDeletedMessage = "Deleted session from local session map";
70+
String sessionDeletedMessage = "Deleted session from local Session Map";
7171
span.addEvent(sessionDeletedMessage, attributeMap);
7272
LOG.info(String.format("%s, Id: %s", sessionDeletedMessage, id));
7373
}

0 commit comments

Comments
 (0)