Skip to content

Commit a61b6b8

Browse files
authored
Merge pull request #956 from jd/simplify-api-count
api: simplify _put codepath
2 parents 6321d3c + fd8c25a commit a61b6b8

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ddtrace/api.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
log = get_logger(__name__)
1515

16-
TRACE_COUNT_HEADER = 'X-Datadog-Trace-Count'
1716

1817
_VERSIONS = {'v0.4': {'traces': '/v0.4/traces',
1918
'services': '/v0.4/services',
@@ -100,6 +99,9 @@ class API(object):
10099
"""
101100
Send data to the trace agent using the HTTP protocol and JSON format
102101
"""
102+
103+
TRACE_COUNT_HEADER = 'X-Datadog-Trace-Count'
104+
103105
def __init__(self, hostname, port, headers=None, encoder=None, priority_sampling=False):
104106
self.hostname = hostname
105107
self.port = int(port)
@@ -169,14 +171,12 @@ def send_traces(self, traces):
169171
def send_services(self, *args, **kwargs):
170172
return
171173

172-
def _put(self, endpoint, data, count=0):
174+
def _put(self, endpoint, data, count):
175+
headers = self._headers.copy()
176+
headers[self.TRACE_COUNT_HEADER] = str(count)
177+
173178
conn = httplib.HTTPConnection(self.hostname, self.port)
174179
try:
175-
headers = self._headers
176-
if count:
177-
headers = dict(self._headers)
178-
headers[TRACE_COUNT_HEADER] = str(count)
179-
180180
conn.request('PUT', endpoint, data, headers)
181181

182182
# Parse the HTTPResponse into an API.Response

0 commit comments

Comments
 (0)