nikhilnadig28 opened a new issue, #58764:
URL: https://github.com/apache/airflow/issues/58764

   ### Description
   
   Add support for `publisher_options` parameter in `PubSubHook` to enable 
OpenTelemetry tracing for Pub/Sub messages via the native `google-cloud-pubsub` 
client library's `enable_open_telemetry_tracing` option.
   
   ### Use case/motivation
   
   Google Cloud Pub/Sub client library (v2.13.0+) supports native OpenTelemetry 
tracing through `PublisherOptions.enable_open_telemetry_tracing`. This enables 
distributed tracing of messages as they flow through Pub/Sub topics, which is 
critical for observability in event-driven architectures.
   
   The hook already passes `PublisherOptions` with `enable_message_ordering`. 
Adding `enable_open_telemetry_tracing` would allow users to trace Pub/Sub 
message flows.
   
   Current behavior: 
   ```   
   pubsub.py
   def get_conn(self) -> PublisherClient:
           """
           Retrieve connection to Google Cloud Pub/Sub.
   
           :return: Google Cloud Pub/Sub client object.
           """
           if not self._client:
               self._client = PublisherClient(
                   credentials=self.get_credentials(),
                   client_info=CLIENT_INFO,
                   publisher_options=PublisherOptions(
                       enable_message_ordering=self.enable_message_ordering, # 
No tracing enabled
                   ),
               )
           return self._client
   ```
   
   Desired behavior:
   ```
   pubsub.py
   def get_conn(self) -> PublisherClient:
           """
           Retrieve connection to Google Cloud Pub/Sub.
   
           :return: Google Cloud Pub/Sub client object.
           """
           if not self._client:
               self._client = PublisherClient(
                   credentials=self.get_credentials(),
                   client_info=CLIENT_INFO,
                   publisher_options=PublisherOptions(
                       enable_message_ordering=self.enable_message_ordering,
                       
enable_open_telemetry_tracing=self.enable_open_telemetry_tracing # Ability to 
enable tracing
                   ),
               )
           return self._client
   ```
   
   
   
   
   ### Related issues
   
   [AIP-49 OpenTelemetry Support for Apache 
Airflow](https://cwiki.apache.org/confluence/display/AIRFLOW/AIP-49+OpenTelemetry+Support+for+Apache+Airflow)
   https://github.com/apache/airflow/issues/37628
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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