Skip to content

Commit e49a254

Browse files
ref: upgrade datadog to a typed version
1 parent 60f2390 commit e49a254

File tree

7 files changed

+23
-12
lines changed

7 files changed

+23
-12
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ module = [
9797
"confluent_kafka.*",
9898
"csp.middleware.*",
9999
"cssselect.*",
100-
"datadog.*",
101100
"django_zero_downtime_migrations.backends.postgres.schema.*",
102101
"docker.*",
103102
"email_reply_parser.*",

requirements-base.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ click>=8.0.4
99
confluent-kafka>=2.1.1
1010
croniter>=1.3.10
1111
cssselect>=1.0.3
12-
datadog>=0.29.3
12+
datadog>=0.46.0
1313
django-crispy-forms>=1.14.0
1414
django-csp>=3.7
1515
django-pg-zero-downtime-migrations>=0.13

requirements-dev-frozen.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ croniter==1.3.10
3535
cryptography==39.0.1
3636
cssselect==1.0.3
3737
cssutils==2.4.0
38-
datadog==0.29.3
39-
decorator==5.1.1
38+
datadog==0.46.0
4039
dictpath==0.1.3
4140
distlib==0.3.4
4241
django==3.2.20

requirements-frozen.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ croniter==1.3.10
3030
cryptography==39.0.1
3131
cssselect==1.0.3
3232
cssutils==2.4.0
33-
datadog==0.29.3
34-
decorator==5.1.1
33+
datadog==0.46.0
3534
django==3.2.20
3635
django-crispy-forms==1.14.0
3736
django-csp==3.7

src/sentry/metrics/datadog.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from typing import Any, Optional, Union
44

5-
from datadog import ThreadStats, initialize
5+
from datadog import initialize
6+
from datadog.threadstats.base import ThreadStats
67
from datadog.util.hostname import get_hostname
78

89
from sentry.utils.cache import memoize
@@ -17,7 +18,7 @@ def __init__(self, prefix: Optional[str] = None, **kwargs: Any) -> None:
1718
if "host" in kwargs:
1819
self.host = kwargs.pop("host")
1920
else:
20-
self.host = get_hostname()
21+
self.host = get_hostname(hostname_from_config=True)
2122
initialize(**kwargs)
2223
super().__init__(prefix=prefix)
2324

src/sentry/metrics/dogstatsd.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Any, Optional, Union
22

3-
from datadog import initialize, statsd
3+
from datadog import initialize
4+
from datadog.dogstatsd.base import statsd
45

56
from .base import MetricsBackend, Tags
67

tests/sentry/metrics/test_datadog.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,31 @@ def setUp(self):
1414
def test_incr(self, mock_incr):
1515
self.backend.incr("foo", instance="bar")
1616
mock_incr.assert_called_once_with(
17-
"sentrytest.foo", 1, sample_rate=1, tags=["instance:bar"], host=get_hostname()
17+
"sentrytest.foo",
18+
1,
19+
sample_rate=1,
20+
tags=["instance:bar"],
21+
host=get_hostname(hostname_from_config=True),
1822
)
1923

2024
@patch("datadog.threadstats.base.ThreadStats.timing")
2125
def test_timing(self, mock_timing):
2226
self.backend.timing("foo", 30, instance="bar")
2327
mock_timing.assert_called_once_with(
24-
"sentrytest.foo", 30, sample_rate=1, tags=["instance:bar"], host=get_hostname()
28+
"sentrytest.foo",
29+
30,
30+
sample_rate=1,
31+
tags=["instance:bar"],
32+
host=get_hostname(hostname_from_config=True),
2533
)
2634

2735
@patch("datadog.threadstats.base.ThreadStats.gauge")
2836
def test_gauge(self, mock_gauge):
2937
self.backend.gauge("foo", 5, instance="bar")
3038
mock_gauge.assert_called_once_with(
31-
"sentrytest.foo", 5, sample_rate=1, tags=["instance:bar"], host=get_hostname()
39+
"sentrytest.foo",
40+
5,
41+
sample_rate=1,
42+
tags=["instance:bar"],
43+
host=get_hostname(hostname_from_config=True),
3244
)

0 commit comments

Comments
 (0)