raghavan-arvind opened a new pull request, #71625:
URL: https://github.com/apache/airflow/pull/71625
## Why
The existing `DatadogSensor` queries the event stream for transition events
in a time window. That shape cannot answer "is this monitor healthy right now":
a monitor that entered Alert before the window (or recovered before it) emits
no event inside it, so gating a pipeline on monitor health requires
reconstructing state from transitions.
This adds `DatadogMonitorSensor`, which checks a monitor's current
`overall_state` — an already-alerting or already-recovered monitor is observed
regardless of when it last changed state.
## What
- `DatadogMonitorSensor`: waits for a monitor to reach one of
`target_states` (default `("OK",)`). Supports poke and reschedule modes via
`poke()`, and deferrable mode (default from `[operators] default_deferrable`)
via a new `DatadogMonitorTrigger`, following the same shape as other deferrable
sensors. In deferrable mode it pokes once before deferring, so an
already-satisfied condition never round-trips through the triggerer.
- `DatadogMonitorTrigger`: polls the monitor state off the event loop
(`asyncio.to_thread`, since the datadog client is sync) and fires when a target
state is reached.
- The datadog library returns API errors as a payload instead of raising;
both paths surface them as a clear `AirflowException` (e.g. `Datadog monitor
999999999: ['Monitor not found']`).
- provider.yaml gains a `triggers` section; unit tests for sensor (all
modes) and trigger (serialize round-trip, poll-until-target, API error).
## Testing
`uv run --project providers/datadog pytest
providers/datadog/tests/unit/datadog`: 19 passed. Also validated end to end in
a production-like Airflow 3.3 deployment: canary tasks covering pass / timeout
/ missing-monitor across poke, reschedule and deferrable modes behave as
expected.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]