trallnag / prometheus-fastapi-instrumentator

Instrument your FastAPI with Prometheus metrics.
ISC License
948 stars 84 forks source link

[TypeError("'ObjectId' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')] #307

Closed chrisg06 closed 6 months ago

chrisg06 commented 6 months ago

Getting the following error on endpoints that are interacting with a MongoDB, and my API is throwing 500 errors. Endpoints that aren't interacting with mongo are working fine.

File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 776, in app await route.handle(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 297, in handle await self.app(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 72, in app response = await func(request) File "/usr/local/lib/python3.9/site-packages/sentry_sdk/integrations/fastapi.py", line 130, in _sentry_app return await old_app(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 296, in app content = await serialize_response( File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 180, in serialize_response return jsonable_encoder(response_content) File "/usr/local/lib/python3.9/site-packages/fastapi/encoders.py", line 287, in jsonable_encoder encoded_value = jsonable_encoder( File "/usr/local/lib/python3.9/site-packages/fastapi/encoders.py", line 301, in jsonable_encoder jsonable_encoder( File "/usr/local/lib/python3.9/site-packages/fastapi/encoders.py", line 287, in jsonable_encoder encoded_value = jsonable_encoder( File "/usr/local/lib/python3.9/site-packages/fastapi/encoders.py", line 330, in jsonable_encoder raise ValueError(errors) from e ValueError: [TypeError("'ObjectId' object is not iterable"), TypeError('vars() argument must have dict attribute')]

chrisg06 commented 6 months ago

Disregard, it was the update to my fastapi version so I could install this that caused the issue.