Skip to content

Commit

Permalink
Updated current.info.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis J. McWherter Jr committed Oct 17, 2016
1 parent f2ef4ac commit 9eb90e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ public void add(LogInfo phase) {
body.put(phase.getName(), phase);
}

/**
* Create a new LogBlock with the same body but updated uuid.
*
* @param uuid New uuid.
* @return New LogBlock with updated uuid.
*/
public LogBlock withUuid(String uuid) {
LogBlock newLogBlock = new LogBlock(uuid);
body.entrySet().forEach(entry -> newLogBlock.body.put(entry.getKey(), entry.getValue()));
return newLogBlock;
}

/**
* Add an entry of given class in this LogBlock that holds no information.
* It is meant to be used only to define the order of {@link LogInfo} parts inside a LogBlock.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ public static String getId() {
public static void addIdPrefix(String idPrefix) {
RequestLog current = RLOG.get();
String newId = idPrefix + getId();
current.info = current.info.withUuid(newId);
current.logId = newId;
MDC.put(ID_KEY, newId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ public void filter(ClientRequestContext request, ClientResponseContext response)
* @param requestId Request id to add as queryId prefix to druid
*/
private void appendRequestId(String requestId) {
if (requestId.length() < 20 || requestId.length() > 200 || !VALID_REQUEST_ID.matcher(requestId).matches()) {
if (requestId == null || requestId.length() < 20 || requestId.length() > 200
|| !VALID_REQUEST_ID.matcher(requestId).matches()) {
return; // Ignore according to https://devcenter.heroku.com/articles/http-request-id
}
RequestLog.addIdPrefix(requestId);
Expand Down

0 comments on commit 9eb90e4

Please sign in to comment.