-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[#19711] Fix missing step_id in Python SDK worker logs during DoFn setup #37413
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1091,6 +1091,7 @@ def __init__( | |
| state_handler: sdk_worker.CachingStateHandler, | ||
| data_channel_factory: data_plane.DataChannelFactory, | ||
| data_sampler: Optional[data_sampler.DataSampler] = None, | ||
| instruction_id: Optional[str] = None, | ||
| ) -> None: | ||
| """Initialize a bundle processor. | ||
|
|
||
|
|
@@ -1159,8 +1160,13 @@ def __init__( | |
| from apache_beam.runners.worker.sdk_worker_main import terminate_sdk_harness | ||
| terminate_sdk_harness() | ||
|
|
||
| for op in reversed(self.ops.values()): | ||
| op.setup(self.data_sampler) | ||
| if instruction_id: | ||
| with statesampler.instruction_id(instruction_id): | ||
| for op in reversed(self.ops.values()): | ||
| op.setup(self.data_sampler) | ||
| else: | ||
| for op in reversed(self.ops.values()): | ||
| op.setup(self.data_sampler) | ||
|
Comment on lines
+1163
to
+1169
Contributor
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. |
||
| self.splitting_lock = threading.Lock() | ||
|
|
||
| def create_execution_tree( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,9 +134,12 @@ def emit(self, record: logging.LogRecord) -> None: | |
| log_entry.timestamp.nanos = int(nanoseconds) | ||
| if record.exc_info: | ||
| log_entry.trace = ''.join(traceback.format_exception(*record.exc_info)) | ||
| instruction_id = statesampler.get_current_instruction_id() | ||
| if instruction_id: | ||
| log_entry.instruction_id = instruction_id | ||
| if hasattr(record, 'instruction_id'): | ||
|
Collaborator
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. Can simplify/optimize by avoid hasattr then acces? |
||
| log_entry.instruction_id = record.instruction_id | ||
| if not log_entry.instruction_id: | ||
| instruction_id = statesampler.get_current_instruction_id() | ||
| if instruction_id: | ||
| log_entry.instruction_id = instruction_id | ||
|
Comment on lines
+137
to
+142
Contributor
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 logic for setting instruction_id = getattr(record, 'instruction_id', None)
if not instruction_id:
instruction_id = statesampler.get_current_instruction_id()
if instruction_id:
log_entry.instruction_id = instruction_id |
||
| tracker = statesampler.get_current_tracker() | ||
| if tracker: | ||
| current_state = tracker.current_state() | ||
|
|
||
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.
Should this be optional, or should we rather make it required?