application_insights 0.2.0 → 0.3.0

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.
Files changed (45) hide show
  1. checksums.yaml +9 -9
  2. data/LICENSE.txt +7 -18
  3. data/README.md +42 -7
  4. data/Rakefile +6 -1
  5. data/application_insights.gemspec +2 -0
  6. data/lib/application_insights.rb +1 -0
  7. data/lib/application_insights/channel/asynchronous_queue.rb +51 -0
  8. data/lib/application_insights/channel/asynchronous_sender.rb +121 -0
  9. data/lib/application_insights/channel/contracts/application.rb +3 -2
  10. data/lib/application_insights/channel/contracts/data.rb +3 -2
  11. data/lib/application_insights/channel/contracts/data_point.rb +15 -10
  12. data/lib/application_insights/channel/contracts/device.rb +42 -28
  13. data/lib/application_insights/channel/contracts/envelope.rb +39 -27
  14. data/lib/application_insights/channel/contracts/event_data.rb +6 -6
  15. data/lib/application_insights/channel/contracts/exception_data.rb +9 -8
  16. data/lib/application_insights/channel/contracts/exception_details.rb +15 -11
  17. data/lib/application_insights/channel/contracts/internal.rb +6 -4
  18. data/lib/application_insights/channel/contracts/location.rb +3 -2
  19. data/lib/application_insights/channel/contracts/message_data.rb +6 -5
  20. data/lib/application_insights/channel/contracts/metric_data.rb +3 -3
  21. data/lib/application_insights/channel/contracts/operation.rb +12 -8
  22. data/lib/application_insights/channel/contracts/page_view_data.rb +12 -10
  23. data/lib/application_insights/channel/contracts/remote_dependency_data.rb +27 -19
  24. data/lib/application_insights/channel/contracts/request_data.rb +15 -12
  25. data/lib/application_insights/channel/contracts/session.rb +9 -6
  26. data/lib/application_insights/channel/contracts/stack_frame.rb +9 -6
  27. data/lib/application_insights/channel/contracts/user.rb +12 -8
  28. data/lib/application_insights/channel/event.rb +64 -0
  29. data/lib/application_insights/channel/queue_base.rb +24 -10
  30. data/lib/application_insights/channel/sender_base.rb +38 -9
  31. data/lib/application_insights/channel/synchronous_queue.rb +16 -5
  32. data/lib/application_insights/channel/synchronous_sender.rb +4 -2
  33. data/lib/application_insights/channel/telemetry_channel.rb +26 -7
  34. data/lib/application_insights/channel/telemetry_context.rb +29 -10
  35. data/lib/application_insights/telemetry_client.rb +84 -15
  36. data/lib/application_insights/unhandled_exception.rb +48 -0
  37. data/lib/application_insights/version.rb +1 -1
  38. data/test/application_insights/channel/test_asynchronous_queue.rb +68 -0
  39. data/test/application_insights/channel/test_asynchronous_sender.rb +81 -0
  40. data/test/application_insights/channel/test_event.rb +53 -0
  41. data/test/application_insights/channel/test_queue_base.rb +10 -9
  42. data/test/application_insights/channel/test_sender_base.rb +0 -9
  43. data/test/application_insights/test_telemetry_client.rb +5 -0
  44. data/test/application_insights/test_unhandled_exception.rb +42 -0
  45. metadata +44 -3
@@ -30,8 +30,9 @@ module ApplicationInsights
30
30
 
31
31
  # Gets the id property.
32
32
  def id
33
- return @values['ai.device.id'] if @values.key?('ai.device.id')
34
- @defaults['ai.device.id']
33
+ @values.fetch('ai.device.id') {
34
+ @values['ai.device.id'] = nil
35
+ }
35
36
  end
36
37
 
37
38
  # Sets the id property.
@@ -45,8 +46,9 @@ module ApplicationInsights
45
46
 
46
47
  # Gets the ip property.
47
48
  def ip
48
- return @values['ai.device.ip'] if @values.key?('ai.device.ip')
49
- @defaults['ai.device.ip']
49
+ @values.fetch('ai.device.ip') {
50
+ @values['ai.device.ip'] = nil
51
+ }
50
52
  end
