-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LC-416 added json logging for elk and setting mdc values #100
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.concurrent.TimeUnit; | ||
import org.slf4j.MDC; | ||
|
||
/** | ||
* Publisher implementation that maintains an in-memory list of pending documents. | ||
|
@@ -93,6 +94,7 @@ public PublisherImpl(Config config, PublisherMessenger messenger, String runId, | |
|
||
@Override | ||
public void publish(Document document) throws Exception { | ||
MDC.put("docId", document.getId()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in local mode, the publisher will be running in one thread, some number of workers will be running in their own threads, and an indexer will be running in yet another thread. I don't think setting the docId in the MDC here will propagate the change to other threads where docId is needed, but even if it did, the propogated docId would be "right" for those other threads because everything is happening concurrently -- one doc3 might be published at the same time worker 1 is processing doc2 and the indexer is indexing doc1... |
||
if (firstDocStopWatch.isStarted()) { | ||
firstDocStopWatch.stop(); | ||
log.info("First doc published after " + firstDocStopWatch.getTime(TimeUnit.MILLISECONDS) + " ms"); | ||
|
@@ -111,6 +113,7 @@ public void publish(Document document) throws Exception { | |
} | ||
|
||
private void publishInternal(Document document) throws Exception { | ||
log.debug("Publishing document with id {}", document.getId()); | ||
if (!isCollapsing) { | ||
sendForProcessing(document); | ||
return; | ||
|
@@ -122,6 +125,7 @@ private void publishInternal(Document document) throws Exception { | |
} | ||
|
||
if (previousDoc.getId().equals(document.getId())) { | ||
log.debug("Sending document."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this clause isn't when we're sending the document |
||
previousDoc.setOrAddAll(document); | ||
} else { | ||
sendForProcessing(previousDoc); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"@timestamp": { | ||
"$resolver": "timestamp", | ||
"pattern": { | ||
"format": "yy/MM/dd'T'HH:mm:ss'Z'", | ||
"timeZone": "UTC" | ||
} | ||
}, | ||
"ecs.version": "1.2.0", | ||
"log.level": { | ||
"$resolver": "level", | ||
"field": "name" | ||
}, | ||
"message": { | ||
"$resolver": "message", | ||
"stringified": true | ||
}, | ||
"process.thread.name": { | ||
"$resolver": "thread", | ||
"field": "name" | ||
}, | ||
"log.logger": { | ||
"$resolver": "logger", | ||
"field": "name" | ||
}, | ||
"labels": { | ||
"$resolver": "mdc", | ||
"flatten": true, | ||
"stringified": true | ||
}, | ||
"tags": { | ||
"$resolver": "ndc" | ||
}, | ||
"error.type": { | ||
"$resolver": "exception", | ||
"field": "className" | ||
}, | ||
"error.message": { | ||
"$resolver": "exception", | ||
"field": "message" | ||
}, | ||
"error.stack_trace": { | ||
"$resolver": "exception", | ||
"field": "stackTrace", | ||
"stackTrace": { | ||
"stringified": true | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the call to sendToIndexWithAccounting is not necessarily the time when the doc is sent to the search engine
batch.add(doc) will typically add the doc to a batch being built up, and return an empty list so the sendToIndexWithAccounting call is effectively a no-op
batch.add(doc) returns a non-empty list only in certain situations, like when the batch is full and ready to be flushed