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