diff --git a/setup.cfg b/setup.cfg index 03d7e5f2..59285ffe 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,6 +26,7 @@ install_requires = opentelemetry-api == 1.18.0 opentelemetry-sdk == 1.18.0 opentelemetry-instrumentation == 0.39b0 + opentelemetry-instrumentation-logging == 0.39b0 packages = solarwinds_apm, solarwinds_apm.api, solarwinds_apm.certs, solarwinds_apm.extension [options.package_data] diff --git a/solarwinds_apm/distro.py b/solarwinds_apm/distro.py index 4a7eafcc..4b2e7460 100644 --- a/solarwinds_apm/distro.py +++ b/solarwinds_apm/distro.py @@ -13,6 +13,9 @@ OTEL_TRACES_EXPORTER, ) from opentelemetry.instrumentation.distro import BaseDistro +from opentelemetry.instrumentation.logging.environment_variables import ( + OTEL_PYTHON_LOG_FORMAT, +) from solarwinds_apm.apm_constants import ( INTL_SWO_DEFAULT_PROPAGATORS, @@ -31,3 +34,7 @@ def _configure(self, **kwargs): environ.setdefault( OTEL_PROPAGATORS, ",".join(INTL_SWO_DEFAULT_PROPAGATORS) ) + environ.setdefault( + OTEL_PYTHON_LOG_FORMAT, + "%(asctime)s %(levelname)s [%(name)s] [%(filename)s:%(lineno)d] [trace_id=%(otelTraceID)s span_id=%(otelSpanID)s trace_flags=%(otelTraceSampled)02d resource.service.name=%(otelServiceName)s] - %(message)s", + ) diff --git a/tox.ini b/tox.ini index a350bc3d..3e3cf7c1 100644 --- a/tox.ini +++ b/tox.ini @@ -36,6 +36,7 @@ deps = opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation + opentelemetry-instrumentation-logging pylint flake8 isort