Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracing for stdlib http.HTTPServer #3059

Open
pavolloffay opened this issue Dec 2, 2024 · 1 comment
Open

Tracing for stdlib http.HTTPServer #3059

pavolloffay opened this issue Dec 2, 2024 · 1 comment

Comments

@pavolloffay
Copy link
Member

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

@pavolloffay pavolloffay added the bug Something isn't working label Dec 2, 2024
@xrmx xrmx added feature-request and removed bug Something isn't working labels Dec 2, 2024
@xrmx
Copy link
Contributor

xrmx commented Dec 2, 2024

I think this is a feature request because we don't have an instrumentation for the stdlib http module.

@xrmx xrmx changed the title Tracing for HTTPServer Tracing for stdlib http.HTTPServer Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants