What is needed?
Due the issue we have in correlating APM logs and traces to have a global view on each request, we need to add to each request 5 new fields to correlate.
The fields needed are:
dd.service
dd.env
dd.version
dd.trace_id
dd.span_id
These fields have to be a printout of some env vars that will be passed to the deployment of the service itself.
In datadog they indicate how to do it:
Include the dd.env, dd.service, dd.version, dd.trace_id and dd.span_id attributes for your log record in the format string.
Here is an example using logging.basicConfig to configure the log injection:
import logging
from ddtrace import tracer
FORMAT = ('%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] '
'[dd.service=%(dd.service)s dd.env=%(dd.env)s dd.version=%(dd.version)s dd.trace_id=%(dd.trace_id)s dd.span_id=%(dd.span_id)s] '
'- %(message)s')
logging.basicConfig(format=FORMAT)
log = logging.getLogger(__name__)
log.level = logging.INFO
@tracer.wrap()
def hello():
a My main idea is in the logger you have to enable these parameters or disable them depending on an environment variable (e.g. DD_TRACE_LOGS_ENABLE or something like this)
References:
What is needed?
Due the issue we have in correlating APM logs and traces to have a global view on each request, we need to add to each request 5 new fields to correlate.
The fields needed are:
These fields have to be a printout of some env vars that will be passed to the deployment of the service itself.
In datadog they indicate how to do it:
a My main idea is in the logger you have to enable these parameters or disable them depending on an environment variable (e.g. DD_TRACE_LOGS_ENABLE or something like this)
References: