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

fix(pymongo): add pin type check #11145

Merged
merged 14 commits into from
Oct 30, 2024
Merged
5 changes: 4 additions & 1 deletion ddtrace/contrib/internal/pymongo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ def _trace_topology_select_server(func, args, kwargs):
# Ensure the pin used on the traced mongo client is passed down to the topology instance
# This allows us to pass the same pin in traced server objects.
topology_instance = get_argument_value(args, kwargs, 0, "self")
ddtrace.Pin.get_from(topology_instance).onto(server)
pin = ddtrace.Pin.get_from(topology_instance)

if pin is not None:
pin.onto(server)
return server


Expand Down
4 changes: 4 additions & 0 deletions releasenotes/notes/pymongo-check-pin-c3cb9d1fbdc82fb3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
pymongo: add type checking to solve an issue where ``NoneType`` instead of expected ``Pin`` object would throw an error in ``TracedTopology`` method.
6 changes: 4 additions & 2 deletions tests/contrib/django/test_django_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from contextlib import contextmanager
import logging
import os
from pathlib import Path
import subprocess
Expand Down Expand Up @@ -66,9 +67,10 @@ def daphne_client(django_asgi, additional_env=None):
# Wait for the server to start up
try:
print("Waiting for server to start")
client.wait(max_tries=120, delay=0.2, initial_wait=2.0)
client.wait(max_tries=130, delay=0.2, initial_wait=5)
print("Server started")
except Exception:
except Exception as e:
logging.warning(e)
raise AssertionError(
"Server failed to start, see stdout and stderr logs"
"\n=== Captured STDOUT ===\n%s=== End of captured STDOUT ==="
Expand Down
Loading