getsentry / getsentry/sentry

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version.

Open
#95,021 6 comments 0 reactions 0 assignees View on GitHub
Product Area: Performance
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
21h 10m
Merged PRs (30d)
635

Description

### Self-Hosted Version

25.6.1

### CPU Architecture

x86_64

### Docker Version

Docker version 28.1.1, build 4eba377

### Docker Compose Version

Docker Compose version v2.35.1

### Machine Specification

- [x] My system meets the minimum system requirements of Sentry

### Steps to Reproduce

-

### Expected Result

-

### Actual Result

```
worker-1 | 13:30:00 [WARNING] py.warnings: /usr/src/sentry/src/sentry/dynamic_sampling/tasks/common.py:250: 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).
worker-1 | Column("timestamp"), Op.GTE, datetime.utcnow() - self.time_interval
worker-1 |
worker-1 | 13:30:00 [WARNING] py.warnings: /usr/src/sentry/src/sentry/dynamic_sampling/tasks/common.py:252: 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).
worker-1 | Condition(Column("timestamp"), Op.LT, datetime.utcnow()),
```

### Event ID

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in src/sentry/dynamic_sampling/tasks/common.py at the reported lines 250 and 252, where the worker constructs the timestamp conditions and emits the deprecation warnings. Check the surrounding task logic and existing tests, then verify that the worker no longer produces these warnings while retaining the intended UTC time bounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
57/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.