Skip to content

Commit 7abe4f7

Browse files
jedcunninghamcursoragent
authored andcommitted
Fix timer.duration unit labels in logs (apache#61824)
Update timer.duration labels and examples to milliseconds, and fix the OTel timing docstring to match runtime behavior. Historical context: apache#39908 introduced milliseconds alignment with a compatibility flag, and apache#43975 removed that flag and standardized milliseconds everywhere. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 7b7e41e commit 7abe4f7

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

airflow-core/src/airflow/jobs/scheduler_job_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,12 +1666,12 @@ def _run_scheduler_loop(self) -> None:
16661666
next_event = timers.run(blocking=False)
16671667
self.log.debug("Next timed event is in %f", next_event)
16681668

1669-
self.log.debug("Ran scheduling loop in %.2f seconds", timer.duration)
1669+
self.log.debug("Ran scheduling loop in %.2f ms", timer.duration)
16701670
if span.is_recording():
16711671
span.add_event(
16721672
name="Ran scheduling loop",
16731673
attributes={
1674-
"duration in seconds": timer.duration,
1674+
"duration in ms": timer.duration,
16751675
},
16761676
)
16771677

airflow-core/src/airflow/plugins_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __register_plugins(plugin_instances: list[AirflowPlugin], errors: dict[str,
128128
if not settings.LAZY_LOAD_PROVIDERS:
129129
__register_plugins(*_load_providers_plugins())
130130

131-
log.debug("Loading %d plugin(s) took %.2f seconds", len(plugins), timer.duration)
131+
log.debug("Loading %d plugin(s) took %.2f ms", len(plugins), timer.duration)
132132
return plugins, import_errors
133133

134134

contributing-docs/05_pull_requests.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ or to time but not send a metric:
326326
with Stats.timer() as timer:
327327
...
328328
329-
log.info("Code took %.3f seconds", timer.duration)
329+
log.info("Code took %.3f ms", timer.duration)
330330
331331
For full docs on ``timer()`` check out `shared/observability/src/airflow_shared/observability/metrics/base_stats_logger.py`_.
332332

shared/observability/src/airflow_shared/observability/metrics/otel_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def timing(
274274
*,
275275
tags: Attributes = None,
276276
) -> None:
277-
"""OTel does not have a native timer, stored as a Gauge whose value is number of seconds elapsed."""
277+
"""OTel does not have a native timer, stored as a Gauge whose value is elapsed ms."""
278278
if self.metrics_validator.test(stat) and name_is_otel_safe(self.prefix, stat):
279279
if isinstance(dt, datetime.timedelta):
280280
dt = dt.total_seconds() * 1000.0

task-sdk/src/airflow/sdk/io/fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _register_filesystems() -> Mapping[
6767
raise ImportError(f"Filesystem {fs_module_name} does not have a get_fs method")
6868
scheme_to_fs[scheme] = method
6969

70-
log.debug("loading filesystems from providers took %.3f seconds", timer.duration)
70+
log.debug("loading filesystems from providers took %.3f ms", timer.duration)
7171
return scheme_to_fs
7272

7373

task-sdk/src/airflow/sdk/plugins_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __register_plugins(plugin_instances: list[AirflowPlugin], errors: dict[str,
111111
if not settings.LAZY_LOAD_PROVIDERS:
112112
__register_plugins(*_load_providers_plugins())
113113

114-
log.debug("Loading %d plugin(s) took %.2f seconds", len(plugins), timer.duration)
114+
log.debug("Loading %d plugin(s) took %.2f ms", len(plugins), timer.duration)
115115
return plugins, import_errors
116116

117117

task-sdk/src/airflow/sdk/serde/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def _register():
406406
log.debug("registering %s for stringifying", c_qualname)
407407
_stringifiers[c_qualname] = module
408408

409-
log.debug("loading serializers took %.3f seconds", timer.duration)
409+
log.debug("loading serializers took %.3f ms", timer.duration)
410410

411411

412412
@functools.cache

0 commit comments

Comments
 (0)