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.
Files changed (68) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +40 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +106 -0
  6. data/Rakefile +10 -0
  7. data/application_insights.gemspec +25 -0
  8. data/lib/application_insights.rb +2 -0
  9. data/lib/application_insights/channel/contracts/application.rb +35 -0
  10. data/lib/application_insights/channel/contracts/data.rb +47 -0
  11. data/lib/application_insights/channel/contracts/data_point.rb +125 -0
  12. data/lib/application_insights/channel/contracts/data_point_type.rb +16 -0
  13. data/lib/application_insights/channel/contracts/dependency_kind.rb +22 -0
  14. data/lib/application_insights/channel/contracts/dependency_source_type.rb +19 -0
  15. data/lib/application_insights/channel/contracts/device.rb +243 -0
  16. data/lib/application_insights/channel/contracts/envelope.rb +254 -0
  17. data/lib/application_insights/channel/contracts/event_data.rb +77 -0
  18. data/lib/application_insights/channel/contracts/exception_data.rb +105 -0
  19. data/lib/application_insights/channel/contracts/exception_details.rb +125 -0
  20. data/lib/application_insights/channel/contracts/internal.rb +51 -0
  21. data/lib/application_insights/channel/contracts/json_serializable.rb +59 -0
  22. data/lib/application_insights/channel/contracts/location.rb +35 -0
  23. data/lib/application_insights/channel/contracts/message_data.rb +76 -0
  24. data/lib/application_insights/channel/contracts/metric_data.rb +60 -0
  25. data/lib/application_insights/channel/contracts/operation.rb +83 -0
  26. data/lib/application_insights/channel/contracts/page_view_data.rb +109 -0
  27. data/lib/application_insights/channel/contracts/remote_dependency_data.rb +218 -0
  28. data/lib/application_insights/channel/contracts/request_data.rb +173 -0
  29. data/lib/application_insights/channel/contracts/session.rb +67 -0
  30. data/lib/application_insights/channel/contracts/severity_level.rb +25 -0
  31. data/lib/application_insights/channel/contracts/stack_frame.rb +91 -0
  32. data/lib/application_insights/channel/contracts/user.rb +83 -0
  33. data/lib/application_insights/channel/queue_base.rb +48 -0
  34. data/lib/application_insights/channel/sender_base.rb +46 -0
  35. data/lib/application_insights/channel/synchronous_queue.rb +28 -0
  36. data/lib/application_insights/channel/synchronous_sender.rb +13 -0
  37. data/lib/application_insights/channel/telemetry_channel.rb +81 -0
  38. data/lib/application_insights/channel/telemetry_context.rb +49 -0
  39. data/lib/application_insights/telemetry_client.rb +111 -0
  40. data/lib/application_insights/version.rb +3 -0
  41. data/test/application_insights.rb +9 -0
  42. data/test/application_insights/channel/contracts/test_application.rb +31 -0
  43. data/test/application_insights/channel/contracts/test_data.rb +44 -0
  44. data/test/application_insights/channel/contracts/test_data_point.rb +109 -0
  45. data/test/application_insights/channel/contracts/test_device.rb +200 -0
  46. data/test/application_insights/channel/contracts/test_envelope.rb +209 -0
  47. data/test/application_insights/channel/contracts/test_event_data.rb +62 -0
  48. data/test/application_insights/channel/contracts/test_exception_data.rb +85 -0
  49. data/test/application_insights/channel/contracts/test_exception_details.rb +106 -0
  50. data/test/application_insights/channel/contracts/test_internal.rb +44 -0
  51. data/test/application_insights/channel/contracts/test_location.rb +31 -0
  52. data/test/application_insights/channel/contracts/test_message_data.rb +66 -0
  53. data/test/application_insights/channel/contracts/test_metric_data.rb +50 -0
  54. data/test/application_insights/channel/contracts/test_operation.rb +70 -0
  55. data/test/application_insights/channel/contracts/test_page_view_data.rb +88 -0
  56. data/test/application_insights/channel/contracts/test_remote_dependency_data.rb +183 -0
  57. data/test/application_insights/channel/contracts/test_request_data.rb +153 -0
  58. data/test/application_insights/channel/contracts/test_session.rb +57 -0
  59. data/test/application_insights/channel/contracts/test_stack_frame.rb +83 -0
  60. data/test/application_insights/channel/contracts/test_user.rb +70 -0
  61. data/test/application_insights/channel/test_queue_base.rb +88 -0
  62. data/test/application_insights/channel/test_sender_base.rb +96 -0
  63. data/test/application_insights/channel/test_synchronous_queue.rb +42 -0
  64. data/test/application_insights/channel/test_synchronous_sender.rb +11 -0
  65. data/test/application_insights/channel/test_telemetry_channel.rb +102 -0
  66. data/test/application_insights/channel/test_telemetry_context.rb +72 -0
  67. data/test/application_insights/test_telemetry_client.rb +107 -0
  68. metadata +166 -0
