|
13 | 13 |
|
14 | 14 | log = get_logger(__name__) |
15 | 15 |
|
16 | | -TRACE_COUNT_HEADER = 'X-Datadog-Trace-Count' |
17 | 16 |
|
18 | 17 | _VERSIONS = {'v0.4': {'traces': '/v0.4/traces', |
19 | 18 | 'services': '/v0.4/services', |
@@ -100,6 +99,9 @@ class API(object): |
100 | 99 | """ |
101 | 100 | Send data to the trace agent using the HTTP protocol and JSON format |
102 | 101 | """ |
| 102 | + |
| 103 | + TRACE_COUNT_HEADER = 'X-Datadog-Trace-Count' |
| 104 | + |
103 | 105 | def __init__(self, hostname, port, headers=None, encoder=None, priority_sampling=False): |
104 | 106 | self.hostname = hostname |
105 | 107 | self.port = int(port) |
@@ -169,14 +171,12 @@ def send_traces(self, traces): |
169 | 171 | def send_services(self, *args, **kwargs): |
170 | 172 | return |
171 | 173 |
|
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 | + |
173 | 178 | conn = httplib.HTTPConnection(self.hostname, self.port) |
174 | 179 | try: |
175 | | - headers = self._headers |
176 | | - if count: |
177 | | - headers = dict(self._headers) |
178 | | - headers[TRACE_COUNT_HEADER] = str(count) |
179 | | - |
180 | 180 | conn.request('PUT', endpoint, data, headers) |
181 | 181 |
|
182 | 182 | # Parse the HTTPResponse into an API.Response |
|
0 commit comments