application_insights 0.1.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.
- checksums.yaml +15 -0
- data/.gitignore +40 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +106 -0
- data/Rakefile +10 -0
- data/application_insights.gemspec +25 -0
- data/lib/application_insights.rb +2 -0
- data/lib/application_insights/channel/contracts/application.rb +35 -0
- data/lib/application_insights/channel/contracts/data.rb +47 -0
- data/lib/application_insights/channel/contracts/data_point.rb +125 -0
- data/lib/application_insights/channel/contracts/data_point_type.rb +16 -0
- data/lib/application_insights/channel/contracts/dependency_kind.rb +22 -0
- data/lib/application_insights/channel/contracts/dependency_source_type.rb +19 -0
- data/lib/application_insights/channel/contracts/device.rb +243 -0
- data/lib/application_insights/channel/contracts/envelope.rb +254 -0
- data/lib/application_insights/channel/contracts/event_data.rb +77 -0
- data/lib/application_insights/channel/contracts/exception_data.rb +105 -0
- data/lib/application_insights/channel/contracts/exception_details.rb +125 -0
- data/lib/application_insights/channel/contracts/internal.rb +51 -0
- data/lib/application_insights/channel/contracts/json_serializable.rb +59 -0
- data/lib/application_insights/channel/contracts/location.rb +35 -0
- data/lib/application_insights/channel/contracts/message_data.rb +76 -0
- data/lib/application_insights/channel/contracts/metric_data.rb +60 -0
- data/lib/application_insights/channel/contracts/operation.rb +83 -0
- data/lib/application_insights/channel/contracts/page_view_data.rb +109 -0
- data/lib/application_insights/channel/contracts/remote_dependency_data.rb +218 -0
- data/lib/application_insights/channel/contracts/request_data.rb +173 -0
- data/lib/application_insights/channel/contracts/session.rb +67 -0
- data/lib/application_insights/channel/contracts/severity_level.rb +25 -0
- data/lib/application_insights/channel/contracts/stack_frame.rb +91 -0
- data/lib/application_insights/channel/contracts/user.rb +83 -0
- data/lib/application_insights/channel/queue_base.rb +48 -0
- data/lib/application_insights/channel/sender_base.rb +46 -0
- data/lib/application_insights/channel/synchronous_queue.rb +28 -0
- data/lib/application_insights/channel/synchronous_sender.rb +13 -0
- data/lib/application_insights/channel/telemetry_channel.rb +81 -0
- data/lib/application_insights/channel/telemetry_context.rb +49 -0
- data/lib/application_insights/telemetry_client.rb +111 -0
- data/lib/application_insights/version.rb +3 -0
- data/test/application_insights.rb +9 -0
- data/test/application_insights/channel/contracts/test_application.rb +31 -0
- data/test/application_insights/channel/contracts/test_data.rb +44 -0
- data/test/application_insights/channel/contracts/test_data_point.rb +109 -0
- data/test/application_insights/channel/contracts/test_device.rb +200 -0
- data/test/application_insights/channel/contracts/test_envelope.rb +209 -0
- data/test/application_insights/channel/contracts/test_event_data.rb +62 -0
- data/test/application_insights/channel/contracts/test_exception_data.rb +85 -0
- data/test/application_insights/channel/contracts/test_exception_details.rb +106 -0
- data/test/application_insights/channel/contracts/test_internal.rb +44 -0
- data/test/application_insights/channel/contracts/test_location.rb +31 -0
- data/test/application_insights/channel/contracts/test_message_data.rb +66 -0
- data/test/application_insights/channel/contracts/test_metric_data.rb +50 -0
- data/test/application_insights/channel/contracts/test_operation.rb +70 -0
- data/test/application_insights/channel/contracts/test_page_view_data.rb +88 -0
- data/test/application_insights/channel/contracts/test_remote_dependency_data.rb +183 -0
- data/test/application_insights/channel/contracts/test_request_data.rb +153 -0
- data/test/application_insights/channel/contracts/test_session.rb +57 -0
- data/test/application_insights/channel/contracts/test_stack_frame.rb +83 -0
- data/test/application_insights/channel/contracts/test_user.rb +70 -0
- data/test/application_insights/channel/test_queue_base.rb +88 -0
- data/test/application_insights/channel/test_sender_base.rb +96 -0
- data/test/application_insights/channel/test_synchronous_queue.rb +42 -0
- data/test/application_insights/channel/test_synchronous_sender.rb +11 -0
- data/test/application_insights/channel/test_telemetry_channel.rb +102 -0
- data/test/application_insights/channel/test_telemetry_context.rb +72 -0
- data/test/application_insights/test_telemetry_client.rb +107 -0
- metadata +166 -0
@@ -0,0 +1,173 @@
|
|
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
|
+
return @values['name'] if @values.key?('name')
|
57
|
+
@defaults['name']
|
58
|
+
end
|
59
|
+
|
60
|
+
# Sets the name property.
|
61
|
+
def name=(value)
|
62
|
+
if value == @defaults['name']
|
63
|
+
@values.delete 'name' if @values.key? 'name'
|
64
|
+
else
|
65
|
+
@values['name'] = value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Gets the start_time property.
|
70
|
+
def start_time
|
71
|
+
@values['startTime']
|
72
|
+
end
|
73
|
+
|
74
|
+
# Sets the start_time property.
|
75
|
+
def start_time=(value)
|
76
|
+
@values['startTime'] = value
|
77
|
+
end
|
78
|
+
|
79
|
+
# Gets the duration property.
|
80
|
+
def duration
|
81
|
+
@values['duration']
|
82
|
+
end
|
83
|
+
|
84
|
+
# Sets the duration property.
|
85
|
+
def duration=(value)
|
86
|
+
@values['duration'] = value
|
87
|
+
end
|
88
|
+
|
89
|
+
# Gets the response_code property.
|
90
|
+
def response_code
|
91
|
+
@values['responseCode']
|
92
|
+
end
|
93
|
+
|
94
|
+
# Sets the response_code property.
|
95
|
+
def response_code=(value)
|
96
|
+
@values['responseCode'] = value
|
97
|
+
end
|
98
|
+
|
99
|
+
# Gets the success property.
|
100
|
+
def success
|
101
|
+
@values['success']
|
102
|
+
end
|
103
|
+
|
104
|
+
# Sets the success property.
|
105
|
+
def success=(value)
|
106
|
+
@values['success'] = value
|
107
|
+
end
|
108
|
+
|
109
|
+
# Gets the http_method property.
|
110
|
+
def http_method
|
111
|
+
return @values['httpMethod'] if @values.key?('httpMethod')
|
112
|
+
@defaults['httpMethod']
|
113
|
+
end
|
114
|
+
|
115
|
+
# Sets the http_method property.
|
116
|
+
def http_method=(value)
|
117
|
+
if value == @defaults['httpMethod']
|
118
|
+
@values.delete 'httpMethod' if @values.key? 'httpMethod'
|
119
|
+
else
|
120
|
+
@values['httpMethod'] = value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Gets the url property.
|
125
|
+
def url
|
126
|
+
return @values['url'] if @values.key?('url')
|
127
|
+
@defaults['url']
|
128
|
+
end
|
129
|
+
|
130
|
+
# Sets the url property.
|
131
|
+
def url=(value)
|
132
|
+
if value == @defaults['url']
|
133
|
+
@values.delete 'url' if @values.key? 'url'
|
134
|
+
else
|
135
|
+
@values['url'] = value
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Gets the properties property.
|
140
|
+
def properties
|
141
|
+
return @values['properties'] if @values.key?('properties')
|
142
|
+
@values['properties'] = {}
|
143
|
+
@values['properties']
|
144
|
+
end
|
145
|
+
|
146
|
+
# Sets the properties property.
|
147
|
+
def properties=(value)
|
148
|
+
if value == @defaults['properties']
|
149
|
+
@values.delete 'properties' if @values.key? 'properties'
|
150
|
+
else
|
151
|
+
@values['properties'] = value
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Gets the measurements property.
|
156
|
+
def measurements
|
157
|
+
return @values['measurements'] if @values.key?('measurements')
|
158
|
+
@values['measurements'] = {}
|
159
|
+
@values['measurements']
|
160
|
+
end
|
161
|
+
|
162
|
+
# Sets the measurements property.
|
163
|
+
def measurements=(value)
|
164
|
+
if value == @defaults['measurements']
|
165
|
+
@values.delete 'measurements' if @values.key? 'measurements'
|
166
|
+
else
|
167
|
+
@values['measurements'] = value
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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
|
+
return @values['ai.session.id'] if @values.key?('ai.session.id')
|
23
|
+
@defaults['ai.session.id']
|
24
|
+
end
|
25
|
+
|
26
|
+
# Sets the id property.
|
27
|
+
def id=(value)
|
28
|
+
if value == @defaults['ai.session.id']
|
29
|
+
@values.delete 'ai.session.id' if @values.key? 'ai.session.id'
|
30
|
+
else
|
31
|
+
@values['ai.session.id'] = value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Gets the is_first property.
|
36
|
+
def is_first
|
37
|
+
return @values['ai.session.isFirst'] if @values.key?('ai.session.isFirst')
|
38
|
+
@defaults['ai.session.isFirst']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Sets the is_first property.
|
42
|
+
def is_first=(value)
|
43
|
+
if value == @defaults['ai.session.isFirst']
|
44
|
+
@values.delete 'ai.session.isFirst' if @values.key? 'ai.session.isFirst'
|
45
|
+
else
|
46
|
+
@values['ai.session.isFirst'] = value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Gets the is_new property.
|
51
|
+
def is_new
|
52
|
+
return @values['ai.session.isNew'] if @values.key?('ai.session.isNew')
|
53
|
+
@defaults['ai.session.isNew']
|
54
|
+
end
|
55
|
+
|
56
|
+
# Sets the is_new property.
|
57
|
+
def is_new=(value)
|
58
|
+
if value == @defaults['ai.session.isNew']
|
59
|
+
@values.delete 'ai.session.isNew' if @values.key? 'ai.session.isNew'
|
60
|
+
else
|
61
|
+
@values['ai.session.isNew'] = value
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,25 @@
|
|
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
|
@@ -0,0 +1,91 @@
|
|
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
|
+
return @values['assembly'] if @values.key?('assembly')
|
47
|
+
@defaults['assembly']
|
48
|
+
end
|
49
|
+
|
50
|
+
# Sets the assembly property.
|
51
|
+
def assembly=(value)
|
52
|
+
if value == @defaults['assembly']
|
53
|
+
@values.delete 'assembly' if @values.key? 'assembly'
|
54
|
+
else
|
55
|
+
@values['assembly'] = value
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Gets the file_name property.
|
60
|
+
def file_name
|
61
|
+
return @values['fileName'] if @values.key?('fileName')
|
62
|
+
@defaults['fileName']
|
63
|
+
end
|
64
|
+
|
65
|
+
# Sets the file_name property.
|
66
|
+
def file_name=(value)
|
67
|
+
if value == @defaults['fileName']
|
68
|
+
@values.delete 'fileName' if @values.key? 'fileName'
|
69
|
+
else
|
70
|
+
@values['fileName'] = value
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Gets the line property.
|
75
|
+
def line
|
76
|
+
return @values['line'] if @values.key?('line')
|
77
|
+
@defaults['line']
|
78
|
+
end
|
79
|
+
|
80
|
+
# Sets the line property.
|
81
|
+
def line=(value)
|
82
|
+
if value == @defaults['line']
|
83
|
+
@values.delete 'line' if @values.key? 'line'
|
84
|
+
else
|
85
|
+
@values['line'] = value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,83 @@
|
|
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
|
+
}
|
16
|
+
values = {
|
17
|
+
}
|
18
|
+
super defaults, values, options
|
19
|
+
end
|
20
|
+
|
21
|
+
# Gets the account_acquisition_date property.
|
22
|
+
def account_acquisition_date
|
23
|
+
return @values['ai.user.accountAcquisitionDate'] if @values.key?('ai.user.accountAcquisitionDate')
|
24
|
+
@defaults['ai.user.accountAcquisitionDate']
|
25
|
+
end
|
26
|
+
|
27
|
+
# Sets the account_acquisition_date property.
|
28
|
+
def account_acquisition_date=(value)
|
29
|
+
if value == @defaults['ai.user.accountAcquisitionDate']
|
30
|
+
@values.delete 'ai.user.accountAcquisitionDate' if @values.key? 'ai.user.accountAcquisitionDate'
|
31
|
+
else
|
32
|
+
@values['ai.user.accountAcquisitionDate'] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Gets the account_id property.
|
37
|
+
def account_id
|
38
|
+
return @values['ai.user.accountId'] if @values.key?('ai.user.accountId')
|
39
|
+
@defaults['ai.user.accountId']
|
40
|
+
end
|
41
|
+
|
42
|
+
# Sets the account_id property.
|
43
|
+
def account_id=(value)
|
44
|
+
if value == @defaults['ai.user.accountId']
|
45
|
+
@values.delete 'ai.user.accountId' if @values.key? 'ai.user.accountId'
|
46
|
+
else
|
47
|
+
@values['ai.user.accountId'] = value
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Gets the user_agent property.
|
52
|
+
def user_agent
|
53
|
+
return @values['ai.user.userAgent'] if @values.key?('ai.user.userAgent')
|
54
|
+
@defaults['ai.user.userAgent']
|
55
|
+
end
|
56
|
+
|
57
|
+
# Sets the user_agent property.
|
58
|
+
def user_agent=(value)
|
59
|
+
if value == @defaults['ai.user.userAgent']
|
60
|
+
@values.delete 'ai.user.userAgent' if @values.key? 'ai.user.userAgent'
|
61
|
+
else
|
62
|
+
@values['ai.user.userAgent'] = value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Gets the id property.
|
67
|
+
def id
|
68
|
+
return @values['ai.user.id'] if @values.key?('ai.user.id')
|
69
|
+
@defaults['ai.user.id']
|
70
|
+
end
|
71
|
+
|
72
|
+
# Sets the id property.
|
73
|
+
def id=(value)
|
74
|
+
if value == @defaults['ai.user.id']
|
75
|
+
@values.delete 'ai.user.id' if @values.key? 'ai.user.id'
|
76
|
+
else
|
77
|
+
@values['ai.user.id'] = value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
module ApplicationInsights
|
4
|
+
module Channel
|
5
|
+
# The base class for all queues.
|
6
|
+
class QueueBase
|
7
|
+
# Initializes a new instance of the queue class.
|
8
|
+
def initialize(sender)
|
9
|
+
raise ArgumentError, 'Sender was required but not provided' unless sender
|
10
|
+
@queue = Queue.new
|
11
|
+
@max_queue_length = 500
|
12
|
+
@sender = sender
|
13
|
+
@sender.queue = self
|
14
|
+
end
|
15
|
+
|
16
|
+
# Gets or sets the maximum number of items that will be held by the queue before we force a send.
|
17
|
+
attr_accessor :max_queue_length
|
18
|
+
|
19
|
+
# Gets the sender associated with this queue
|
20
|
+
attr_reader :sender
|
21
|
+
|
22
|
+
# Adds a single item to the queue.
|
23
|
+
def push(item)
|
24
|
+
unless item
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
@queue.push(item)
|
29
|
+
if @queue.length >= @max_queue_length
|
30
|
+
flush()
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Gets a single item from the queue. If no item is available, return nil.
|
35
|
+
def pop
|
36
|
+
begin
|
37
|
+
return @queue.pop(TRUE)
|
38
|
+
rescue ThreadError => _
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Flushes the current queue to the passed in sender.
|
44
|
+
def flush
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|