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