When messages from other containers appear in the master log, we can often not tell where they are from. For example:
Here, we can see the thread name (MessagingMetricsCollectionService), however, a thread with that name is used by every single container CDAP starts, and also by the master. So it is impossible to know where this comes from: the master? one of the cdap services? a program container?
In addition to the thread name, we also need the program id or container id.
We actually do have the required information in the MDC. However, for messages from containers that show in the master log, the MDC is always empty. i am not sure whether that is by design or a bug.
Also, the MDC tags are different based on the type of container. For example, a system service will have
whereas a user service will have .userserviceid and .userhandelerid. In order to include this in the formatted log messages (all described by a single pattern/format string), we need a single tag that is present across all containers.