You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ferruzzi (via GitHub)" <gi...@apache.org> on 2023/06/14 03:55:53 UTC

[GitHub] [airflow] ferruzzi commented on a diff in pull request #31859: AIP-49 OTel Timers

ferruzzi commented on code in PR #31859:
URL: https://github.com/apache/airflow/pull/31859#discussion_r1228953001


##########
airflow/metrics/otel_logger.py:
##########
@@ -233,27 +255,32 @@ def gauge(
         if self.metrics_validator.test(stat):
             self.metrics_map.set_gauge_value(full_name(prefix=self.prefix, name=stat), value, delta, tags)
 
-    @validate_stat
     def timing(
         self,
         stat: str,
         dt: DeltaType,
         *,
         tags: Attributes = None,
     ) -> None:
-        warnings.warn(f"Create timer {stat}: OpenTelemetry Timers are not yet implemented.")
+        """
+        OpenTelemetry does not have a native timer, we will store
+        them as a Gauge whose value represents the seconds elapsed.
+        """
+        if self.metrics_validator.test(stat) and name_is_otel_safe(self.prefix, stat):
+            if isinstance(dt, datetime.timedelta):
+                dt = dt.total_seconds()
+            self.metrics_map.set_gauge_value(full_name(prefix=self.prefix, name=stat), float(dt), False, tags)
         return None

Review Comment:
   🤦



-- 
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