open-telemetry / open-telemetry/opentelemetry-python-contrib
Application does not emit logs on stderr when auto-instrumented
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Describe your environment
OS: (e.g, Ubuntu)
Python version: (e.g., Python 3.8.10)
Instrumentation image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:0.46b0
What happened?
I have a container running a simple application running on a k8s pod (code attached below).
The application emits the logs messages through stderr when running.
When instrumentation is attached to it, the logs are streamed to the backend, as expected.
Yet, the application stops emitting logs through stderr.
Application code
import logging
import random
import time
random.seed(time.time_ns())
app_name = f'app_{random.randint(1, 100)}'
logger = logging.getLogger(f"{app_name}_logger")
for i in range(3000):
sleep_ms = 10 * random.randint(1, 100)
logger.warning(f"Python app '{app_name}' sleeping for {sleep_ms} ms")
time.sleep(sleep_ms / 1000)
Dockerfile
FROM python:3.9.6
WORKDIR /usr/app
RUN python -m venv /usr/app/venv
ENV PATH="/usr/app/venv/bin:$PATH"
COPY ./requirements.txt .
RUN pip install -r requirements.txt
COPY ./app .
CMD ["python", "-u", "./app.py"]
Steps to Reproduce
Build app, deploy on k8s.
Expected Result
Logs should be streamed through stderr even when the application is instrumented.
Actual Result
Logs are not produced to stderr when the app is instrumented using auto-instrumentation.
Additional context
No response
Would you like to implement a fix?
None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached app.py and Dockerfile, deploying the application with the stated Python auto-instrumentation image on a Kubernetes pod. Compare stderr output with and without instrumentation, then trace the auto-instrumentation logging setup. Done means application warning logs continue to appear on stderr while still reaching the backend.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kubernetes, python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100