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

Commit 1328fbf

Browse files
authored
Fix async.py is_exporter context (#909)
1 parent 36b326a commit 1328fbf

File tree

6 files changed

+10
-3
lines changed

6 files changed

+10
-3
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33

44
# For anything not explicitly taken by someone else:
55
* @census-instrumentation/global-owners @c24t @hectorhdzg @lzchen @reyang @songy23 @victoraugustolls
6-

contrib/opencensus-ext-azure/opencensus/ext/azure/common/exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def __init__(self, src, dst):
6565

6666
def run(self): # pragma: NO COVER
6767
# Indicate that this thread is an exporter thread.
68+
# Used to suppress tracking of requests in this thread
6869
execution_context.set_is_exporter(True)
6970
src = self.src
7071
dst = self.dst

contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def __init__(self, src, dst):
7979

8080
def run(self):
8181
# Indicate that this thread is an exporter thread.
82+
# Used to suppress tracking of requests in this thread
8283
execution_context.set_is_exporter(True)
8384
src = self._src
8485
dst = self._dst

opencensus/common/transports/async_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def _thread_main(self):
9292
Pulls pending data off the queue and writes them in
9393
batches to the specified tracing backend using the exporter.
9494
"""
95+
# Indicate that this thread is an exporter thread.
96+
# Used to suppress tracking of requests in this thread
9597
execution_context.set_is_exporter(True)
9698
quit_ = False
9799

@@ -142,8 +144,6 @@ def start(self):
142144
self._thread = threading.Thread(
143145
target=self._thread_main, name=_WORKER_THREAD_NAME)
144146
self._thread.daemon = True
145-
# Indicate that this thread is an exporter thread. Used for
146-
# auto-collection.
147147
self._thread.start()
148148
atexit.register(self._export_pending_data)
149149

opencensus/common/transports/sync.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@
1313
# limitations under the License.
1414

1515
from opencensus.common.transports import base
16+
from opencensus.trace import execution_context
1617

1718

1819
class SyncTransport(base.Transport):
1920
def __init__(self, exporter):
2021
self.exporter = exporter
2122

2223
def export(self, datas):
24+
# Used to suppress tracking of requests in export
25+
execution_context.set_is_exporter(True)
2326
self.exporter.emit(datas)
27+
# Reset the context
28+
execution_context.set_is_exporter(False)

opencensus/metrics/transport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def func(*aa, **kw):
6666

6767
def run(self):
6868
# Indicate that this thread is an exporter thread.
69+
# Used to suppress tracking of requests in this thread
6970
execution_context.set_is_exporter(True)
7071
super(PeriodicMetricTask, self).run()
7172

0 commit comments

Comments
 (0)