-
Notifications
You must be signed in to change notification settings - Fork 757
Description
Describe your environment Docker compose that includes 1.21/0.42b0 of the API/SDK and contrib. I manually set PYTHONPATH to point to sitecustomize in order to trigger auto-instrumentation. However, the same app and sitecustomize work outside of docker
Steps to reproduce
Dockerfile:
FROM python
# Create app directory
WORKDIR /usr/src/pythonapp
COPY test_app.py ./
# TODO: Copy json for AAD and statsbeat
# copy applicationinsights.json if it exists. This is used for AAD authentication and statsbeat
# COPY applicationinsights.json* ./
EXPOSE 8082
RUN python3 -m ensurepip && \
python3 -m pip install flask && \
python3 -m pip install requests && \
pip list
EXPOSE 8082
CMD [ "python3", "test_app.py" ]
docker-compose.yml:
version: "3.9"
services:
inprocagent:
image: {Image with SDK/API 1.21, Instrumentations 0.42b0 and sitecustomize}
volumes:
- "agentvolume:/agents"
pythonapp:
build:
context: ./TestApp
ports:
- "${PYTHON_TEST_APP_PORT}:${PYTHON_TEST_APP_PORT}"
volumes:
- "agentvolume:/agents"
environment:
APPLICATIONINSIGHTS_CONNECTION_STRING: ${APPLICATIONINSIGHTS_CONNECTION_STRING}
PYTHONPATH: ${PYTHONPATH}
PYTHON_TEST_APP_PORT: ${PYTHON_TEST_APP_PORT}
OTEL_TRACES_EXPORTER: ${OTEL_TRACES_EXPORTER}
OTEL_METRICS_EXPORTER: ${OTEL_METRICS_EXPORTER}
PYTHONPATH=/agents/python
stdin_open: true
tty: true
volumes:
agentvolume:
test_app.py:
import logging
logger = logging.getLogger(__name__)
logger.error("TEST")
Commands:
docker compose build
docker compose up
What is the expected behavior?
Logs are instrumented and exported.
What is the actual behavior?
I get an infinite stack trace loop:
…
File "/usr/local/lib/python3.12/logging/__init__.py", line 1028, in handle
self.emit(record)
File "/agents/python/opentelemetry/sdk/_logs/_internal/__init__.py", line 541, in emit
self._logger.emit(self._translate(record))
^^^^^^^^^^^^^^^^^^^^^^^
File "/agents/python/opentelemetry/sdk/_logs/_internal/__init__.py", line 522, in _translate
return LogRecord(
^^^^^^^^^^
File "/agents/python/opentelemetry/sdk/_logs/_internal/__init__.py", line 183, in __init__
"attributes": BoundedAttributes(
^^^^^^^^^^^^^^^^^^
File "/agents/python/opentelemetry/attributes/__init__.py", line 154, in __init__
self[key] = value
~~~~^^^^^
File "/agents/python/opentelemetry/attributes/__init__.py", line 173, in __setitem__
value = _clean_attribute(key, value, self.max_value_len)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/agents/python/opentelemetry/attributes/__init__.py", line 100, in _clean_attribute
_logger.warning(
File "/usr/local/lib/python3.12/logging/__init__.py", line 1551, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1684, in _log
self.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1700, in handle
self.callHandlers(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1762, in callHandlers
hdlr.handle(record)
File "/usr/local/lib/python3.12/logging/__init__.py", line 1028, in handle
self.emit(record)
…
By adding print statements into the attributes module, I figured out that the warning is as follows:
Invalid type NoneType for attribute 'taskName' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types
My guess is that the taskName is None because it is running inside Docker or something along those lines.
Additional context
Add any other context about the problem here.