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

opentelemetry-instrumentation-asgi not compatible with starlette/fastapi #2565

Closed
sk- opened this issue May 29, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@sk-
Copy link
Contributor

sk- commented May 29, 2024

When we bumped opentelemetry-instrumentation-asgi to 0.45b0, we got type errors due to the changes introduced by PR #2026.

error: Argument 1 to "add_middleware" of "Starlette" has incompatible type "type[AsgiMiddleware]"; expected "type[_MiddlewareClass[[]]]"  [arg-type]

The problem is that it is specifying the types as dict, whereas Starlette requires MutableMapping. See https://github.com/encode/starlette/blob/9f16bf5c25e126200701f6e04330864f4a91a898/starlette/types.py#L10-L14.

Describe your environment

  • Python 3.12
  • Fastapi 0.111.0
  • Starlette 0.37.2
  • opentelemetry-instrumentation-asgi 0.45b0
  • Mypy 1.10.0

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

What is the expected behavior?
It should be possible to add OpentelemetryMiddleware to starlette/fastapi

What is the actual behavior?
Got a type error

@sk- sk- added the bug Something isn't working label May 29, 2024
@sk-
Copy link
Contributor Author

sk- commented Jun 10, 2024

Closing as it seems starlette is using broader types than what the spec specifies. See encode/starlette#2040

@sk- sk- closed this as completed Jun 10, 2024
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
1 participant