Open jbaxleyiii opened 9 months ago
If I understand correctly from the code you posted, an HTTP status 3xx would only set the status to ERROR if allow_redirect=False, which is not by default. 4xx status means client errors so they are treated as errors if inside a client span which is expected.
Describe your environment python 3.9 opentelemetry-api==1.22.0 opentelemetry-instrumentation-requests==0.43b0
Steps to reproduce Make an http call with requests and get back any http status code >= 300
What is the expected behavior? This could very much be a misunderstanding on my part! When making an http call with requests, I would expect only >= 500 status codes to be treated as exceptions on traces but right now all codes above 299 are treated as exceptions. I didn't expect redirects or 400s to be logged as errors on my traces.
What is the actual behavior? In the requests library, when it creates a span it sets the type to be client (https://github.com/open-telemetry/opentelemetry-python-contrib/blob/8fd2105ceae604cf39a67f1c4dd154753b43fcd1/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L208-L210). When it converts this to an otel status code, it uses:
and doesn't pass in a server_span so all non 2** status codes are treated as errors.