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,176 +1,36 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type RequestData.
7
- class RequestData < JsonSerializable
8
- # Initializes a new instance of the RequestData class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ver' => 2,
12
- 'id' => nil,
13
- 'name' => nil,
14
- 'startTime' => nil,
15
- 'duration' => nil,
16
- 'responseCode' => nil,
17
- 'success' => nil,
18
- 'httpMethod' => nil,
19
- 'url' => nil,
20
- 'properties' => {},
21
- 'measurements' => {}
22
- }
23
- values = {
24
- 'ver' => 2,
25
- 'id' => nil,
26
- 'startTime' => nil,
27
- 'duration' => nil,
28
- 'responseCode' => nil,
29
- 'success' => nil
30
- }
31
- super defaults, values, options
32
- end
33
-
34
- # Gets the ver property.
35
- def ver
36
- @values['ver']
37
- end
38
-
39
- # Sets the ver property.
40
- def ver=(value)
41
- @values['ver'] = value
42
- end
43
-
44
- # Gets the id property.
45
- def id
46
- @values['id']
47
- end
48
-
49
- # Sets the id property.
50
- def id=(value)
51
- @values['id'] = value
52
- end
53
-
54
- # Gets the name property.
55
- def name
56
- @values.fetch('name') {
57
- @values['name'] = nil
58
- }
59
- end
60
-
61
- # Sets the name property.
62
- def name=(value)
63
- if value == @defaults['name']
64
- @values.delete 'name' if @values.key? 'name'
65
- else
66
- @values['name'] = value
67
- end
68
- end
69
-
70
- # Gets the start_time property.
71
- def start_time
72
- @values['startTime']
73
- end
74
-
75
- # Sets the start_time property.
76
- def start_time=(value)
77
- @values['startTime'] = value
78
- end
79
-
80
- # Gets the duration property.
81
- def duration
82
- @values['duration']
83
- end
84
-
85
- # Sets the duration property.
86
- def duration=(value)
87
- @values['duration'] = value
88
- end
89
-
90
- # Gets the response_code property.
91
- def response_code
92
- @values['responseCode']
93
- end
94
-
95
- # Sets the response_code property.
96
- def response_code=(value)
97
- @values['responseCode'] = value
98
- end
99
-
100
- # Gets the success property.
101
- def success
102
- @values['success']
103
- end
104
-
105
- # Sets the success property.
106
- def success=(value)
107
- @values['success'] = value
108
- end
109
-
110
- # Gets the http_method property.
111
- def http_method
112
- @values.fetch('httpMethod') {
113
- @values['httpMethod'] = nil
114
- }
115
- end
116
-
117
- # Sets the http_method property.
118
- def http_method=(value)
119
- if value == @defaults['httpMethod']
120
- @values.delete 'httpMethod' if @values.key? 'httpMethod'
121
- else
122
- @values['httpMethod'] = value
123
- end
124
- end
125
-
126
- # Gets the url property.
127
- def url
128
- @values.fetch('url') {
129
- @values['url'] = nil
130
- }
131
- end
132
-
133
- # Sets the url property.
134
- def url=(value)
135
- if value == @defaults['url']
136
- @values.delete 'url' if @values.key? 'url'
137
- else
138
- @values['url'] = value
139
- end
140
- end
141
-
142
- # Gets the properties property.
143
- def properties
144
- @values.fetch('properties') {
145
- @values['properties'] = {}
146
- }
147
- end
148
-
149
- # Sets the properties property.
150
- def properties=(value)
151
- if value == @defaults['properties']
152
- @values.delete 'properties' if @values.key? 'properties'
153
- else
154
- @values['properties'] = value
155
- end
156
- end
157
-
158
- # Gets the measurements property.
159
- def measurements
160
- @values.fetch('measurements') {
161
- @values['measurements'] = {}
162
- }
163
- end
164
-
165
- # Sets the measurements property.
166
- def measurements=(value)
167
- if value == @defaults['measurements']
168
- @values.delete 'measurements' if @values.key? 'measurements'
169
- else
170
- @values['measurements'] = value
171
- end
172
- end
173
- end
174
- end
175
- end
176
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class RequestData
5
+ include JsonSerializable
6
+
7
+ attr_accessor :ver, :id, :name, :start_time, :duration, :response_code,
8
+ :success, :http_method, :url, :properties, :measurements
9
+
10
+ attribute_mapping(
11
+ ver: 'ver',
12
+ id: 'id',
13
+ name: 'name',
14
+ start_time: 'startTime',
15
+ duration: 'duration',
16
+ response_code: 'responseCode',
17
+ success: 'success',
18
+ http_method: 'httpMethod',
19
+ url: 'url',
20
+ properties: 'properties',
21
+ measurements: 'measurements'
22
+ )
23
+
24
+ def ver
25
+ @ver ||= 2
26
+ end
27
+
28
+ def properties
29
+ @properties ||= {}
30
+ end
31
+
32
+ def measurements
33
+ @measurements ||= {}
34
+ end
35
+ end
36
+ end
@@ -1,70 +1,15 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type Session.
7
- class Session < JsonSerializable
8
- # Initializes a new instance of the Session class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ai.session.id' => nil,
12
- 'ai.session.isFirst' => nil,
13
- 'ai.session.isNew' => nil
14
- }
15
- values = {
16
- }
17
- super defaults, values, options
18
- end
19
-
20
- # Gets the id property.
21
- def id
22
- @values.fetch('ai.session.id') {
23
- @values['ai.session.id'] = nil
24
- }
25
- end
26
-
27
- # Sets the id property.
28
- def id=(value)
29
- if value == @defaults['ai.session.id']
30
- @values.delete 'ai.session.id' if @values.key? 'ai.session.id'
31
- else
32
- @values['ai.session.id'] = value
33
- end
34
- end
35
-
36
- # Gets the is_first property.
37
- def is_first
38
- @values.fetch('ai.session.isFirst') {
39
- @values['ai.session.isFirst'] = nil
40
- }
41
- end
42
-
43
- # Sets the is_first property.
44
- def is_first=(value)
45
- if value == @defaults['ai.session.isFirst']
46
- @values.delete 'ai.session.isFirst' if @values.key? 'ai.session.isFirst'
47
- else
48
- @values['ai.session.isFirst'] = value
49
- end
50
- end
51
-
52
- # Gets the is_new property.
53
- def is_new
54
- @values.fetch('ai.session.isNew') {
55
- @values['ai.session.isNew'] = nil
56
- }
57
- end
58
-
59
- # Sets the is_new property.
60
- def is_new=(value)
61
- if value == @defaults['ai.session.isNew']
62
- @values.delete 'ai.session.isNew' if @values.key? 'ai.session.isNew'
63
- else
64
- @values['ai.session.isNew'] = value
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class Session
5
+ include JsonSerializable
6
+
7
+ attr_accessor :id, :is_first, :is_new
8
+
9
+ attribute_mapping(
10
+ id: 'ai.session.id',
11
+ is_first: 'ai.session.isFirst',
12
+ is_new: 'ai.session.isNew'
13
+ )
14
+ end
15
+ end
@@ -1,25 +1,13 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type SeverityLevel.
7
- class SeverityLevel
8
- # Enumeration value VERBOSE.
9
- VERBOSE = 0
10
-
11
- # Enumeration value INFORMATION.
12
- INFORMATION = 1
13
-
14
- # Enumeration value WARNING.
15
- WARNING = 2
16
-
17
- # Enumeration value ERROR.
18
- ERROR = 3
19
-
20
- # Enumeration value CRITICAL.
21
- CRITICAL = 4
22
- end
23
- end
24
- end
25
- end
1
+ module ApplicationInsights::Channel::Contracts
2
+ class SeverityLevel
3
+ VERBOSE = 0
4
+
5
+ INFORMATION = 1
6
+
7
+ WARNING = 2
8
+
9
+ ERROR = 3
10
+
11
+ CRITICAL = 4
12
+ end
13
+ end
@@ -1,94 +1,17 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type StackFrame.
7
- class StackFrame < JsonSerializable
8
- # Initializes a new instance of the StackFrame class.
9
- def initialize(options={})
10
- defaults = {
11
- 'level' => nil,
12
- 'method' => nil,
13
- 'assembly' => nil,
14
- 'fileName' => nil,
15
- 'line' => nil
16
- }
17
- values = {
18
- 'level' => nil,
19
- 'method' => nil
20
- }
21
- super defaults, values, options
22
- end
23
-
24
- # Gets the level property.
25
- def level
26
- @values['level']
27
- end
28
-
29
- # Sets the level property.
30
- def level=(value)
31
- @values['level'] = value
32
- end
33
-
34
- # Gets the method property.
35
- def method
36
- @values['method']
37
- end
38
-
39
- # Sets the method property.
40
- def method=(value)
41
- @values['method'] = value
42
- end
43
-
44
- # Gets the assembly property.
45
- def assembly
46
- @values.fetch('assembly') {
47
- @values['assembly'] = nil
48
- }
49
- end
50
-
51
- # Sets the assembly property.
52
- def assembly=(value)
53
- if value == @defaults['assembly']
54
- @values.delete 'assembly' if @values.key? 'assembly'
55
- else
56
- @values['assembly'] = value
57
- end
58
- end
59
-
60
- # Gets the file_name property.
61
- def file_name
62
- @values.fetch('fileName') {
63
- @values['fileName'] = nil
64
- }
65
- end
66
-
67
- # Sets the file_name property.
68
- def file_name=(value)
69
- if value == @defaults['fileName']
70
- @values.delete 'fileName' if @values.key? 'fileName'
71
- else
72
- @values['fileName'] = value
73
- end
74
- end
75
-
76
- # Gets the line property.
77
- def line
78
- @values.fetch('line') {
79
- @values['line'] = nil
80
- }
81
- end
82
-
83
- # Sets the line property.
84
- def line=(value)
85
- if value == @defaults['line']
86
- @values.delete 'line' if @values.key? 'line'
87
- else
88
- @values['line'] = value
89
- end
90
- end
91
- end
92
- end
93
- end
94
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class StackFrame
5
+ include JsonSerializable
6
+
7
+ attr_accessor :level, :method, :assembly, :file_name, :line
8
+
9
+ attribute_mapping(
10
+ level: 'level',
11
+ method: 'method',
12
+ assembly: 'assembly',
13
+ file_name: 'fileName',
14
+ line: 'line'
15
+ )
16
+ end
17
+ end
@@ -1,104 +1,19 @@
1
- require_relative 'json_serializable'
2
-
3
- module ApplicationInsights
4
- module Channel
5
- module Contracts
6
- # Data contract class for type User.
7
- class User < JsonSerializable
8
- # Initializes a new instance of the User class.
9
- def initialize(options={})
10
- defaults = {
11
- 'ai.user.accountAcquisitionDate' => nil,
12
- 'ai.user.accountId' => nil,
13
- 'ai.user.userAgent' => nil,
14
- 'ai.user.id' => nil,
15
- 'ai.user.storeRegion' => nil
16
- }
17
- values = {
18
- }
19
- super defaults, values, options
20
- end
21
-
22
- # Gets the account_acquisition_date property.
23
- def account_acquisition_date
24
- @values.fetch('ai.user.accountAcquisitionDate') {
25
- @values['ai.user.accountAcquisitionDate'] = nil
26
- }
27
- end
28
-
29
- # Sets the account_acquisition_date property.
30
- def account_acquisition_date=(value)
31
- if value == @defaults['ai.user.accountAcquisitionDate']
32
- @values.delete 'ai.user.accountAcquisitionDate' if @values.key? 'ai.user.accountAcquisitionDate'
33
- else
34
- @values['ai.user.accountAcquisitionDate'] = value
35
- end
36
- end
37
-
38
- # Gets the account_id property.
39
- def account_id
40
- @values.fetch('ai.user.accountId') {
41
- @values['ai.user.accountId'] = nil
42
- }
43
- end
44
-
45
- # Sets the account_id property.
46
- def account_id=(value)
47
- if value == @defaults['ai.user.accountId']
48
- @values.delete 'ai.user.accountId' if @values.key? 'ai.user.accountId'
49
- else
50
- @values['ai.user.accountId'] = value
51
- end
52
- end
53
-
54
- # Gets the user_agent property.
55
- def user_agent
56
- @values.fetch('ai.user.userAgent') {
57
- @values['ai.user.userAgent'] = nil
58
- }
59
- end
60
-
61
- # Sets the user_agent property.
62
- def user_agent=(value)
63
- if value == @defaults['ai.user.userAgent']
64
- @values.delete 'ai.user.userAgent' if @values.key? 'ai.user.userAgent'
65
- else
66
- @values['ai.user.userAgent'] = value
67
- end
68
- end
69
-
70
- # Gets the id property.
71
- def id
72
- @values.fetch('ai.user.id') {
73
- @values['ai.user.id'] = nil
74
- }
75
- end
76
-
77
- # Sets the id property.
78
- def id=(value)
79
- if value == @defaults['ai.user.id']
80
- @values.delete 'ai.user.id' if @values.key? 'ai.user.id'
81
- else
82
- @values['ai.user.id'] = value
83
- end
84
- end
85
-
86
- # Gets the store_region property.
87
- def store_region
88
- @values.fetch('ai.user.storeRegion') {
89
- @values['ai.user.storeRegion'] = nil
90
- }
91
- end
92
-
93
- # Sets the store_region property.
94
- def store_region=(value)
95
- if value == @defaults['ai.user.storeRegion']
96
- @values.delete 'ai.user.storeRegion' if @values.key? 'ai.user.storeRegion'
97
- else
98
- @values['ai.user.storeRegion'] = value
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights::Channel::Contracts
4
+ class User
5
+ include JsonSerializable
6
+
7
+ attr_accessor :account_acquisition_date, :account_id, :auth_user_id, :user_agent, :id,
8
+ :store_region
9
+
10
+ attribute_mapping(
11
+ account_acquisition_date: 'ai.user.accountAcquisitionDate',
12
+ account_id: 'ai.user.accountId',
13
+ user_agent: 'ai.user.userAgent',
14
+ id: 'ai.user.id',
15
+ auth_user_id: 'ai.user.authUserId',
16
+ store_region: 'ai.user.storeRegion'
17
+ )
18
+ end
19
+ end