application_insights 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +6 -14
  2. data/.travis.yml +21 -9
  3. data/CONTRIBUTING.md +30 -0
  4. data/Gemfile +4 -4
  5. data/LICENSE.txt +11 -11
  6. data/README.md +13 -14
  7. data/Rakefile +14 -14
  8. data/application_insights.gemspec +28 -29
  9. data/lib/application_insights.rb +9 -9
  10. data/lib/application_insights/channel/asynchronous_queue.rb +58 -51
  11. data/lib/application_insights/channel/asynchronous_sender.rb +132 -123
  12. data/lib/application_insights/channel/contracts/application.rb +14 -53
  13. data/lib/application_insights/channel/contracts/cloud.rb +14 -0
  14. data/lib/application_insights/channel/contracts/data.rb +14 -48
  15. data/lib/application_insights/channel/contracts/data_point.rb +24 -130
  16. data/lib/application_insights/channel/contracts/data_point_type.rb +7 -16
  17. data/lib/application_insights/channel/contracts/dependency_kind.rb +9 -19
  18. data/lib/application_insights/channel/contracts/dependency_source_type.rb +9 -19
  19. data/lib/application_insights/channel/contracts/device.rb +28 -257
  20. data/lib/application_insights/channel/contracts/envelope.rb +40 -266
  21. data/lib/application_insights/channel/contracts/event_data.rb +28 -77
  22. data/lib/application_insights/channel/contracts/exception_data.rb +37 -140
  23. data/lib/application_insights/channel/contracts/exception_details.rb +28 -129
  24. data/lib/application_insights/channel/contracts/internal.rb +14 -53
  25. data/lib/application_insights/channel/contracts/json_serializable.rb +59 -59
  26. data/lib/application_insights/channel/contracts/location.rb +16 -36
  27. data/lib/application_insights/channel/contracts/message_data.rb +24 -77
  28. data/lib/application_insights/channel/contracts/metric_data.rb +27 -60
  29. data/lib/application_insights/channel/contracts/operation.rb +19 -121
  30. data/lib/application_insights/channel/contracts/page_view_data.rb +30 -111
  31. data/lib/application_insights/channel/contracts/remote_dependency_data.rb +56 -260
  32. data/lib/application_insights/channel/contracts/request_data.rb +36 -176
  33. data/lib/application_insights/channel/contracts/session.rb +15 -70
  34. data/lib/application_insights/channel/contracts/severity_level.rb +13 -25
  35. data/lib/application_insights/channel/contracts/stack_frame.rb +17 -94
  36. data/lib/application_insights/channel/contracts/user.rb +19 -104
  37. data/lib/application_insights/channel/event.rb +68 -64
  38. data/lib/application_insights/channel/queue_base.rb +65 -62
  39. data/lib/application_insights/channel/sender_base.rb +79 -72
  40. data/lib/application_insights/channel/synchronous_queue.rb +45 -39
  41. data/lib/application_insights/channel/synchronous_sender.rb +17 -15
  42. data/lib/application_insights/channel/telemetry_channel.rb +120 -102
  43. data/lib/application_insights/channel/telemetry_context.rb +85 -68
  44. data/lib/application_insights/rack/track_request.rb +87 -84
  45. data/lib/application_insights/telemetry_client.rb +229 -217
  46. data/lib/application_insights/unhandled_exception.rb +49 -47
  47. data/lib/application_insights/version.rb +3 -3
  48. data/test/application_insights.rb +8 -9
  49. data/test/application_insights/channel/contracts/test_application.rb +44 -44
  50. data/test/application_insights/channel/contracts/test_cloud.rb +44 -0
  51. data/test/application_insights/channel/contracts/test_data.rb +44 -44
  52. data/test/application_insights/channel/contracts/test_data_point.rb +109 -109
  53. data/test/application_insights/channel/contracts/test_device.rb +200 -200
  54. data/test/application_insights/channel/contracts/test_envelope.rb +209 -209
  55. data/test/application_insights/channel/contracts/test_event_data.rb +62 -62
  56. data/test/application_insights/channel/contracts/test_exception_data.rb +111 -111
  57. data/test/application_insights/channel/contracts/test_exception_details.rb +106 -106
  58. data/test/application_insights/channel/contracts/test_internal.rb +44 -44
  59. data/test/application_insights/channel/contracts/test_location.rb +70 -31
  60. data/test/application_insights/channel/contracts/test_message_data.rb +66 -66
  61. data/test/application_insights/channel/contracts/test_metric_data.rb +50 -50
  62. data/test/application_insights/channel/contracts/test_operation.rb +109 -96
  63. data/test/application_insights/channel/contracts/test_page_view_data.rb +88 -88
  64. data/test/application_insights/channel/contracts/test_remote_dependency_data.rb +209 -209
  65. data/test/application_insights/channel/contracts/test_request_data.rb +153 -153
  66. data/test/application_insights/channel/contracts/test_session.rb +57 -57
  67. data/test/application_insights/channel/contracts/test_stack_frame.rb +83 -83
  68. data/test/application_insights/channel/contracts/test_user.rb +96 -83
  69. data/test/application_insights/channel/test_asynchronous_queue.rb +47 -47
  70. data/test/application_insights/channel/test_asynchronous_sender.rb +80 -80
  71. data/test/application_insights/channel/test_event.rb +52 -52
  72. data/test/application_insights/channel/test_queue_base.rb +88 -88
  73. data/test/application_insights/channel/test_sender_base.rb +87 -87
  74. data/test/application_insights/channel/test_synchronous_queue.rb +27 -27
  75. data/test/application_insights/channel/test_synchronous_sender.rb +10 -10
  76. data/test/application_insights/channel/test_telemetry_channel.rb +126 -102
  77. data/test/application_insights/channel/test_telemetry_context.rb +82 -74
  78. data/test/application_insights/mock_sender.rb +37 -37
  79. data/test/application_insights/rack/test_track_request.rb +142 -139
  80. data/test/application_insights/test_telemetry_client.rb +133 -123
  81. data/test/application_insights/test_unhandled_exception.rb +23 -24
  82. metadata +23 -33
