diff --git a/contrib/opencensus-ext-azure/CHANGELOG.md b/contrib/opencensus-ext-azure/CHANGELOG.md index 4e5e2d0a7..e70c79ab1 100644 --- a/contrib/opencensus-ext-azure/CHANGELOG.md +++ b/contrib/opencensus-ext-azure/CHANGELOG.md @@ -6,6 +6,8 @@ ([#1127](https://github.com/census-instrumentation/opencensus-python/pull/1127)) - Fix failure counting statsbeat - refactor status code logic in transport ([#1132](https://github.com/census-instrumentation/opencensus-python/pull/1132)) +- Use logging handler close instead of custom atexit hook +([#1134](https://github.com/census-instrumentation/opencensus-python/pull/1134)) ## 1.1.4 Released 2022-04-20 diff --git a/contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py b/contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py index d014d7922..c3538fb99 100644 --- a/contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py +++ b/contrib/opencensus-ext-azure/opencensus/ext/azure/log_exporter/__init__.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import atexit import logging import os import random @@ -67,7 +66,6 @@ def __init__(self, **options): self._queue = Queue(capacity=self.options.queue_capacity) self._worker = Worker(self._queue, self) self._worker.start() - atexit.register(self.close, self.options.grace_period) # start statsbeat on exporter instantiation if not os.environ.get("APPLICATIONINSIGHTS_STATSBEAT_DISABLED_ALL"): statsbeat.collect_statsbeat_metrics(self.options) @@ -96,11 +94,15 @@ def _export(self, batch, event=None): # pragma: NO COVER if event: event.set() + # Close is automatically called as part of logging shutdown def close(self, timeout=None): + if not timeout: + timeout = self.options.grace_period if self.storage: self.storage.close() if self._worker: self._worker.stop(timeout) + super(BaseLogHandler, self).close() def createLock(self): self.lock = None