Skip to content

Commit c146621

Browse files
committed
[grid] Making the tracing logs to be FINE(debug) level
Only outputting INFO for session creation and session deletion.
1 parent e087911 commit c146621

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

java/client/test/org/openqa/selenium/json/JsonOutputTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ public Optional<String> getNoValue() {
690690
}
691691

692692
@Test
693-
public void onRequsetShouldNotWriteClassNamesIntoJson() {
693+
public void onRequestShouldNotWriteClassNamesIntoJson() {
694694
class WithClassName {
695695
public String getCheese() {
696696
return "gouda";

java/server/src/org/openqa/selenium/grid/distributor/Distributor.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import java.util.concurrent.locks.ReentrantReadWriteLock;
6868
import java.util.function.Predicate;
6969
import java.util.function.Supplier;
70+
import java.util.logging.Logger;
7071
import java.util.stream.Collectors;
7172

7273
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES;
@@ -118,6 +119,8 @@
118119
*/
119120
public abstract class Distributor implements HasReadyState, Predicate<HttpRequest>, Routable {
120121

122+
private static final Logger LOG = Logger.getLogger(Distributor.class.getName());
123+
121124
private final Route routes;
122125
protected final Tracer tracer;
123126
private final SlotSelector slotSelector;
@@ -173,7 +176,9 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Http
173176

174177
Iterator<Capabilities> iterator = payload.stream().iterator();
175178
attributeMap.put("request.payload", EventAttribute.setValue(payload.toString()));
176-
span.addEvent("Session request received by the distributor", attributeMap);
179+
String sessionReceivedMessage = "Session request received by the distributor";
180+
span.addEvent(sessionReceivedMessage, attributeMap);
181+
LOG.info(String.format("%s: \n %s", sessionReceivedMessage, payload));
177182

178183
if (!iterator.hasNext()) {
179184
SessionNotCreatedException exception =
@@ -242,7 +247,9 @@ public Either<SessionNotCreatedException, CreateSessionResponse> newSession(Http
242247
span.setAttribute(AttributeKey.SESSION_URI.getKey(), sessionUri);
243248
attributeMap.put(AttributeKey.SESSION_URI.getKey(), EventAttribute.setValue(sessionUri));
244249

245-
span.addEvent("Session created by the distributor", attributeMap);
250+
String sessionCreatedMessage = "Session created by the distributor";
251+
span.addEvent(sessionCreatedMessage, attributeMap);
252+
LOG.info(String.format("%s. Id: %s, Caps: %s", sessionCreatedMessage, sessionId, caps));
246253
return Either.right(sessionResponse);
247254

248255
} else {

java/server/src/org/openqa/selenium/grid/log/LoggingFlags.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ public class LoggingFlags implements HasRoles {
3333

3434
@Parameter(description = "Configure logging", hidden = true, names = "--configure-logging", arity = 1)
3535
@ConfigValue(section = "logging", name = "enable", example = "true")
36-
private Boolean configureLogging = true;
36+
private Boolean configureLogging;
3737

38-
@Parameter(description = "Use structured logs", names = "--structured-logs")
38+
@Parameter(description = "Use structured logs", names = "--structured-logs", arity = 1)
3939
@ConfigValue(section = "logging", name = "structured-logs", example = "false")
40-
private Boolean structuredLogs = false;
40+
private Boolean structuredLogs;
4141

4242
@Parameter(description = "Use plain log lines", names = "--plain-logs", arity = 1)
4343
@ConfigValue(section = "logging", name = "plain-logs", example = "true")
44-
private Boolean plainLogs = true;
44+
private Boolean plainLogs;
4545

4646
@Parameter(description = "Enable trace collection", hidden = true, names = "--tracing", arity = 1)
4747
@ConfigValue(section = "logging", name = "tracing", example = "true")
48-
private Boolean enableTracing = true;
48+
private Boolean enableTracing;
4949

5050
@Parameter(description = "File to write out logs", hidden = true, names = "--log", arity = 1)
5151
@ConfigValue(section = "logging", name = "log-file", example = "true")
5252
private String logFile;
5353

5454
@Parameter(description = "Log encoding", names = "--log-encoding", arity = 1)
5555
@ConfigValue(section = "logging", name = "log-encoding", example = "UTF-8")
56-
private String logEncoding = null;
56+
private String logEncoding;
5757

58-
@Parameter(description = "Log level. Default logging level is INFO." +
59-
"Log levels are described here https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html ",
58+
@Parameter(description = "Log level. Default logging level is INFO. Log levels are described here " +
59+
"https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html",
6060
names = "--log-level", arity = 1)
6161
@ConfigValue(section = "logging", name = "log-level", example = "INFO")
6262
private String logLevel;

java/server/src/org/openqa/selenium/grid/log/LoggingOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public CompletableResultCode export(Collection<SpanData> spans) {
166166
map.put("attributes", attributeMap);
167167
String jsonString = getJsonString(map);
168168
if (status.isOk()) {
169-
LOG.log(Level.INFO, jsonString);
169+
LOG.log(Level.FINE, jsonString);
170170
} else {
171171
LOG.log(Level.WARNING, jsonString);
172172
}
@@ -188,7 +188,7 @@ public CompletableResultCode shutdown() {
188188
}).build());
189189

190190
// The Jaeger exporter doesn't yet have a `TracerFactoryProvider`, so we
191-
//shall look up the class using reflection, and beg for forgiveness
191+
// shall look up the class using reflection, and beg for forgiveness
192192
// later.
193193
Optional<SpanExporter> maybeJaeger = JaegerTracing.findJaegerExporter();
194194
maybeJaeger.ifPresent(

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,15 @@
3939
import java.util.concurrent.locks.Lock;
4040
import java.util.concurrent.locks.ReadWriteLock;
4141
import java.util.concurrent.locks.ReentrantReadWriteLock;
42+
import java.util.logging.Logger;
4243

4344
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
4445
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
4546

4647
public class LocalSessionMap extends SessionMap {
4748

49+
private static final Logger LOG = Logger.getLogger(LocalSessionMap.class.getName());
50+
4851
private final EventBus bus;
4952
private final Map<SessionId, Session> knownSessions = new ConcurrentHashMap<>();
5053
private final ReadWriteLock lock = new ReentrantReadWriteLock(/* be fair */ true);
@@ -62,7 +65,9 @@ public LocalSessionMap(Tracer tracer, EventBus bus) {
6265
SESSION_ID.accept(span, id);
6366
SESSION_ID_EVENT.accept(attributeMap, id);
6467
knownSessions.remove(id);
65-
span.addEvent("Deleted session from local session map", attributeMap);
68+
String sessionDeletedMessage = "Deleted session from local session map";
69+
span.addEvent(sessionDeletedMessage, attributeMap);
70+
LOG.info(String.format("%s, Id: %s", sessionDeletedMessage, id));
6671
}
6772
}));
6873
}

0 commit comments

Comments
 (0)