azure_application_insights 0.5.7 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -2
- data/CONTRIBUTING.md +10 -10
- data/Gemfile +1 -1
- data/README.md +37 -37
- data/Rakefile +1 -1
- data/application_insights.gemspec +3 -3
- data/lib/{application_insights → azure_application_insights}/channel/asynchronous_queue.rb +4 -4
- data/lib/{application_insights → azure_application_insights}/channel/asynchronous_sender.rb +2 -2
- data/lib/{application_insights → azure_application_insights}/channel/contracts/application.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/cloud.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/data_point.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/data_point_type.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/dependency_kind.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/dependency_source_type.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/device.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/envelope.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/event_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/exception_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/exception_details.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/internal.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/json_serializable.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/location.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/message_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/metric_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/operation.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/page_view_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/remote_dependency_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/request_data.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/session.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/severity_level.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/stack_frame.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/contracts/user.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/event.rb +3 -3
- data/lib/{application_insights → azure_application_insights}/channel/queue_base.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/sender_base.rb +2 -2
- data/lib/{application_insights → azure_application_insights}/channel/synchronous_queue.rb +3 -3
- data/lib/{application_insights → azure_application_insights}/channel/synchronous_sender.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/channel/telemetry_channel.rb +7 -7
- data/lib/{application_insights → azure_application_insights}/channel/telemetry_context.rb +3 -3
- data/lib/{application_insights → azure_application_insights}/rack/track_request.rb +4 -4
- data/lib/{application_insights → azure_application_insights}/telemetry_client.rb +1 -1
- data/lib/{application_insights → azure_application_insights}/unhandled_exception.rb +4 -4
- data/lib/azure_application_insights/version.rb +3 -0
- data/lib/azure_application_insights.rb +9 -0
- data/test/application_insights/channel/contracts/test_application.rb +2 -2
- data/test/application_insights/channel/contracts/test_cloud.rb +2 -2
- data/test/application_insights/channel/contracts/test_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_data_point.rb +2 -2
- data/test/application_insights/channel/contracts/test_device.rb +2 -2
- data/test/application_insights/channel/contracts/test_envelope.rb +2 -2
- data/test/application_insights/channel/contracts/test_event_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_exception_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_exception_details.rb +2 -2
- data/test/application_insights/channel/contracts/test_internal.rb +2 -2
- data/test/application_insights/channel/contracts/test_location.rb +2 -2
- data/test/application_insights/channel/contracts/test_message_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_metric_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_operation.rb +2 -2
- data/test/application_insights/channel/contracts/test_page_view_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_remote_dependency_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_request_data.rb +2 -2
- data/test/application_insights/channel/contracts/test_session.rb +2 -2
- data/test/application_insights/channel/contracts/test_stack_frame.rb +2 -2
- data/test/application_insights/channel/contracts/test_user.rb +2 -2
- data/test/application_insights/channel/test_asynchronous_queue.rb +3 -3
- data/test/application_insights/channel/test_asynchronous_sender.rb +4 -4
- data/test/application_insights/channel/test_event.rb +3 -3
- data/test/application_insights/channel/test_queue_base.rb +3 -3
- data/test/application_insights/channel/test_sender_base.rb +3 -3
- data/test/application_insights/channel/test_synchronous_queue.rb +3 -3
- data/test/application_insights/channel/test_synchronous_sender.rb +2 -2
- data/test/application_insights/channel/test_telemetry_channel.rb +8 -8
- data/test/application_insights/channel/test_telemetry_context.rb +2 -2
- data/test/application_insights/mock_sender.rb +3 -3
- data/test/application_insights/rack/test_track_request.rb +8 -8
- data/test/application_insights/test_telemetry_client.rb +14 -14
- data/test/application_insights/test_unhandled_exception.rb +2 -2
- data/test/application_insights.rb +1 -1
- metadata +42 -42
- data/lib/application_insights/version.rb +0 -3
- data/lib/application_insights.rb +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require_relative 'sender_base'
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module AzureApplicationInsights
|
|
4
4
|
module Channel
|
|
5
5
|
# A synchronous sender that works in conjunction with the {SynchronousQueue}.
|
|
6
6
|
# The queue will call {#send} on the current instance with the data to send.
|
|
@@ -7,18 +7,18 @@ require_relative 'synchronous_sender'
|
|
|
7
7
|
require_relative 'contracts/envelope'
|
|
8
8
|
require_relative 'contracts/data'
|
|
9
9
|
require_relative 'contracts/internal'
|
|
10
|
-
require_relative '../../
|
|
10
|
+
require_relative '../../azure_application_insights/version'
|
|
11
11
|
|
|
12
|
-
module
|
|
12
|
+
module AzureApplicationInsights
|
|
13
13
|
module Channel
|
|
14
14
|
# The telemetry channel is responsible for constructing a
|
|
15
15
|
# {Contracts::Envelope} object from the passed in data and specified
|
|
16
16
|
# telemetry context.
|
|
17
17
|
#
|
|
18
18
|
# @example
|
|
19
|
-
# require '
|
|
20
|
-
# channel =
|
|
21
|
-
# event =
|
|
19
|
+
# require 'azure_application_insights'
|
|
20
|
+
# channel = AzureApplicationInsights::Channel::TelemetryChannel.new
|
|
21
|
+
# event = AzureApplicationInsights::Channel::Contracts::EventData.new name: 'My event'
|
|
22
22
|
# channel.write event
|
|
23
23
|
class TelemetryChannel
|
|
24
24
|
# Initializes a new instance of the class.
|
|
@@ -82,7 +82,7 @@ module ApplicationInsights
|
|
|
82
82
|
:base_data => data
|
|
83
83
|
}
|
|
84
84
|
envelope_attributes = {
|
|
85
|
-
:name => 'Microsoft.
|
|
85
|
+
:name => 'Microsoft.AzureApplicationInsights.' + data_type[0..-5],
|
|
86
86
|
:time => local_time,
|
|
87
87
|
:i_key => local_context.instrumentation_key,
|
|
88
88
|
:tags => get_tags(local_context),
|
|
@@ -97,7 +97,7 @@ module ApplicationInsights
|
|
|
97
97
|
def get_tags(context)
|
|
98
98
|
hash = {}
|
|
99
99
|
internal_context_attributes = {
|
|
100
|
-
:sdk_version => 'rb:' +
|
|
100
|
+
:sdk_version => 'rb:' + AzureApplicationInsights::VERSION
|
|
101
101
|
}
|
|
102
102
|
internal_context = Contracts::Internal.new internal_context_attributes
|
|
103
103
|
|
|
@@ -6,14 +6,14 @@ require_relative 'contracts/session'
|
|
|
6
6
|
require_relative 'contracts/operation'
|
|
7
7
|
require_relative 'contracts/location'
|
|
8
8
|
|
|
9
|
-
module
|
|
9
|
+
module AzureApplicationInsights
|
|
10
10
|
module Channel
|
|
11
11
|
# Represents the context for sending telemetry to the
|
|
12
12
|
# Application Insights service.
|
|
13
13
|
#
|
|
14
14
|
# @example
|
|
15
|
-
# require '
|
|
16
|
-
# context =
|
|
15
|
+
# require 'azure_application_insights'
|
|
16
|
+
# context = AzureApplicationInsights::Channel::TelemetryContext.new
|
|
17
17
|
# context.instrumentation_key = '<YOUR INSTRUMENTATION KEY GOES HERE>'
|
|
18
18
|
# context.application.id = 'My application'
|
|
19
19
|
# context.application.ver = '1.2.3'
|
|
@@ -3,7 +3,7 @@ require 'securerandom'
|
|
|
3
3
|
require_relative '../channel/contracts/request_data'
|
|
4
4
|
require_relative '../telemetry_client'
|
|
5
5
|
|
|
6
|
-
module
|
|
6
|
+
module AzureApplicationInsights
|
|
7
7
|
module Rack
|
|
8
8
|
# Track every request and sends the request data to Application Insights.
|
|
9
9
|
class TrackRequest
|
|
@@ -35,7 +35,7 @@ module ApplicationInsights
|
|
|
35
35
|
def call(env)
|
|
36
36
|
# Build a request ID, incorporating one from our request if one exists.
|
|
37
37
|
request_id = request_id_header(env['HTTP_REQUEST_ID'])
|
|
38
|
-
env['
|
|
38
|
+
env['AzureApplicationInsights.request.id'] = request_id
|
|
39
39
|
|
|
40
40
|
start = Time.now
|
|
41
41
|
begin
|
|
@@ -124,8 +124,8 @@ module ApplicationInsights
|
|
|
124
124
|
http_method: request.request_method,
|
|
125
125
|
url: request.url,
|
|
126
126
|
properties: {
|
|
127
|
-
params: request.params.to_json
|
|
128
|
-
|
|
127
|
+
params: request.params.to_json#,
|
|
128
|
+
# requestBody: request.body.to_json
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
end
|
|
@@ -12,7 +12,7 @@ require_relative 'channel/contracts/stack_frame'
|
|
|
12
12
|
require_relative 'channel/contracts/request_data'
|
|
13
13
|
require_relative 'channel/contracts/severity_level'
|
|
14
14
|
|
|
15
|
-
module
|
|
15
|
+
module AzureApplicationInsights
|
|
16
16
|
# The telemetry client used for sending all types of telemetry. It serves as
|
|
17
17
|
# the main entry point for interacting with the Application Insights service.
|
|
18
18
|
class TelemetryClient
|
|
@@ -3,9 +3,9 @@ require_relative 'channel/telemetry_channel'
|
|
|
3
3
|
require_relative 'channel/synchronous_queue'
|
|
4
4
|
require_relative 'channel/synchronous_sender'
|
|
5
5
|
|
|
6
|
-
include
|
|
6
|
+
include AzureApplicationInsights
|
|
7
7
|
|
|
8
|
-
module
|
|
8
|
+
module AzureApplicationInsights
|
|
9
9
|
module UnhandledException
|
|
10
10
|
@sender = nil
|
|
11
11
|
|
|
@@ -13,8 +13,8 @@ module ApplicationInsights
|
|
|
13
13
|
# @param (string) instrumentation_key used to identify which Application
|
|
14
14
|
# Insights application this data is for.
|
|
15
15
|
# @example
|
|
16
|
-
# require '
|
|
17
|
-
#
|
|
16
|
+
# require 'azure_application_insights'
|
|
17
|
+
# AzureApplicationInsights::UnhandledException.collect('<YOUR INSTRUMENTATION KEY GOES HERE>')
|
|
18
18
|
# raise Exception, 'Boom!'
|
|
19
19
|
def self.collect(instrumentation_key)
|
|
20
20
|
at_exit do
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require_relative 'azure_application_insights/telemetry_client'
|
|
2
|
+
require_relative 'azure_application_insights/unhandled_exception'
|
|
3
|
+
require_relative 'azure_application_insights/version'
|
|
4
|
+
|
|
5
|
+
module AzureApplicationInsights
|
|
6
|
+
module Rack
|
|
7
|
+
autoload :TrackRequest, "azure_application_insights/rack/track_request"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/application'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestApplication < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/cloud'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestCloud < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/data_point'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestDataPoint < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/device'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestDevice < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/envelope'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestEnvelope < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/event_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestEventData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/exception_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestExceptionData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/exception_details'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestExceptionDetails < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/internal'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestInternal < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/location'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestLocation < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/message_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestMessageData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/metric_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestMetricData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/operation'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestOperation < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/page_view_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestPageViewData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/remote_dependency_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestRemoteDependencyData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/request_data'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestRequestData < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/session'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestSession < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/stack_frame'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestStackFrame < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../../lib/
|
|
1
|
+
require_relative '../../../../lib/azure_application_insights/channel/contracts/user'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestUser < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/asynchronous_queue'
|
|
3
3
|
require_relative '../mock_sender'
|
|
4
4
|
require 'test/unit'
|
|
5
5
|
|
|
6
|
-
include
|
|
6
|
+
include AzureApplicationInsights::Channel
|
|
7
7
|
|
|
8
8
|
class TestAsynchronousQueue < Test::Unit::TestCase
|
|
9
9
|
def test_initialize
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
3
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/asynchronous_sender'
|
|
3
|
+
require_relative '../../../lib/azure_application_insights/channel/asynchronous_queue'
|
|
4
4
|
require 'test/unit'
|
|
5
5
|
|
|
6
|
-
include
|
|
6
|
+
include AzureApplicationInsights::Channel
|
|
7
7
|
|
|
8
8
|
class TestAsynchronousSender < Test::Unit::TestCase
|
|
9
9
|
def test_initialize
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/asynchronous_queue'
|
|
3
3
|
require 'thread'
|
|
4
4
|
require 'test/unit'
|
|
5
5
|
|
|
6
|
-
include
|
|
6
|
+
include AzureApplicationInsights::Channel
|
|
7
7
|
|
|
8
8
|
class TestEvent < Test::Unit::TestCase
|
|
9
9
|
def test_initialize
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/queue_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
3
3
|
require 'test/unit'
|
|
4
4
|
|
|
5
|
-
include
|
|
5
|
+
include AzureApplicationInsights::Channel
|
|
6
6
|
|
|
7
7
|
class TestQueueBase < Test::Unit::TestCase
|
|
8
8
|
def test_initialize
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/queue_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
3
3
|
require_relative '../test_logger'
|
|
4
4
|
require 'socket'
|
|
5
5
|
require 'test/unit'
|
|
6
6
|
require 'thread'
|
|
7
7
|
|
|
8
|
-
include
|
|
8
|
+
include AzureApplicationInsights::Channel
|
|
9
9
|
|
|
10
10
|
class TestSenderBase < Test::Unit::TestCase
|
|
11
11
|
def test_initialize
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/sender_base'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/synchronous_queue'
|
|
3
3
|
require_relative '../mock_sender'
|
|
4
4
|
require 'test/unit'
|
|
5
5
|
|
|
6
|
-
include
|
|
6
|
+
include AzureApplicationInsights::Channel
|
|
7
7
|
|
|
8
8
|
class TestSynchronousQueue < Test::Unit::TestCase
|
|
9
9
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/synchronous_sender'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestSynchronousSender < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
2
|
-
require_relative '../../../lib/
|
|
3
|
-
require_relative '../../../lib/
|
|
4
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/telemetry_channel'
|
|
2
|
+
require_relative '../../../lib/azure_application_insights/channel/telemetry_context'
|
|
3
|
+
require_relative '../../../lib/azure_application_insights/channel/synchronous_queue'
|
|
4
|
+
require_relative '../../../lib/azure_application_insights/channel/synchronous_sender'
|
|
5
5
|
require 'test/unit'
|
|
6
6
|
require 'time'
|
|
7
7
|
|
|
8
|
-
include
|
|
8
|
+
include AzureApplicationInsights::Channel
|
|
9
9
|
|
|
10
10
|
class TestTelemetryChannel < Test::Unit::TestCase
|
|
11
11
|
def test_initialize
|
|
@@ -62,12 +62,12 @@ class TestTelemetryChannel < Test::Unit::TestCase
|
|
|
62
62
|
assert_not_nil actual
|
|
63
63
|
assert_equal 1, actual.ver
|
|
64
64
|
assert_equal 100, actual.sample_rate
|
|
65
|
-
assert_equal 'Microsoft.
|
|
65
|
+
assert_equal 'Microsoft.AzureApplicationInsights.MockTelemetryItem', actual.name
|
|
66
66
|
assert_not_nil actual.time
|
|
67
67
|
assert_equal 'instrumentation key', actual.i_key
|
|
68
68
|
assert_not_nil actual.tags
|
|
69
69
|
assert_equal 1, actual.tags.count
|
|
70
|
-
assert_equal 'rb:'+
|
|
70
|
+
assert_equal 'rb:'+ AzureApplicationInsights::VERSION, actual.tags['ai.internal.sdkVersion']
|
|
71
71
|
assert_not_nil actual.data
|
|
72
72
|
assert_equal 'MockTelemetryItemData', actual.data.base_type
|
|
73
73
|
assert_same expected, actual.data.base_data
|
|
@@ -129,7 +129,7 @@ class TestTelemetryChannel < Test::Unit::TestCase
|
|
|
129
129
|
|
|
130
130
|
assert_equal 1, queue.queue.count
|
|
131
131
|
tags = queue.queue[0].tags
|
|
132
|
-
assert_equal 'rb:'+
|
|
132
|
+
assert_equal 'rb:'+ AzureApplicationInsights::VERSION, tags['ai.internal.sdkVersion']
|
|
133
133
|
assert_equal 'ver', tags['ai.application.ver']
|
|
134
134
|
assert_equal 'role name', tags['ai.cloud.role']
|
|
135
135
|
assert_equal 'device id', tags['ai.device.id']
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../../lib/
|
|
1
|
+
require_relative '../../../lib/azure_application_insights/channel/telemetry_context'
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class TestTelemetryContext < Test::Unit::TestCase
|
|
7
7
|
def test_initialize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative '../../lib/
|
|
2
|
-
require_relative '../../lib/
|
|
1
|
+
require_relative '../../lib/azure_application_insights/channel/synchronous_sender'
|
|
2
|
+
require_relative '../../lib/azure_application_insights/channel/asynchronous_sender'
|
|
3
3
|
|
|
4
|
-
include
|
|
4
|
+
include AzureApplicationInsights::Channel
|
|
5
5
|
|
|
6
6
|
class MockSynchronousSender < SynchronousSender
|
|
7
7
|
def initialize
|
|
@@ -2,9 +2,9 @@ require 'test/unit'
|
|
|
2
2
|
require 'mocha/test_unit'
|
|
3
3
|
require 'rack/mock'
|
|
4
4
|
require_relative '../mock_sender'
|
|
5
|
-
require_relative '../../../lib/
|
|
5
|
+
require_relative '../../../lib/azure_application_insights/rack/track_request'
|
|
6
6
|
|
|
7
|
-
include
|
|
7
|
+
include AzureApplicationInsights::Rack
|
|
8
8
|
|
|
9
9
|
class TestTrackRequest < Test::Unit::TestCase
|
|
10
10
|
|
|
@@ -95,7 +95,7 @@ class TestTrackRequest < Test::Unit::TestCase
|
|
|
95
95
|
track_request = TrackRequest.new app, 'key', buffer_size, send_interval
|
|
96
96
|
client = track_request.send(:client)
|
|
97
97
|
# test client initialization
|
|
98
|
-
assert_equal
|
|
98
|
+
assert_equal AzureApplicationInsights::TelemetryClient, client.class
|
|
99
99
|
|
|
100
100
|
track_request.call(env)
|
|
101
101
|
client = track_request.send(:client)
|
|
@@ -153,30 +153,30 @@ class TestTrackRequest < Test::Unit::TestCase
|
|
|
153
153
|
env['HTTP_REQUEST_ID'] = 'ab456_1.ea6741a'
|
|
154
154
|
SecureRandom.expects(:base64).with(10).returns('y0NM2eOY/fnQPw==')
|
|
155
155
|
track_request.call(env)
|
|
156
|
-
assert_equal '|y0NM2eOY/fnQPw==.', env['
|
|
156
|
+
assert_equal '|y0NM2eOY/fnQPw==.', env['AzureApplicationInsights.request.id']
|
|
157
157
|
|
|
158
158
|
# appends to ids with a dot (8 chars)
|
|
159
159
|
env['HTTP_REQUEST_ID'] = '|1234.'
|
|
160
160
|
SecureRandom.expects(:base64).with(5).returns('eXsMFHs=')
|
|
161
161
|
track_request.call(env)
|
|
162
|
-
assert_equal '|1234.eXsMFHs=_', env['
|
|
162
|
+
assert_equal '|1234.eXsMFHs=_', env['AzureApplicationInsights.request.id']
|
|
163
163
|
|
|
164
164
|
# appends to ids with an underscore (8 chars)
|
|
165
165
|
env['HTTP_REQUEST_ID'] = '|1234_'
|
|
166
166
|
SecureRandom.expects(:base64).with(5).returns('eXsMFHs=')
|
|
167
167
|
track_request.call(env)
|
|
168
|
-
assert_equal '|1234_eXsMFHs=_', env['
|
|
168
|
+
assert_equal '|1234_eXsMFHs=_', env['AzureApplicationInsights.request.id']
|
|
169
169
|
|
|
170
170
|
# appends a dot if neither a dot or underscore are present (8 chars)
|
|
171
171
|
env['HTTP_REQUEST_ID'] = '|ab456_1.ea6741a'
|
|
172
172
|
SecureRandom.expects(:base64).with(5).returns('eXsMFHs=')
|
|
173
173
|
track_request.call(env)
|
|
174
|
-
assert_equal '|ab456_1.ea6741a.eXsMFHs=_', env['
|
|
174
|
+
assert_equal '|ab456_1.ea6741a.eXsMFHs=_', env['AzureApplicationInsights.request.id']
|
|
175
175
|
|
|
176
176
|
# generates a stand-alone id if one is not provided (16 chars)
|
|
177
177
|
env.delete('HTTP_REQUEST_ID')
|
|
178
178
|
SecureRandom.expects(:base64).with(10).returns('y0NM2eOY/fnQPw==')
|
|
179
179
|
track_request.call(env)
|
|
180
|
-
assert_equal '|y0NM2eOY/fnQPw==.', env['
|
|
180
|
+
assert_equal '|y0NM2eOY/fnQPw==.', env['AzureApplicationInsights.request.id']
|
|
181
181
|
end
|
|
182
182
|
end
|