You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "shivaam (via GitHub)" <gi...@apache.org> on 2026/06/26 00:52:53 UTC
[PR] Add team_name tag to Edge executor sync metric [airflow]
shivaam opened a new pull request, #69005:
URL: https://github.com/apache/airflow/pull/69005
Add the `team_name` tag to the Edge executor sync duration metric for multi-team deployments.
This follows the same pattern as #68593 for executor metrics:
- use `self.team_name` as the metric tag source
- wrap tags with `prune_dict` so global/no-team executors keep the existing empty tag set
- keep the change scoped to the Edge executor metric only
This PR covers the `edge_executor.sync.duration` item from #68996. Edge worker metrics and ECS executor metrics are being kept in separate PRs.
Tests:
- `uv run ruff format --check providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py providers/edge3/tests/unit/edge3/executors/test_edge_executor.py`
- `uv run ruff check providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py providers/edge3/tests/unit/edge3/executors/test_edge_executor.py`
- `git diff --check`
- `uv run pytest providers/edge3/tests/unit/edge3/executors/test_edge_executor.py -q`
- `breeze run pytest providers/edge3/tests/unit/edge3/executors/test_edge_executor.py -q`
- `uvx prek run --from-ref upstream/main --stage pre-commit`
Results:
- ruff format/check passed
- diff check clean
- `20 passed, 1 warning`
- pre-commit stage passed
Related: #68996
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes - OpenAI Codex
Generated-by: OpenAI Codex following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
Drafted-by: OpenAI Codex (no human review before posting)
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "shivaam (via GitHub)" <gi...@apache.org>.
shivaam commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484991975
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
Review Comment:
It will be in the follow up PR
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3483035608
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
I would add this here:
```
@pytest.mark.skipif(
not AIRFLOW_V_3_2_PLUS,
reason="team_name is only available in Airflow 3.3+",
)
```
I would double-check the exact version with @ferruzzi. Looking at this PR:
https://github.com/apache/airflow/pull/55003
It looks like `team_name` was added to `BaseExecutor` just before 3.1 was released but I am not sure if that means it is officially supported for 3.1. So it could be either `not AIRFLOW_V_3_1_PLUS` or `not AIRFLOW_V_3_2_PLUS`
Edit: I am doing not AIRFLOW_V_3_1_PLUS in PR #69046. So maybe it is best to follow that?
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
I would add this here:
```
@pytest.mark.skipif(
not AIRFLOW_V_3_2_PLUS,
reason="team_name is only available in Airflow 3.3+",
)
```
I would double-check the exact version with @ferruzzi. Looking at this PR:
https://github.com/apache/airflow/pull/55003
It looks like `team_name` was added to `BaseExecutor` just before 3.1 was released but I am not sure if that means it is officially supported for 3.1. So it could be either `not AIRFLOW_V_3_1_PLUS` or `not AIRFLOW_V_3_2_PLUS`
Edit: I am doing `not AIRFLOW_V_3_1_PLUS` in PR #69046. So maybe it is best to follow that?
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484404127
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
@@ -340,7 +341,7 @@ def _purge_jobs(self, session: Session) -> bool:
@provide_session
def sync(self, *, session: Session = NEW_SESSION) -> None:
"""Sync will get called periodically by the heartbeat method."""
- with Stats.timer("edge_executor.sync.duration"):
+ with Stats.timer("edge_executor.sync.duration", tags=prune_dict({"team_name": self.team_name})):
Review Comment:
Good catch, I didn't see that in the diff and assumed it wasn't there. That's on me, thanks. Resolving.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484117644
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
@@ -340,7 +341,7 @@ def _purge_jobs(self, session: Session) -> bool:
@provide_session
def sync(self, *, session: Session = NEW_SESSION) -> None:
"""Sync will get called periodically by the heartbeat method."""
- with Stats.timer("edge_executor.sync.duration"):
+ with Stats.timer("edge_executor.sync.duration", tags=prune_dict({"team_name": self.team_name})):
Review Comment:
Looks like Edge has support for 3.0+; self.team_name was added in 3.1 so this could be a problem. This should be safer:
```suggestion
with Stats.timer("edge_executor.sync.duration", tags=prune_dict({"team_name": getattr(self, "team_name", None)}})):
```
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
Review Comment:
It should be done, but it falls under the edge_worker metrics which he said he'll do in another batch, which is fair. You could argue it's the same file and may as well do it now, or you could argue to keep related changes bundled; I'm indifferent as long as it gets done.
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
This part is always tricky. I am pretty sure the right answer is `not AIRFLOW_V_3_1_PLUS`.
Edge's airflow version support is `apache-airflow>=3.0.0,!=3.1.0` and team_name doesn't exist on 3.0, so we should use `not AIRFLOW_V_3_2_PLUS` on this one, but 3.1+ in the others (unless they also exclude 3.1 explicitly)
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal merged PR #69005:
URL: https://github.com/apache/airflow/pull/69005
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3483061423
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
Review Comment:
Are we sure we don't want to tag this one? My understanding is that this metric (if tagged by team) could help measure workload distribution across teams. Doesn't make sense to exclude it. But check with @ferruzzi first.
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
I would add this here:
```
@pytest.mark.skipif(
not AIRFLOW_V_3_2_PLUS,
reason="team_name is only available in Airflow 3.3+",
)
```
I would double-check the exact version with @ferruzzi. Looking at this PR:
https://github.com/apache/airflow/pull/55003
It looks like `team_name` was added to `BaseExecutor` just before 3.1 was released but I am not sure if that means it is officially supported for 3.1. So it could be either `not AIRFLOW_V_3_1_PLUS` or `not AIRFLOW_V_3_2_PLUS`
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484098105
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
Review Comment:
I might be overly-nitpicking, but these mat as well be a parameterized test like the examples in core.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484299246
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
Review Comment:
Okay. It's up to him.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484098105
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
Review Comment:
I might be overly-nitpicking, but these may as well be a parameterized test like the examples in core.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "shivaam (via GitHub)" <gi...@apache.org>.
shivaam commented on PR #69005:
URL: https://github.com/apache/airflow/pull/69005#issuecomment-4814709476
Thanks @ferruzzi @SameerMesiah97 .
I updated the PR to match the existing Edge executor multi-team test pattern:
- added the `AIRFLOW_V_3_2_PLUS` guard for the `EdgeExecutor(team_name=...)` metric test
- parameterized the team/no-team timer assertions
- kept `prune_dict({"team_name": self.team_name})` so the no-team path continues to emit `tags={}` rather than `team_name=None`
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3483035608
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
I would add this here:
```
@pytest.mark.skipif(
not AIRFLOW_V_3_2_PLUS,
reason="team_name is only available in Airflow 3.2+",
)
```
I would double-check the exact version with @ferruzzi. Looking at this PR:
https://github.com/apache/airflow/pull/55003
It looks like `team_name` was added to `BaseExecutor` just before 3.1 was released but I am not sure if that means it is officially supported for 3.1. So it could be either `not AIRFLOW_V_3_1_PLUS` or `not AIRFLOW_V_3_2_PLUS`
Edit: I am doing `not AIRFLOW_V_3_1_PLUS` in PR #69046. So maybe it is best to follow that?
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484285153
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
+ @patch(f"{Stats.__module__}.Stats.timer")
Review Comment:
This part is always tricky. I am pretty sure the right answer is `not AIRFLOW_V_3_1_PLUS` in general, but Edge's airflow version support is `apache-airflow>=3.0.0,!=3.1.0`. Since team_name doesn't exist on 3.0, and the provider doesn't support 3.1.0, I think we should use `not AIRFLOW_V_3_2_PLUS` on this one, and 3.1+ in the others (unless they also exclude 3.1 explicitly)
(Edited for clarity)
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484365213
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
@@ -340,7 +341,7 @@ def _purge_jobs(self, session: Session) -> bool:
@provide_session
def sync(self, *, session: Session = NEW_SESSION) -> None:
"""Sync will get called periodically by the heartbeat method."""
- with Stats.timer("edge_executor.sync.duration"):
+ with Stats.timer("edge_executor.sync.duration", tags=prune_dict({"team_name": self.team_name})):
Review Comment:
I am just wondering why this is needed if we have this already on lines 75-76:
```
if not hasattr(self, "team_name"):
self.team_name = None
```
In the older versions where `BaseExecutor` has no `team_name`, won't `self.team_name` default to `None` and this would render the `getattr(self, "team_name", None)` redundant? I am asking this here because I am handling it the exact same way as the Edge Executor does right now in the Kubernetes Executor i.e. default to a `None` value for `self.team_name` at object level if it can not be inherited from `BaseExecutor`.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "SameerMesiah97 (via GitHub)" <gi...@apache.org>.
SameerMesiah97 commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484365213
##########
providers/edge3/src/airflow/providers/edge3/executors/edge_executor.py:
##########
@@ -340,7 +341,7 @@ def _purge_jobs(self, session: Session) -> bool:
@provide_session
def sync(self, *, session: Session = NEW_SESSION) -> None:
"""Sync will get called periodically by the heartbeat method."""
- with Stats.timer("edge_executor.sync.duration"):
+ with Stats.timer("edge_executor.sync.duration", tags=prune_dict({"team_name": self.team_name})):
Review Comment:
I am just wondering why this is needed if we have this already on lines 75-76:
```
if not hasattr(self, "team_name"):
self.team_name = None
```
In the older versions where BaseExecutor has no `team_name`, won't `self.team_name` default to `None` and this would render the `getattr(self, "team_name", None)` redundant? I am asking this here because I am handling it the exact same way as the Edge Executor does right now in the Kubernetes Executor i.e. default to a `None` value for `self.team_name` at object level if it can not be inherited from `BaseExecutor`.
--
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] Add team_name tag to Edge executor sync metric [airflow]
Posted by "shivaam (via GitHub)" <gi...@apache.org>.
shivaam commented on code in PR #69005:
URL: https://github.com/apache/airflow/pull/69005#discussion_r3484987505
##########
providers/edge3/tests/unit/edge3/executors/test_edge_executor.py:
##########
@@ -120,6 +120,38 @@ def test_sync_orphaned_tasks(self, mock_stats_incr):
assert jobs[0].task_id == "started_running_orphaned"
assert jobs[0].state == TaskInstanceState.REMOVED
Review Comment:
less code is better in this case. Changed to parametrized 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