51
53
 
52
54
  # Sets the ip property.
@@ -60,8 +62,9 @@ module ApplicationInsights
60
62
 
61
63
  # Gets the language property.
62
64
  def language
63
- return @values['ai.device.language'] if @values.key?('ai.device.language')
64
- @defaults['ai.device.language']
65
+ @values.fetch('ai.device.language') {
66
+ @values['ai.device.language'] = nil
67
+ }
65
68
  end
66
69
 
67
70
  # Sets the language property.
@@ -75,8 +78,9 @@ module ApplicationInsights
75
78
 
76
79
  # Gets the locale property.
77
80
  def locale
78
- return @values['ai.device.locale'] if @values.key?('ai.device.locale')
79
- @defaults['ai.device.locale']
81
+ @values.fetch('ai.device.locale') {
82
+ @values['ai.device.locale'] = nil
83
+ }
80
84
  end
81
85
 
82
86
  # Sets the locale property.
@@ -90,8 +94,9 @@ module ApplicationInsights
90
94
 
91
95
  # Gets the model property.
92
96
  def model
93
- return @values['ai.device.model'] if @values.key?('ai.device.model')
94
- @defaults['ai.device.model']
97
+ @values.fetch('ai.device.model') {
98
+ @values['ai.device.model'] = nil
99
+ }
95
100
  end
96
101
 
97
102
  # Sets the model property.
@@ -105,8 +110,9 @@ module ApplicationInsights
105
110
 
106
111
  # Gets the network property.
107
112
  def network
108
- return @values['ai.device.network'] if @values.key?('ai.device.network')
109
- @defaults['ai.device.network']
113
+ @values.fetch('ai.device.network') {
114
+ @values['ai.device.network'] = nil
115
+ }
110
116
  end
111
117
 
112
118
  # Sets the network property.
@@ -120,8 +126,9 @@ module ApplicationInsights
120
126
 
121
127
  # Gets the oem_name property.
122
128
  def oem_name
123
- return @values['ai.device.oemName'] if @values.key?('ai.device.oemName')
124
- @defaults['ai.device.oemName']
129
+ @values.fetch('ai.device.oemName') {
130
+ @values['ai.device.oemName'] = nil
131
+ }
125
132
  end
126
133
 
127
134
  # Sets the oem_name property.
@@ -135,8 +142,9 @@ module ApplicationInsights
135
142
 
136
143
  # Gets the os property.
137
144
  def os
138
- return @values['ai.device.os'] if @values.key?('ai.device.os')
139
- @defaults['ai.device.os']
145
+ @values.fetch('ai.device.os') {
146
+ @values['ai.device.os'] = nil
147
+ }
140
148
  end
141
149
 
142
150
  # Sets the os property.
@@ -150,8 +158,9 @@ module ApplicationInsights
150
158
 
151
159
  # Gets the os_version property.
152
160
  def os_version
153
- return @values['ai.device.osVersion'] if @values.key?('ai.device.osVersion')
154
- @defaults['ai.device.osVersion']
161
+ @values.fetch('ai.device.osVersion') {
162
+ @values['ai.device.osVersion'] = nil
163
+ }
155
164
  end
156
165
 
157
166
  # Sets the os_version property.
@@ -165,8 +174,9 @@ module ApplicationInsights
165
174
 
166
175
  # Gets the role_instance property.
167
176
  def role_instance
168
- return @values['ai.device.roleInstance'] if @values.key?('ai.device.roleInstance')
169
- @defaults['ai.device.roleInstance']
177
+ @values.fetch('ai.device.roleInstance') {
178
+ @values['ai.device.roleInstance'] = nil
179
+ }
170
180
  end
171
181
 
172
182
  # Sets the role_instance property.
@@ -180,8 +190,9 @@ module ApplicationInsights
180
190
 
181
191
  # Gets the role_name property.
182
192
  def role_name
183
- return @values['ai.device.roleName'] if @values.key?('ai.device.roleName')
184
- @defaults['ai.device.roleName']
193
+ @values.fetch('ai.device.roleName') {
194
+ @values['ai.device.roleName'] = nil
195
+ }
185
196
  end
186
197
 
187
198
  # Sets the role_name property.
@@ -195,8 +206,9 @@ module ApplicationInsights
195
206
 
196
207
  # Gets the screen_resolution property.
197
208
  def screen_resolution
198
- return @values['ai.device.screenResolution'] if @values.key?('ai.device.screenResolution')
199
- @defaults['ai.device.screenResolution']
209
+ @values.fetch('ai.device.screenResolution') {
210
+ @values['ai.device.screenResolution'] = nil
211
+ }
200
212
  end
201
213
 
202
214
  # Sets the screen_resolution property.
@@ -210,8 +222,9 @@ module ApplicationInsights
210
222
 
211
223
  # Gets the type property.
212
224
  def type
213
- return @values['ai.device.type'] if @values.key?('ai.device.type')
214
- @defaults['ai.device.type']
225
+ @values.fetch('ai.device.type') {
226
+ @values['ai.device.type'] = nil
227
+ }
215
228
  end
216
229
 
217
230
  # Sets the type property.
@@ -225,8 +238,9 @@ module ApplicationInsights
225
238
 
226
239
  # Gets the vm_name property.
227
240
  def vm_name
228
- return @values['ai.device.vmName'] if @values.key?('ai.device.vmName')
229
- @defaults['ai.device.vmName']
241
+ @values.fetch('ai.device.vmName') {
242
+ @values['ai.device.vmName'] = nil
243
+ }
230
244
  end
231
245
 
232
246
  # Sets the vm_name property.
@@ -35,8 +35,9 @@ module ApplicationInsights
35
35
 
36
36
  # Gets the ver property.
37
37
  def ver
38
- return @values['ver'] if @values.key?('ver')
39
- @defaults['ver']
38
+ @values.fetch('ver') {
39
+ @values['ver'] = 1
40
+ }
40
41
  end
41
42
 
42
43
  # Sets the ver property.
@@ -70,8 +71,9 @@ module ApplicationInsights
70
71
 
71
72
  # Gets the sample_rate property.
72
73
  def sample_rate
73
- return @values['sampleRate'] if @values.key?('sampleRate')
74
- @defaults['sampleRate']
74
+ @values.fetch('sampleRate') {
75
+ @values['sampleRate'] = 100.0
76
+ }
75
77
  end
76
78
 
77
79
  # Sets the sample_rate property.
@@ -85,8 +87,9 @@ module ApplicationInsights
85
87
 
86
88
  # Gets the seq property.
87
89
  def seq
88
- return @values['seq'] if @values.key?('seq')
89
- @defaults['seq']
90
+ @values.fetch('seq') {
91
+ @values['seq'] = nil
92
+ }
90
93
  end
91
94
 
92
95
  # Sets the seq property.
@@ -100,8 +103,9 @@ module ApplicationInsights
100
103
 
101
104
  # Gets the i_key property.
102
105
  def i_key
103
- return @values['iKey'] if @values.key?('iKey')
104
- @defaults['iKey']
106
+ @values.fetch('iKey') {
107
+ @values['iKey'] = nil
108
+ }
105
109
  end
106
110
 
107
111
  # Sets the i_key property.
@@ -115,8 +119,9 @@ module ApplicationInsights
115
119
 
116
120
  # Gets the flags property.
117
121
  def flags
118
- return @values['flags'] if @values.key?('flags')
119
- @defaults['flags']
122
+ @values.fetch('flags') {
123
+ @values['flags'] = nil
124
+ }
120
125
  end
121
126
 
122
127
  # Sets the flags property.
@@ -130,8 +135,9 @@ module ApplicationInsights
130
135
 
131
136
  # Gets the device_id property.
132
137
  def device_id
133
- return @values['deviceId'] if @values.key?('deviceId')
134
- @defaults['deviceId']
138
+ @values.fetch('deviceId') {
139
+ @values['deviceId'] = nil
140
+ }
135
141
  end
136
142
 
137
143
  # Sets the device_id property.
@@ -145,8 +151,9 @@ module ApplicationInsights
145
151
 
146
152
  # Gets the os property.
147
153
  def os
148
- return @values['os'] if @values.key?('os')
149
- @defaults['os']
154
+ @values.fetch('os') {
155
+ @values['os'] = nil
156
+ }
150
157
  end
151
158
 
152
159
  # Sets the os property.
@@ -160,8 +167,9 @@ module ApplicationInsights
160
167
 
161
168
  # Gets the os_ver property.
162
169
  def os_ver
163
- return @values['osVer'] if @values.key?('osVer')
164
- @defaults['osVer']
170
+ @values.fetch('osVer') {
171
+ @values['osVer'] = nil
172
+ }
165
173
  end
166
174
 
167
175
  # Sets the os_ver property.
@@ -175,8 +183,9 @@ module ApplicationInsights
175
183
 
176
184
  # Gets the app_id property.
177
185
  def app_id
178
- return @values['appId'] if @values.key?('appId')
179
- @defaults['appId']
186
+ @values.fetch('appId') {
187
+ @values['appId'] = nil
188
+ }
180
189
  end
181
190
 
182
191
  # Sets the app_id property.
@@ -190,8 +199,9 @@ module ApplicationInsights
190
199
 
191
200
  # Gets the app_ver property.
192
201
  def app_ver
193
- return @values['appVer'] if @values.key?('appVer')
194
- @defaults['appVer']
202
+ @values.fetch('appVer') {
203
+ @values['appVer'] = nil
204
+ }
195
205
  end
196
206
 
197
207
  # Sets the app_ver property.
@@ -205,8 +215,9 @@ module ApplicationInsights
205
215
 
206
216
  # Gets the user_id property.
207
217
  def user_id
208
- return @values['userId'] if @values.key?('userId')
209
- @defaults['userId']
218
+ @values.fetch('userId') {
219
+ @values['userId'] = nil
220
+ }
210
221
  end
211
222
 
212
223
  # Sets the user_id property.
@@ -220,9 +231,9 @@ module ApplicationInsights
220
231
 
221
232
  # Gets the tags property.
222
233
  def tags
223
- return @values['tags'] if @values.key?('tags')
224
- @values['tags'] = {}
225
- @values['tags']
234
+ @values.fetch('tags') {
235
+ @values['tags'] = {}
236
+ }
226
237
  end
227
238
 
228
239
  # Sets the tags property.
@@ -236,8 +247,9 @@ module ApplicationInsights
236
247
 
237
248
  # Gets the data property.
238
249
  def data
239
- return @values['data'] if @values.key?('data')
240
- @defaults['data']
250
+ @values.fetch('data') {
251
+ @values['data'] = nil
252
+ }
241
253
  end
242
254
 
243
255
  # Sets the data property.
@@ -42,9 +42,9 @@ module ApplicationInsights
42
42
 
43
43
  # Gets the properties property.
44
44
  def properties
45
- return @values['properties'] if @values.key?('properties')
46
- @values['properties'] = {}
47
- @values['properties']
45
+ @values.fetch('properties') {
46
+ @values['properties'] = {}
47
+ }
48
48
  end
49
49
 
50
50
  # Sets the properties property.
@@ -58,9 +58,9 @@ module ApplicationInsights
58
58
 
59
59
  # Gets the measurements property.
60
60
  def measurements
61
- return @values['measurements'] if @values.key?('measurements')
62
- @values['measurements'] = {}
63
- @values['measurements']
61
+ @values.fetch('measurements') {
62
+ @values['measurements'] = {}
63
+ }
64
64
  end
65
65
 
66
66
  # Sets the measurements property.
@@ -55,8 +55,9 @@ module ApplicationInsights
55
55
 
56
56
  # Gets the severity_level property.
57
57
  def severity_level
58
- return @values['severityLevel'] if @values.key?('severityLevel')
59
- @defaults['severityLevel']
58
+ @values.fetch('severityLevel') {
59
+ @values['severityLevel'] = nil
60
+ }
60
61
  end
61
62
 
