|
18 | 18 | import certifi
|
19 | 19 | import urllib3
|
20 | 20 | from .log import logger as log
|
| 21 | +from .util import package_version |
21 | 22 |
|
22 | 23 |
|
23 | 24 | PY2 = sys.version_info[0] == 2
|
@@ -138,7 +139,7 @@ def __init__(self, **kwds):
|
138 | 139 | log.warn("APIClient: API token or Base URL not set. No-op mode")
|
139 | 140 | else:
|
140 | 141 | self.api_key = "apiToken %s" % self.api_token
|
141 |
| - self.headers = {'Authorization': self.api_key} |
| 142 | + self.headers = {'Authorization': self.api_key, 'User-Agent': 'instana-python-sensor v' + package_version()} |
142 | 143 | self.http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED',
|
143 | 144 | ca_certs=certifi.where())
|
144 | 145 |
|
@@ -271,18 +272,18 @@ def upsert_service_extraction_configs(self, service_extraction_config):
|
271 | 272 | return self.put(path, service_extraction_config)
|
272 | 273 |
|
273 | 274 | def snapshot(self, id, timestamp=None):
|
274 |
| - if timestamp is None: |
275 |
| - timestamp = self.ts_now() |
| 275 | + params = {} |
| 276 | + if timestamp is not None: |
| 277 | + params['time'] = timestamp |
276 | 278 |
|
277 |
| - params = {'time': timestamp} |
278 | 279 | path = "/api/snapshots/%s" % id
|
279 | 280 | return self.get(path, query_args=params)
|
280 | 281 |
|
281 | 282 | def snapshots(self, query, timestamp=None, size=5):
|
282 |
| - if timestamp is None: |
283 |
| - timestamp = self.ts_now() |
| 283 | + params = {'q': query, 'size': size} |
| 284 | + if timestamp is not None: |
| 285 | + params['time'] = timestamp |
284 | 286 |
|
285 |
| - params = {'time': timestamp, 'q': query, 'size': size} |
286 | 287 | path = "/api/snapshots"
|
287 | 288 | return self.get(path, query_args=params)
|
288 | 289 |
|
|
0 commit comments