diff --git a/airflow/metrics/validators.py b/airflow/metrics/validators.py index 5b7e74aa2d104..fd43a8adf3bc9 100644 --- a/airflow/metrics/validators.py +++ b/airflow/metrics/validators.py @@ -63,7 +63,7 @@ class MetricNameLengthExemptionWarning(Warning): r"^ti.finish.(?P.*)\.(?P.*)\.(?P.*)$", r"^task_removed_from_dag\.(?P.*)$", r"^task_restored_to_dag\.(?P.*)$", - r"^task_instance_created-(?P.*)$", + r"^task_instance_created_(?P.*)$", r"^dag_processing\.last_run\.seconds_ago\.(?P.*)$", r"^pool\.open_slots\.(?P.*)$", r"^pool\.queued_slots\.(?P.*)$", diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py index 45989be15a07e..538cceede8b18 100644 --- a/airflow/models/dagrun.py +++ b/airflow/models/dagrun.py @@ -1187,7 +1187,7 @@ def _create_task_instances( session.bulk_save_objects(tasks) for task_type, count in created_counts.items(): - Stats.incr(f"task_instance_created-{task_type}", count, tags=self.stats_tags) + Stats.incr(f"task_instance_created_{task_type}", count, tags=self.stats_tags) # Same metric with tagging Stats.incr("task_instance_created", count, tags={**self.stats_tags, "task_type": task_type}) session.flush() diff --git a/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst b/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst index 4998fcb71d51e..23223486364c8 100644 --- a/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst +++ b/docs/apache-airflow/administration-and-deployment/logging-monitoring/metrics.rst @@ -164,7 +164,7 @@ Name Descripti ``task_removed_from_dag.`` Number of tasks removed for a given dag (i.e. task no longer exists in DAG) ``task_restored_to_dag.`` 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) -``task_instance_created-`` Number of tasks instances created for a given Operator +``task_instance_created_`` Number of tasks instances created for a given Operator ``triggers.blocked_main_thread`` Number of triggers that blocked the main thread (likely due to not being fully asynchronous) ``triggers.failed`` Number of triggers that errored before they could fire an event diff --git a/tests/core/test_otel_logger.py b/tests/core/test_otel_logger.py index 75f4ebdc802d5..1f04edd1bfe68 100644 --- a/tests/core/test_otel_logger.py +++ b/tests/core/test_otel_logger.py @@ -91,7 +91,7 @@ def test_invalid_stat_names_are_caught(self, invalid_stat_combo): self.meter.assert_not_called() def test_old_name_exception_works(self, caplog): - name = "task_instance_created-OperatorNameWhichIsSuperLongAndExceedsTheOpenTelemetryCharacterLimit" + name = "task_instance_created_OperatorNameWhichIsSuperLongAndExceedsTheOpenTelemetryCharacterLimit" assert len(name) > OTEL_NAME_MAX_LENGTH with pytest.warns(MetricNameLengthExemptionWarning): diff --git a/tests/models/test_dagrun.py b/tests/models/test_dagrun.py index ef0ae229efc01..024b9df3a1f32 100644 --- a/tests/models/test_dagrun.py +++ b/tests/models/test_dagrun.py @@ -984,7 +984,7 @@ def test_verify_integrity_task_start_and_end_date(Stats_incr, session, run_type, assert len(tis) == expected_tis Stats_incr.assert_any_call( - "task_instance_created-EmptyOperator", expected_tis, tags={"dag_id": "test", "run_type": run_type} + "task_instance_created_EmptyOperator", expected_tis, tags={"dag_id": "test", "run_type": run_type} ) Stats_incr.assert_any_call( "task_instance_created",