You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: Prior to adding the job id to new log messages, and changing the job id format, understand the impact on end-user parsers and visualizations.
Update the WFM to use a Mapped Diagnostic Context (MDC) for reporting the Job Id for all job-specific log lines. Currently, many log lines lack the job id since it's burden to have to pass it to every method in every class. MDC gets around this.
We can modify the layoutPattern in openmpf/trunk/workflow-manager/src/main/resources/log4j2.xml:
Here's an example of changes that need to be made to the Java code:
packageorg.mitre.mpf;
importorg.junit.Test;
importorg.slf4j.Logger;
importorg.slf4j.LoggerFactory;
importorg.slf4j.MDC;
publicclassTestMdc {
privatestaticfinalLoggerLOG = LoggerFactory.getLogger(TestMdc.class);
@Testpublicvoidtest() {
varjobId = 1234;
try (varctx = MDC.putCloseable("jobId", String.valueOf(jobId))) {
doesNotKnowJobId();
existingMethodThatAlreadyLogsJobId(jobId);
}
LOG.info("Message not related to a specific job.");
}
privatestaticvoiddoesNotKnowJobId() {
LOG.info("hello");
}
privatestaticvoidexistingMethodThatAlreadyLogsJobId(intjobId) {
LOG.info("Doing something for Job id {}", jobId);
}
}
Output:
2021-05-28 15:18:37,123 INFO [main] o.m.m.TestMdc [Job 1234] - hello
2021-05-28 15:18:37,126 INFO [main] o.m.m.TestMdc [Job 1234] - Doing something for Job id 1234
2021-05-28 15:18:37,126 INFO [main] o.m.m.TestMdc - Message not related to a specific job.
If we just put it in WfmProcessor and WfmSplitter, we will have it applied to the majority of the log messages with only a few lines of code.
Also, note that currently we have some WFM messages that generate messages with job information like [Job 864|*|*], where the asterisks are intended to represent the task and action id. There are only 8 non-debug places in the code where they are provided with actual values and not just *. We should consider removing the |*|* part of the log messages altogether if no one uses that information.
Ensure that the media inspection work queue log job ids for all messages (should be handled by above).
It may make the most sense to complete #1282 at the same time as this task.
The text was updated successfully, but these errors were encountered:
Currently blocked pending more information about the impact on end-user parsers and visualizations.
jrobble
changed the title
Add job id to all job-specific Workflow Manager log messages and other improvements
Add job id to all job-specific Workflow Manager log messages
Jun 11, 2021
jrobble
changed the title
Add job id to all job-specific Workflow Manager log messages
Add job id to all batch-job-specific Workflow Manager log messages
Aug 31, 2021
Note: Prior to adding the job id to new log messages, and changing the job id format, understand the impact on end-user parsers and visualizations.
Update the WFM to use a Mapped Diagnostic Context (MDC) for reporting the Job Id for all job-specific log lines. Currently, many log lines lack the job id since it's burden to have to pass it to every method in every class. MDC gets around this.
We can modify the layoutPattern in
openmpf/trunk/workflow-manager/src/main/resources/log4j2.xml
:Here's an example of changes that need to be made to the Java code:
Output:
If we just put it in WfmProcessor and WfmSplitter, we will have it applied to the majority of the log messages with only a few lines of code.
Also, note that currently we have some WFM messages that generate messages with job information like
[Job 864|*|*]
, where the asterisks are intended to represent the task and action id. There are only 8 non-debug places in the code where they are provided with actual values and not just*
. We should consider removing the|*|*
part of the log messages altogether if no one uses that information.Ensure that the media inspection work queue log job ids for all messages (should be handled by above).
It may make the most sense to complete #1282 at the same time as this task.
The text was updated successfully, but these errors were encountered: