Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 4ca0055

Browse files
kornholic24t
authored andcommitted
Fix requests integration when there is no tracer (#418)
1 parent 25362e7 commit 4ca0055

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

opencensus/trace/ext/requests/trace.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ def wrap_session_request(wrapped, instance, args, kwargs):
112112
_span.name = '[requests]{}'.format(method)
113113
_span.span_kind = span_module.SpanKind.CLIENT
114114

115-
tracer_headers = _tracer.propagator.to_headers(
116-
_tracer.span_context)
117-
118-
kwargs.setdefault('headers', {}).update(
119-
tracer_headers)
115+
try:
116+
tracer_headers = _tracer.propagator.to_headers(
117+
_tracer.span_context)
118+
kwargs.setdefault('headers', {}).update(
119+
tracer_headers)
120+
except Exception: # pragma: NO COVER
121+
pass
120122

121123
# Add the requests url to attributes
122124
_tracer.add_attribute_to_current_span(HTTP_URL, url)

0 commit comments

Comments
 (0)