Merge remote-tracking branch 'upstream/master' into refactor/contracts

This commit is contained in:
eMancu 2015-03-04 14:52:50 -03:00
Родитель 3b7e2e829a 56d5791d72
Коммит 5db8c63a3f
6 изменённых файлов: 11 добавлений и 19 удалений

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

@ -55,15 +55,6 @@ module ApplicationInsights
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
response = http.request(request)
case response
when Net::HTTPSuccess, Net::HTTPRedirection, Net::HTTPBadRequest
return
else
data_to_send.each do |item|
@queue.push item
end
end
end
private

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

@ -7,6 +7,7 @@ require_relative 'synchronous_sender'
require_relative 'contracts/envelope'
require_relative 'contracts/data'
require_relative 'contracts/internal'
require_relative '../../application_insights/version'
module ApplicationInsights
module Channel
@ -77,7 +78,7 @@ module ApplicationInsights
def get_tags(context)
hash = {}
internal_context_attributes = {
:sdk_version => 'rb:0.1.0'
:sdk_version => 'rb:' + ApplicationInsights::VERSION
}
internal_context = Contracts::Internal.new internal_context_attributes

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

@ -1,3 +1,3 @@
module ApplicationInsights
VERSION = '0.5.1'
VERSION = '0.5.2'
end

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

@ -51,7 +51,7 @@ class TestSenderBase < Test::Unit::TestCase
sender.queue = []
sender.send([1, 2])
thread.join
assert_equal [1, 2], sender.queue
assert_equal [], sender.queue
end
def execute_server(code)

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

@ -66,7 +66,7 @@ class TestTelemetryChannel < Test::Unit::TestCase
assert_equal 'instrumentation key', actual.i_key
assert_not_nil actual.tags
assert_equal 1, actual.tags.count
assert_equal 'rb:0.1.0', actual.tags['ai.internal.sdkVersion']
assert_equal 'rb:'+ ApplicationInsights::VERSION, actual.tags['ai.internal.sdkVersion']
assert_not_nil actual.data
assert_equal 'MockTelemetryItemData', actual.data.base_type
assert_same expected, actual.data.base_data

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

@ -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