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

Commit e385880

Browse files
angelinireyang
authored andcommitted
Use scopped logger in transports.async_ (#691)
1 parent bb770a5 commit e385880

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

opencensus/common/transports/async_.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
_WORKER_THREAD_NAME = 'opencensus.common.Worker'
2828
_WORKER_TERMINATOR = object()
2929

30+
logger = logging.getLogger(__name__)
31+
3032

3133
class _Worker(object):
3234
"""A background thread that exports batches of data.
@@ -108,7 +110,7 @@ def _thread_main(self):
108110
try:
109111
self.exporter.emit(data)
110112
except Exception:
111-
logging.exception(
113+
logger.exception(
112114
'%s failed to emit data.'
113115
'Dropping %s objects from queue.',
114116
self.exporter.__class__.__name__,

tests/unit/common/transports/test_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def emit(self, span):
199199
# trace2 should be left in the queue because worker is terminated.
200200
self.assertEqual(worker._queue.qsize(), 1)
201201

202-
@mock.patch('logging.exception')
202+
@mock.patch('opencensus.common.transports.async_.logger.exception')
203203
def test__thread_main_alive_on_emit_failed(self, mock):
204204

205205
class Exporter(object):

0 commit comments

Comments
 (0)