Skip to content

Commit

Permalink
Removing event logs with repetitive attributes that is covered by a d…
Browse files Browse the repository at this point in the history
…ifferent event log. (#8773)

Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
  • Loading branch information
pujagani and AutomatedTester committed Oct 14, 2020
1 parent c785b1f commit 7ee0bac
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,11 @@ public WebSocket openSocket(HttpRequest request, WebSocket.Listener listener) {
@Override
public HttpResponse execute(HttpRequest req) {
try (Span span = newSpanAsChildOf(tracer, req, "httpclient.execute")) {
Map<String, EventAttributeValue> attributeMap = new HashMap<>();
attributeMap.put(AttributeKey.HTTP_CLIENT_CLASS.getKey(),
EventAttribute.setValue(delegate.getClass().getName()));

KIND.accept(span, Span.Kind.CLIENT);
HTTP_REQUEST.accept(span, req);
HTTP_REQUEST_EVENT.accept(attributeMap, req);
tracer.getPropagator().inject(span, req, (r, key, value) -> r.setHeader(key, value));
HttpResponse response = delegate.execute(req);
HTTP_RESPONSE.accept(span, response);
HTTP_RESPONSE_EVENT.accept(attributeMap, response);
span.addEvent("HTTP request received response", attributeMap);
return response;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public CreateSessionResponse newSession(HttpRequest request)

Iterator<Capabilities> iterator = payload.stream().iterator();
attributeMap.put("request.payload", EventAttribute.setValue(payload.toString()));
span.addEvent("Session request received by the distributor", attributeMap);

if (!iterator.hasNext()) {
SessionNotCreatedException exception = new SessionNotCreatedException("No capabilities found");
Expand Down Expand Up @@ -239,7 +240,6 @@ public CreateSessionResponse newSession(HttpRequest request)
span.setAttribute(AttributeKey.SESSION_URI.getKey(), sessionUri);
attributeMap.put(AttributeKey.SESSION_URI.getKey(), EventAttribute.setValue(sessionUri));

span.addEvent("Session created by the distributor", attributeMap);
return sessionResponse;
} catch (SessionNotCreatedException e) {
span.setAttribute("error", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public Optional<ActiveSession> apply(CreateSessionRequest sessionRequest) {
LOG.info(String.format("Waiting for server to start (container id: %s)", container.getId()));
try {
waitForServerToStart(client, Duration.ofMinutes(1));
span.addEvent("Container started. Docker server ready.", attributeMap);
} catch (TimeoutException e) {
span.setAttribute("error", true);
span.setStatus(Status.CANCELLED);
Expand Down Expand Up @@ -178,7 +177,7 @@ public Optional<ActiveSession> apply(CreateSessionRequest sessionRequest) {
attributeMap.put(AttributeKey.DRIVER_RESPONSE.getKey(), EventAttribute.setValue(response.toString()));

span.addEvent("Docker driver service created session", attributeMap);
LOG.info(String.format(
LOG.fine(String.format(
"Created session: %s - %s (container id: %s)",
id,
capabilities,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,13 @@ public Optional<CreateSessionResponse> newSession(CreateSessionRequest sessionRe
Capabilities caps = session.getCapabilities();
SESSION_ID.accept(span, sessionId);
CAPABILITIES.accept(span, caps);
SESSION_ID_EVENT.accept(attributeMap, sessionId);
CAPABILITIES_EVENT.accept(attributeMap, caps);
String downstream = session.getDownstreamDialect().toString();
String upstream = session.getUpstreamDialect().toString();
String sessionUri = session.getUri().toString();
span.setAttribute(AttributeKey.DOWNSTREAM_DIALECT.getKey(), downstream);
span.setAttribute(AttributeKey.UPSTREAM_DIALECT.getKey(), upstream);
span.setAttribute(AttributeKey.SESSION_URI.getKey(), sessionUri);

attributeMap.put(AttributeKey.DOWNSTREAM_DIALECT.getKey(), EventAttribute.setValue(downstream));
attributeMap.put(AttributeKey.UPSTREAM_DIALECT.getKey(), EventAttribute.setValue(upstream));
attributeMap.put(AttributeKey.SESSION_URI.getKey(), EventAttribute.setValue(sessionUri));

span.addEvent("Session created by node", attributeMap);

// The session we return has to look like it came from the node, since we might be dealing
// with a webdriver implementation that only accepts connections from localhost
Session externalSession = createExternalSession(session, externalUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ public HttpResponse execute(HttpRequest req) {
HttpResponse res = knownSessions.get(id, loadSessionId(tracer, span, id)).execute(req);

HTTP_RESPONSE.accept(span, res);
HTTP_RESPONSE_EVENT.accept(attributeMap, res);

span.addEvent("Session request execution complete", attributeMap);
return res;
} catch (ExecutionException e) {
span.setAttribute("error", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ public ReverseProxyHandler(Tracer tracer, HttpClient httpClient) {
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
try (Span span = newSpanAsChildOf(tracer, req, "reverse_proxy")) {

Map<String, EventAttributeValue> attributeMap = new HashMap<>();
attributeMap.put(AttributeKey.HTTP_HANDLER_CLASS.getKey(),
EventAttribute.setValue(getClass().getName()));

KIND.accept(span, Span.Kind.SERVER);
HTTP_REQUEST.accept(span, req);
HTTP_REQUEST_EVENT.accept(attributeMap, req);

HttpRequest toUpstream = new HttpRequest(req.getMethod(), req.getUri());

Expand All @@ -102,15 +96,13 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
HttpResponse resp = upstream.execute(toUpstream);

HTTP_RESPONSE.accept(span,resp);
HTTP_RESPONSE_EVENT.accept(attributeMap, resp);

// clear response defaults.
resp.removeHeader("Date");
resp.removeHeader("Server");

IGNORED_REQ_HEADERS.forEach(resp::removeHeader);

span.addEvent("HTTP request execution complete", attributeMap);
return resp;
}
}
Expand Down

0 comments on commit 7ee0bac

Please sign in to comment.