Skip to main content

Apache Airflow provider for Telomere lifecycle tracking

Project description

Telomere Airflow Provider

Apache Airflow provider for Telomere lifecycle tracking. It monitors whole DAG runs and individual critical tasks, with server-side timeouts as a fallback when Airflow cannot report.

Requires Apache Airflow >= 3.0, < 4 and Python >= 3.10. Airflow 2 users should pin telomere-airflow-provider==0.0.1.

Installation

pip install telomere-airflow-provider

Add a connection named telomere_default with connection type Telomere and your API key in the password field:

airflow connections add telomere_default \
  --conn-type telomere \
  --conn-password YOUR_API_KEY

Or configure it through the environment:

export AIRFLOW_CONN_TELOMERE_DEFAULT='telomere://:YOUR_API_KEY@'

DAG-run tracking

Opt a DAG in with the telomere tag:

from airflow.sdk import DAG

dag = DAG(
    "daily_report",
    schedule="0 2 * * *",
    tags=["telomere"],
)

Existing callers can keep the one-line helper. In 2.0 it only adds the tag and does not modify the task graph:

from telomere_provider.utils import enable_telomere_tracking

enable_telomere_tracking(dag)

The provider's Airflow plugin listens for scheduler-computed DAG-run state changes:

  • on_dag_run_running creates <dag_id>.dag and starts a Telomere run.
  • on_dag_run_success resolves the matching run as completed.
  • on_dag_run_failed resolves it as failed, including scheduler timeouts and all-tasks-deadlocked outcomes.

Runs carry dag_id, Airflow run_id, run_type, and (when present) logical_date tags, plus a link to the Airflow run. Terminal events find the running Telomere run by its Airflow run_id, so tracking remains correct after scheduler restarts and when a run is marked manually through the API server.

The run timeout is selected in this order:

  1. the DAG's dagrun_timeout;
  2. the data-interval length;
  3. one hour.

Every schedulable DAG also maintains <dag_id>.schedule. Its deadline uses Airflow's next_dagrun_create_after plus five minutes of grace, falling back to the current data-interval end. This is the deadman switch for a scheduler or DAG that stops creating runs entirely.

Listener errors are isolated by Airflow and cannot change a DAG run's state. A write outage can therefore leave a Telomere run open until its timeout, but it cannot fail the user's workflow.

Upgrading to 2.0

enable_telomere_tracking no longer accepts lifecycle_name, timeout_seconds, tags, telomere_conn_id, fail_on_telomere_error, track_schedule, or other options. Stale calls raise TypeError during DAG parsing instead of silently changing behavior.

Use dagrun_timeout for a per-DAG execution timeout. DAG lifecycle names are now always <dag_id>.dag, schedule monitoring is automatic for schedulable DAGs, and the listener always uses telomere_default. The removed TelomereDAGStartOperator, TelomereCanaryOperator, and TelomereFinalizeOperator are no longer needed because no tasks are injected.

Task-level tracking

TelomereLifecycleOperator remains available for critical operations that need their own lifecycle, custom timeout, tags, or connection:

from telomere_provider.operators.telomere import TelomereLifecycleOperator

critical_task = TelomereLifecycleOperator(
    task_id="process_payment",
    python_callable=process_payment_batch,
    lifecycle_name="payment_processing",
    timeout_seconds=300,
    tags={"priority": "high"},
    dag=dag,
)

Relative lifecycle names are namespaced by the DAG ID. For example, lifecycle_name="validate" becomes <dag_id>.validate. The value may also be a callable that receives the Airflow task context.

By default, Telomere errors do not fail the task. Set fail_on_telomere_error=True when inability to record the task should fail the Airflow task itself.

Connection options

The connection extra JSON supports read retry and timeout settings:

{
  "timeout": 30,
  "max_retries": 3,
  "backoff_factor": 0.3
}

Retries apply to reads only. Writes are not replayed because retrying a run start after an ambiguous response could create a duplicate.

Development

uv sync
uv run ruff check .
uv run pytest

The test suite has three tiers:

  • unit tests for the hook, listener, tag shim, and task operator;
  • an Airflow-version matrix that drives terminal DAG shapes through dag.test() and the real listener plugin;
  • end-to-end tests using a real scheduler and Telomere API.

Run the end-to-end tier with:

TELOMERE_API_KEY=... tests/e2e/run.sh

The Docker Compose stack exposes Airflow at http://localhost:8080 with username and password airflow. See docker/README.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telomere_airflow_provider-2.0.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telomere_airflow_provider-2.0.0-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file telomere_airflow_provider-2.0.0.tar.gz.

File metadata

File hashes

Hashes for telomere_airflow_provider-2.0.0.tar.gz
Algorithm Hash digest
SHA256 4cee4d99fe64650ef1737b2d8e73fc33ab86dbd86049f0da1ba4b3d140ebdc69
MD5 7462cc69fa448089e801d940b69a6c12
BLAKE2b-256 981c6b8a0f8e4f3a2253328baa88fcb70d3a9c81dd8a4a40eef1112373034818

See more details on using hashes here.

Provenance

The following attestation bundles were made for telomere_airflow_provider-2.0.0.tar.gz:

Publisher: publish.yml on modulecollective/telomere-airflow-provider

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file telomere_airflow_provider-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for telomere_airflow_provider-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 be6fe741f8a23804cf92171771729b285c96f03b72d6176302630150c4f18e41
MD5 078e23dd2e24a27b5831279458358a0a
BLAKE2b-256 28533ea5c6b28eea453e31d693a07969fd925e1e6559231d63fda83aeaa5ba2c

See more details on using hashes here.

Provenance

The following attestation bundles were made for telomere_airflow_provider-2.0.0-py3-none-any.whl:

Publisher: publish.yml on modulecollective/telomere-airflow-provider

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page