62
63
  # Sets the severity_level property.
@@ -70,9 +71,9 @@ module ApplicationInsights
70
71
 
71
72
  # Gets the properties property.
72
73
  def properties
73
- return @values['properties'] if @values.key?('properties')
74
- @values['properties'] = {}
75
- @values['properties']
74
+ @values.fetch('properties') {
75
+ @values['properties'] = {}
76
+ }
76
77
  end
77
78
 
78
79
  # Sets the properties property.
@@ -86,9 +87,9 @@ module ApplicationInsights
86
87
 
87
88
  # Gets the measurements property.
88
89
  def measurements
89
- return @values['measurements'] if @values.key?('measurements')
90
- @values['measurements'] = {}
91
- @values['measurements']
90
+ @values.fetch('measurements') {
91
+ @values['measurements'] = {}
92
+ }
92
93
  end
93
94
 
94
95
  # Sets the measurements property.
@@ -26,8 +26,9 @@ module ApplicationInsights
26
26
 
27
27
  # Gets the id property.
28
28
  def id
29
- return @values['id'] if @values.key?('id')
30
- @defaults['id']
29
+ @values.fetch('id') {
30
+ @values['id'] = nil
31
+ }
31
32
  end
32
33
 
33
34
  # Sets the id property.
@@ -41,8 +42,9 @@ module ApplicationInsights
41
42
 
42
43
  # Gets the outer_id property.
43
44
  def outer_id
44
- return @values['outerId'] if @values.key?('outerId')
45
- @defaults['outerId']
45
+ @values.fetch('outerId') {
46
+ @values['outerId'] = nil
47
+ }
46
48
  end
47
49
 
48
50
  # Sets the outer_id property.
@@ -76,8 +78,9 @@ module ApplicationInsights
76
78
 
77
79
  # Gets the has_full_stack property.
78
80
  def has_full_stack
79
- return @values['hasFullStack'] if @values.key?('hasFullStack')
80
- @defaults['hasFullStack']
81
+ @values.fetch('hasFullStack') {
82
+ @values['hasFullStack'] = true
83
+ }
81
84
  end
82
85
 
83
86
  # Sets the has_full_stack property.
@@ -91,8 +94,9 @@ module ApplicationInsights
91
94
 
92
95
  # Gets the stack property.
93
96
  def stack
94
- return @values['stack'] if @values.key?('stack')
95
- @defaults['stack']
97
+ @values.fetch('stack') {
98
+ @values['stack'] = nil
99
+ }
96
100
  end
97
101
 
98
102
  # Sets the stack property.
@@ -106,9 +110,9 @@ module ApplicationInsights
106
110
 
107
111
  # Gets the parsed_stack property.
108
112
  def parsed_stack
109
- return @values['parsedStack'] if @values.key?('parsedStack')
110
- @values['parsedStack'] = []
111
- @values['parsedStack']
113
+ @values.fetch('parsedStack') {
114
+ @values['parsedStack'] = []
115
+ }
112
116
  end
113
117
 
114
118
  # Sets the parsed_stack property.
@@ -18,8 +18,9 @@ module ApplicationInsights
18
18
 
19
19
  # Gets the sdk_version property.
20
20
  def sdk_version
21
- return @values['ai.internal.sdkVersion'] if @values.key?('ai.internal.sdkVersion')
22
- @defaults['ai.internal.sdkVersion']
21
+ @values.fetch('ai.internal.sdkVersion') {
22
+ @values['ai.internal.sdkVersion'] = nil
23
+ }
23
24
  end
24
25
 
25
26
  # Sets the sdk_version property.
@@ -33,8 +34,9 @@ module ApplicationInsights
33
34
 
34
35
  # Gets the agent_version property.
35
36
  def agent_version
36
- return @values['ai.internal.agentVersion'] if @values.key?('ai.internal.agentVersion')
37
- @defaults['ai.internal.agentVersion']
37
+ @values.fetch('ai.internal.agentVersion') {
38
+ @values['ai.internal.agentVersion'] = nil
39
+ }
38
40
  end
39
41
 
40
42
  # Sets the agent_version property.