You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "xBis7 (via GitHub)" <gi...@apache.org> on 2025/07/24 16:27:41 UTC
[PR] Option to disable exporting of legacy metric names [airflow]
xBis7 opened a new pull request, #53722:
URL: https://github.com/apache/airflow/pull/53722
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
In many places, the same metrics are exported twice but with different names. In one case, variables such as `dag_id` and `task_id` are part of the name while in the other case, the info is added under tags.
Here is an example,
```
- new
airflow.task.scheduled_duration(dag_id="dag1", task_id="task1")
airflow.task.scheduled_duration(dag_id="dag1", task_id="task2")
- legacy
airflow.dag.dag1.task1.scheduled_duration
airflow.dag.dag1.task2.scheduled_duration
```
Throughout the code, the metrics with the variables in their names, are referred to as legacy metrics.
This patch is adding a new config flag and a new helper class that make it easier to enable/disable the export of legacy metrics.
The legacy metrics are increasing cardinality. They aren't removed because people are already using them and to avoid disturbing them, they are enabled by default.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
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 [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3130281597
These can be fixed like this
https://github.com/apache/airflow/pull/53791/files#diff-5c668b939784008b1d1702152b233972dfe2507ac29c721309c5259d845ec964
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495747310
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -651,9 +652,14 @@ def _executable_task_instances_to_queued(self, max_tis: int, session: Session) -
)
for pool_name, num_starving_tasks in pool_num_starving_tasks.items():
- Stats.gauge(f"pool.starving_tasks.{pool_name}", num_starving_tasks)
- # Same metric with tagging
- Stats.gauge("pool.starving_tasks", num_starving_tasks, tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
Review Comment:
I can clean this up.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3713951434
One more question: -> why this is not in `shared` observability but in airflow.observability - > it is also used in providers and it does seem like a functionality that should be shared and imported from appropriate `airflow._shared.observability` or `airlfow.sdk._shared.observability` not `from airflow.observability` ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2492956460
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
I updated the patch. All legacy metrics are accessed through the yaml file. I also added some validations to make sure that the legacy names always exist on the yaml and that we have declared the variables needed for the name.
I built the yaml using the existing tables from the `metrics.rst`. The failing tests on the CI have to do with the new validations. It seems that some metrics didn't exist in the old docs. I'm going to add them to the yaml and also fix any other failures.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495787706
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -161,8 +161,16 @@ def emit(self, event: RunEvent):
try:
with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
+ try:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ stack.enter_context(DualStatsManager.timer("ol.emit.attempts"))
Review Comment:
Yes, with the latest changes it will fail to build the legacy metric without them. BTW, that's another metric that doesn't exist in the docs and needs to be added.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2445258491
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
> also providing a regex pattern for the old name conversion.
@ferruzzi Do you mean forcing all legacy metric names to follow the same convention?
Right now, it goes like this
* name: `<metric_name>`
* legacy: `<metric_name>.<variables>`
In place of `<variables>` we could have any number of values. It could be one or more, all connected with dots. E.g. `<metric_name>.dag_id` or `<metric_name>.dag_id.task_id`.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253873622
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
We could iterate over the tags and for each tag, add a dot and the value in the name. That would standardize it, but the legacy names don't always follow the same format.
For example, in the `dagrun` the legacy name contains just the `dag_id` but the tags have extra info.
Here are some examples,
https://github.com/apache/airflow/blob/e4c01c3b330c68feff7cd7dee0983858e6d6c2d0/airflow-core/src/airflow/models/dagrun.py#L1723-L1728
https://github.com/apache/airflow/blob/e4c01c3b330c68feff7cd7dee0983858e6d6c2d0/airflow-core/src/airflow/models/dagrun.py#L1153-L1158
and these are the tags
https://github.com/apache/airflow/blob/e4c01c3b330c68feff7cd7dee0983858e6d6c2d0/airflow-core/src/airflow/models/dagrun.py#L426-L427
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495605286
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
Sorry I missed you previous comment from last week. The way you mentioned you were going to try is exactly my thought as well.
> The failing tests on the CI have to do with the new validations. It seems that some metrics didn't exist in the old docs
That's exactly what I was hoping to catch and fix with the registry idea. There needs to be a check the other way as well; just because it is in the docs doesn't mean it still exists in the code... but we can do that part later if you want. That might just be an initial manual cleanup plus a pre-commit hook that checks the commit for changes, but that may be a side project on its own.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2691349777
##########
contributing-docs/05_pull_requests.rst:
##########
@@ -283,7 +283,7 @@ will be timed and submitted automatically:
.. code-block:: python
- from airflow.observability.stats import Stats
+ from airflow._shared.observability.metrics.stats import Stats
Review Comment:
I updated it.
##########
contributing-docs/05_pull_requests.rst:
##########
Review Comment:
I updated it.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2664275639
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -1085,6 +1085,15 @@ metrics:
example: "\"scheduler,executor,dagrun,pool,triggerer,celery\"
or \"^scheduler,^executor,heartbeat|timeout\""
default: ""
+ legacy_names_on:
+ description: |
+ If true, it exports both new and legacy metric names.
+ Legacy names contain variables such as dag_id and task_id,
+ while the new names set these variables inside tags.
+ version_added: 3.1.0
Review Comment:
```suggestion
version_added: 3.2.0
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254115064
##########
devel-common/src/tests_common/test_utils/otel_utils.py:
##########
@@ -94,14 +95,23 @@ def clean_task_lines(lines: list) -> list:
return cleaned_lines
-def extract_spans_from_output(output_lines: list):
+def _extract_obj_from_output(output_lines: list[str], kind: str):
Review Comment:
Done.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3496400280
The CI failure is unrelated. The test passes locally. I'll trigger it again.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2497602231
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -161,8 +161,16 @@ def emit(self, event: RunEvent):
try:
with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
+ try:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ stack.enter_context(DualStatsManager.timer("ol.emit.attempts"))
Review Comment:
> BTW, that's another metric that doesn't exist in the docs and needs to be added.
I love that these are getting caught and updated. Thanks. At a guess, how many would you say you've "discovered" so far? I'm concerned what that may mean for ones that we "advertise" but don't actually exist. This is a great step forward.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2497643895
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -161,8 +161,16 @@ def emit(self, event: RunEvent):
try:
with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
+ try:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ stack.enter_context(DualStatsManager.timer("ol.emit.attempts"))
Review Comment:
* https://github.com/apache/airflow/pull/53722/commits/043f1408cd2f34c0dc65c1f05454f1af21de453d#diff-1aa980cab8965838a6274f4d9c6fe4b39229d4b8c4cba216ed4e8a7f072efaa1R58
* In this one the legacy name was wrong in the docs. (1)
* https://github.com/apache/airflow/pull/53722/commits/70d022ebe34e10adb25ce740c4d4d6fcaeb16413
* The variable in the legacy name was different from what was in the docs. (1)
* https://github.com/apache/airflow/pull/53722/commits/b3053322f3301f733c0dbc97f48ecd05a22607bd
* 6 missing from the docs.
* https://github.com/apache/airflow/pull/53722/commits/33d6f5aef4b684dbc6b6e13de7a5e3a79be9d289
* 1 more missing.
* https://github.com/apache/airflow/pull/53722/commits/1889f45e59f66e4d85d2bac20082ca8148fb22d2
* 1 more missing.
So, it's 8 missing and 2 where there was a mismatch between the docs and the code. That's the total so far.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2687799448
##########
contributing-docs/05_pull_requests.rst:
##########
Review Comment:
Nit. Old import
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3244146052
@ashb Did you have a chance to take another look at this?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3124269131
I see a weird error on the pre-commit static code checks
```
Run mypy for providers......................................................Failed
- hook id: mypy-providers
- exit code: 1
Using 'uv' to install Airflow
Using airflow version from current sources
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:31: error:
Module "airflow.utils" has no attribute "timezone" [attr-defined]
from airflow.utils import timezone
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
providers/edge3/src/airflow/providers/edge3/worker_api/routes/worker.py:44: error:
Module "airflow.utils" has no attribute "timezone" [attr-defined]
from airflow.utils import timezone
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in 2 files (checked 2 source files)
Error 1 returned
If you see strange stacktraces above, and can't reproduce it, please run this command and try again:
breeze ci-image build --python 3.10
You can also run `breeze down --cleanup-mypy-cache` to clean up the cache used.
```
I can see that this is used everywhere. I skipped the check for the commit and pushed the changes but if it fails on the CI, I'll look for a fix.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253680601
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -1050,6 +1050,15 @@ metrics:
example: "\"scheduler,executor,dagrun,pool,triggerer,celery\"
or \"^scheduler,^executor,heartbeat|timeout\""
default: ""
+ legacy_names_on:
+ description: |
+ If true, it exports both new and legacy metric names.
+ Legacy names contain variables such as dag_id and task_id, which increases cardinality.
+ The new names set these variables inside tags.
Review Comment:
Doesn't including them in tags still increase cardinality? (I still think this is worth doing, just not sure this comment is right)
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254608903
##########
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:
##########
@@ -27,13 +27,18 @@
from airflow.exceptions import AirflowException
from airflow.models.base import Base
+from airflow.providers.edge3.version_compat import AIRFLOW_V_3_1_PLUS
Review Comment:
This is still needed because it's used later on
https://github.com/apache/airflow/blob/2f737d2e252e8651f877ee2ab809475db9d8f62e/providers/edge3/src/airflow/providers/edge3/models/edge_worker.py#L173-L225
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254648021
##########
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:
##########
@@ -27,13 +27,18 @@
from airflow.exceptions import AirflowException
from airflow.models.base import Base
+from airflow.providers.edge3.version_compat import AIRFLOW_V_3_1_PLUS
from airflow.stats import Stats
-from airflow.utils import timezone
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.utils.providers_configuration_loader import providers_configuration_loaded
from airflow.utils.session import NEW_SESSION, provide_session
from airflow.utils.sqlalchemy import UtcDateTime
+if AIRFLOW_V_3_1_PLUS:
+ from airflow.sdk import timezone
+else:
+ from airflow.utils import timezone # type: ignore[attr-defined,no-redef]
Review Comment:
Fixed.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253687812
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
I didn't check all cases in this PR, but I wonder if we could do this as
```suggestion
DualStatsManager.gauge(
"pool.open_slots",
slot_stats["open"],
tags={},
extra_tags={"pool_name": pool_name},
)
```
And then we can build the old name via something like this:
```python
metric_name = metric + ".".join(extra_tags.values())
```
wdyt?
##########
devel-common/src/tests_common/test_utils/otel_utils.py:
##########
@@ -94,14 +95,23 @@ def clean_task_lines(lines: list) -> list:
return cleaned_lines
-def extract_spans_from_output(output_lines: list):
+def _extract_obj_from_output(output_lines: list[str], kind: str):
"""
- For a given list of ConsoleSpanExporter output lines, it extracts the json spans and creates two dictionaries.
-
- :return: root spans dict (key: root_span_id - value: root_span), spans dict (key: span_id - value: span)
+ Used to extract spans or metrics from the output.
+
+ Parameters
+ ----------
+ output_lines : list[str]
+ The captured stdout split into lines.
+ kind : "spans" | "metrics"
+ Which json type to extract from the output.
Review Comment:
```suggestion
Parameters
----------
:param output_lines: The captured stdout split into lines.
:param kind: Which json type to extract from the output.
```
##########
devel-common/src/tests_common/test_utils/otel_utils.py:
##########
@@ -94,14 +95,23 @@ def clean_task_lines(lines: list) -> list:
return cleaned_lines
-def extract_spans_from_output(output_lines: list):
+def _extract_obj_from_output(output_lines: list[str], kind: str):
Review Comment:
```suggestion
def _extract_obj_from_output(output_lines: list[str], kind: Literal["spans"] | Literal["metrics"]):
```
##########
providers/edge3/src/airflow/providers/edge3/version_compat.py:
##########
@@ -33,3 +33,15 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
+AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
+
+if AIRFLOW_V_3_0_PLUS:
+ from airflow.sdk import BaseOperator
+else:
+ from airflow.models import BaseOperator
+
+__all__ = [
+ "AIRFLOW_V_3_0_PLUS",
+ "AIRFLOW_V_3_1_PLUS",
+ "BaseOperator",
+]
Review Comment:
Ditto here
```suggestion
try:
from airflow.sdk import BaseOperator
except ImportError:
from airflow.models import BaseOperator
__all__ = [
"AIRFLOW_V_3_0_PLUS",
"BaseOperator",
]
```
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -157,15 +158,30 @@ def emit(self, event: RunEvent):
transport_type = f"{self._client.transport.kind}".lower()
try:
- with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
- self._client.emit(redacted_event)
- self.log.info(
- "Successfully emitted OpenLineage `%s` event of id `%s`",
- event_type.upper(),
- event.run.runId,
- )
+ if AIRFLOW_V_3_1_PLUS:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ with DualStatsManager.timer(
+ f"ol.emit.attempts.{event_type}.{transport_type}", "ol.emit.attempts"
+ ):
+ self._client.emit(redacted_event)
+ self.log.info(
+ "Successfully emitted OpenLineage `%s` event of id `%s`",
+ event_type.upper(),
+ event.run.runId,
+ )
Review Comment:
Rather than duplicating the code here, I think it would be better to use the exist stack and have this as something like
```python
with ExitStack() as stack:
if AIRFLOW_V_3_1_PLUS:
stack.enter_context(DualStatsManager)
else:
stack.enter_context(Stats.timer(...))
stack.enter_context(Stats.timer(...))
self._client.emit(redacted_event)
self.log.info(
"Successfully emitted OpenLineage `%s` event of id `%s`",
event_type.upper(),
event.run.runId,
)
```
##########
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:
##########
@@ -27,13 +27,18 @@
from airflow.exceptions import AirflowException
from airflow.models.base import Base
+from airflow.providers.edge3.version_compat import AIRFLOW_V_3_1_PLUS
from airflow.stats import Stats
-from airflow.utils import timezone
from airflow.utils.log.logging_mixin import LoggingMixin
from airflow.utils.providers_configuration_loader import providers_configuration_loaded
from airflow.utils.session import NEW_SESSION, provide_session
from airflow.utils.sqlalchemy import UtcDateTime
+if AIRFLOW_V_3_1_PLUS:
+ from airflow.sdk import timezone
+else:
+ from airflow.utils import timezone # type: ignore[attr-defined,no-redef]
Review Comment:
```suggestion
try:
from airflow.sdk import timezone
except ImportError:
from airflow.utils import timezone # type: ignore[attr-defined,no-redef]
```
Better not to use version checks, especially as this an import from TaskSDK, which is working torwards independence from the Airflow version.
##########
providers/edge3/src/airflow/providers/edge3/version_compat.py:
##########
@@ -33,3 +33,15 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
+AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
+
+if AIRFLOW_V_3_0_PLUS:
+ from airflow.sdk import BaseOperator
+else:
+ from airflow.models import BaseOperator
+
+__all__ = [
+ "AIRFLOW_V_3_0_PLUS",
+ "AIRFLOW_V_3_1_PLUS",
+ "BaseOperator",
+]
Review Comment:
A few more places have this pattern that I haven't commented on
##########
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:
##########
@@ -27,13 +27,18 @@
from airflow.exceptions import AirflowException
from airflow.models.base import Base
+from airflow.providers.edge3.version_compat import AIRFLOW_V_3_1_PLUS
Review Comment:
```suggestion
```
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254841560
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -157,15 +158,30 @@ def emit(self, event: RunEvent):
transport_type = f"{self._client.transport.kind}".lower()
try:
- with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
- self._client.emit(redacted_event)
- self.log.info(
- "Successfully emitted OpenLineage `%s` event of id `%s`",
- event_type.upper(),
- event.run.runId,
- )
+ if AIRFLOW_V_3_1_PLUS:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ with DualStatsManager.timer(
+ f"ol.emit.attempts.{event_type}.{transport_type}", "ol.emit.attempts"
+ ):
+ self._client.emit(redacted_event)
+ self.log.info(
+ "Successfully emitted OpenLineage `%s` event of id `%s`",
+ event_type.upper(),
+ event.run.runId,
+ )
Review Comment:
Done.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2683510441
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -1085,6 +1085,15 @@ metrics:
example: "\"scheduler,executor,dagrun,pool,triggerer,celery\"
or \"^scheduler,^executor,heartbeat|timeout\""
default: ""
+ legacy_names_on:
+ description: |
+ If true, it exports both new and legacy metric names.
+ Legacy names contain variables such as dag_id and task_id,
+ while the new names set these variables inside tags.
+ version_added: 3.1.0
Review Comment:
Fixed.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253841595
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -1050,6 +1050,15 @@ metrics:
example: "\"scheduler,executor,dagrun,pool,triggerer,celery\"
or \"^scheduler,^executor,heartbeat|timeout\""
default: ""
+ legacy_names_on:
+ description: |
+ If true, it exports both new and legacy metric names.
+ Legacy names contain variables such as dag_id and task_id, which increases cardinality.
+ The new names set these variables inside tags.
Review Comment:
I updated it.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3130675976
> These can be fixed like this
>
> https://github.com/apache/airflow/pull/53791/files#diff-5c668b939784008b1d1702152b233972dfe2507ac29c721309c5259d845ec964
@uranusjr Thank you! I used your suggestion to fix the imports.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2474126706
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
@ferruzzi I made the changes. The metric tables are generated from a common yaml file. I replaced the syntax `<variable>` with `{variable}` because we can do something like this
```python
legacy_name = "ti.finish.{dag_id}.{task_id}.{state}"
formatted_legacy_name = legacy_name.format(dag_id="my_dag", task_id="my_task1", state="success")
```
I'm not sure if it's worth it. We could end up writing way more code and complicating things with no significant benefit. I'll do a POC first and see how it looks.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2393070561
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
When I considered this problem in the past I had a half-baked idea of creating a "metrics registry" (a yaml file?) which would serve the purpose of being used to build the metrics documentation page so it was always up to date, and also providing a regex pattern for the old name conversion. I don't know if you want to attempt that approach or not, but it's (half of) a thought. Something like:
- metrics
- metric_name_1
- description
- type
- old_name_pattern
- metric_name_2
Then the table at https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#metric-descriptions could be built from that and we could use a static check to make sure that yaml (and therefor the docs) are always up to date.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495624522
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -161,8 +161,16 @@ def emit(self, event: RunEvent):
try:
with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
+ try:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ stack.enter_context(DualStatsManager.timer("ol.emit.attempts"))
Review Comment:
Doesn't this need the extras_tags?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495653763
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
> I think that it should happen in another PR because it would widen the scope of this one by a lot.
Yeah, I'm happy with that. Sorry to blow the scope out on this one already. I'm working through the changes but have a lot of meetings today so i may not get through it all today.
Thanks for sticking with this one, I know it's been a pretty long haul
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495811777
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -651,9 +652,14 @@ def _executable_task_instances_to_queued(self, max_tis: int, session: Session) -
)
for pool_name, num_starving_tasks in pool_num_starving_tasks.items():
- Stats.gauge(f"pool.starving_tasks.{pool_name}", num_starving_tasks)
- # Same metric with tagging
- Stats.gauge("pool.starving_tasks", num_starving_tasks, tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
Review Comment:
Fixed.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254048244
##########
devel-common/src/tests_common/test_utils/otel_utils.py:
##########
@@ -94,14 +95,23 @@ def clean_task_lines(lines: list) -> list:
return cleaned_lines
-def extract_spans_from_output(output_lines: list):
+def _extract_obj_from_output(output_lines: list[str], kind: str):
"""
- For a given list of ConsoleSpanExporter output lines, it extracts the json spans and creates two dictionaries.
-
- :return: root spans dict (key: root_span_id - value: root_span), spans dict (key: span_id - value: span)
+ Used to extract spans or metrics from the output.
+
+ Parameters
+ ----------
+ output_lines : list[str]
+ The captured stdout split into lines.
+ kind : "spans" | "metrics"
+ Which json type to extract from the output.
Review Comment:
Done.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3508854928
Yeah unfortunately this needs again conflict resolution after other PR merged.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3509840997
@potiuk I updated the PR and the CI is green.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3890588153
Agreed, let me look into it
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495639245
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
Right now I added a validation just for when reading the legacy metric from the yaml.
A pre-commit check or a cross-check validation everytime we try to add a metric to the metric_map would be good to have. But I think that it should happen in another PR because it would widen the scope of this one by a lot.
Just to get the tests working, I'm adding metrics that have been missing from the docs. The issue is that I'm not entirely sure about the description. I'm reading the code but still what I'm writing is a guess. So the validation PR, should start as a draft with a list of newly documented metrics so that people can add comments and explain what each does.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2686669132
##########
devel-common/src/docs/build_docs.py:
##########
@@ -224,6 +224,12 @@ def build_docs_for_packages(
builder = AirflowDocsBuilder(package_name=package_name)
builder.is_autobuild = is_autobuild
builder.clean_files()
+
Review Comment:
I haven't worked with sphinx before. I did some research and it turns out you are right. A sphinx extension is cleaner and more suitable for this scenario.
Right before building the docs, we read the yaml and generate a new metrics table. During the build, the metrics table is there and the `metrics.rst` successfully includes it.
An extension will handle the process and make sure that the table is always built and in sync with the yaml during the sphinx startup.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3740060809
@potiuk I made the changes and moved the `dual_stats_manager` and the `stats` files under shared.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "jscheffl (via GitHub)" <gi...@apache.org>.
jscheffl commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3751966284
Wow, this was a large one!
#protm
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #53722:
URL: https://github.com/apache/airflow/pull/53722
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2687806988
##########
contributing-docs/05_pull_requests.rst:
##########
@@ -283,7 +283,7 @@ will be timed and submitted automatically:
.. code-block:: python
- from airflow.observability.stats import Stats
+ from airflow._shared.observability.metrics.stats import Stats
Review Comment:
Nit: Maybe we should add two options here of the import (or a comment that it only works for airflow-core, and that for task-sdk we should use `airflow.sdk._shared` ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3890597309
I thought that if a provider needed to use shared code, it would have to get it from the sdk. What's the way forward? Getting it directly from shared?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3890734858
@xBis7 your assumption is correct, providers need to get it from task sdk but not from `airflow.sdk._shared` since its an internal path. This PR: https://github.com/apache/airflow/pull/56187/changes#diff-8603867cd4927a3bbbfe40fd1e3250eff900162514c9b70d41fa8ddfaefc5809 did the right thing but some part of it was lost in rebase I guess
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2450478680
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
We could also use the registry to address the initial comment of this thread and simplify the usage of the `DualStatsManager` calls. Each method will only accept the metric name and we will look it up in the registry and get the legacy name from there. @ashb Wdyt?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495746142
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
Don't worry about it. I'm also not done with the CI errors. Thanks!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2449691238
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
LOL Sory, I'm not explaining my idea very well I guess. Alright, back this up a bit. Forget everything about a possible default, that was just adding confusion.
The registry entries for `ti.finish.<dag_id>.<task_id>.<state>` and `task_restored_to_dag.<dag_id>` might look like this:
```
metrics:
- name: "ti.finish"
description: "Number of completed task in a given Dag. Similar to <job_name>_end but for task"
type: "counter"
legacy_name: "ti.finish.{dag_id}.{task_id}.{state}"
- name: "task_restored_to_dag"
description: "Number of tasks restored for a given Dag (i.e. task instance which was previously in REMOVED state in the DB is added to Dag file). Metric with dag_id and run_type tagging."
type: "counter"
legacy_name: "task_restored_to_dag.{dag_id}"
```
then in the code before emitting the metric, we populate the legacy_name template using the metric's `tags`.
As an added bonus, as part of the build-docs script we can walk through this registry and generate the table [in the docs](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html) so that doc page is always up to date.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2393070561
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
When I considered this problem in the past I had a half-baked idea of creating a "metrics registry" (a yaml file?) which would serve the purpose of being used to build the metrics documentation page so it was always up to date, and also providing a regex pattern for the old name conversion. I don't know if you want to attempt that approach or not, but it's (half of) a thought. Something like:
- metrics
- metric_name_1
- description
- type
- legacy_name_pattern
- metric_name_2
Then the table at https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/metrics.html#metric-descriptions could be built from that and we could use a static check to make sure that yaml (and therefor the docs) are always up to date.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254693193
##########
providers/edge3/src/airflow/providers/edge3/version_compat.py:
##########
@@ -33,3 +33,15 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
+AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
+
+if AIRFLOW_V_3_0_PLUS:
+ from airflow.sdk import BaseOperator
+else:
+ from airflow.models import BaseOperator
+
+__all__ = [
+ "AIRFLOW_V_3_0_PLUS",
+ "AIRFLOW_V_3_1_PLUS",
+ "BaseOperator",
+]
Review Comment:
I get the idea but we still need
```
AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
```
in order to check whether to use the `DualStatsManager` or the original code. Otherwise there are compatibility issues because the `DualStatsManager` doesn't exist in older providers.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253949087
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
Maybe then a `legacy_name` that defaults to None and is generated in that case? That would make most cases simpler?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495614302
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -651,9 +652,14 @@ def _executable_task_instances_to_queued(self, max_tis: int, session: Session) -
)
for pool_name, num_starving_tasks in pool_num_starving_tasks.items():
- Stats.gauge(f"pool.starving_tasks.{pool_name}", num_starving_tasks)
- # Same metric with tagging
- Stats.gauge("pool.starving_tasks", num_starving_tasks, tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
Review Comment:
Just personal preference, but I don't think we need a 2-line comment every time we emit the metrics. A good docstring in the DualStatsManager should suffice IMHO.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2442439767
##########
providers/edge3/src/airflow/providers/edge3/version_compat.py:
##########
@@ -33,3 +33,15 @@ def get_base_airflow_version_tuple() -> tuple[int, int, int]:
AIRFLOW_V_3_0_PLUS = get_base_airflow_version_tuple() >= (3, 0, 0)
+AIRFLOW_V_3_1_PLUS: bool = get_base_airflow_version_tuple() >= (3, 1, 0)
+
+if AIRFLOW_V_3_0_PLUS:
+ from airflow.sdk import BaseOperator
+else:
+ from airflow.models import BaseOperator
+
+__all__ = [
+ "AIRFLOW_V_3_0_PLUS",
+ "AIRFLOW_V_3_1_PLUS",
+ "BaseOperator",
+]
Review Comment:
Same here, I replaced it with `try-except`.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2445839487
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
No, I was thinking we could have a default regex pattern, but not all legacy names follow the same naming convention so the legacy_name_pattern would let us define the regex pattern for the ones that don't follow the default.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2448796127
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
> or only for the ones that don't follow the default.
I think you mean that we can't define a pattern for the ones that don't follow the default naming convention.
Or do you mean define a pattern so that they don't deviate much and make sure that the pattern is followed?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2448796127
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
> or only for the ones that don't follow the default.
I think you mean that we can't define a pattern for the ones that don't follow the default naming convention.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3753302792
@potiuk Thank you for the help and the merge!
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ashb (via GitHub)" <gi...@apache.org>.
ashb commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3890564550
@potiuk @xBis7 FYI Provider code should not ever be importing from `airflow.sdk._shared`.
cc @amoghrajesh
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2495809206
##########
providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:
##########
@@ -161,8 +161,16 @@ def emit(self, event: RunEvent):
try:
with ExitStack() as stack:
- stack.enter_context(Stats.timer(f"ol.emit.attempts.{event_type}.{transport_type}"))
- stack.enter_context(Stats.timer("ol.emit.attempts"))
+ try:
+ from airflow.metrics.dual_stats_manager import DualStatsManager
+
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ stack.enter_context(DualStatsManager.timer("ol.emit.attempts"))
Review Comment:
Fixed.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2664286769
##########
airflow-core/src/airflow/observability/metrics/dual_stats_manager.py:
##########
@@ -0,0 +1,277 @@
+# Licensed to the Apache Software Foundation (ASF) under one
Review Comment:
Should not it be in `shared.observability` ?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2664266026
##########
devel-common/src/docs/build_docs.py:
##########
@@ -224,6 +224,12 @@ def build_docs_for_packages(
builder = AirflowDocsBuilder(package_name=package_name)
builder.is_autobuild = is_autobuild
builder.clean_files()
+
Review Comment:
Question: Should we do it as sphinx extension maybe?
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2253712781
##########
airflow-core/src/airflow/config_templates/config.yml:
##########
@@ -1050,6 +1050,15 @@ metrics:
example: "\"scheduler,executor,dagrun,pool,triggerer,celery\"
or \"^scheduler,^executor,heartbeat|timeout\""
default: ""
+ legacy_names_on:
+ description: |
+ If true, it exports both new and legacy metric names.
+ Legacy names contain variables such as dag_id and task_id, which increases cardinality.
+ The new names set these variables inside tags.
Review Comment:
The distinct names will be decreased but the number of different metrics will be the same. So from that point of view, there is no change in cardinality. I see how that comment can be misinterpreted.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3154308073
@ashb Thank you for the review! I'll start addressing your comments.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2254001767
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
When it defaults to `None`, we will append all available tags to the legacy_name?
My preference would be to remove the legacy names entirely but I don't know how many people are using the names in their workflows to gather stats. That's why I tried to keep the exports the same and tried to make the existing tests work with the new code.
Your suggestion will make the code simpler but it might not be that easy to maintain exactly the same metrics as before.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3156034646
@ashb I addressed all your comments.
> Could you add somewhere that checks the legacy name with more than a single tag in extra_tags -- the tests only have a single case.
Let me know if the test cases that I added are sufficient or you need me to add different tests.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2442439605
##########
providers/edge3/src/airflow/providers/edge3/models/edge_worker.py:
##########
@@ -27,13 +27,18 @@
from airflow.exceptions import AirflowException
from airflow.models.base import Base
+from airflow.providers.edge3.version_compat import AIRFLOW_V_3_1_PLUS
Review Comment:
I replaced it with `try-except`.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2445839487
##########
airflow-core/src/airflow/jobs/scheduler_job_runner.py:
##########
@@ -2108,18 +2136,43 @@ def _emit_pool_metrics(self, session: Session = NEW_SESSION) -> None:
with DebugTrace.start_span(span_name="emit_pool_metrics", component="SchedulerJobRunner") as span:
pools = Pool.slots_stats(session=session)
for pool_name, slot_stats in pools.items():
- Stats.gauge(f"pool.open_slots.{pool_name}", slot_stats["open"])
- Stats.gauge(f"pool.queued_slots.{pool_name}", slot_stats["queued"])
- Stats.gauge(f"pool.running_slots.{pool_name}", slot_stats["running"])
- Stats.gauge(f"pool.deferred_slots.{pool_name}", slot_stats["deferred"])
- Stats.gauge(f"pool.scheduled_slots.{pool_name}", slot_stats["scheduled"])
-
- # Same metrics with tagging
- Stats.gauge("pool.open_slots", slot_stats["open"], tags={"pool_name": pool_name})
- Stats.gauge("pool.queued_slots", slot_stats["queued"], tags={"pool_name": pool_name})
- Stats.gauge("pool.running_slots", slot_stats["running"], tags={"pool_name": pool_name})
- Stats.gauge("pool.deferred_slots", slot_stats["deferred"], tags={"pool_name": pool_name})
- Stats.gauge("pool.scheduled_slots", slot_stats["scheduled"], tags={"pool_name": pool_name})
+ # If enabled on the config, publish metrics twice,
+ # once with backward compatible name, and then with tags.
+ DualStatsManager.gauge(
+ f"pool.open_slots.{pool_name}",
+ "pool.open_slots",
+ slot_stats["open"],
+ tags={},
+ extra_tags={"pool_name": pool_name},
+ )
Review Comment:
No, I was thinking we could maybe have a default regex pattern, but not all legacy names follow the same naming convention so the legacy_name_pattern would let us define the regex pattern for each, or only for the ones that don't follow the default.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #53722:
URL: https://github.com/apache/airflow/pull/53722#issuecomment-3905323464
> @xBis7 your assumption is correct, providers need to get it from task sdk but not from airflow.sdk._shared since its an internal path. This PR: https://github.com/apache/airflow/pull/56187/changes#diff-8603867cd4927a3bbbfe40fd1e3250eff900162514c9b70d41fa8ddfaefc5809 did the right thing but some part of it was lost in rebase I guess
Yes. airflow.sdk should expose everything it needs via non `_*` module - I keep on rebasing this one that should make all the checks automatically - but there are still a number of violations that prevent it from being merged (and it's likely some rules will need to be adjusted/refreshed) https://github.com/apache/airflow/pull/58825
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Option to disable exporting of legacy metric names [airflow]
Posted by "xBis7 (via GitHub)" <gi...@apache.org>.
xBis7 commented on code in PR #53722:
URL: https://github.com/apache/airflow/pull/53722#discussion_r2683507326
##########
shared/observability/src/airflow_shared/observability/metrics/dual_stats_manager.py:
##########
@@ -0,0 +1,277 @@
+# Licensed to the Apache Software Foundation (ASF) under one
Review Comment:
I made the change.
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org