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

TypeError: http_status_to_status_code() got an unexpected keyword argument 'server_span' #811

Closed
talboren opened this issue Nov 15, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@talboren
Copy link

talboren commented Nov 15, 2021

Describe your environment

python 3.7-slim

pip freeze

#13 0.770 aiohttp==3.8.1
#13 0.770 aiosignal==1.2.0
#13 0.770 alembic==1.7.5
#13 0.770 anyio==3.3.4
#13 0.770 asgiref==3.4.1
#13 0.770 asn1crypto==1.4.0
#13 0.770 async-timeout==4.0.1
#13 0.770 asynctest==0.13.0
#13 0.770 attrs==21.2.0
#13 0.770 azure-common==1.1.27
#13 0.770 azure-core==1.20.1
#13 0.770 azure-storage-blob==12.9.0
#13 0.770 backoff==1.10.0
#13 0.770 beautifulsoup4==4.10.0
#13 0.770 boto3==1.20.5
#13 0.770 botocore==1.23.5
#13 0.770 CacheControl==0.12.10
#13 0.770 cachetools==4.2.4
#13 0.770 certifi==2020.12.5
#13 0.770 cffi==1.15.0
#13 0.770 chardet==3.0.4
#13 0.770 charset-normalizer==2.0.7
#13 0.770 click==8.0.3
#13 0.770 clickclick==20.10.2
#13 0.770 cloudflare==2.8.15
#13 0.770 connexion==2.7.0
#13 0.770 croniter==1.0.15
#13 0.770 cryptography==3.2.1
#13 0.770 Deprecated==1.2.13
#13 0.770 elastic-apm==6.6.3
#13 0.770 fastapi==0.70.0
#13 0.770 firebase-admin==4.5.3
#13 0.770 Flask==2.0.2
#13 0.770 Flask-Injector==0.13.0
#13 0.770 frozenlist==1.2.0
#13 0.770 google-api-core==1.22.2
#13 0.770 google-api-python-client==1.9.3
#13 0.770 google-auth==1.35.0
#13 0.770 google-auth-httplib2==0.1.0
#13 0.770 google-cloud-core==1.7.2
#13 0.770 google-cloud-datastore==2.3.0
#13 0.770 google-cloud-firestore==2.1.3
#13 0.770 google-cloud-iam==2.2.0
#13 0.770 google-cloud-kms==1.4.0
#13 0.770 google-cloud-pubsub==2.6.1
#13 0.770 google-cloud-scheduler==2.2.0
#13 0.770 google-cloud-secret-manager==1.0.0
#13 0.770 google-cloud-storage==1.29.0
#13 0.770 google-cloud-tasks==1.5.0
#13 0.770 google-resumable-media==0.5.1
#13 0.770 googleapis-common-protos==1.53.0
#13 0.770 grpc-google-iam-v1==0.12.3
#13 0.770 grpcio==1.41.1
#13 0.770 gunicorn==20.0.4
#13 0.770 h11==0.12.0
#13 0.770 httplib2==0.20.2
#13 0.770 httptools==0.2.0
#13 0.770 idna==2.8
#13 0.770 importlib-metadata==4.8.2
#13 0.770 importlib-resources==5.4.0
#13 0.770 inflection==0.5.1
#13 0.770 injector==0.18.4
#13 0.770 isodate==0.6.0
#13 0.770 itsdangerous==2.0.1
#13 0.770 jeepney==0.7.1
#13 0.770 Jinja2==3.0.3
#13 0.770 jmespath==0.10.0
#13 0.770 jsonlines==2.0.0
#13 0.770 jsonpatch==1.32
#13 0.770 jsonpointer==2.2
#13 0.770 jsonschema==4.2.1
#13 0.770 jwcrypto==1.0
#13 0.770 keyring==23.2.1
#13 0.770 libcst==0.3.21
#13 0.770 Mako==1.1.5
#13 0.770 MarkupSafe==2.0.1
#13 0.770 msgpack==1.0.2
#13 0.770 msrest==0.6.21
#13 0.770 multidict==5.2.0
#13 0.770 mypy-extensions==0.4.3
#13 0.770 ndg-httpsclient==0.5.1
#13 0.770 oauth2client==4.1.3
#13 0.770 oauthlib==3.1.1
#13 0.770 openapi-schema-validator==0.1.5
#13 0.770 openapi-spec-validator==0.3.1
#13 0.770 opentelemetry-api==1.5.0
#13 0.770 opentelemetry-exporter-otlp==1.5.0
#13 0.770 opentelemetry-exporter-otlp-proto-grpc==1.5.0
#13 0.770 opentelemetry-exporter-otlp-proto-http==1.7.1
#13 0.770 opentelemetry-instrumentation==0.24b0
#13 0.770 opentelemetry-instrumentation-asgi==0.26b1
#13 0.770 opentelemetry-instrumentation-fastapi==0.26b1
#13 0.770 opentelemetry-instrumentation-flask==0.24b0
#13 0.770 opentelemetry-instrumentation-logging==0.24b0
#13 0.770 opentelemetry-instrumentation-requests==0.24b0
#13 0.770 opentelemetry-instrumentation-sqlalchemy==0.24b0
#13 0.770 opentelemetry-instrumentation-wsgi==0.24b0
#13 0.770 opentelemetry-proto==1.5.0
#13 0.770 opentelemetry-sdk==1.5.0
#13 0.770 opentelemetry-semantic-conventions==0.24b0
#13 0.770 opentelemetry-util-http==0.24b0
#13 0.770 oscrypto==1.2.1
#13 0.770 packaging==21.2
#13 0.770 proto-plus==1.19.8
#13 0.770 protobuf==3.19.1
#13 0.770 pusher==3.1.0
#13 0.770 pyasn1==0.4.8
#13 0.770 pyasn1-modules==0.2.8
#13 0.770 pycparser==2.21
#13 0.770 pycryptodomex==3.11.0
#13 0.770 pydantic==1.8.2
#13 0.770 PyJWT==2.3.0
#13 0.770 PyNaCl==1.4.0
#13 0.770 pyOpenSSL==20.0.1
#13 0.770 pyparsing==2.4.7
#13 0.770 pyrsistent==0.18.0
#13 0.770 python-dateutil==2.6.0
#13 0.770 python-dotenv==0.19.2
#13 0.770 python-json-logger==2.0.2
#13 0.770 python-jwt==3.3.1
#13 0.770 pytz==2021.3
#13 0.770 PyYAML==6.0
#13 0.770 requests==2.26.0
#13 0.770 requests-oauthlib==1.3.0
#13 0.770 rsa==4.7.2
#13 0.770 s3transfer==0.5.0
#13 0.770 SecretStorage==3.3.1
#13 0.770 six==1.16.0
#13 0.770 sniffio==1.2.0
#13 0.770 snowflake-connector-python==2.5.1
#13 0.770 snowflake-sqlalchemy==1.2.4
#13 0.770 soupsieve==2.3.1
#13 0.770 SQLAlchemy==1.3.23
#13 0.770 SQLAlchemy-Utils==0.37.9
#13 0.770 starlette==0.16.0
#13 0.770 starlette-context==0.3.3
#13 0.770 typing-extensions==4.0.0
#13 0.770 typing-inspect==0.7.1
#13 0.770 uritemplate==3.0.1
#13 0.770 urllib3==1.26.5
#13 0.770 uvicorn==0.15.0
#13 0.770 uvloop==0.16.0
#13 0.770 watchgod==0.7
#13 0.770 websockets==10.1
#13 0.770 Werkzeug==2.0.2
#13 0.770 wrapt==1.13.3
#13 0.770 yarl==1.7.2
#13 0.770 zipp==3.6.0

Steps to reproduce
Describe exactly how to reproduce the error. Include a code sample if applicable.

What is the expected behavior?
No exception being thrown, some HTTP requests are failing due to this

What is the actual behavior?

Traceback (most recent call last):
File "/home/anecdotes/.local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 375, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/fastapi/applications.py", line 208, in call
await super().call(scope, receive, send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/cors.py", line 84, in call
await self.app(scope, receive, send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/base.py", line 57, in call
task_group.cancel_scope.cancel()
File "/home/anecdotes/.local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 567, in aexit
raise exceptions[0]
File "/home/anecdotes/.local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 604, in _run_wrapped_task
await coro
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/base.py", line 30, in coro
await self.app(scope, request.receive, send_stream.send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/opentelemetry/instrumentation/asgi/init.py", line 346, in call
await self.app(scope, wrapped_receive, wrapped_send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/middleware/base.py", line 56, in call
await response(scope, receive, send)
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/responses.py", line 227, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "/home/anecdotes/.local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 567, in aexit
raise exceptions[0]
File "/home/anecdotes/.local/lib/python3.7/site-packages/anyio/_backends/_asyncio.py", line 604, in _run_wrapped_task
await coro
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/responses.py", line 223, in wrap
await func()
File "/home/anecdotes/.local/lib/python3.7/site-packages/starlette/responses.py", line 209, in stream_response
"headers": self.raw_headers,
File "/home/anecdotes/.local/lib/python3.7/site-packages/opentelemetry/instrumentation/asgi/init.py", line 338, in wrapped_send
set_status_code(span, status_code)
File "/home/anecdotes/.local/lib/python3.7/site-packages/opentelemetry/instrumentation/asgi/init.py", line 222, in set_status_code
Status(http_status_to_status_code(status_code, server_span=True))
TypeError: http_status_to_status_code() got an unexpected keyword argument 'server_span'

Additional context
Add any other context about the problem here.

@owais
Copy link
Contributor

owais commented Nov 15, 2021

You seem to be mixing 0.24 and 0.26 releases of instrumentation packages. They must be on the same version. Either downgrade the 0.26 ones to 0.24 or upgrade everything to 0.26.

#13 0.770 opentelemetry-instrumentation==0.24b0
#13 0.770 opentelemetry-instrumentation-asgi==0.26b1
#13 0.770 opentelemetry-instrumentation-fastapi==0.26b1

@owais
Copy link
Contributor

owais commented Nov 15, 2021

I'm surprised how pip even installed these as we set requirements explicitly to the corresponding version. For example, https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-wsgi/setup.cfg#L45

@talboren
Copy link
Author

You seem to be mixing 0.24 and 0.26 releases of instrumentation packages. They must be on the same version. Either downgrade the 0.26 ones to 0.24 or upgrade everything to 0.26.

#13 0.770 opentelemetry-instrumentation==0.24b0
#13 0.770 opentelemetry-instrumentation-asgi==0.26b1
#13 0.770 opentelemetry-instrumentation-fastapi==0.26b1

I'm surprised how pip even installed these as we set requirements explicitly to the corresponding version. For example, https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-wsgi/setup.cfg#L45

Very weird, guess it has something to do with requirements order and some dependency of another package since we do not enforce any specific version.
will look in to this tomorrow morning and post updates.

Thanks!

@owais
Copy link
Contributor

owais commented Nov 15, 2021

I'd highly recommend to pin all opentelemetry packages with versions less than 1.0 or things will keep breaking unexpectedly for you :)

@talboren
Copy link
Author

Thanks for all your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants