Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metrics names to allow multiple executors to report metrics #40778

Merged
merged 8 commits into from
Jul 23, 2024

Conversation

syedahsn
Copy link
Contributor

Currently, metrics for executors are emitted using the following format:

airflow_executor_open_slots
airflow_executor_queued_tasks
airflow_executor_running_tasks

When multiple executors are configured, this format will not work because each executor will emit its data under the same name. In order to resolve this, we can include the executor to differentiate between each executor:

airflow_executor_open_slots_LocalExecutor
airflow_executor_queued_tasks_LocalExecutor
airflow_executor_running_tasks_LocalExecutor


airflow_executor_open_slots_AwsEcsExecutor
airflow_executor_queued_tasks_AwsEcsExecutor
airflow_executor_running_tasks_AwsEcsExecutor

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added the area:Executors-core LocalExecutor & SequentialExecutor label Jul 14, 2024
@romsharon98
Copy link
Contributor

Why not adding this suffix for each executor no matter number of executors?

@syedahsn
Copy link
Contributor Author

Why not adding this suffix for each executor no matter number of executors?

We could do that, but that would be a breaking change. Any workflows that require these metrics to be emitted will break if we change the naming format.

@syedahsn syedahsn force-pushed the syedahsn/hybrid-executor-metrics branch from cef2150 to 23920ca Compare July 15, 2024 08:08
@o-nikolas
Copy link
Contributor

Why not adding this suffix for each executor no matter number of executors?

We could do that, but that would be a breaking change. Any workflows that require these metrics to be emitted will break if we change the naming format.

Yeah, doing it this way allows the default case (one executor only) which most folks will continue to use for some time, will work as it always has without a change in the metric names (since a name change may interfere with people's dashboards and metrics processing). For Airflow 3 (when we can easily make breaking changes) we'll update the metrics to include the executor name in all cases always.

@eladkal
Copy link
Contributor

eladkal commented Jul 15, 2024

For Airflow 3 (when we can easily make breaking changes) we'll update the metrics to include the executor name in all cases always.

What about introducing a setting that will control over which behavior is used and for Airflow 3 we will eliminate the setting and make the new way (with executor name) the default one? This way we can implement everything now and not have a tech debt later.

WDYT?

@o-nikolas
Copy link
Contributor

For Airflow 3 (when we can easily make breaking changes) we'll update the metrics to include the executor name in all cases always.

What about introducing a setting that will control over which behavior is used and for Airflow 3 we will eliminate the setting and make the new way (with executor name) the default one? This way we can implement everything now and not have a tech debt later.

WDYT?

I think Airflow has too many configurations as it is 😅 Given the short period of time between now and Airflow 3 I don't think it's worth the complexity. Either way we'll have to circle back and make a code change (either remove that configuration logic or make the small code change to modify the behaviour) so I don't think it buys us too much, personally.

@shubham22
Copy link

I am with @o-nikolas on this one. Introducing a config, just to remove it again in next version (assuming there is no v2.11) does not make much sense. We anyways need a lot of clean up, and this tech debt is a trivial change that we can keep track and ensure that it is there in v3.

Copy link
Contributor

@o-nikolas o-nikolas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look fine, but should this have a unit test?

@eladkal
Copy link
Contributor

eladkal commented Jul 15, 2024

I am with @o-nikolas on this one. Introducing a config, just to remove it again in next version (assuming there is no v2.11) does not make much sense. We anyways need a lot of clean up, and this tech debt is a trivial change that we can keep track and ensure that it is there in v3.

It can make sense if you want to allow users to be prepared earlier and have 1 less thing to worry about. You give them the chance to be Aifflow 3 complient. This may be something we want to think about more generally... cc @kaxil

This is not something I feel strongly about so either way we can proceed.

@syedahsn
Copy link
Contributor Author

Code changes look fine, but should this have a unit test?

There wasn't a unit test initially that tested original behavior, so I didn't write one to test the updated behavior. As far as I can tell, there are no tests related to metrics being emitted.

@syedahsn
Copy link
Contributor Author

What about introducing a setting that will control over which behavior is used and for Airflow 3 we will eliminate the setting and make the new way (with executor name) the default one? This way we can implement everything now and not have a tech debt later.

Agree with the others on this. There isn't necessarily a tech debt here, and if so, it wouldn't take much more effort to update the metric than it would to remove a configuration which allows the newer metric to be emitted.

You give them the chance to be Aifflow 3 complient.

I do agree with this point, but ultimately, its not a big enough change to warrant to much prep work.

@kaxil
Copy link
Member

kaxil commented Jul 16, 2024

The other option is to emit both metrics, so users can move to Airflow 3 style without worrying about Airflow configs but can still stay ahead of the curve.

Could you also update the following 2 places:

@syedahsn syedahsn force-pushed the syedahsn/hybrid-executor-metrics branch from 9d0784e to b019f28 Compare July 20, 2024 08:38
@o-nikolas o-nikolas merged commit 7d35e04 into apache:main Jul 23, 2024
64 checks passed
@o-nikolas o-nikolas deleted the syedahsn/hybrid-executor-metrics branch July 23, 2024 18:51
sunank200 pushed a commit to astronomer/airflow that referenced this pull request Jul 24, 2024
…pache#40778)

* Update metrics.rst and helm chart to include new metrics format

* Add Unit test to ensure correct metrics names are being emitted depending on whether multiple executors are configured

* Fix unit test for statsd
@ephraimbuddy ephraimbuddy added the type:improvement Changelog: Improvements label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Executors-core LocalExecutor & SequentialExecutor type:improvement Changelog: Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants