AI reports an error when sending requests currently. The "duration" field is not in the expected format. AI expects "dd.hh:mm:ss.fffffff" and the SDK is sending "d:hh:mm:ss.fffffff".

Also updating to use "true" instead of "TRUE" as the "TRUE" constant was deprecated in Ruby 2.4
This commit is contained in:
Aaron Patterson 2017-06-29 12:43:28 -07:00
Родитель 7d58f44f2c
Коммит b19de3f4ee
6 изменённых файлов: 16 добавлений и 16 удалений

Просмотреть файл

@ -78,10 +78,10 @@ module ApplicationInsights
if duration_seconds >= 86_400 if duration_seconds >= 86_400
# just return 1 day when it takes more than 1 day which should not # just return 1 day when it takes more than 1 day which should not
# happen for requests. # happen for requests.
return "%d:%02d:%02d:%02d.%07d" % [1, 0, 0, 0, 0] return "%02d.%02d:%02d:%02d.%07d" % [1, 0, 0, 0, 0]
end end
Time.at(duration_seconds).gmtime.strftime("0:%H:%M:%S.%7N") Time.at(duration_seconds).gmtime.strftime("00.%H:%M:%S.%7N")
end end
end end
end end

Просмотреть файл

@ -58,7 +58,7 @@ class TestExceptionDetails < Test::Unit::TestCase
end end
def test_has_full_stack_works_as_expected def test_has_full_stack_works_as_expected
expected = TRUE expected = true
item = Contracts::ExceptionDetails.new item = Contracts::ExceptionDetails.new
item.has_full_stack = expected item.has_full_stack = expected
actual = item.has_full_stack actual = item.has_full_stack
@ -93,7 +93,7 @@ class TestExceptionDetails < Test::Unit::TestCase
item.outer_id = 42 item.outer_id = 42
item.type_name = 'Test string' item.type_name = 'Test string'
item.message = 'Test string' item.message = 'Test string'
item.has_full_stack = TRUE item.has_full_stack = true
item.stack = 'Test string' item.stack = 'Test string'
[ { 'key' => 'value' } ].each do |value| [ { 'key' => 'value' } ].each do |value|
item.parsed_stack.push value item.parsed_stack.push value

Просмотреть файл

@ -118,7 +118,7 @@ class TestRemoteDependencyData < Test::Unit::TestCase
end end
def test_success_works_as_expected def test_success_works_as_expected
expected = TRUE expected = true
item = Contracts::RemoteDependencyData.new item = Contracts::RemoteDependencyData.new
item.success = expected item.success = expected
actual = item.success actual = item.success
@ -130,7 +130,7 @@ class TestRemoteDependencyData < Test::Unit::TestCase
end end
def test_async_works_as_expected def test_async_works_as_expected
expected = TRUE expected = true
item = Contracts::RemoteDependencyData.new item = Contracts::RemoteDependencyData.new
item.async = expected item.async = expected
actual = item.async actual = item.async
@ -194,8 +194,8 @@ class TestRemoteDependencyData < Test::Unit::TestCase
item.max = 1.5 item.max = 1.5
item.std_dev = 1.5 item.std_dev = 1.5
item.dependency_kind = 5 item.dependency_kind = 5
item.success = TRUE item.success = true
item.async = TRUE item.async = true
item.dependency_source = 5 item.dependency_source = 5
item.command_name = 'Test string' item.command_name = 'Test string'
item.dependency_type_name = 'Test string' item.dependency_type_name = 'Test string'

Просмотреть файл

@ -82,7 +82,7 @@ class TestRequestData < Test::Unit::TestCase
end end
def test_success_works_as_expected def test_success_works_as_expected
expected = TRUE expected = true
item = Contracts::RequestData.new item = Contracts::RequestData.new
item.success = expected item.success = expected
actual = item.success actual = item.success
@ -137,7 +137,7 @@ class TestRequestData < Test::Unit::TestCase
item.start_time = 'Test string' item.start_time = 'Test string'
item.duration = 'Test string' item.duration = 'Test string'
item.response_code = 'Test string' item.response_code = 'Test string'
item.success = TRUE item.success = true
item.http_method = 'Test string' item.http_method = 'Test string'
item.url = 'Test string' item.url = 'Test string'
{ 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value| { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|

Просмотреть файл

@ -61,7 +61,7 @@ class TestSenderBase < Test::Unit::TestCase
client = server.accept client = server.accept
request = '' request = ''
read_buffer_size = 64 read_buffer_size = 64
while TRUE while true
temp = client.recv(read_buffer_size) temp = client.recv(read_buffer_size)
request += temp request += temp
break if temp.length < read_buffer_size break if temp.length < read_buffer_size

Просмотреть файл

@ -31,7 +31,7 @@ class TestTrackRequest < Test::Unit::TestCase
assert_equal true, request_data.success assert_equal true, request_data.success
assert_equal http_method, request_data.http_method assert_equal http_method, request_data.http_method
assert_equal url, request_data.url assert_equal url, request_data.url
assert_equal true, request_data.duration.start_with?("0:00:00:02") assert_equal true, request_data.duration.start_with?("00.00:00:02")
assert Time.parse(request_data.start_time) - start_time < 0.01 assert Time.parse(request_data.start_time) - start_time < 0.01
end end
@ -107,7 +107,7 @@ class TestTrackRequest < Test::Unit::TestCase
track_request = TrackRequest.new app, 'one' track_request = TrackRequest.new app, 'one'
duration_seconds = rand(86400) + rand duration_seconds = rand(86400) + rand
time_span = track_request.send(:format_request_duration, duration_seconds) time_span = track_request.send(:format_request_duration, duration_seconds)
time_span_format = /^(?<day>\d{1}):(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}).(?<fraction>\d{7})$/ time_span_format = /^(?<day>\d{2}).(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}).(?<fraction>\d{7})$/
match = time_span_format.match time_span match = time_span_format.match time_span
assert_not_nil match assert_not_nil match
days = duration_seconds.to_i/86400 days = duration_seconds.to_i/86400
@ -127,7 +127,7 @@ class TestTrackRequest < Test::Unit::TestCase
track_request = TrackRequest.new app, 'one' track_request = TrackRequest.new app, 'one'
duration_seconds = rand(86400..240000) + rand duration_seconds = rand(86400..240000) + rand
time_span = track_request.send(:format_request_duration, duration_seconds) time_span = track_request.send(:format_request_duration, duration_seconds)
time_span_format = /^(?<day>\d{1}):(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}).(?<fraction>\d{7})$/ time_span_format = /^(?<day>\d{2}).(?<hour>\d{2}):(?<minute>\d{2}):(?<second>\d{2}).(?<fraction>\d{7})$/
match = time_span_format.match time_span match = time_span_format.match time_span
assert_not_nil match assert_not_nil match
assert_equal 1, match['day'].to_i assert_equal 1, match['day'].to_i