Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dmacvicar
Copy link
Contributor

Motivation

I was a bit annoyed to see this every single time I ran a test:

/home/work/src/localstack/localstack/localstack-core/localstack/utils/analytics/service_request_aggregator.py:104:
  DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-
  aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    self._period_start_time = datetime.datetime.utcnow()

Changes

Basically utcnow is deprecated. The code was creating a naive datetime just to calculate an interval, and then attaching it to the payload adding a Zulu marker.

I just create now the forced UTC equivalent from the beginning datetime.datetime.now(datetime.UTC). I am not sure if the backend would work with the standard isoformat(), so I kept the Zulu based format.

This is a critical piece of analytics, so let me know if I miss something important in the picture.

Tests

Just made sure that tests/unit/utils/analytics/test_service_call_aggregator.py passes. It does not test the payload, but at least parses it and checks the times are relative to each other.

Related

There are other pieces of the code that use the deprecated method, which is a nice code janitor job. Expect more.

@dmacvicar dmacvicar requested a review from thrau as a code owner November 12, 2025 16:21
@dmacvicar dmacvicar added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes labels Nov 12, 2025
@github-actions
Copy link

Test Results - Preflight, Unit

22 309 tests  ±0   20 555 ✅ ±0   6m 14s ⏱️ -4s
     1 suites ±0    1 754 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 17964c4. ± Comparison against base commit c1abe8d.

@github-actions
Copy link

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 19s ⏱️ -9s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 17964c4. ± Comparison against base commit c1abe8d.

@github-actions
Copy link

Test Results (amd64) - Integration, Bootstrap

    5 files      5 suites   2h 41m 56s ⏱️
5 312 tests 4 773 ✅ 539 💤 0 ❌
5 318 runs  4 773 ✅ 545 💤 0 ❌

Results for commit 17964c4.

@github-actions
Copy link

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   2h 3m 3s ⏱️ -39s
4 938 tests ±0  4 559 ✅ ±0  379 💤 ±0  0 ❌ ±0 
4 940 runs  ±0  4 559 ✅ ±0  381 💤 ±0  0 ❌ ±0 

Results for commit 17964c4. ± Comparison against base commit c1abe8d.

@dmacvicar dmacvicar added the notes: skip Pull request does not have to be mentioned in the release notes label Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants