New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BEAM-2732][BEAM-4028] Logging relies on StateSampler for context #5356
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
import threading | ||
import traceback | ||
|
||
from apache_beam.runners.common import LoggingContext | ||
from apache_beam.runners.worker import statesampler | ||
|
||
# This module is experimental. No backwards-compatibility guarantees. | ||
|
||
|
@@ -38,7 +38,6 @@ class _PerThreadWorkerData(threading.local): | |
|
||
def __init__(self): | ||
super(_PerThreadWorkerData, self).__init__() | ||
# TODO(robertwb): Consider starting with an initial (ignored) ~20 elements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accidental deletion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logging context will be removed once it's no longer useful (after it's removed from Google code) so optimizations should not be considered anymore. I'll remove it ASAP as part of BEAM-4728 |
||
# in the list, as going up and down all the way to zero incurs several | ||
# reallocations. | ||
self.stack = [] | ||
|
@@ -53,7 +52,7 @@ def get_data(self): | |
per_thread_worker_data = _PerThreadWorkerData() | ||
|
||
|
||
class PerThreadLoggingContext(LoggingContext): | ||
class PerThreadLoggingContext(object): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we able to get rid of this class entirely? It looks like you removed the only usage in operations.py. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is used internally at google, so we need to remove it from there first. |
||
"""A context manager to add per thread attributes.""" | ||
|
||
def __init__(self, **kwargs): | ||
|
@@ -150,10 +149,14 @@ def format(self, record): | |
data = per_thread_worker_data.get_data() | ||
if 'work_item_id' in data: | ||
output['work'] = data['work_item_id'] | ||
if 'stage_name' in data: | ||
output['stage'] = data['stage_name'] | ||
if 'step_name' in data: | ||
output['step'] = data['step_name'] | ||
|
||
tracker = statesampler.get_current_tracker() | ||
if tracker: | ||
output['stage'] = tracker.stage_name | ||
|
||
if tracker.current_state() and tracker.current_state().name_context: | ||
output['step'] = tracker.current_state().name_context.logging_name() | ||
|
||
# All logging happens using the root logger. We will add the basename of the | ||
# file and the function name where the logging happened to make it easier | ||
# to identify who generated the record. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this deletion intentional? If so, can you add a comment / JIRA reference to clean up step_name in the arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is part of my goal with BEAM-4028. The step name is meant to only be retrievable through the name context.