Skip to content

Commit 20acf56

Browse files
final fixes
1 parent 45f43a9 commit 20acf56

3 files changed

Lines changed: 3 additions & 8 deletions

File tree

drift/instrumentation/django/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def dict_to_schema_merges(merges_dict):
397397
status = SpanStatus(code=StatusCode.OK, message="")
398398

399399
# Django-specific: use route template for span name to avoid cardinality explosion
400-
method = request.method
400+
method = request.method or ""
401401
route_template = getattr(request, "_drift_route_template", None)
402402
if route_template:
403403
# Use route template (e.g., "users/<int:id>/")

drift/instrumentation/requests/instrumentation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def __init__(self, message: str, method: str, url: str):
4444
SpanStatus,
4545
StatusCode,
4646
TuskDriftMode,
47-
calling_library_context,
4847
)
4948
from ..base import InstrumentationBase
5049
from ..http import HttpSpanData, HttpTransformEngine
@@ -267,16 +266,13 @@ def _handle_record(
267266
error = None
268267
response = None
269268

270-
# Set calling_library_context to prevent socket instrumentation warnings
271-
calling_lib_token = calling_library_context.set("RequestsInstrumentation")
272269
try:
273270
response = original_request(session_self, method, url, **kwargs)
274271
return response
275272
except Exception as e:
276273
error = e
277274
raise
278275
finally:
279-
calling_library_context.reset(calling_lib_token)
280276
# Finalize span with request/response data
281277
self._finalize_span(
282278
span_info.span,

drift/instrumentation/socket/instrumentation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ def _handle_socket_call(self, method_name: str, socket_self: Any) -> None:
136136

137137
# Detect unpatched dependency:
138138
# - Must be in a SERVER span (inbound request context)
139-
# - Must NOT be from an instrumented library (calling_library is set)
140-
# Examples: ProtobufCommunicator, HttpxInstrumentation, RequestsInstrumentation
141-
if span_kind == SpanKind.SERVER and calling_library is None:
139+
# - Must NOT be from ProtobufCommunicator
140+
if span_kind == SpanKind.SERVER and calling_library != "ProtobufCommunicator":
142141
self._log_unpatched_dependency(method_name, socket_self)
143142

144143
def _log_unpatched_dependency(self, method_name: str, socket_self: Any) -> None:

0 commit comments

Comments
 (0)