@@ -1,266 +1,40 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type Envelope.
7
- class Envelope < JsonSerializable
8
- # Initializes a new instance of the Envelope class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ver' => 1,
12
- 'name' => nil,
13
- 'time' => nil,
14
- 'sampleRate' => 100.0,
15
- 'seq' => nil,
16
- 'iKey' => nil,
17
- 'flags' => nil,
18
- 'deviceId' => nil,
19
- 'os' => nil,
20
- 'osVer' => nil,
21
- 'appId' => nil,
22
- 'appVer' => nil,
23
- 'userId' => nil,
24
- 'tags' => {},
25
- 'data' => nil
26
- }
27
- values = {
28
- 'ver' => 1,
29
- 'name' => nil,
30
- 'time' => nil,
31
- 'sampleRate' => 100.0
32
- }
33
- super defaults, values, options
34
- end
35
-
36
- # Gets the ver property.
37
- def ver
38
- @values.fetch('ver') {
39
- @values['ver'] = 1
40
- }
41
- end
42
-
43
- # Sets the ver property.
44
- def ver=(value)
45
- if value == @defaults['ver']
46
- @values.delete 'ver' if @values.key? 'ver'
47
- else
48
- @values['ver'] = value
49
- end
50
- end
51
-
52
- # Gets the name property.
53
- def name
54
- @values['name']
55
- end
56
-
57
- # Sets the name property.
58
- def name=(value)
59
- @values['name'] = value
60
- end
61
-
62
- # Gets the time property.
63
- def time
64
- @values['time']
65
- end
66
-
67
- # Sets the time property.
68
- def time=(value)
69
- @values['time'] = value
70
- end
71
-
72
- # Gets the sample_rate property.
73
- def sample_rate
74
- @values.fetch('sampleRate') {
75
- @values['sampleRate'] = 100.0
76
- }
77
- end
78
-
79
- # Sets the sample_rate property.
80
- def sample_rate=(value)
81
- if value == @defaults['sampleRate']
82
- @values.delete 'sampleRate' if @values.key? 'sampleRate'
83
- else
84
- @values['sampleRate'] = value
85
- end
86
- end
87
-
88
- # Gets the seq property.
89
- def seq
90
- @values.fetch('seq') {
91
- @values['seq'] = nil
92
- }
93
- end
94
-
95
- # Sets the seq property.
96
- def seq=(value)
97
- if value == @defaults['seq']
98
- @values.delete 'seq' if @values.key? 'seq'
99
- else
100
- @values['seq'] = value
101
- end
102
- end
103
-
104
- # Gets the i_key property.
105
- def i_key
106
- @values.fetch('iKey') {
107
- @values['iKey'] = nil
108
- }
109
- end
110
-
111
- # Sets the i_key property.
112
- def i_key=(value)
113
- if value == @defaults['iKey']
114
- @values.delete 'iKey' if @values.key? 'iKey'
115
- else
116
- @values['iKey'] = value
117
- end
118
- end
119
-
120
- # Gets the flags property.
121
- def flags
122
- @values.fetch('flags') {
123
- @values['flags'] = nil
124
- }
125
- end
126
-
127
- # Sets the flags property.
128
- def flags=(value)
129
- if value == @defaults['flags']
130
- @values.delete 'flags' if @values.key? 'flags'
131
- else
132
- @values['flags'] = value
133
- end
134
- end
135
-
136
- # Gets the device_id property.
137
- def device_id
138
- @values.fetch('deviceId') {
139
- @values['deviceId'] = nil
140
- }
141
- end
142
-
143
- # Sets the device_id property.
144
- def device_id=(value)
145
- if value == @defaults['deviceId']
146
- @values.delete 'deviceId' if @values.key? 'deviceId'
147
- else
148
- @values['deviceId'] = value
149
- end
150
- end
151
-
152
- # Gets the os property.
153
- def os
154
- @values.fetch('os') {
155
- @values['os'] = nil
156
- }
157
- end
158
-
159
- # Sets the os property.
160
- def os=(value)
161
- if value == @defaults['os']
162
- @values.delete 'os' if @values.key? 'os'
163
- else
164
- @values['os'] = value
165
- end
166
- end
167
-
168
- # Gets the os_ver property.
169
- def os_ver
170
- @values.fetch('osVer') {
171
- @values['osVer'] = nil
172
- }
173
- end
174
-
175
- # Sets the os_ver property.
176
- def os_ver=(value)
177
- if value == @defaults['osVer']
178
- @values.delete 'osVer' if @values.key? 'osVer'
179
- else
180
- @values['osVer'] = value
181
- end
182
- end
183
-
184
- # Gets the app_id property.
185
- def app_id
186
- @values.fetch('appId') {
187
- @values['appId'] = nil
188
- }
189
- end
190
-
191
- # Sets the app_id property.
192
- def app_id=(value)
193
- if value == @defaults['appId']
194
- @values.delete 'appId' if @values.key? 'appId'
195
- else
196
- @values['appId'] = value
197
- end
198
- end
199
-
200
- # Gets the app_ver property.
201
- def app_ver
202
- @values.fetch('appVer') {
203
- @values['appVer'] = nil
204
- }
205
- end
206
-
207
- # Sets the app_ver property.
208
- def app_ver=(value)
209
- if value == @defaults['appVer']
210
- @values.delete 'appVer' if @values.key? 'appVer'
211
- else
212
- @values['appVer'] = value
213
- end
214
- end
215
-
216
- # Gets the user_id property.
217
- def user_id
218
- @values.fetch('userId') {
219
- @values['userId'] = nil
220
- }
221
- end
222
-
223
- # Sets the user_id property.
224
- def user_id=(value)
225
- if value == @defaults['userId']
226
- @values.delete 'userId' if @values.key? 'userId'
227
- else
228
- @values['userId'] = value
229
- end
230
- end
231
-
232
- # Gets the tags property.
233
- def tags
234
- @values.fetch('tags') {
235
- @values['tags'] = {}
236
- }
237
- end
238
-
239
- # Sets the tags property.
240
- def tags=(value)
241
- if value == @defaults['tags']
242
- @values.delete 'tags' if @values.key? 'tags'
243
- else
244
- @values['tags'] = value
245
- end
246
- end
247
-
248
- # Gets the data property.
249
- def data
250
- @values.fetch('data') {
251
- @values['data'] = nil
252
- }
253
- end
254
-
255
- # Sets the data property.
256
- def data=(value)
257
- if value == @defaults['data']
258
- @values.delete 'data' if @values.key? 'data'
259
- else
260
- @values['data'] = value
261
- end
262
- end
263
- end
264
- end
265
- end
266
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Envelope
5
+ include JsonSerializable
6
+
7
+ attr_accessor :ver, :name, :time, :sample_rate, :seq, :i_key, :flags, :device_id,
8
+ :os, :os_ver, :app_id, :app_ver, :user_id, :tags, :data
9
+
10
+ attribute_mapping(
11
+ ver: 'ver',
12
+ name: 'name',
13
+ time: 'time',
14
+ sample_rate: 'sampleRate',
15
+ seq: 'seq',
16
+ i_key: 'iKey',
17
+ flags: 'flags',
18
+ device_id: 'deviceId',
19
+ os: 'os',
20
+ os_ver: 'osVer',
21
+ app_id: 'appId',
22
+ app_ver: 'appVer',
23
+ user_id: 'userId',
24
+ tags: 'tags',
25
+ data: 'data'
26
+ )
27
+
28
+ def ver
29
+ @ver ||= 1
30
+ end
31
+
32
+ def sample_rate
33
+ @sample_rate ||= 100.0
34
+ end
35
+
36
+ def tags
37
+ @tags ||= {}
38
+ end
39
+ end
40
+ end
@@ -1,77 +1,28 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type EventData.
7
- class EventData < JsonSerializable
8
- # Initializes a new instance of the EventData class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ver' => 2,
12
- 'name' => nil,
13
- 'properties' => {},
14
- 'measurements' => {}
15
- }
16
- values = {
17
- 'ver' => 2,
18
- 'name' => nil
19
- }
20
- super defaults, values, options
21
- end
22
-
23
- # Gets the ver property.
24
- def ver
25
- @values['ver']
26
- end
27
-
28
- # Sets the ver property.
29
- def ver=(value)
30
- @values['ver'] = value
31
- end
32
-
33
- # Gets the name property.
34
- def name
35
- @values['name']
36
- end
37
-
38
- # Sets the name property.
39
- def name=(value)
40
- @values['name'] = value
41
- end
42
-
43
- # Gets the properties property.
44
- def properties
45
- @values.fetch('properties') {
46
- @values['properties'] = {}
47
- }
48
- end
49
-
50
- # Sets the properties property.
51
- def properties=(value)
52
- if value == @defaults['properties']
53
- @values.delete 'properties' if @values.key? 'properties'
54
- else
55
- @values['properties'] = value
56
- end
57
- end
58
-
59
- # Gets the measurements property.
60
- def measurements
61
- @values.fetch('measurements') {
62
- @values['measurements'] = {}
63
- }
64
- end
65
-
66
- # Sets the measurements property.
67
- def measurements=(value)
68
- if value == @defaults['measurements']
69
- @values.delete 'measurements' if @values.key? 'measurements'
70
- else
71
- @values['measurements'] = value
72
- end
73
- end
74
- end
75
- end
76
- end
77
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class EventData
5
+ include JsonSerializable
6
+
7
+ attr_accessor :ver, :name, :properties, :measurements
8
+
9
+ attribute_mapping(
10
+ ver: 'ver',
11
+ name: 'name',
12
+ properties: 'properties',
13
+ measurements: 'measurements'
14
+ )
15
+
16
+ def ver
17
+ @ver ||= 2
18
+ end
19
+
20
+ def properties
21
+ @properties ||= {}
22
+ end
23
+
24
+ def measurements
25
+ @measurements ||= {}
26
+ end
27
+ end
28
+ end
@@ -1,140 +1,37 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type ExceptionData.
7
- class ExceptionData < JsonSerializable
8
- # Initializes a new instance of the ExceptionData class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ver' => 2,
12
- 'handledAt' => nil,
13
- 'exceptions' => [],
14
- 'severityLevel' => nil,
15
- 'problemId' => nil,
16
- 'crashThreadId' => nil,
17
- 'properties' => {},
18
- 'measurements' => {}
19
- }
20
- values = {
21
- 'ver' => 2,
22
- 'handledAt' => nil,
23
- 'exceptions' => []
24
- }
25
- super defaults, values, options
26
- end
27
-
28
- # Gets the ver property.
29
- def ver
30
- @values['ver']
31
- end
32
-
33
- # Sets the ver property.
34
- def ver=(value)
35
- @values['ver'] = value
36
- end
37
-
38
- # Gets the handled_at property.
39
- def handled_at
40
- @values['handledAt']
41
- end
42
-
43
- # Sets the handled_at property.
44
- def handled_at=(value)
45
- @values['handledAt'] = value
46
- end
47
-
48
- # Gets the exceptions property.
49
- def exceptions
50
- @values['exceptions']
51
- end
52
-
53
- # Sets the exceptions property.
54
- def exceptions=(value)
55
- @values['exceptions'] = value
56
- end
57
-
58
- # Gets the severity_level property.
59
- def severity_level
60
- @values.fetch('severityLevel') {
61
- @values['severityLevel'] = nil
62
- }
63
- end
64
-
65
- # Sets the severity_level property.
66
- def severity_level=(value)
67
- if value == @defaults['severityLevel']
68
- @values.delete 'severityLevel' if @values.key? 'severityLevel'
69
- else
70
- @values['severityLevel'] = value
71
- end
72
- end
73
-
74
- # Gets the problem_id property.
75
- def problem_id
76
- @values.fetch('problemId') {
77
- @values['problemId'] = nil
78
- }
79
- end
80
-
81
- # Sets the problem_id property.
82
- def problem_id=(value)
83
- if value == @defaults['problemId']
84
- @values.delete 'problemId' if @values.key? 'problemId'
85
- else
86
- @values['problemId'] = value
87
- end
88
- end
89
-
90
- # Gets the crash_thread_id property.
91
- def crash_thread_id
92
- @values.fetch('crashThreadId') {
93
- @values['crashThreadId'] = nil
94
- }
95
- end
96
-
97
- # Sets the crash_thread_id property.
98
- def crash_thread_id=(value)
99
- if value == @defaults['crashThreadId']
100
- @values.delete 'crashThreadId' if @values.key? 'crashThreadId'
101
- else
102
- @values['crashThreadId'] = value
103
- end
104
- end
105
-
106
- # Gets the properties property.
107
- def properties
108
- @values.fetch('properties') {
109
- @values['properties'] = {}
110
- }
111
- end
112
-
113
- # Sets the properties property.
114
- def properties=(value)
115
- if value == @defaults['properties']
116
- @values.delete 'properties' if @values.key? 'properties'
117
- else
118
- @values['properties'] = value
119
- end
120
- end
121
-
122
- # Gets the measurements property.
123
- def measurements
124
- @values.fetch('measurements') {
125
- @values['measurements'] = {}
126
- }
127
- end
128
-
129
- # Sets the measurements property.
130
- def measurements=(value)
131
- if value == @defaults['measurements']
132
- @values.delete 'measurements' if @values.key? 'measurements'
133
- else
134
- @values['measurements'] = value
135
- end
136
- end
137
- end
138
- end
139
- end
140
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class ExceptionData
5
+ include JsonSerializable
6
+
7
+ attr_accessor :ver, :handled_at, :exceptions, :severity_level, :problem_id,
8
+ :crash_thread_id, :properties, :measurements
9
+
10
+ attribute_mapping(
11
+ ver: 'ver',
12
+ handled_at: 'handledAt',
13
+ exceptions: 'exceptions',
14
+ severity_level: 'severityLevel',
15
+ problem_id: 'problemId',
16
+ crash_thread_id: 'crashThreadId',
17
+ properties: 'properties',
18
+ measurements: 'measurements'
19
+ )
20
+
21
+ def ver
22
+ @ver ||= 2
23
+ end
24
+
25
+ def exceptions
26
+ @exceptions ||= []
27
+ end
28
+
29
+ def properties
30
+ @properties ||= {}
31
+ end
32
+
33
+ def measurements
34
+ @measurements ||= {}
35
+ end
36
+ end
37
+ end