Skip to content

Commit

Permalink
feat: future proofing the tag used to trigger run metrics collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mlarose committed Oct 8, 2024
1 parent 61bff7c commit 710652d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python_modules/dagster/dagster/_cli/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
get_python_environment_entry_point,
)
from dagster._core.storage.dagster_run import DagsterRun, DagsterRunStatus
from dagster._core.storage.tags import (
RUN_METRIC_TAGS,
RUN_METRICS_POLLING_INTERVAL_TAG,
RUN_METRICS_PYTHON_RUNTIME_TAG,
)
from dagster._core.types.loadable_target_origin import LoadableTargetOrigin
from dagster._core.utils import FuturesAwareThreadPoolExecutor
from dagster._grpc import DagsterGrpcClient, DagsterGrpcServer
Expand Down Expand Up @@ -87,11 +92,11 @@ def send_to_buffer(event):


def _should_start_metrics_thread(dagster_run: DagsterRun) -> bool:
return get_boolean_tag_value(dagster_run.tags.get("dagster/run_metrics"))
return any(get_boolean_tag_value(dagster_run.tags.get(tag)) for tag in RUN_METRIC_TAGS)


def _enable_python_runtime_metrics(dagster_run: DagsterRun) -> bool:
return get_boolean_tag_value(dagster_run.tags.get("dagster/python_runtime_metrics"))
return get_boolean_tag_value(dagster_run.tags.get(RUN_METRICS_PYTHON_RUNTIME_TAG))


def _metrics_polling_interval(
Expand All @@ -100,7 +105,7 @@ def _metrics_polling_interval(
try:
return float(
dagster_run.tags.get(
"dagster/run_metrics_polling_interval_seconds",
RUN_METRICS_POLLING_INTERVAL_TAG,
DEFAULT_RUN_METRICS_POLL_INTERVAL_SECONDS,
)
)
Expand Down
3 changes: 3 additions & 0 deletions python_modules/dagster/dagster/_core/storage/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
f"{SYSTEM_TAG_PREFIX}run_metrics",
]

RUN_METRICS_POLLING_INTERVAL_TAG = f"{HIDDEN_TAG_PREFIX}run_metrics_polling_interval"
RUN_METRICS_PYTHON_RUNTIME_TAG = f"{HIDDEN_TAG_PREFIX}python_runtime_metrics"


class TagType(Enum):
# Custom tag provided by a user
Expand Down

0 comments on commit 710652d

Please sign in to comment.