Skip to content
Discussion options

You must be logged in to vote

Yeah, that's basically the supported way. In Airflow 3 the metrics client moved to the task SDK, and the import you wrote is the right one:

from airflow.sdk.observability import stats

stats.gauge("my_service.queue_depth", 42)
stats.incr("my_service.processed")
stats.decr("my_service.in_flight")
stats.timing("my_service.batch_ms", 1234)      # ms or a timedelta
with stats.timer("my_service.batch"):          # times the block
    ...

from airflow.stats import Stats still works but it's deprecated now (it just warns and forwards to the same place), so the airflow.sdk.observability path is the one to use going forward.

The one gotcha that trips people up: these calls are no-ops unless you ac…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aeroyorch
Comment options

Answer selected by aeroyorch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants