application_insights 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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,85 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/exception_data'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestExceptionData < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::ExceptionData.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_ver_works_as_expected
13
+ expected = 42
14
+ item = Contracts::ExceptionData.new
15
+ item.ver = expected
16
+ actual = item.ver
17
+ assert_equal expected, actual
18
+ expected = 13
19
+ item.ver = expected
20
+ actual = item.ver
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_handled_at_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::ExceptionData.new
27
+ item.handled_at = expected
28
+ actual = item.handled_at
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.handled_at = expected
32
+ actual = item.handled_at
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_exceptions_works_as_expected
37
+ item = Contracts::ExceptionData.new
38
+ actual = item.exceptions
39
+ assert_not_nil actual
40
+ end
41
+
42
+ def test_severity_level_works_as_expected
43
+ expected = { 'key' => 'value' }
44
+ item = Contracts::ExceptionData.new
45
+ item.severity_level = expected
46
+ actual = item.severity_level
47
+ assert_equal expected, actual
48
+ expected = { 'key' => 'value' }
49
+ item.severity_level = expected
50
+ actual = item.severity_level
51
+ assert_equal expected, actual
52
+ end
53
+
54
+ def test_properties_works_as_expected
55
+ item = Contracts::ExceptionData.new
56
+ actual = item.properties
57
+ assert_not_nil actual
58
+ end
59
+
60
+ def test_measurements_works_as_expected
61
+ item = Contracts::ExceptionData.new
62
+ actual = item.measurements
63
+ assert_not_nil actual
64
+ end
65
+
66
+ def test_to_json_works_as_expected
67
+ item = Contracts::ExceptionData.new
68
+ item.ver = 42
69
+ item.handled_at = 'Test string'
70
+ [ { 'key' => 'value' } ].each do |value|
71
+ item.exceptions.push value
72
+ end
73
+
74
+ item.severity_level = { 'key' => 'value' }
75
+ { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|
76
+ item.properties[key] = value
77
+ end
78
+ { 'key1' => 3.1415 , 'key2' => 42.2 }.each do |key, value|
79
+ item.measurements[key] = value
80
+ end
81
+ actual = item.to_json
82
+ expected = '{"ver":42,"handledAt":"Test string","exceptions":[{"key":"value"}],"severityLevel":{"key":"value"},"properties":{"key1":"test value 1","key2":"test value 2"},"measurements":{"key1":3.1415,"key2":42.2}}'
83
+ assert_equal expected, actual
84
+ end
85
+ end
@@ -0,0 +1,106 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/exception_details'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestExceptionDetails < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::ExceptionDetails.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_id_works_as_expected
13
+ expected = 42
14
+ item = Contracts::ExceptionDetails.new
15
+ item.id = expected
16
+ actual = item.id
17
+ assert_equal expected, actual
18
+ expected = 13
19
+ item.id = expected
20
+ actual = item.id
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_outer_id_works_as_expected
25
+ expected = 42
26
+ item = Contracts::ExceptionDetails.new
27
+ item.outer_id = expected
28
+ actual = item.outer_id
29
+ assert_equal expected, actual
30
+ expected = 13
31
+ item.outer_id = expected
32
+ actual = item.outer_id
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_type_name_works_as_expected
37
+ expected = 'Test string'
38
+ item = Contracts::ExceptionDetails.new
39
+ item.type_name = expected
40
+ actual = item.type_name
41
+ assert_equal expected, actual
42
+ expected = 'Other string'
43
+ item.type_name = expected
44
+ actual = item.type_name
45
+ assert_equal expected, actual
46
+ end
47
+
48
+ def test_message_works_as_expected
49
+ expected = 'Test string'
50
+ item = Contracts::ExceptionDetails.new
51
+ item.message = expected
52
+ actual = item.message
53
+ assert_equal expected, actual
54
+ expected = 'Other string'
55
+ item.message = expected
56
+ actual = item.message
57
+ assert_equal expected, actual
58
+ end
59
+
60
+ def test_has_full_stack_works_as_expected
61
+ expected = TRUE
62
+ item = Contracts::ExceptionDetails.new
63
+ item.has_full_stack = expected
64
+ actual = item.has_full_stack
65
+ assert_equal expected, actual
66
+ expected = FALSE
67
+ item.has_full_stack = expected
68
+ actual = item.has_full_stack
69
+ assert_equal expected, actual
70
+ end
71
+
72
+ def test_stack_works_as_expected
73
+ expected = 'Test string'
74
+ item = Contracts::ExceptionDetails.new
75
+ item.stack = expected
76
+ actual = item.stack
77
+ assert_equal expected, actual
78
+ expected = 'Other string'
79
+ item.stack = expected
80
+ actual = item.stack
81
+ assert_equal expected, actual
82
+ end
83
+
84
+ def test_parsed_stack_works_as_expected
85
+ item = Contracts::ExceptionDetails.new
86
+ actual = item.parsed_stack
87
+ assert_not_nil actual
88
+ end
89
+
90
+ def test_to_json_works_as_expected
91
+ item = Contracts::ExceptionDetails.new
92
+ item.id = 42
93
+ item.outer_id = 42
94
+ item.type_name = 'Test string'
95
+ item.message = 'Test string'
96
+ item.has_full_stack = TRUE
97
+ item.stack = 'Test string'
98
+ [ { 'key' => 'value' } ].each do |value|
99
+ item.parsed_stack.push value
100
+ end
101
+
102
+ actual = item.to_json
103
+ expected = '{"id":42,"outerId":42,"typeName":"Test string","message":"Test string","hasFullStack":true,"stack":"Test string","parsedStack":[{"key":"value"}]}'
104
+ assert_equal expected, actual
105
+ end
106
+ end
@@ -0,0 +1,44 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/internal'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestInternal < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::Internal.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_sdk_version_works_as_expected
13
+ expected = 'Test string'
14
+ item = Contracts::Internal.new
15
+ item.sdk_version = expected
16
+ actual = item.sdk_version
17
+ assert_equal expected, actual
18
+ expected = 'Other string'
19
+ item.sdk_version = expected
20
+ actual = item.sdk_version
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_agent_version_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::Internal.new
27
+ item.agent_version = expected
28
+ actual = item.agent_version
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.agent_version = expected
32
+ actual = item.agent_version
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_to_json_works_as_expected
37
+ item = Contracts::Internal.new
38
+ item.sdk_version = 'Test string'
39
+ item.agent_version = 'Test string'
40
+ actual = item.to_json
41
+ expected = '{"ai.internal.sdkVersion":"Test string","ai.internal.agentVersion":"Test string"}'
42
+ assert_equal expected, actual
43
+ end
44
+ end
@@ -0,0 +1,31 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/location'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestLocation < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::Location.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_ip_works_as_expected
13
+ expected = 'Test string'
14
+ item = Contracts::Location.new
15
+ item.ip = expected
16
+ actual = item.ip
17
+ assert_equal expected, actual
18
+ expected = 'Other string'
19
+ item.ip = expected
20
+ actual = item.ip
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_to_json_works_as_expected
25
+ item = Contracts::Location.new
26
+ item.ip = 'Test string'
27
+ actual = item.to_json
28
+ expected = '{"ai.location.ip":"Test string"}'
29
+ assert_equal expected, actual
30
+ end
31
+ end
@@ -0,0 +1,66 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/message_data'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestMessageData < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::MessageData.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_ver_works_as_expected
13
+ expected = 42
14
+ item = Contracts::MessageData.new
15
+ item.ver = expected
16
+ actual = item.ver
17
+ assert_equal expected, actual
18
+ expected = 13
19
+ item.ver = expected
20
+ actual = item.ver
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_message_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::MessageData.new
27
+ item.message = expected
28
+ actual = item.message
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.message = expected
32
+ actual = item.message
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_severity_level_works_as_expected
37
+ expected = { 'key' => 'value' }
38
+ item = Contracts::MessageData.new
39
+ item.severity_level = expected
40
+ actual = item.severity_level
41
+ assert_equal expected, actual
42
+ expected = { 'key' => 'value' }
43
+ item.severity_level = expected
44
+ actual = item.severity_level
45
+ assert_equal expected, actual
46
+ end
47
+
48
+ def test_properties_works_as_expected
49
+ item = Contracts::MessageData.new
50
+ actual = item.properties
51
+ assert_not_nil actual
52
+ end
53
+
54
+ def test_to_json_works_as_expected
55
+ item = Contracts::MessageData.new
56
+ item.ver = 42
57
+ item.message = 'Test string'
58
+ item.severity_level = { 'key' => 'value' }
59
+ { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|
60
+ item.properties[key] = value
61
+ end
62
+ actual = item.to_json
63
+ expected = '{"ver":42,"message":"Test string","severityLevel":{"key":"value"},"properties":{"key1":"test value 1","key2":"test value 2"}}'
64
+ assert_equal expected, actual
65
+ end
66
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/metric_data'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestMetricData < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::MetricData.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_ver_works_as_expected
13
+ expected = 42
14
+ item = Contracts::MetricData.new
15
+ item.ver = expected
16
+ actual = item.ver
17
+ assert_equal expected, actual
18
+ expected = 13
19
+ item.ver = expected
20
+ actual = item.ver
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_metrics_works_as_expected
25
+ item = Contracts::MetricData.new
26
+ actual = item.metrics
27
+ assert_not_nil actual
28
+ end
29
+
30
+ def test_properties_works_as_expected
31
+ item = Contracts::MetricData.new
32
+ actual = item.properties
33
+ assert_not_nil actual
34
+ end
35
+
36
+ def test_to_json_works_as_expected
37
+ item = Contracts::MetricData.new
38
+ item.ver = 42
39
+ [ { 'key' => 'value' } ].each do |value|
40
+ item.metrics.push value
41
+ end
42
+
43
+ { 'key1' => 'test value 1' , 'key2' => 'test value 2' }.each do |key, value|
44
+ item.properties[key] = value
45
+ end
46
+ actual = item.to_json
47
+ expected = '{"ver":42,"metrics":[{"key":"value"}],"properties":{"key1":"test value 1","key2":"test value 2"}}'
48
+ assert_equal expected, actual
49
+ end
50
+ end
@@ -0,0 +1,70 @@
1
+ require_relative '../../../../lib/application_insights/channel/contracts/operation'
2
+ require 'test/unit'
3
+
4
+ include ApplicationInsights::Channel
5
+
6
+ class TestOperation < Test::Unit::TestCase
7
+ def test_initialize
8
+ item = Contracts::Operation.new
9
+ assert_not_nil item
10
+ end
11
+
12
+ def test_id_works_as_expected
13
+ expected = 'Test string'
14
+ item = Contracts::Operation.new
15
+ item.id = expected
16
+ actual = item.id
17
+ assert_equal expected, actual
18
+ expected = 'Other string'
19
+ item.id = expected
20
+ actual = item.id
21
+ assert_equal expected, actual
22
+ end
23
+
24
+ def test_name_works_as_expected
25
+ expected = 'Test string'
26
+ item = Contracts::Operation.new
27
+ item.name = expected
28
+ actual = item.name
29
+ assert_equal expected, actual
30
+ expected = 'Other string'
31
+ item.name = expected
32
+ actual = item.name
33
+ assert_equal expected, actual
34
+ end
35
+
36
+ def test_parent_id_works_as_expected
37
+ expected = 'Test string'
38
+ item = Contracts::Operation.new
39
+ item.parent_id = expected
40
+ actual = item.parent_id
41
+ assert_equal expected, actual
42
+ expected = 'Other string'
43
+ item.parent_id = expected
44
+ actual = item.parent_id
45
+ assert_equal expected, actual
46
+ end
47
+
48
+ def test_root_id_works_as_expected
49
+ expected = 'Test string'
50
+ item = Contracts::Operation.new
51
+ item.root_id = expected
52
+ actual = item.root_id
53
+ assert_equal expected, actual
54
+ expected = 'Other string'
55
+ item.root_id = expected
56
+ actual = item.root_id
57
+ assert_equal expected, actual
58
+ end
59
+
60
+ def test_to_json_works_as_expected
61
+ item = Contracts::Operation.new
62
+ item.id = 'Test string'
63
+ item.name = 'Test string'
64
+ item.parent_id = 'Test string'
65
+ item.root_id = 'Test string'
66
+ actual = item.to_json
67
+ expected = '{"ai.operation.id":"Test string","ai.operation.name":"Test string","ai.operation.parentId":"Test string","ai.operation.rootId":"Test string"}'
68
+ assert_equal expected, actual
69
+ end
70
+ end