open-telemetry / open-telemetry/opentelemetry-python-contrib
Tracing for stdlib http.HTTPServer
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: Fedora 41
Python version: 3.13
Package version: 0.49b2 / latest
What happened?
A simple app is not instrumented properly
from http.server import BaseHTTPRequestHandler, HTTPServer
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(b'Hello')
else:
self.send_response(404)
self.send_header('Content-type', 'text/plain')
self.end_headers()
self.wfile.write(b'not found')
def run(server_class=HTTPServer, handler_class=RequestHandler, port=8080):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print(f'Starting server on: {port}')
httpd.serve_forever()
if __name__ == '__main__':
run()
Steps to Reproduce
And instrument
pip install opentelemetry-distro opentelemetry-exporter-otlp
~/.local/bin/opentelemetry-bootstrap -a install
~/.local/bin/opentelemetry-instrument --service_name python-example --exporter_otlp_endpoint localhost:4317 --traces_exporter console,otlp --metrics_exporter console python helloworld.py
...
Starting httpd server on port 8080
127.0.0.1 - - [02/Dec/2024 13:59:40] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [02/Dec/2024 13:59:40] "GET / HTTP/1.1" 200 -
Follow steps in https://github.com/pavolloffay/otel-python-bug-03969593
Expected Result
See traces from HTTP server
Actual Result
No traces reported, no logged error in the app.
Additional context
https://github.com/pavolloffay/otel-python-bug-03969593
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
Reproduce the report with the linked repository and its helloworld.py HTTPServer example; start at the opentelemetry-instrument entry point and Python's stdlib HTTPServer. Compare the run with the expected console or OTLP output, and consider it done when HTTP requests produce traces without application errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100