Skip to content

Feature: Add publisher_options support to PubSubHook for OpenTelemetry tracing #58764

Closed

Description

@nikhilnadig28

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.24.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:

providers/google/src/airflow/providers/google/cloud/hooks/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:

providers/google/src/airflow/providers/google/cloud/hooks/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
#37628

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. added
    kind:feature
    needs-triage
    on Nov 27, 2025
  2. boring-cyborg commented on Nov 27, 2025

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.

  3. added
    provider:google
    on Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:providerskind:featureneeds-triageprovider:google

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions