Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
reyang committed Sep 27, 2019
1 parent 7c657f4 commit aa1b9aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def enable(tracer):

@functools.wraps(wrapped)
def instrumented_request(self, method, url, *args, **kwargs):
if Context.is_exporter: # Check if we are in an exporter
if Context.suppress_instrumentation:
return wrapped(self, method, url, *args, **kwargs)

# See
Expand Down
10 changes: 7 additions & 3 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def on_start(self, span: Span) -> None:
pass

def on_end(self, span: Span) -> None:
is_exporter = Context.is_exporter
suppress_instrumentation = Context.suppress_instrumentation
try:
Context.is_exporter = True
Context.suppress_instrumentation = True
self.span_exporter.export((span,))
# pylint: disable=broad-except
except Exception as exc:
logger.warning("Exception while exporting data: %s", exc)
finally:
Context.is_exporter = is_exporter
Context.suppress_instrumentation = suppress_instrumentation

def shutdown(self) -> None:
self.span_exporter.shutdown()
Expand Down Expand Up @@ -181,11 +181,15 @@ def export(self) -> bool:
while idx < self.max_export_batch_size and self.queue:
self.spans_list[idx] = self.queue.pop()
idx += 1
suppress_instrumentation = Context.suppress_instrumentation
try:
Context.suppress_instrumentation = True
self.span_exporter.export(self.spans_list[:idx])
# pylint: disable=broad-except
except Exception:
logger.exception("Exception while exporting data.")
finally:
Context.suppress_instrumentation = suppress_instrumentation

# clean up list
for index in range(idx):
Expand Down

0 comments on commit aa1b9aa

Please sign in to comment.