|
|
|
@ -34,7 +34,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client, sender = self.create_client
|
|
|
|
|
client.track_page_view 'test', 'http://tempuri.org'
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.PageView","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"PageViewData","baseData":{"ver":2,"url":"http://tempuri.org","name":"test"}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.PageView","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"PageViewData","baseData":{"ver":2,"url":"http://tempuri.org","name":"test"}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
sender.data_to_send[0].time = 'TIME_PLACEHOLDER'
|
|
|
|
|
actual = sender.data_to_send.to_json
|
|
|
|
|
assert_equal expected, actual
|
|
|
|
@ -48,7 +48,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client.track_exception e
|
|
|
|
|
end
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Exception","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"ExceptionData","baseData":{"ver":2,"handledAt":"UserCode","exceptions":[{"id":1,"stack":"STACK_PLACEHOLDER","message":"Some error","outerId":0,"typeName":"ArgumentError","hasFullStack":true}]}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Exception","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"ExceptionData","baseData":{"ver":2,"handledAt":"UserCode","exceptions":[{"id":1,"stack":"STACK_PLACEHOLDER","message":"Some error","outerId":0,"typeName":"ArgumentError","hasFullStack":true}]}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
assert_equal 'UserCode', sender.data_to_send[0].data.base_data.handled_at
|
|
|
|
|
assert_operator sender.data_to_send[0].data.base_data.exceptions[0].parsed_stack.count, :>, 0
|
|
|
|
|
assert_equal 'test_track_exception_works_as_expected', sender.data_to_send[0].data.base_data.exceptions[0].parsed_stack[0].method
|
|
|
|
@ -64,7 +64,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client, sender = self.create_client
|
|
|
|
|
client.track_event 'test'
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Event","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"EventData","baseData":{"ver":2,"name":"test"}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Event","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"EventData","baseData":{"ver":2,"name":"test"}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
sender.data_to_send[0].time = 'TIME_PLACEHOLDER'
|
|
|
|
|
actual = sender.data_to_send.to_json
|
|
|
|
|
assert_equal expected, actual
|
|
|
|
@ -74,7 +74,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client, sender = self.create_client
|
|
|
|
|
client.track_metric 'test', 42
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"MetricData","baseData":{"ver":2,"metrics":[{"name":"test","kind":1,"value":42}]}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Metric","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"MetricData","baseData":{"ver":2,"metrics":[{"name":"test","kind":1,"value":42}]}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
sender.data_to_send[0].time = 'TIME_PLACEHOLDER'
|
|
|
|
|
actual = sender.data_to_send.to_json
|
|
|
|
|
assert_equal expected, actual
|
|
|
|
@ -84,7 +84,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client, sender = self.create_client
|
|
|
|
|
client.track_trace 'test', Channel::Contracts::SeverityLevel::WARNING
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Message","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"test","severityLevel":2}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Message","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"MessageData","baseData":{"ver":2,"message":"test","severityLevel":2}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
sender.data_to_send[0].time = 'TIME_PLACEHOLDER'
|
|
|
|
|
actual = sender.data_to_send.to_json
|
|
|
|
|
assert_equal expected, actual
|
|
|
|
@ -94,7 +94,7 @@ class TestTelemetryClient < Test::Unit::TestCase
|
|
|
|
|
client, sender = self.create_client
|
|
|
|
|
client.track_request 'test', '2015-01-24T23:10:22.7411910-08:00', '0:00:00:02.0000000','200', true
|
|
|
|
|
client.flush
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:0.1.0"},"data":{"baseType":"RequestData","baseData":{"id":"test","ver":2,"success":true,"duration":"0:00:00:02.0000000","startTime":"2015-01-24T23:10:22.7411910-08:00","responseCode":"200"}},"sampleRate":100.0}]'
|
|
|
|
|
expected = '[{"ver":1,"name":"Microsoft.ApplicationInsights.Request","time":"TIME_PLACEHOLDER","tags":{"ai.internal.sdkVersion":"rb:__version__"},"data":{"baseType":"RequestData","baseData":{"id":"test","ver":2,"success":true,"duration":"0:00:00:02.0000000","startTime":"2015-01-24T23:10:22.7411910-08:00","responseCode":"200"}},"sampleRate":100.0}]'.gsub!(/__version__/, ApplicationInsights::VERSION)
|
|
|
|
|
sender.data_to_send[0].time = 'TIME_PLACEHOLDER'
|
|
|
|
|
actual = sender.data_to_send.to_json
|
|
|
|
|
assert_equal expected, actual
|
|
|
|
|