Skip to content

fix: Fix non-UTC timestamps#3461

Merged
szokeasaurusrex merged 2 commits into
masterfrom
szokeasaurusrex/fix-timestamps
Aug 27, 2024
Merged

fix: Fix non-UTC timestamps#3461
szokeasaurusrex merged 2 commits into
masterfrom
szokeasaurusrex/fix-timestamps

Conversation

@szokeasaurusrex

@szokeasaurusrex szokeasaurusrex commented Aug 26, 2024

Copy link
Copy Markdown
Member

Fixes a bug where all datetime timestamps in an event payload were serialized as if they were UTC timestamps, even if they were non-UTC timestamps, completely ignoring the timezone. Now, we convert all datetime objects to UTC before formatting them as a UTC timestamp.

Fixes #3453.

@codecov

codecov Bot commented Aug 26, 2024

Copy link
Copy Markdown

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
11521 4 11517 1636
View the top 3 failed tests by shortest run time
tests.integrations.aws_lambda.test_aws test_init_error[python3.9]
Stack Traces | 15.8s run time
.../integrations/aws_lambda/test_aws.py:334: in test_init_error
    (event,) = envelope_items
E   ValueError: not enough values to unpack (expected 1, got 0)
tests.integrations.aws_lambda.test_aws test_init_error[python3.10]
Stack Traces | 15.8s run time
.../integrations/aws_lambda/test_aws.py:334: in test_init_error
    (event,) = envelope_items
E   ValueError: not enough values to unpack (expected 1, got 0)
tests.integrations.aws_lambda.test_aws test_init_error[python3.11]
Stack Traces | 15.9s run time
.../integrations/aws_lambda/test_aws.py:334: in test_init_error
    (event,) = envelope_items
E   ValueError: not enough values to unpack (expected 1, got 0)

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

@szokeasaurusrex

Copy link
Copy Markdown
Member Author

Looks like this maybe does not work on Python <3.12

@szokeasaurusrex

Copy link
Copy Markdown
Member Author

Yeah, seems that %:z was introduced in 3.12, since it is not mentioned in the 3.11 docs

@szokeasaurusrex
szokeasaurusrex marked this pull request as draft August 27, 2024 06:57
Comment thread sentry_sdk/utils.py Outdated
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/fix-timestamps branch 2 times, most recently from a456a68 to d7669f9 Compare August 27, 2024 09:28
@szokeasaurusrex
szokeasaurusrex marked this pull request as ready for review August 27, 2024 09:29
Comment thread tests/test_utils.py
Comment thread sentry_sdk/utils.py
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/fix-timestamps branch from d7669f9 to efc8e56 Compare August 27, 2024 09:43
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/fix-timestamps branch from efc8e56 to 79e04c4 Compare August 27, 2024 10:55
Fixes a bug where all `datetime` timestamps in an event payload were serialized as if they were UTC timestamps, even if they were non-UTC timestamps, completely ignoring the timezone. Now, we convert all datetime objects to UTC before formatting them as a UTC timestamp.

Fixes #3453
@szokeasaurusrex
szokeasaurusrex force-pushed the szokeasaurusrex/fix-timestamps branch from 79e04c4 to 99be567 Compare August 27, 2024 10:55
@szokeasaurusrex
szokeasaurusrex enabled auto-merge (squash) August 27, 2024 11:01
@szokeasaurusrex
szokeasaurusrex merged commit bde87ff into master Aug 27, 2024
@szokeasaurusrex
szokeasaurusrex deleted the szokeasaurusrex/fix-timestamps branch August 27, 2024 14:48
arjennienhuis pushed a commit to arjennienhuis/sentry-python that referenced this pull request Sep 30, 2024
Fixes a bug where all `datetime` timestamps in an event payload were serialized as if they were UTC timestamps, even if they were non-UTC timestamps, completely ignoring the timezone. Now, we convert all datetime objects to UTC before formatting them as a UTC timestamp.

Fixes getsentry#3453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix datetime serialization for non-UTC timestamps

3 participants