Коммит
7000e7abe0
|
@ -200,7 +200,18 @@ class TelemetryClient(object):
|
|||
data.id = str(uuid.uuid4())
|
||||
data.name = name
|
||||
data.start_time = start_time or datetime.datetime.utcnow().isoformat() + 'Z'
|
||||
data.duration = duration or 0
|
||||
|
||||
local_duration = duration or 0
|
||||
duration_parts = []
|
||||
for multiplier in [1000, 60, 60, 24]:
|
||||
duration_parts.append(local_duration % multiplier)
|
||||
local_duration //= multiplier
|
||||
|
||||
duration_parts.reverse()
|
||||
data.duration = '%02d:%02d:%02d.%03d' % tuple(duration_parts)
|
||||
if local_duration:
|
||||
data.duration = '%d.%s' % (local_duration, data.duration)
|
||||
|
||||
data.response_code = response_code or '200'
|
||||
data.success = success
|
||||
data.http_method = http_method or 'GET'
|
||||
|
|
|
@ -132,7 +132,7 @@ class TestTelemetryClient(unittest.TestCase):
|
|||
client.context.device = None
|
||||
client.track_request('test', 'http://tempuri.org', True, 'START_TIME', 13, '42', 'OPTIONS', { 'foo': 'bar' }, { 'x': 42 })
|
||||
client.flush()
|
||||
expected = '{"ver": 1, "name": "Microsoft.ApplicationInsights.Request", "time": "TIME_PLACEHOLDER", "sampleRate": 100.0, "iKey": "99999999-9999-9999-9999-999999999999", "tags": {"ai.internal.sdkVersion": "SDK_VERSION_PLACEHOLDER"}, "data": {"baseType": "RequestData", "baseData": {"ver": 2, "id": "ID_PLACEHOLDER", "name": "test", "startTime": "START_TIME", "duration": 13, "responseCode": "42", "success": true, "httpMethod": "OPTIONS", "url": "http://tempuri.org", "properties": {"foo": "bar"}, "measurements": {"x": 42}}}}'
|
||||
expected = '{"ver": 1, "name": "Microsoft.ApplicationInsights.Request", "time": "TIME_PLACEHOLDER", "sampleRate": 100.0, "iKey": "99999999-9999-9999-9999-999999999999", "tags": {"ai.internal.sdkVersion": "SDK_VERSION_PLACEHOLDER"}, "data": {"baseType": "RequestData", "baseData": {"ver": 2, "id": "ID_PLACEHOLDER", "name": "test", "startTime": "START_TIME", "duration": "00:00:00.013", "responseCode": "42", "success": true, "httpMethod": "OPTIONS", "url": "http://tempuri.org", "properties": {"foo": "bar"}, "measurements": {"x": 42}}}}'
|
||||
sender.data.time = 'TIME_PLACEHOLDER'
|
||||
sender.data.tags['ai.internal.sdkVersion'] = 'SDK_VERSION_PLACEHOLDER'
|
||||
sender.data.data.base_data.id = 'ID_PLACEHOLDER'
|
||||
|
|
Загрузка…
Ссылка в новой задаче