helios-opentelemetry-sdk 0.1.17 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +10 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/lib/helios/opentelemetry/sdk/instrumentations.rb +22 -0
- data/lib/helios/opentelemetry/sdk/patches/faraday_patch.rb +2 -2
- data/lib/helios/opentelemetry/sdk/patches/mongo_patch.rb +36 -0
- data/lib/helios/opentelemetry/sdk/patches/net_http_patch.rb +4 -4
- data/lib/helios/opentelemetry/sdk/patches/rack_patch.rb +4 -4
- data/lib/helios/opentelemetry/sdk/version.rb +1 -1
- data/lib/helios/opentelemetry/semantic_attributes.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 889fa8ef795bda2e3a01cf6dbf9670126977fdf24a5bb813bba82d6468b74791
|
4
|
+
data.tar.gz: ef1827c4e26eabd10fe8842f2bc6bcee6c49e2b5e7d699143fc0884717a3d9ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f981326aec00f05820ff100717cbe93637e10503a26bc85798a0359dd0cba1b41745c28759730ca7b94cac8fbd40f1ef3f1158e1a49f3570b0c7ebd8def4564
|
7
|
+
data.tar.gz: beb783d8219358140e293f124e59a69d0f5bf0498d32095989aae3c4985232df976ef2151a90117b8a787e911a575e069dd45b97553f64bdbac52a22c09fe41d
|
data/.github/workflows/test.yml
CHANGED
@@ -21,6 +21,16 @@ jobs:
|
|
21
21
|
fail-fast: false
|
22
22
|
matrix:
|
23
23
|
ruby-version: ['2.6', '2.7', '3.1']
|
24
|
+
services:
|
25
|
+
mongodb:
|
26
|
+
image: mongo@sha256:845fd775d7a58f564fae7c17a4eec7ff038e1c4004ebe05cc1cb5fc3767cf6cc
|
27
|
+
ports:
|
28
|
+
- 27017:27017
|
29
|
+
options: >-
|
30
|
+
--health-cmd="echo 'db.runCommand(\"ping\").ok' | mongo localhost:27017/test --quiet"
|
31
|
+
--health-interval=10s
|
32
|
+
--health-timeout=5s
|
33
|
+
--health-retries=3
|
24
34
|
steps:
|
25
35
|
- uses: actions/checkout@v2
|
26
36
|
- uses: actions/setup-ruby@v1
|
data/Gemfile
CHANGED
@@ -10,3 +10,4 @@ gem 'rubocop', '~> 1.30.1', group: [:development, :test]
|
|
10
10
|
gem 'bundler', '~> 2.3.16', group: [:development, :test]
|
11
11
|
gem 'faraday', '~> 2.3.0', group: [:development, :test]
|
12
12
|
gem 'rack', '~> 2.2.4', group: [:development, :test]
|
13
|
+
gem 'mongo', '~> 2.5', group: [:development, :test]
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
helios-opentelemetry-sdk (0.1.
|
4
|
+
helios-opentelemetry-sdk (0.1.18)
|
5
5
|
opentelemetry-exporter-otlp (~> 0.22.0)
|
6
6
|
opentelemetry-instrumentation-all (~> 0.25.0)
|
7
7
|
opentelemetry-instrumentation-rspec (~> 0.2.0)
|
@@ -11,6 +11,7 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
ast (2.4.2)
|
14
|
+
bson (4.15.0)
|
14
15
|
diff-lcs (1.5.0)
|
15
16
|
faraday (2.3.0)
|
16
17
|
faraday-net_http (~> 2.0)
|
@@ -19,6 +20,8 @@ GEM
|
|
19
20
|
google-protobuf (3.21.1)
|
20
21
|
googleapis-common-protos-types (1.3.1)
|
21
22
|
google-protobuf (~> 3.14)
|
23
|
+
mongo (2.18.1)
|
24
|
+
bson (>= 4.14.1, < 5.0.0)
|
22
25
|
opentelemetry-api (1.0.2)
|
23
26
|
opentelemetry-common (0.19.6)
|
24
27
|
opentelemetry-api (~> 1.0)
|
@@ -245,6 +248,7 @@ DEPENDENCIES
|
|
245
248
|
bundler (~> 2.3.16)
|
246
249
|
faraday (~> 2.3.0)
|
247
250
|
helios-opentelemetry-sdk!
|
251
|
+
mongo (~> 2.5)
|
248
252
|
opentelemetry-exporter-otlp (~> 0.22.0)
|
249
253
|
opentelemetry-instrumentation-all (~> 0.25.0)
|
250
254
|
opentelemetry-instrumentation-rspec (~> 0.2.0)
|
@@ -55,6 +55,8 @@ end
|
|
55
55
|
def patch_net_http
|
56
56
|
require_relative 'patches/net_http_patch'
|
57
57
|
::Net::HTTP.prepend(NetHttpPatch::Instrumentation)
|
58
|
+
rescue StandardError => e
|
59
|
+
::OpenTelemetry.logger.debug("Error patching net http: #{e}")
|
58
60
|
end
|
59
61
|
|
60
62
|
def patch_faraday
|
@@ -65,6 +67,8 @@ def patch_faraday
|
|
65
67
|
::OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware.prepend(
|
66
68
|
FaradayPatch::HeliosFaradayMiddleware
|
67
69
|
)
|
70
|
+
rescue StandardError => e
|
71
|
+
::OpenTelemetry.logger.debug("Error patching faraday: #{e}")
|
68
72
|
end
|
69
73
|
|
70
74
|
def patch_rack
|
@@ -75,10 +79,28 @@ def patch_rack
|
|
75
79
|
::OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware.prepend(
|
76
80
|
RackPatch::HeliosRackMiddleware
|
77
81
|
)
|
82
|
+
rescue StandardError => e
|
83
|
+
::OpenTelemetry.logger.debug("Error patching rack: #{e}")
|
84
|
+
end
|
85
|
+
|
86
|
+
def patch_mongo
|
87
|
+
return unless defined?(::Mongo::Monitoring::Global)
|
88
|
+
|
89
|
+
require 'opentelemetry/instrumentation/mongo/subscriber'
|
90
|
+
min_version = ::OpenTelemetry::Instrumentation::Mongo::Instrumentation::MINIMUM_VERSION
|
91
|
+
mongo_version = Gem::Version.new(::Mongo::VERSION)
|
92
|
+
return unless mongo_version >= min_version
|
93
|
+
|
94
|
+
require_relative 'patches/mongo_patch'
|
95
|
+
::OpenTelemetry::Instrumentation::Mongo::Subscriber.prepend(MongoPatch::Subscriber)
|
96
|
+
::OpenTelemetry::Instrumentation::Mongo::CommandSerializer.prepend(MongoPatch::CommandSerializer)
|
97
|
+
rescue StandardError => e
|
98
|
+
::OpenTelemetry.logger.debug("Error patching mongo: #{e}")
|
78
99
|
end
|
79
100
|
|
80
101
|
def additional_patches
|
81
102
|
patch_net_http
|
82
103
|
patch_faraday
|
83
104
|
patch_rack
|
105
|
+
patch_mongo
|
84
106
|
end
|
@@ -17,8 +17,8 @@ module FaradayPatch
|
|
17
17
|
response_headers = env.response_headers
|
18
18
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, response_headers.to_json)
|
19
19
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, env.response_body) unless env.response_body.nil?
|
20
|
-
rescue StandardError
|
21
|
-
|
20
|
+
rescue StandardError => e
|
21
|
+
::OpenTelemetry.logger.debug("Error extracting faraday attributes: #{e}")
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'json'
|
2
|
+
require_relative '../../semantic_attributes'
|
3
|
+
|
4
|
+
module MongoPatch
|
5
|
+
module Subscriber
|
6
|
+
def succeeded(event)
|
7
|
+
extract_query_result(event)
|
8
|
+
super(event)
|
9
|
+
end
|
10
|
+
|
11
|
+
def extract_query_result(event)
|
12
|
+
span = get_span(event)
|
13
|
+
return unless span
|
14
|
+
|
15
|
+
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::DB_QUERY_RESULT, event.reply.to_json)
|
16
|
+
rescue StandardError => e
|
17
|
+
::OpenTelemetry.logger.debug("Error extracting mongo query result: #{e}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module CommandSerializer
|
22
|
+
# Temp patch until the upstream fix is released
|
23
|
+
def mask(hash)
|
24
|
+
hash.each_with_object({}) do |(k, v), h|
|
25
|
+
value = if v.is_a?(Hash)
|
26
|
+
mask(v)
|
27
|
+
elsif @obfuscate
|
28
|
+
MASK_VALUE
|
29
|
+
else
|
30
|
+
v
|
31
|
+
end
|
32
|
+
h[k] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -36,15 +36,15 @@ module NetHttpPatch
|
|
36
36
|
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
|
37
37
|
body.is_a?(String) ? body : body.to_s)
|
38
38
|
end
|
39
|
-
rescue StandardError
|
40
|
-
|
39
|
+
rescue StandardError => e
|
40
|
+
::OpenTelemetry.logger.debug("Error extracting net http request attributes: #{e}")
|
41
41
|
end
|
42
42
|
|
43
43
|
def extract_response_attributes(span, response)
|
44
44
|
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_HEADERS, collect_headers(response))
|
45
45
|
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_BODY, response.body)
|
46
|
-
rescue StandardError
|
47
|
-
|
46
|
+
rescue StandardError => e
|
47
|
+
::OpenTelemetry.logger.debug("Error extracting net http response attributes: #{e}")
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -23,8 +23,8 @@ module RackPatch
|
|
23
23
|
request_body = env['rack.input']&.read
|
24
24
|
env['rack.input']&.rewind
|
25
25
|
res[semantic_attributes::HTTP_REQUEST_BODY] = request_body if request_body&.length&.positive?
|
26
|
-
rescue StandardError
|
27
|
-
|
26
|
+
rescue StandardError => e
|
27
|
+
::OpenTelemetry.logger.debug("Error extracting rack request attributes: #{e}")
|
28
28
|
end
|
29
29
|
|
30
30
|
def extract_response_attributes(span, headers, response)
|
@@ -33,8 +33,8 @@ module RackPatch
|
|
33
33
|
if response.respond_to?(:first) && response.first&.length&.positive?
|
34
34
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, response.first)
|
35
35
|
end
|
36
|
-
rescue StandardError
|
37
|
-
|
36
|
+
rescue StandardError => e
|
37
|
+
::OpenTelemetry.logger.debug("Error extracting rack response attributes: #{e}")
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helios-opentelemetry-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Helios
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/helios/opentelemetry/sdk.rb
|
132
132
|
- lib/helios/opentelemetry/sdk/instrumentations.rb
|
133
133
|
- lib/helios/opentelemetry/sdk/patches/faraday_patch.rb
|
134
|
+
- lib/helios/opentelemetry/sdk/patches/mongo_patch.rb
|
134
135
|
- lib/helios/opentelemetry/sdk/patches/net_http_patch.rb
|
135
136
|
- lib/helios/opentelemetry/sdk/patches/rack_patch.rb
|
136
137
|
- lib/helios/opentelemetry/sdk/version.rb
|