You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ElasticAPM middleware for Starlette appears to be missing a default value for the client parameter, resulting in a TypeError when using the middleware without explicitly providing a client.
To Reproduce
Add the ElasticAPM middleware without explicitly providing a client.
Observe the TypeError mentioned above.
Environment (please complete the following information)
OS: Linux
Python version: 3.11
Framework and version [e.g. Django 2.1]: fastapi 0.104.1
Good find! @gabriel-f-santos, we would love to see a PR if you're willing. You've done all the legwork, so you deserve the credit! But if you don't have time, I can open one.
Good find! @gabriel-f-santos, we would love to see a PR if you're willing. You've done all the legwork, so you deserve the credit! But if you don't have time, I can open one.
Thanks for the quick response! I appreciate the offer, and I'm more than happy to open a pull request to address this issue. I'll work on the changes and submit the PR as soon as possible.
Describe the bug:
The
ElasticAPM
middleware for Starlette appears to be missing a default value for theclient
parameter, resulting in aTypeError
when using the middleware without explicitly providing aclient
.To Reproduce
ElasticAPM
middleware without explicitly providing aclient
.TypeError
mentioned above.Environment (please complete the following information)
Additional context
Add any other context about the problem here.
Error:
The
ElasticAPM
middleware should allow for theclient
parameter to be optional, as indicated in the documentation, and should default toNone
if not provided.From docs: https://www.elastic.co/guide/en/apm/agent/python/current/starlette-support.html
Result:
in the doc string shows that client its optional in type, but doesnt have None as default value, so passing:
it seems to work.
Proposed Solution
Change the
ElasticAPM
constructor signature to includeOptional[Client] = None
for theclient
parameter, making it optional with a default value ofNone
in https://github.com/elastic/apm-agent-python/blob/4f5661277becc1034ee588bae4b018a4b22cc02b/elasticapm/contrib/starlette/__init__.py#L108C41-L108C41.The text was updated successfully, but these errors were encountered: