application_insights 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +9 -9
- data/LICENSE.txt +7 -18
- data/README.md +42 -7
- data/Rakefile +6 -1
- data/application_insights.gemspec +2 -0
- data/lib/application_insights.rb +1 -0
- data/lib/application_insights/channel/asynchronous_queue.rb +51 -0
- data/lib/application_insights/channel/asynchronous_sender.rb +121 -0
- data/lib/application_insights/channel/contracts/application.rb +3 -2
- data/lib/application_insights/channel/contracts/data.rb +3 -2
- data/lib/application_insights/channel/contracts/data_point.rb +15 -10
- data/lib/application_insights/channel/contracts/device.rb +42 -28
- data/lib/application_insights/channel/contracts/envelope.rb +39 -27
- data/lib/application_insights/channel/contracts/event_data.rb +6 -6
- data/lib/application_insights/channel/contracts/exception_data.rb +9 -8
- data/lib/application_insights/channel/contracts/exception_details.rb +15 -11
- data/lib/application_insights/channel/contracts/internal.rb +6 -4
- data/lib/application_insights/channel/contracts/location.rb +3 -2
- data/lib/application_insights/channel/contracts/message_data.rb +6 -5
- data/lib/application_insights/channel/contracts/metric_data.rb +3 -3
- data/lib/application_insights/channel/contracts/operation.rb +12 -8
- data/lib/application_insights/channel/contracts/page_view_data.rb +12 -10
- data/lib/application_insights/channel/contracts/remote_dependency_data.rb +27 -19
- data/lib/application_insights/channel/contracts/request_data.rb +15 -12
- data/lib/application_insights/channel/contracts/session.rb +9 -6
- data/lib/application_insights/channel/contracts/stack_frame.rb +9 -6
- data/lib/application_insights/channel/contracts/user.rb +12 -8
- data/lib/application_insights/channel/event.rb +64 -0
- data/lib/application_insights/channel/queue_base.rb +24 -10
- data/lib/application_insights/channel/sender_base.rb +38 -9
- data/lib/application_insights/channel/synchronous_queue.rb +16 -5
- data/lib/application_insights/channel/synchronous_sender.rb +4 -2
- data/lib/application_insights/channel/telemetry_channel.rb +26 -7
- data/lib/application_insights/channel/telemetry_context.rb +29 -10
- data/lib/application_insights/telemetry_client.rb +84 -15
- data/lib/application_insights/unhandled_exception.rb +48 -0
- data/lib/application_insights/version.rb +1 -1
- data/test/application_insights/channel/test_asynchronous_queue.rb +68 -0
- data/test/application_insights/channel/test_asynchronous_sender.rb +81 -0
- data/test/application_insights/channel/test_event.rb +53 -0
- data/test/application_insights/channel/test_queue_base.rb +10 -9
- data/test/application_insights/channel/test_sender_base.rb +0 -9
- data/test/application_insights/test_telemetry_client.rb +5 -0
- data/test/application_insights/test_unhandled_exception.rb +42 -0
- metadata +44 -3
@@ -17,8 +17,9 @@ module ApplicationInsights
|
|
17
17
|
|
18
18
|
# Gets the ip property.
|
19
19
|
def ip
|
20
|
-
|
21
|
-
|
20
|
+
@values.fetch('ai.location.ip') {
|
21
|
+
@values['ai.location.ip'] = nil
|
22
|
+
}
|
22
23
|
end
|
23
24
|
|
24
25
|
# Sets the ip property.
|
@@ -42,8 +42,9 @@ module ApplicationInsights
|
|
42
42
|
|
43
43
|
# Gets the severity_level property.
|
44
44
|
def severity_level
|
45
|
-
|
46
|
-
|
45
|
+
@values.fetch('severityLevel') {
|
46
|
+
@values['severityLevel'] = nil
|
47
|
+
}
|
47
48
|
end
|
48
49
|
|
49
50
|
# Sets the severity_level property.
|
@@ -57,9 +58,9 @@ module ApplicationInsights
|
|
57
58
|
|
58
59
|
# Gets the properties property.
|
59
60
|
def properties
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
@values.fetch('properties') {
|
62
|
+
@values['properties'] = {}
|
63
|
+
}
|
63
64
|
end
|
64
65
|
|
65
66
|
# Sets the properties property.
|
@@ -41,9 +41,9 @@ module ApplicationInsights
|
|
41
41
|
|
42
42
|
# Gets the properties property.
|
43
43
|
def properties
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
@values.fetch('properties') {
|
45
|
+
@values['properties'] = {}
|
46
|
+
}
|
47
47
|
end
|
48
48
|
|
49
49
|
# Sets the properties property.
|
@@ -20,8 +20,9 @@ module ApplicationInsights
|
|
20
20
|
|
21
21
|
# Gets the id property.
|
22
22
|
def id
|
23
|
-
|
24
|
-
|
23
|
+
@values.fetch('ai.operation.id') {
|
24
|
+
@values['ai.operation.id'] = nil
|
25
|
+
}
|
25
26
|
end
|
26
27
|
|
27
28
|
# Sets the id property.
|
@@ -35,8 +36,9 @@ module ApplicationInsights
|
|
35
36
|
|
36
37
|
# Gets the name property.
|
37
38
|
def name
|
38
|
-
|
39
|
-
|
39
|
+
@values.fetch('ai.operation.name') {
|
40
|
+
@values['ai.operation.name'] = nil
|
41
|
+
}
|
40
42
|
end
|
41
43
|
|
42
44
|
# Sets the name property.
|
@@ -50,8 +52,9 @@ module ApplicationInsights
|
|
50
52
|
|
51
53
|
# Gets the parent_id property.
|
52
54
|
def parent_id
|
53
|
-
|
54
|
-
|
55
|
+
@values.fetch('ai.operation.parentId') {
|
56
|
+
@values['ai.operation.parentId'] = nil
|
57
|
+
}
|
55
58
|
end
|
56
59
|
|
57
60
|
# Sets the parent_id property.
|
@@ -65,8 +68,9 @@ module ApplicationInsights
|
|
65
68
|
|
66
69
|
# Gets the root_id property.
|
67
70
|
def root_id
|
68
|
-
|
69
|
-
|
71
|
+
@values.fetch('ai.operation.rootId') {
|
72
|
+
@values['ai.operation.rootId'] = nil
|
73
|
+
}
|
70
74
|
end
|
71
75
|
|
72
76
|
# Sets the root_id property.
|
@@ -34,8 +34,9 @@ module ApplicationInsights
|
|
34
34
|
|
35
35
|
# Gets the url property.
|
36
36
|
def url
|
37
|
-
|
38
|
-
|
37
|
+
@values.fetch('url') {
|
38
|
+
@values['url'] = nil
|
39
|
+
}
|
39
40
|
end
|
40
41
|
|
41
42
|
# Sets the url property.
|
@@ -59,8 +60,9 @@ module ApplicationInsights
|
|
59
60
|
|
60
61
|
# Gets the duration property.
|
61
62
|
def duration
|
62
|
-
|
63
|
-
|
63
|
+
@values.fetch('duration') {
|
64
|
+
@values['duration'] = nil
|
65
|
+
}
|
64
66
|
end
|
65
67
|
|
66
68
|
# Sets the duration property.
|
@@ -74,9 +76,9 @@ module ApplicationInsights
|
|
74
76
|
|
75
77
|
# Gets the properties property.
|
76
78
|
def properties
|
77
|
-
|
78
|
-
|
79
|
-
|
79
|
+
@values.fetch('properties') {
|
80
|
+
@values['properties'] = {}
|
81
|
+
}
|
80
82
|
end
|
81
83
|
|
82
84
|
# Sets the properties property.
|
@@ -90,9 +92,9 @@ module ApplicationInsights
|
|
90
92
|
|
91
93
|
# Gets the measurements property.
|
92
94
|
def measurements
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
@values.fetch('measurements') {
|
96
|
+
@values['measurements'] = {}
|
97
|
+
}
|
96
98
|
end
|
97
99
|
|
98
100
|
# Sets the measurements property.
|
@@ -59,8 +59,9 @@ module ApplicationInsights
|
|
59
59
|
|
60
60
|
# Gets the kind property.
|
61
61
|
def kind
|
62
|
-
|
63
|
-
|
62
|
+
@values.fetch('kind') {
|
63
|
+
@values['kind'] = DataPointType::MEASUREMENT
|
64
|
+
}
|
64
65
|
end
|
65
66
|
|
66
67
|
# Sets the kind property.
|
@@ -84,8 +85,9 @@ module ApplicationInsights
|
|
84
85
|
|
85
86
|
# Gets the count property.
|
86
87
|
def count
|
87
|
-
|
88
|
-
|
88
|
+
@values.fetch('count') {
|
89
|
+
@values['count'] = nil
|
90
|
+
}
|
89
91
|
end
|
90
92
|
|
91
93
|
# Sets the count property.
|
@@ -99,8 +101,9 @@ module ApplicationInsights
|
|
99
101
|
|
100
102
|
# Gets the min property.
|
101
103
|
def min
|
102
|
-
|
103
|
-
|
104
|
+
@values.fetch('min') {
|
105
|
+
@values['min'] = nil
|
106
|
+
}
|
104
107
|
end
|
105
108
|
|
106
109
|
# Sets the min property.
|
@@ -114,8 +117,9 @@ module ApplicationInsights
|
|
114
117
|
|
115
118
|
# Gets the max property.
|
116
119
|
def max
|
117
|
-
|
118
|
-
|
120
|
+
@values.fetch('max') {
|
121
|
+
@values['max'] = nil
|
122
|
+
}
|
119
123
|
end
|
120
124
|
|
121
125
|
# Sets the max property.
|
@@ -129,8 +133,9 @@ module ApplicationInsights
|
|
129
133
|
|
130
134
|
# Gets the std_dev property.
|
131
135
|
def std_dev
|
132
|
-
|
133
|
-
|
136
|
+
@values.fetch('stdDev') {
|
137
|
+
@values['stdDev'] = nil
|
138
|
+
}
|
134
139
|
end
|
135
140
|
|
136
141
|
# Sets the std_dev property.
|
@@ -154,8 +159,9 @@ module ApplicationInsights
|
|
154
159
|
|
155
160
|
# Gets the success property.
|
156
161
|
def success
|
157
|
-
|
158
|
-
|
162
|
+
@values.fetch('success') {
|
163
|
+
@values['success'] = true
|
164
|
+
}
|
159
165
|
end
|
160
166
|
|
161
167
|
# Sets the success property.
|
@@ -169,8 +175,9 @@ module ApplicationInsights
|
|
169
175
|
|
170
176
|
# Gets the async property.
|
171
177
|
def async
|
172
|
-
|
173
|
-
|
178
|
+
@values.fetch('async') {
|
179
|
+
@values['async'] = nil
|
180
|
+
}
|
174
181
|
end
|
175
182
|
|
176
183
|
# Sets the async property.
|
@@ -184,8 +191,9 @@ module ApplicationInsights
|
|
184
191
|
|
185
192
|
# Gets the dependency_source property.
|
186
193
|
def dependency_source
|
187
|
-
|
188
|
-
|
194
|
+
@values.fetch('dependencySource') {
|
195
|
+
@values['dependencySource'] = DependencySourceType::UNDEFINED
|
196
|
+
}
|
189
197
|
end
|
190
198
|
|
191
199
|
# Sets the dependency_source property.
|
@@ -199,9 +207,9 @@ module ApplicationInsights
|
|
199
207
|
|
200
208
|
# Gets the properties property.
|
201
209
|
def properties
|
202
|
-
|
203
|
-
|
204
|
-
|
210
|
+
@values.fetch('properties') {
|
211
|
+
@values['properties'] = {}
|
212
|
+
}
|
205
213
|
end
|
206
214
|
|
207
215
|
# Sets the properties property.
|
@@ -53,8 +53,9 @@ module ApplicationInsights
|
|
53
53
|
|
54
54
|
# Gets the name property.
|
55
55
|
def name
|
56
|
-
|
57
|
-
|
56
|
+
@values.fetch('name') {
|
57
|
+
@values['name'] = nil
|
58
|
+
}
|
58
59
|
end
|
59
60
|
|
60
61
|
# Sets the name property.
|
@@ -108,8 +109,9 @@ module ApplicationInsights
|
|
108
109
|
|
109
110
|
# Gets the http_method property.
|
110
111
|
def http_method
|
111
|
-
|
112
|
-
|
112
|
+
@values.fetch('httpMethod') {
|
113
|
+
@values['httpMethod'] = nil
|
114
|
+
}
|
113
115
|
end
|
114
116
|
|
115
117
|
# Sets the http_method property.
|
@@ -123,8 +125,9 @@ module ApplicationInsights
|
|
123
125
|
|
124
126
|
# Gets the url property.
|
125
127
|
def url
|
126
|
-
|
127
|
-
|
128
|
+
@values.fetch('url') {
|
129
|
+
@values['url'] = nil
|
130
|
+
}
|
128
131
|
end
|
129
132
|
|
130
133
|
# Sets the url property.
|
@@ -138,9 +141,9 @@ module ApplicationInsights
|
|
138
141
|
|
139
142
|
# Gets the properties property.
|
140
143
|
def properties
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
+
@values.fetch('properties') {
|
145
|
+
@values['properties'] = {}
|
146
|
+
}
|
144
147
|
end
|
145
148
|
|
146
149
|
# Sets the properties property.
|
@@ -154,9 +157,9 @@ module ApplicationInsights
|
|
154
157
|
|
155
158
|
# Gets the measurements property.
|
156
159
|
def measurements
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
+
@values.fetch('measurements') {
|
161
|
+
@values['measurements'] = {}
|
162
|
+
}
|
160
163
|
end
|
161
164
|
|
162
165
|
# Sets the measurements property.
|
@@ -19,8 +19,9 @@ module ApplicationInsights
|
|
19
19
|
|
20
20
|
# Gets the id property.
|
21
21
|
def id
|
22
|
-
|
23
|
-
|
22
|
+
@values.fetch('ai.session.id') {
|
23
|
+
@values['ai.session.id'] = nil
|
24
|
+
}
|
24
25
|
end
|
25
26
|
|
26
27
|
# Sets the id property.
|
@@ -34,8 +35,9 @@ module ApplicationInsights
|
|
34
35
|
|
35
36
|
# Gets the is_first property.
|
36
37
|
def is_first
|
37
|
-
|
38
|
-
|
38
|
+
@values.fetch('ai.session.isFirst') {
|
39
|
+
@values['ai.session.isFirst'] = nil
|
40
|
+
}
|
39
41
|
end
|
40
42
|
|
41
43
|
# Sets the is_first property.
|
@@ -49,8 +51,9 @@ module ApplicationInsights
|
|
49
51
|
|
50
52
|
# Gets the is_new property.
|
51
53
|
def is_new
|
52
|
-
|
53
|
-
|
54
|
+
@values.fetch('ai.session.isNew') {
|
55
|
+
@values['ai.session.isNew'] = nil
|
56
|
+
}
|
54
57
|
end
|
55
58
|
|
56
59
|
# Sets the is_new property.
|
@@ -43,8 +43,9 @@ module ApplicationInsights
|
|
43
43
|
|
44
44
|
# Gets the assembly property.
|
45
45
|
def assembly
|
46
|
-
|
47
|
-
|
46
|
+
@values.fetch('assembly') {
|
47
|
+
@values['assembly'] = nil
|
48
|
+
}
|
48
49
|
end
|
49
50
|
|
50
51
|
# Sets the assembly property.
|
@@ -58,8 +59,9 @@ module ApplicationInsights
|
|
58
59
|
|
59
60
|
# Gets the file_name property.
|
60
61
|
def file_name
|
61
|
-
|
62
|
-
|
62
|
+
@values.fetch('fileName') {
|
63
|
+
@values['fileName'] = nil
|
64
|
+
}
|
63
65
|
end
|
64
66
|
|
65
67
|
# Sets the file_name property.
|
@@ -73,8 +75,9 @@ module ApplicationInsights
|
|
73
75
|
|
74
76
|
# Gets the line property.
|
75
77
|
def line
|
76
|
-
|
77
|
-
|
78
|
+
@values.fetch('line') {
|
79
|
+
@values['line'] = nil
|
80
|
+
}
|
78
81
|
end
|
79
82
|
|
80
83
|
# Sets the line property.
|
@@ -20,8 +20,9 @@ module ApplicationInsights
|
|
20
20
|
|
21
21
|
# Gets the account_acquisition_date property.
|
22
22
|
def account_acquisition_date
|
23
|
-
|
24
|
-
|
23
|
+
@values.fetch('ai.user.accountAcquisitionDate') {
|
24
|
+
@values['ai.user.accountAcquisitionDate'] = nil
|
25
|
+
}
|
25
26
|
end
|
26
27
|
|
27
28
|
# Sets the account_acquisition_date property.
|
@@ -35,8 +36,9 @@ module ApplicationInsights
|
|
35
36
|
|
36
37
|
# Gets the account_id property.
|
37
38
|
def account_id
|
38
|
-
|
39
|
-
|
39
|
+
@values.fetch('ai.user.accountId') {
|
40
|
+
@values['ai.user.accountId'] = nil
|
41
|
+
}
|
40
42
|
end
|
41
43
|
|
42
44
|
# Sets the account_id property.
|
@@ -50,8 +52,9 @@ module ApplicationInsights
|
|
50
52
|
|
51
53
|
# Gets the user_agent property.
|
52
54
|
def user_agent
|
53
|
-
|
54
|
-
|
55
|
+
@values.fetch('ai.user.userAgent') {
|
56
|
+
@values['ai.user.userAgent'] = nil
|
57
|
+
}
|
55
58
|
end
|
56
59
|
|
57
60
|
# Sets the user_agent property.
|
@@ -65,8 +68,9 @@ module ApplicationInsights
|
|
65
68
|
|
66
69
|
# Gets the id property.
|
67
70
|
def id
|
68
|
-
|
69
|
-
|
71
|
+
@values.fetch('ai.user.id') {
|
72
|
+
@values['ai.user.id'] = nil
|
73
|
+
}
|
70
74
|
end
|
71
75
|
|
72
76
|
# Sets the id property.
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_relative 'queue_base'
|
2
|
+
require 'thread'
|
3
|
+
|
4
|
+
module ApplicationInsights
|
5
|
+
module Channel
|
6
|
+
# An event class that allows simple cross-thread signalling.
|
7
|
+
#
|
8
|
+
# An object of this type managers an internal flag that can be set to true via the {#set} method and reset via the
|
9
|
+
# {#clear} method. Calling the {#wait} method will block until the flag is set to true.
|
10
|
+
# @example
|
11
|
+
# require 'application_insights'
|
12
|
+
# require 'thread'
|
13
|
+
# event = ApplicationInsights::Channel::Event.new
|
14
|
+
# Thread.new do
|
15
|
+
# sleep 1
|
16
|
+
# event.set
|
17
|
+
# end
|
18
|
+
# puts 'Main screen turn on.'
|
19
|
+
# result = event.wait
|
20
|
+
# puts 'All your base are belong to us.'
|
21
|
+
class Event
|
22
|
+
# Initializes a new instance of the class.
|
23
|
+
def initialize
|
24
|
+
@mutex = Mutex.new
|
25
|
+
@condition_variable = ConditionVariable.new
|
26
|
+
@signal = false
|
27
|
+
end
|
28
|
+
|
29
|
+
# The signal value for this object. Note that the value of this property is not synchronized
|
30
|
+
# with respect to {#set} and {#clear} meaning that it could return false positives or negatives.
|
31
|
+
# @return [Boolean] the signal value.
|
32
|
+
attr_reader :signal
|
33
|
+
|
34
|
+
# Sets the internal flag to true. Calling this method will also cause all waiting threads to awaken.
|
35
|
+
def set
|
36
|
+
@mutex.synchronize do
|
37
|
+
@signal = true
|
38
|
+
@condition_variable.broadcast
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Sets the internal flag to false.
|
43
|
+
def clear
|
44
|
+
@mutex.synchronize do
|
45
|
+
@signal = false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Calling this method will block until the internal flag is set to true. If the flag is set to true before calling
|
50
|
+
# this method, we will return immediately. If the timeout parameter is specified, the method will unblock after the
|
51
|
+
# specified number of seconds.
|
52
|
+
# @param [Fixnum] timeout the timeout for the operation in seconds.
|
53
|
+
# @return [Boolean] the value of the internal flag on exit.
|
54
|
+
def wait(timeout=nil)
|
55
|
+
@mutex.synchronize do
|
56
|
+
if @signal == false
|
57
|
+
@condition_variable.wait @mutex, (timeout == nil) ? nil : timeout
|
58
|
+
end
|
59
|
+
@signal
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|