Kludex commented on issue #33176:
URL: https://github.com/apache/beam/issues/33176#issuecomment-2517598403

   > This looks interesting. I am wondering how this can work with remote 
Runners like Dataflow or Flink.
   
   I'm going to run with `Dataflow` soon.
   
   I still didn't find the what I wanted... I want to get the place where the 
Map function runs, for example... But I think that gets pickled or something, 
and then I'm having a hard time to find the right location (I think).
   
   <img width="1478" alt="Screenshot 2024-12-04 at 15 25 25" 
src="https://github.com/user-attachments/assets/e8b7fa7b-04c7-400b-a912-329a61b73f1e";>
   
   This is the code I use - it's not as clean as the snippets above:
   
   ```py
   def Pipeline__init_subclass__(cls: Pipeline, **kwargs):
       cls.apply = logfire.instrument("{transform}", 
extract_args=True)(cls.apply)
       cls.run = logfire.instrument("running {cls}")(cls.run)
       cls.visit = logfire.instrument()(cls.visit)
   
   
   def PipelineRunner__init_subclass__(cls: PipelineRunner, **kwargs):
       cls.run_pipeline = logfire.instrument()(cls.run_pipeline)
   
   
   def DoFnInvoker__init_subclass__(cls: DoFnInvoker, **kwargs):
       cls.invoke_process = 
logfire.instrument("{transform}")(cls.invoke_process)
   
   
   def patch_beam_pipeline():
       Pipeline.__init_subclass__ = classmethod(Pipeline__init_subclass__)
       Pipeline.apply = logfire.instrument("{transform}", 
extract_args=True)(Pipeline.apply)
       Pipeline.run = logfire.instrument("running {self}")(Pipeline.run)
       Pipeline.visit = logfire.instrument()(Pipeline.visit)
   
       PipelineRunner.__init_subclass__ = 
classmethod(PipelineRunner__init_subclass__)
       PipelineRunner.run_pipeline = 
logfire.instrument()(PipelineRunner.run_pipeline)
   
       FnApiRunner.run_stages = logfire.instrument("running stages from 
{self}")(FnApiRunner.run_stages)
   
       SdkWorker.process_bundle = logfire.instrument("running process_bundle 
from {self}")(SdkWorker.process_bundle)
   
   patch_beam_pipeline()
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to