Skip to content

Commit

Permalink
Add 'paused' label to 'prefect_info_deployments' metric (#47)
Browse files Browse the repository at this point in the history
* Add 'paused' label to 'prefect_info_deployments' metric

- Adds the 'paused' label to the 'prefect_info_deployments' metric
- Also uses this value for the 'is_schedule_active' label, which is
  deprecated and always returns Null.
- Updates the docker-compose testing setup to use Prefect 3

Related to PLA-224

* Negate the 'paused' value for 'is_schedule_active'

'is_schedule_active' is the opposite of 'paused', so if we're using the
'paused' value we need to negate it.

* Fix null case

* Fix logic for negating value

If we get "null" back, we don't want to `not` that because we'll always
get False instead of "null". This separates the logic and only negates
the value if we don't get "null" back.
  • Loading branch information
mitchnielsen authored Oct 17, 2024
1 parent ee961e8 commit 2ca2eb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
prefect:
image: prefecthq/prefect:2-latest
image: prefecthq/prefect:3-latest
ports:
- "4200:4200"
environment:
Expand Down
13 changes: 12 additions & 1 deletion metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def collect(self):
"is_schedule_active",
"deployment_name",
"path",
"paused",
"work_pool_name",
"work_queue_name",
"status",
Expand All @@ -122,15 +123,25 @@ def collect(self):
"null",
)

# The "is_schedule_active" field is deprecated, and always returns
# "null". For backward compatibility, we will populate the value of
# this label with the "paused" field.
is_schedule_active = deployment.get("paused", "null")
if is_schedule_active != "null":
# Negate the value we get from "paused" because "is_schedule_active"
# is the opposite of "paused".
is_schedule_active = not is_schedule_active

prefect_info_deployments.add_metric(
[
str(deployment.get("created", "null")),
str(deployment.get("flow_id", "null")),
str(flow_name),
str(deployment.get("id", "null")),
str(deployment.get("is_schedule_active", "null")),
str(is_schedule_active),
str(deployment.get("name", "null")),
str(deployment.get("path", "null")),
str(deployment.get("paused", "null")),
str(deployment.get("work_pool_name", "null")),
str(deployment.get("work_queue_name", "null")),
str(deployment.get("status", "null")),
Expand Down

0 comments on commit 2ca2eb1

Please sign in to comment.