application_insights 0.5.3 → 0.5.4

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 (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,53 +1,14 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type Application.
7
- class Application < JsonSerializable
8
- # Initializes a new instance of the Application class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ai.application.ver' => nil,
12
- 'ai.application.build' => nil
13
- }
14
- values = {
15
- }
16
- super defaults, values, options
17
- end
18
-
19
- # Gets the ver property.
20
- def ver
21
- @values.fetch('ai.application.ver') {
22
- @values['ai.application.ver'] = nil
23
- }
24
- end
25
-
26
- # Sets the ver property.
27
- def ver=(value)
28
- if value == @defaults['ai.application.ver']
29
- @values.delete 'ai.application.ver' if @values.key? 'ai.application.ver'
30
- else
31
- @values['ai.application.ver'] = value
32
- end
33
- end
34
-
35
- # Gets the build property.
36
- def build
37
- @values.fetch('ai.application.build') {
38
- @values['ai.application.build'] = nil
39
- }
40
- end
41
-
42
- # Sets the build property.
43
- def build=(value)
44
- if value == @defaults['ai.application.build']
45
- @values.delete 'ai.application.build' if @values.key? 'ai.application.build'
46
- else
47
- @values['ai.application.build'] = value
48
- end
49
- end
50
- end
51
- end
52
- end
53
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Application
5
+ include JsonSerializable
6
+
7
+ attr_accessor :ver, :build
8
+
9
+ attribute_mapping(
10
+ ver: 'ai.application.ver',
11
+ build: 'ai.application.build'
12
+ )
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Cloud
5
+ include JsonSerializable
6
+
7
+ attr_accessor :role_name, :role_instance
8
+
9
+ attribute_mapping(
10
+ role_name: 'ai.cloud.role',
11
+ role_instance: 'ai.cloud.roleInstance'
12
+ )
13
+ end
14
+ end
@@ -1,48 +1,14 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type Data.
7
- class Data < JsonSerializable
8
- # Initializes a new instance of the Data class.
9
- def initialize(options={})
10
- defaults = {
11
- 'baseType' => nil,
12
- 'baseData' => nil
13
- }
14
- values = {
15
- 'baseData' => nil
16
- }
17
- super defaults, values, options
18
- end
19
-
20
- # Gets the base_type property.
21
- def base_type
22
- @values.fetch('baseType') {
23
- @values['baseType'] = nil
24
- }
25
- end
26
-
27
- # Sets the base_type property.
28
- def base_type=(value)
29
- if value == @defaults['baseType']
30
- @values.delete 'baseType' if @values.key? 'baseType'
31
- else
32
- @values['baseType'] = value
33
- end
34
- end
35
-
36
- # Gets the base_data property.
37
- def base_data
38
- @values['baseData']
39
- end
40
-
41
- # Sets the base_data property.
42
- def base_data=(value)
43
- @values['baseData'] = value
44
- end
45
- end
46
- end
47
- end
48
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Data
5
+ include JsonSerializable
6
+
7
+ attr_accessor :base_type, :base_data
8
+
9
+ attribute_mapping(
10
+ base_type: 'baseType',
11
+ base_data: 'baseData'
12
+ )
13
+ end
14
+ end
@@ -1,130 +1,24 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- require_relative 'data_point_type'
7
- # Data contract class for type DataPoint.
8
- class DataPoint < JsonSerializable
9
- # Initializes a new instance of the DataPoint class.
10
- def initialize(options={})
11
- defaults = {
12
- 'name' => nil,
13
- 'kind' => DataPointType::MEASUREMENT,
14
- 'value' => nil,
15
- 'count' => nil,
16
- 'min' => nil,
17
- 'max' => nil,
18
- 'stdDev' => nil
19
- }
20
- values = {
21
- 'name' => nil,
22
- 'kind' => DataPointType::MEASUREMENT,
23
- 'value' => nil
24
- }
25
- super defaults, values, options
26
- end
27
-
28
- # Gets the name property.
29
- def name
30
- @values['name']
31
- end
32
-
33
- # Sets the name property.
34
- def name=(value)
35
- @values['name'] = value
36
- end
37
-
38
- # Gets the kind property.
39
- def kind
40
- @values.fetch('kind') {
41
- @values['kind'] = DataPointType::MEASUREMENT
42
- }
43
- end
44
-
45
- # Sets the kind property.
46
- def kind=(value)
47
- if value == @defaults['kind']
48
- @values.delete 'kind' if @values.key? 'kind'
49
- else
50
- @values['kind'] = value
51
- end
52
- end
53
-
54
- # Gets the value property.
55
- def value
56
- @values['value']
57
- end
58
-
59
- # Sets the value property.
60
- def value=(value)
61
- @values['value'] = value
62
- end
63
-
64
- # Gets the count property.
65
- def count
66
- @values.fetch('count') {
67
- @values['count'] = nil
68
- }
69
- end
70
-
71
- # Sets the count property.
72
- def count=(value)
73
- if value == @defaults['count']
74
- @values.delete 'count' if @values.key? 'count'
75
- else
76
- @values['count'] = value
77
- end
78
- end
79
-
80
- # Gets the min property.
81
- def min
82
- @values.fetch('min') {
83
- @values['min'] = nil
84
- }
85
- end
86
-
87
- # Sets the min property.
88
- def min=(value)
89
- if value == @defaults['min']
90
- @values.delete 'min' if @values.key? 'min'
91
- else
92
- @values['min'] = value
93
- end
94
- end
95
-
96
- # Gets the max property.
97
- def max
98
- @values.fetch('max') {
99
- @values['max'] = nil
100
- }
101
- end
102
-
103
- # Sets the max property.
104
- def max=(value)
105
- if value == @defaults['max']
106
- @values.delete 'max' if @values.key? 'max'
107
- else
108
- @values['max'] = value
109
- end
110
- end
111
-
112
- # Gets the std_dev property.
113
- def std_dev
114
- @values.fetch('stdDev') {
115
- @values['stdDev'] = nil
116
- }
117
- end
118
-
119
- # Sets the std_dev property.
120
- def std_dev=(value)
121
- if value == @defaults['stdDev']
122
- @values.delete 'stdDev' if @values.key? 'stdDev'
123
- else
124
- @values['stdDev'] = value
125
- end
126
- end
127
- end
128
- end
129
- end
130
- end
1
+ require_relative 'json_serializable'
2
+ require_relative 'data_point_type'
3
+
4
+ module ApplicationInsights::Channel::Contracts
5
+ class DataPoint
6
+ include JsonSerializable
7
+
8
+ attr_accessor :name, :kind, :value, :count, :min, :max, :std_dev
9
+
10
+ attribute_mapping(
11
+ name: 'name',
12
+ kind: 'kind',
13
+ value: 'value',
14
+ count: 'count',
15
+ min: 'min',
16
+ max: 'max',
17
+ std_dev: 'stdDev'
18
+ )
19
+
20
+ def kind
21
+ @kind ||= DataPointType::MEASUREMENT
22
+ end
23
+ end
24
+ end
@@ -1,16 +1,7 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type DataPointType.
7
- class DataPointType
8
- # Enumeration value MEASUREMENT.
9
- MEASUREMENT = 0
10
-
11
- # Enumeration value AGGREGATION.
12
- AGGREGATION = 1
13
- end
14
- end
15
- end
16
- end
1
+ module ApplicationInsights::Channel::Contracts
2
+ class DataPointType
3
+ MEASUREMENT = 0
4
+
5
+ AGGREGATION = 1
6
+ end
7
+ end
@@ -1,19 +1,9 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type DependencyKind.
7
- class DependencyKind
8
- # Enumeration value SQL.
9
- SQL = 0
10
-
11
- # Enumeration value HTTP.
12
- HTTP = 1
13
-
14
- # Enumeration value OTHER.
15
- OTHER = 2
16
- end
17
- end
18
- end
19
- end
1
+ module ApplicationInsights::Channel::Contracts
2
+ class DependencyKind
3
+ SQL = 0
4
+
5
+ HTTP = 1
6
+
7
+ OTHER = 2
8
+ end
9
+ end
@@ -1,19 +1,9 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type DependencySourceType.
7
- class DependencySourceType
8
- # Enumeration value UNDEFINED.
9
- UNDEFINED = 0
10
-
11
- # Enumeration value AIC.
12
- AIC = 1
13
-
14
- # Enumeration value APMC.
15
- APMC = 2
16
- end
17
- end
18
- end
19
- end
1
+ module ApplicationInsights::Channel::Contracts
2
+ class DependencySourceType
3
+ UNDEFINED = 0
4
+
5
+ AIC = 1
6
+
7
+ APMC = 2
8
+ end
9
+ end
@@ -1,257 +1,28 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type Device.
7
- class Device < JsonSerializable
8
- # Initializes a new instance of the Device class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ai.device.id' => nil,
12
- 'ai.device.ip' => nil,
13
- 'ai.device.language' => nil,
14
- 'ai.device.locale' => nil,
15
- 'ai.device.model' => nil,
16
- 'ai.device.network' => nil,
17
- 'ai.device.oemName' => nil,
18
- 'ai.device.os' => nil,
19
- 'ai.device.osVersion' => nil,
20
- 'ai.device.roleInstance' => nil,
21
- 'ai.device.roleName' => nil,
22
- 'ai.device.screenResolution' => nil,
23
- 'ai.device.type' => nil,
24
- 'ai.device.machineName' => nil
25
- }
26
- values = {
27
- }
28
- super defaults, values, options
29
- end
30
-
31
- # Gets the id property.
32
- def id
33
- @values.fetch('ai.device.id') {
34
- @values['ai.device.id'] = nil
35
- }
36
- end
37
-
38
- # Sets the id property.
39
- def id=(value)
40
- if value == @defaults['ai.device.id']
41
- @values.delete 'ai.device.id' if @values.key? 'ai.device.id'
42
- else
43
- @values['ai.device.id'] = value
44
- end
45
- end
46
-
47
- # Gets the ip property.
48
- def ip
49
- @values.fetch('ai.device.ip') {
50
- @values['ai.device.ip'] = nil
51
- }
52
- end
53
-
54
- # Sets the ip property.
55
- def ip=(value)
56
- if value == @defaults['ai.device.ip']
57
- @values.delete 'ai.device.ip' if @values.key? 'ai.device.ip'
58
- else
59
- @values['ai.device.ip'] = value
60
- end
61
- end
62
-
63
- # Gets the language property.
64
- def language
65
- @values.fetch('ai.device.language') {
66
- @values['ai.device.language'] = nil
67
- }
68
- end
69
-
70
- # Sets the language property.
71
- def language=(value)
72
- if value == @defaults['ai.device.language']
73
- @values.delete 'ai.device.language' if @values.key? 'ai.device.language'
74
- else
75
- @values['ai.device.language'] = value
76
- end
77
- end
78
-
79
- # Gets the locale property.
80
- def locale
81
- @values.fetch('ai.device.locale') {
82
- @values['ai.device.locale'] = nil
83
- }
84
- end
85
-
86
- # Sets the locale property.
87
- def locale=(value)
88
- if value == @defaults['ai.device.locale']
89
- @values.delete 'ai.device.locale' if @values.key? 'ai.device.locale'
90
- else
91
- @values['ai.device.locale'] = value
92
- end
93
- end
94
-
95
- # Gets the model property.
96
- def model
97
- @values.fetch('ai.device.model') {
98
- @values['ai.device.model'] = nil
99
- }
100
- end
101
-
102
- # Sets the model property.
103
- def model=(value)
104
- if value == @defaults['ai.device.model']
105
- @values.delete 'ai.device.model' if @values.key? 'ai.device.model'
106
- else
107
- @values['ai.device.model'] = value
108
- end
109
- end
110
-
111
- # Gets the network property.
112
- def network
113
- @values.fetch('ai.device.network') {
114
- @values['ai.device.network'] = nil
115
- }
116
- end
117
-
118
- # Sets the network property.
119
- def network=(value)
120
- if value == @defaults['ai.device.network']
121
- @values.delete 'ai.device.network' if @values.key? 'ai.device.network'
122
- else
123
- @values['ai.device.network'] = value
124
- end
125
- end
126
-
127
- # Gets the oem_name property.
128
- def oem_name
129
- @values.fetch('ai.device.oemName') {
130
- @values['ai.device.oemName'] = nil
131
- }
132
- end
133
-
134
- # Sets the oem_name property.
135
- def oem_name=(value)
136
- if value == @defaults['ai.device.oemName']
137
- @values.delete 'ai.device.oemName' if @values.key? 'ai.device.oemName'
138
- else
139
- @values['ai.device.oemName'] = value
140
- end
141
- end
142
-
143
- # Gets the os property.
144
- def os
145
- @values.fetch('ai.device.os') {
146
- @values['ai.device.os'] = nil
147
- }
148
- end
149
-
150
- # Sets the os property.
151
- def os=(value)
152
- if value == @defaults['ai.device.os']
153
- @values.delete 'ai.device.os' if @values.key? 'ai.device.os'
154
- else
155
- @values['ai.device.os'] = value
156
- end
157
- end
158
-
159
- # Gets the os_version property.
160
- def os_version
161
- @values.fetch('ai.device.osVersion') {
162
- @values['ai.device.osVersion'] = nil
163
- }
164
- end
165
-
166
- # Sets the os_version property.
167
- def os_version=(value)
168
- if value == @defaults['ai.device.osVersion']
169
- @values.delete 'ai.device.osVersion' if @values.key? 'ai.device.osVersion'
170
- else
171
- @values['ai.device.osVersion'] = value
172
- end
173
- end
174
-
175
- # Gets the role_instance property.
176
- def role_instance
177
- @values.fetch('ai.device.roleInstance') {
178
- @values['ai.device.roleInstance'] = nil
179
- }
180
- end
181
-
182
- # Sets the role_instance property.
183
- def role_instance=(value)
184
- if value == @defaults['ai.device.roleInstance']
185
- @values.delete 'ai.device.roleInstance' if @values.key? 'ai.device.roleInstance'
186
- else
187
- @values['ai.device.roleInstance'] = value
188
- end
189
- end
190
-
191
- # Gets the role_name property.
192
- def role_name
193
- @values.fetch('ai.device.roleName') {
194
- @values['ai.device.roleName'] = nil
195
- }
196
- end
197
-
198
- # Sets the role_name property.
199
- def role_name=(value)
200
- if value == @defaults['ai.device.roleName']
201
- @values.delete 'ai.device.roleName' if @values.key? 'ai.device.roleName'
202
- else
203
- @values['ai.device.roleName'] = value
204
- end
205
- end
206
-
207
- # Gets the screen_resolution property.
208
- def screen_resolution
209
- @values.fetch('ai.device.screenResolution') {
210
- @values['ai.device.screenResolution'] = nil
211
- }
212
- end
213
-
214
- # Sets the screen_resolution property.
215
- def screen_resolution=(value)
216
- if value == @defaults['ai.device.screenResolution']
217
- @values.delete 'ai.device.screenResolution' if @values.key? 'ai.device.screenResolution'
218
- else
219
- @values['ai.device.screenResolution'] = value
220
- end
221
- end
222
-
223
- # Gets the type property.
224
- def type
225
- @values.fetch('ai.device.type') {
226
- @values['ai.device.type'] = nil
227
- }
228
- end
229
-
230
- # Sets the type property.
231
- def type=(value)
232
- if value == @defaults['ai.device.type']
233
- @values.delete 'ai.device.type' if @values.key? 'ai.device.type'
234
- else
235
- @values['ai.device.type'] = value
236
- end
237
- end
238
-
239
- # Gets the machine_name property.
240
- def machine_name
241
- @values.fetch('ai.device.machineName') {
242
- @values['ai.device.machineName'] = nil
243
- }
244
- end
245
-
246
- # Sets the machine_name property.
247
- def machine_name=(value)
248
- if value == @defaults['ai.device.machineName']
249
- @values.delete 'ai.device.machineName' if @values.key? 'ai.device.machineName'
250
- else
251
- @values['ai.device.machineName'] = value
252
- end
253
- end
254
- end
255
- end
256
- end
257
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Device
5
+ include JsonSerializable
6
+
7
+ attr_accessor :id, :ip, :language, :locale, :model, :network, :oem_name,
8
+ :os, :os_version, :role_instance, :role_name, :screen_resolution, :type,
9
+ :machine_name
10
+
11
+ attribute_mapping(
12
+ id: 'ai.device.id',
13
+ ip: 'ai.device.ip',
14
+ language: 'ai.device.language',
15
+ locale: 'ai.device.locale',
16
+ model: 'ai.device.model',
17
+ network: 'ai.device.network',
18
+ oem_name: 'ai.device.oemName',
19
+ os: 'ai.device.os',
20
+ os_version: 'ai.device.osVersion',
21
+ role_instance: 'ai.device.roleInstance',
22
+ role_name: 'ai.device.roleName',
23
+ screen_resolution: 'ai.device.screenResolution',
24
+ type: 'ai.device.type',
25
+ machine_name: 'ai.device.machineName'
26
+ )
27
+ end
28
+ end