From f26f45d48378505281c6155973996dc907f86e17 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Tue, 5 Mar 2024 13:44:17 +0100 Subject: [PATCH 1/2] Fix python 3.12 deprecation warning utcfromtimestamp is deprecated replace with fromtimestamp with explict UTC timezone See https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp --- opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py index 37ca62b017c..c74ecd0c649 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/util/__init__.py @@ -23,7 +23,9 @@ def ns_to_iso_str(nanoseconds): """Get an ISO 8601 string from time_ns value.""" - ts = datetime.datetime.utcfromtimestamp(nanoseconds / 1e9) + ts = datetime.datetime.fromtimestamp( + nanoseconds / 1e9, tz=datetime.timezone.utc + ) return ts.strftime("%Y-%m-%dT%H:%M:%S.%fZ") From f1ad811aa423af66a9a4d06490a6383179a24121 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Tue, 5 Mar 2024 13:50:54 +0100 Subject: [PATCH 2/2] add changelog for 3751 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 276a5e9a037..c8e983f5ec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Fix python 3.12 deprecation warning + ([#3751](https://github.com/open-telemetry/opentelemetry-python/pull/3751)) + ## Version 1.23.0/0.44b0 (2024-02-23) - Use Attribute rather than boundattribute in logrecord