@@ -0,0 +1,77 @@
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
+ return @values['properties'] if @values.key?('properties')
46
+ @values['properties'] = {}
47
+ @values['properties']
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
+ return @values['measurements'] if @values.key?('measurements')
62
+ @values['measurements'] = {}
63
+ @values['measurements']
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
@@ -0,0 +1,105 @@
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
+ 'properties' => {},
16
+ 'measurements' => {}
17
+ }
18
+ values = {
19
+ 'ver' => 2,
20
+ 'handledAt' => nil,
21
+ 'exceptions' => []
22
+ }
23
+ super defaults, values, options
24
+ end
25
+
26
+ # Gets the ver property.
27
+ def ver
28
+ @values['ver']
29
+ end
30
+
31
+ # Sets the ver property.
32
+ def ver=(value)
33
+ @values['ver'] = value
34
+ end
35
+
36
+ # Gets the handled_at property.
37
+ def handled_at
38
+ @values['handledAt']
39
+ end
40
+
41
+ # Sets the handled_at property.
42
+ def handled_at=(value)
43
+ @values['handledAt'] = value
44
+ end
45
+
46
+ # Gets the exceptions property.
47
+ def exceptions
48
+ @values['exceptions']
49
+ end
50
+
51
+ # Sets the exceptions property.
52
+ def exceptions=(value)
53
+ @values['exceptions'] = value
54
+ end
55
+
56
+ # Gets the severity_level property.
57
+ def severity_level
58
+ return @values['severityLevel'] if @values.key?('severityLevel')
59
+ @defaults['severityLevel']
60
+ end
61
+
62
+ # Sets the severity_level property.
63
+ def severity_level=(value)
64
+ if value == @defaults['severityLevel']
65
+ @values.delete 'severityLevel' if @values.key? 'severityLevel'
66
+ else
67
+ @values['severityLevel'] = value
68
+ end
69
+ end
70
+
71
+ # Gets the properties property.
72
+ def properties
73
+ return @values['properties'] if @values.key?('properties')
74
+ @values['properties'] = {}
75
+ @values['properties']
76
+ end
77
+
78
+ # Sets the properties property.
79
+ def properties=(value)
80
+ if value == @defaults['properties']
81
+ @values.delete 'properties' if @values.key? 'properties'
82
+ else
83
+ @values['properties'] = value
84
+ end
85
+ end
86
+
87
+ # Gets the measurements property.
88
+ def measurements
89
+ return @values['measurements'] if @values.key?('measurements')
90
+ @values['measurements'] = {}
91
+ @values['measurements']
92
+ end
93
+
94
+ # Sets the measurements property.
95
+ def measurements=(value)
96
+ if value == @defaults['measurements']
97
+ @values.delete 'measurements' if @values.key? 'measurements'
98
+ else
99
+ @values['measurements'] = value
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,125 @@
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights
4
+ module Channel
5
+ module Contracts
6
+ # Data contract class for type ExceptionDetails.
7
+ class ExceptionDetails < JsonSerializable
8
+ # Initializes a new instance of the ExceptionDetails class.
9
+ def initialize(options={})
10
+ defaults = {
11
+ 'id' => nil,
12
+ 'outerId' => nil,
13
+ 'typeName' => nil,
14
+ 'message' => nil,
15
+ 'hasFullStack' => true,
16
+ 'stack' => nil,
17
+ 'parsedStack' => []
18
+ }
19
+ values = {
20
+ 'typeName' => nil,
21
+ 'message' => nil,
22
+ 'hasFullStack' => true
23
+ }
24
+ super defaults, values, options
25
+ end
26
+
27
+ # Gets the id property.
28
+ def id
29
+ return @values['id'] if @values.key?('id')
30
+ @defaults['id']
31
+ end
32
+
33
+ # Sets the id property.
34
+ def id=(value)
35
+ if value == @defaults['id']
36
+ @values.delete 'id' if @values.key? 'id'
37
+ else
38
+ @values['id'] = value
39
+ end
40
+ end
41
+
42
+ # Gets the outer_id property.
43
+ def outer_id
44
+ return @values['outerId'] if @values.key?('outerId')
45
+ @defaults['outerId']
46
+ end
47
+
48
+ # Sets the outer_id property.
49
+ def outer_id=(value)
50
+ if value == @defaults['outerId']
51
+ @values.delete 'outerId' if @values.key? 'outerId'
52
+ else
53
+ @values['outerId'] = value
54
+ end
55
+ end
56
+
57
+ # Gets the type_name property.
58
+ def type_name
59
+ @values['typeName']
60
+ end
61
+
62
+ # Sets the type_name property.
63
+ def type_name=(value)
64
+ @values['typeName'] = value
65
+ end
66
+
67
+ # Gets the message property.
68
+ def message
69
+ @values['message']
70
+ end
71
+
72
+ # Sets the message property.
73
+ def message=(value)
74
+ @values['message'] = value
75
+ end
76
+
77
+ # Gets the has_full_stack property.
78
+ def has_full_stack
79
+ return @values['hasFullStack'] if @values.key?('hasFullStack')
80
+ @defaults['hasFullStack']
81
+ end
82
+
83
+ # Sets the has_full_stack property.
84
+ def has_full_stack=(value)
85
+ if value == @defaults['hasFullStack']
86
+ @values.delete 'hasFullStack' if @values.key? 'hasFullStack'
87
+ else
88
+ @values['hasFullStack'] = value
89
+ end
90
+ end
91
+
92
+ # Gets the stack property.
93
+ def stack
94
+ return @values['stack'] if @values.key?('stack')
95
+ @defaults['stack']
96
+ end
97
+
98
+ # Sets the stack property.
99
+ def stack=(value)
100
+ if value == @defaults['stack']
101
+ @values.delete 'stack' if @values.key? 'stack'
102
+ else
103
+ @values['stack'] = value
104
+ end
105
+ end
106
+
107
+ # Gets the parsed_stack property.
108
+ def parsed_stack
109
+ return @values['parsedStack'] if @values.key?('parsedStack')
110
+ @values['parsedStack'] = []
111
+ @values['parsedStack']
112
+ end
113
+
114
+ # Sets the parsed_stack property.
115
+ def parsed_stack=(value)
116
+ if value == @defaults['parsedStack']
117
+ @values.delete 'parsedStack' if @values.key? 'parsedStack'
118
+ else
119
+ @values['parsedStack'] = value
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights
4
+ module Channel
5
+ module Contracts
6
+ # Data contract class for type Internal.
7
+ class Internal < JsonSerializable
8
+ # Initializes a new instance of the Internal class.
9
+ def initialize(options={})
10
+ defaults = {
11
+ 'ai.internal.sdkVersion' => nil,
12
+ 'ai.internal.agentVersion' => nil
13
+ }
14
+ values = {
15
+ }
16
+ super defaults, values, options
17
+ end
18
+
19
+ # Gets the sdk_version property.
20
+ def sdk_version
21
+ return @values['ai.internal.sdkVersion'] if @values.key?('ai.internal.sdkVersion')
22
+ @defaults['ai.internal.sdkVersion']
23
+ end
24
+
25
+ # Sets the sdk_version property.
26
+ def sdk_version=(value)
27
+ if value == @defaults['ai.internal.sdkVersion']
28
+ @values.delete 'ai.internal.sdkVersion' if @values.key? 'ai.internal.sdkVersion'
29
+ else
30
+ @values['ai.internal.sdkVersion'] = value
31
+ end
32
+ end
33
+
34
+ # Gets the agent_version property.
35
+ def agent_version
36
+ return @values['ai.internal.agentVersion'] if @values.key?('ai.internal.agentVersion')
37
+ @defaults['ai.internal.agentVersion']
38
+ end
39
+
40
+ # Sets the agent_version property.
41
+ def agent_version=(value)
42
+ if value == @defaults['ai.internal.agentVersion']
43
+ @values.delete 'ai.internal.agentVersion' if @values.key? 'ai.internal.agentVersion'
44
+ else
45
+ @values['ai.internal.agentVersion'] = value
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,59 @@
1
+ require 'json'
2
+
3
+ module ApplicationInsights
4
+ module Channel
5
+ module Contracts
6
+ class JsonSerializable
7
+ def initialize(defaults, values, options)
8
+ @defaults = defaults
9
+ @values = values
10
+ if options != nil
11
+ options.each do |key, value|
12
+ self.send key.to_s + '=', value
13
+ end
14
+ end
15
+ end
16
+
17
+ def to_h
18
+ output = {}
19
+ @defaults.each do |key, default|
20
+ if @values.key? key
21
+ value = @values[key]
22
+ value = default if value == nil
23
+ elsif default
24
+ value = default
25
+ else
26
+ next
27
+ end
28
+
29
+ if value.class == Array
30
+ value_copy = []
31
+ value.each do |item|
32
+ item.respond_to?(:to_h) ? value_copy.push(item.to_h) : value_copy.push(item)
33
+ end
34
+ output[key] = value_copy if value_copy.length > 0
35
+ elsif value.class == Hash
36
+ value_copy = {}
37
+ value.each do |item_key, item_value|
38
+ (item_value.respond_to? :to_h) ? value_copy[item_key] = item_value.to_h : value_copy[item_key] = item_value
39
+ end
40
+ output[key] = value_copy if value_copy.length > 0
41
+ elsif value.respond_to? :to_h
42
+ value_copy = value.to_h
43
+ output[key] = value_copy if value_copy.length > 0
44
+ else
45
+ output[key] = value
46
+ end
47
+ end
48
+ output
49
+ end
50
+
51
+ def to_json(*)
52
+ hash = self.to_h
53
+ hash.to_json
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
@@ -0,0 +1,35 @@
1
+ require_relative 'json_serializable'
2
+
3
+ module ApplicationInsights
4
+ module Channel
5
+ module Contracts
6
+ # Data contract class for type Location.
7
+ class Location < JsonSerializable
8
+ # Initializes a new instance of the Location class.
9
+ def initialize(options={})
10
+ defaults = {
11
+ 'ai.location.ip' => nil
12
+ }
13
+ values = {
14
+ }
15
+ super defaults, values, options
16
+ end
17
+
18
+ # Gets the ip property.
19
+ def ip
20
+ return @values['ai.location.ip'] if @values.key?('ai.location.ip')
21
+ @defaults['ai.location.ip']
22
+ end
23
+
24
+ # Sets the ip property.
25
+ def ip=(value)
26
+ if value == @defaults['ai.location.ip']
27
+ @values.delete 'ai.location.ip' if @values.key? 'ai.location.ip'
28
+ else
29
+ @values['ai.location.ip'] = value
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end