StackdriverTaskHandler

Google

Handler that directly makes Stackdriver logging API calls.

View Source

Last Updated: Mar. 6, 2021

Access Instructions

Install the Google provider package into your Airflow environment.

Import the module into your DAG file and instantiate it with your desired params.

Parameters

gcp_key_pathstrPath to Google Cloud Credential JSON file. If omitted, authorization based on the Application Default Credentials will be used.
scopesSequence[str]OAuth scopes for the credentials,
namestrthe name of the custom log in Stackdriver Logging. Defaults to 'airflow'. The name of the Python logger will be represented in the python_logger field.
transport:class:`type`No role entry for "class" in module "docutils.parsers.rst.languages.en". Trying "class" as canonical role name.Unknown interpreted text role "class".Class for creating new transport objects. It should extend from the base :class:`google.cloud.logging.handlers.Transport` type and implement :meth`google.cloud.logging.handlers.Transport.send`. Defaults to :class:`google.cloud.logging.handlers.BackgroundThreadTransport`. The other option is :class:`google.cloud.logging.handlers.SyncTransport`.No role entry for "class" in module "docutils.parsers.rst.languages.en". Trying "class" as canonical role name.Unknown interpreted text role "class".No role entry for "class" in module "docutils.parsers.rst.languages.en". Trying "class" as canonical role name.Unknown interpreted text role "class".No role entry for "class" in module "docutils.parsers.rst.languages.en". Trying "class" as canonical role name.Unknown interpreted text role "class".
resource:class:`~google.cloud.logging.resource.Resource`No role entry for "class" in module "docutils.parsers.rst.languages.en". Trying "class" as canonical role name.Unknown interpreted text role "class".(Optional) Monitored resource of the entry, defaults to the global resource type.
labelsdict(Optional) Mapping of labels for the entry.

Documentation

This is a Python standard logging handler using that can be used to route Python standard logging messages directly to the Stackdriver Logging API.

It can also be used to save logs for executing tasks. To do this, you should set as a handler with the name “tasks”. In this case, it will also be used to read the log for display in Web UI.

This handler supports both an asynchronous and synchronous transport.

Example DAGs

Improve this module by creating an example DAG.

View Source
  1. Add an `example_dags` directory to the top-level source of the provider package with an empty `__init__.py` file.
  2. Add your DAG to this directory. Be sure to include a well-written and descriptive docstring
  3. Create a pull request against the source code. Once the package gets released, your DAG will show up on the Registry.

Was this page helpful?