Add type hints to the logging context code. (#8939)

This commit is contained in:
Patrick Cloke 2021-01-05 08:06:55 -05:00 committed by GitHub
parent 9dde9c9f01
commit 06fefe0bb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 22 deletions

View file

@ -108,7 +108,15 @@ class Measure:
def __init__(self, clock, name):
self.clock = clock
self.name = name
parent_context = current_context()
curr_context = current_context()
if not curr_context:
logger.warning(
"Starting metrics collection from sentinel context: metrics will be lost"
)
parent_context = None
else:
assert isinstance(curr_context, LoggingContext)
parent_context = curr_context
self._logging_context = LoggingContext(
"Measure[%s]" % (self.name,), parent_context
)