Skip to content

Commit f85cc44

Browse files
authored
fix(profiling): use timeout attribute (#1373)
The timeout defined in the HTTP exporter was never used and system default was used instead.
1 parent ff380f8 commit f85cc44

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ddtrace/profiling/exporter/http.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import logging
66
import os
77
import platform
8+
import socket
89
import uuid
910

1011
from ddtrace.utils import deprecation
@@ -200,6 +201,6 @@ def export(self, events, start_time_ns, end_time_ns):
200201
req = request.Request(self.endpoint, data=body, headers=headers)
201202

202203
try:
203-
request.urlopen(req)
204-
except (error.HTTPError, error.URLError, http_client.HTTPException) as e:
204+
request.urlopen(req, timeout=self.timeout)
205+
except (error.HTTPError, error.URLError, http_client.HTTPException, socket.timeout) as e:
205206
raise UploadFailed(e)

tests/profiling/exporter/test_http.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import collections
33
import email.parser
44
import platform
5+
import socket
56
import threading
67
import time
78

@@ -11,7 +12,6 @@
1112
from ddtrace.vendor import six
1213
from ddtrace.vendor.six.moves import BaseHTTPServer
1314
from ddtrace.vendor.six.moves import http_client
14-
from ddtrace.vendor.six.moves.urllib import error
1515

1616
import ddtrace
1717
from ddtrace.profiling.exporter import http
@@ -172,7 +172,7 @@ def test_export_timeout(endpoint_test_timeout_server):
172172
with pytest.raises(http.UploadFailed) as t:
173173
exp.export(test_pprof.TEST_EVENTS, 0, 1)
174174
e = t.value.exception
175-
assert isinstance(e, error.HTTPError)
175+
assert isinstance(e, socket.timeout)
176176

177177

178178
def test_export_reset(endpoint_test_reset_server):

0 commit comments

Comments
 (0)