helios-opentelemetry-sdk 0.1.13 → 0.1.14
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 +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -1
- data/lib/helios/opentelemetry/sdk/instrumentations.rb +29 -3
- data/lib/helios/opentelemetry/sdk/patches/faraday_patch.rb +19 -0
- data/lib/helios/opentelemetry/sdk/{net_http_patch.rb → patches/net_http_patch.rb} +1 -1
- data/lib/helios/opentelemetry/sdk/patches/rack_patch.rb +29 -0
- data/lib/helios/opentelemetry/sdk/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e7f2f77a8b66880739f7a053fd1e0ac0ed6a9330d9d9068ccbeb060460ba7db
|
4
|
+
data.tar.gz: 806da26e71661cb27095bcc616d098b1a36af5ffbb4699e461cdeae5d0e077f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dd2dac65944039de49814d7958161bcd5317864bc1bc3b35c89024691739ce4dd4bdfbd168fcd9a2a2df75212dea7c7a7c81e716156880c5e5ce6bc8618aee0
|
7
|
+
data.tar.gz: f5ae7746690135bf149d897fcb61fe53709a5b7bc0f8f7ed32c48116b686a2a74e4b3d79f762ce0c16425cbfb5b7cc760da4f9d23c69a848c97fa03132e03df5
|
data/Gemfile
CHANGED
@@ -8,3 +8,5 @@ gem 'opentelemetry-instrumentation-all', '~> 0.25.0'
|
|
8
8
|
gem 'opentelemetry-instrumentation-rspec', '~> 0.2.0'
|
9
9
|
gem 'rubocop', '~> 1.30.1', group: [:development, :test]
|
10
10
|
gem 'bundler', '~> 2.3.16', group: [:development, :test]
|
11
|
+
gem 'faraday', '~> 2.3.0', group: [:development, :test]
|
12
|
+
gem 'rack', '~> 2.2.4', 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.14)
|
5
5
|
opentelemetry-exporter-otlp (~> 0.22.0)
|
6
6
|
opentelemetry-instrumentation-all (~> 0.25.0)
|
7
7
|
opentelemetry-instrumentation-rspec (~> 0.2.0)
|
@@ -12,6 +12,10 @@ GEM
|
|
12
12
|
specs:
|
13
13
|
ast (2.4.2)
|
14
14
|
diff-lcs (1.5.0)
|
15
|
+
faraday (2.3.0)
|
16
|
+
faraday-net_http (~> 2.0)
|
17
|
+
ruby2_keywords (>= 0.0.4)
|
18
|
+
faraday-net_http (2.0.3)
|
15
19
|
google-protobuf (3.21.1)
|
16
20
|
googleapis-common-protos-types (1.3.1)
|
17
21
|
google-protobuf (~> 3.14)
|
@@ -201,6 +205,7 @@ GEM
|
|
201
205
|
parallel (1.22.1)
|
202
206
|
parser (3.1.2.0)
|
203
207
|
ast (~> 2.4.1)
|
208
|
+
rack (2.2.4)
|
204
209
|
rainbow (3.1.1)
|
205
210
|
rake (13.0.6)
|
206
211
|
regexp_parser (2.5.0)
|
@@ -238,11 +243,13 @@ PLATFORMS
|
|
238
243
|
|
239
244
|
DEPENDENCIES
|
240
245
|
bundler (~> 2.3.16)
|
246
|
+
faraday (~> 2.3.0)
|
241
247
|
helios-opentelemetry-sdk!
|
242
248
|
opentelemetry-exporter-otlp (~> 0.22.0)
|
243
249
|
opentelemetry-instrumentation-all (~> 0.25.0)
|
244
250
|
opentelemetry-instrumentation-rspec (~> 0.2.0)
|
245
251
|
opentelemetry-sdk (~> 1.1.0)
|
252
|
+
rack (~> 2.2.4)
|
246
253
|
rake (~> 13.0)
|
247
254
|
rspec (~> 3.0)
|
248
255
|
rubocop (~> 1.30.1)
|
@@ -32,7 +32,7 @@ SUPPORTED_INSTRUMENTATIONS = {
|
|
32
32
|
'OpenTelemetry::Instrumentation::Que' => { propagation_style: :child },
|
33
33
|
'OpenTelemetry::Instrumentation::Rack' => {},
|
34
34
|
'OpenTelemetry::Instrumentation::Rdkafka' => {},
|
35
|
-
'OpenTelemetry::Instrumentation::Redis' => {},
|
35
|
+
'OpenTelemetry::Instrumentation::Redis' => { db_statement: :include },
|
36
36
|
'OpenTelemetry::Instrumentation::Resque' => { propagation_style: :child },
|
37
37
|
'OpenTelemetry::Instrumentation::RestClient' => {},
|
38
38
|
'OpenTelemetry::Instrumentation::RSpec' => nil, # Disabled for now
|
@@ -52,7 +52,33 @@ def apply_instrumentations(otel_config)
|
|
52
52
|
additional_patches
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
require_relative 'net_http_patch'
|
55
|
+
def patch_net_http
|
56
|
+
require_relative 'patches/net_http_patch'
|
57
57
|
::Net::HTTP.prepend(NetHttpPatch::Instrumentation)
|
58
58
|
end
|
59
|
+
|
60
|
+
def patch_faraday
|
61
|
+
return unless defined?(::Faraday)
|
62
|
+
|
63
|
+
require 'opentelemetry/instrumentation/faraday/middlewares/tracer_middleware'
|
64
|
+
require_relative 'patches/faraday_patch'
|
65
|
+
::OpenTelemetry::Instrumentation::Faraday::Middlewares::TracerMiddleware.prepend(
|
66
|
+
FaradayPatch::HeliosFaradayMiddleware
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def patch_rack
|
71
|
+
return unless defined?(::Rack)
|
72
|
+
|
73
|
+
require 'opentelemetry/instrumentation/rack/middlewares/tracer_middleware'
|
74
|
+
require_relative 'patches/rack_patch'
|
75
|
+
::OpenTelemetry::Instrumentation::Rack::Middlewares::TracerMiddleware.prepend(
|
76
|
+
RackPatch::HeliosRackMiddleware
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def additional_patches
|
81
|
+
patch_net_http
|
82
|
+
patch_faraday
|
83
|
+
patch_rack
|
84
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
require_relative '../../semantic_attributes'
|
4
|
+
|
5
|
+
module FaradayPatch
|
6
|
+
module HeliosFaradayMiddleware
|
7
|
+
def trace_response(span, env)
|
8
|
+
request_headers = env.request_headers
|
9
|
+
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
10
|
+
span.set_attribute(semantic_attributes::HTTP_REQUEST_HEADERS, request_headers.to_json)
|
11
|
+
span.set_attribute(semantic_attributes::HTTP_REQUEST_BODY, env.body) unless env.body.nil?
|
12
|
+
response_headers = env.response_headers
|
13
|
+
span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, response_headers.to_json)
|
14
|
+
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, env.response_body) unless env.response_body.nil?
|
15
|
+
|
16
|
+
super(span, env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'json'
|
3
|
+
require_relative '../../semantic_attributes'
|
4
|
+
|
5
|
+
module RackPatch
|
6
|
+
module HeliosRackMiddleware
|
7
|
+
def request_span_attributes(env:)
|
8
|
+
res = super(env: env)
|
9
|
+
# Request headers are attributes in the env hash that start with HTTP_
|
10
|
+
request_headers = env.select { |k, _v| k.start_with? 'HTTP_' }.transform_keys { |k| k.sub(/^HTTP_/, '').downcase }
|
11
|
+
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
12
|
+
res[semantic_attributes::HTTP_REQUEST_HEADERS] = request_headers.to_json
|
13
|
+
request_body = env['rack.input']&.read
|
14
|
+
env['rack.input']&.rewind
|
15
|
+
if request_body&.length&.positive?
|
16
|
+
res[semantic_attributes::HTTP_REQUEST_BODY] = request_body
|
17
|
+
end
|
18
|
+
|
19
|
+
res
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_attributes_after_request(span, status, headers, response)
|
23
|
+
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
24
|
+
span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, headers.to_json)
|
25
|
+
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, response[0]) if response[0]&.length&.positive?
|
26
|
+
super(span, status, headers, response)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Helios
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
- helios-opentelemetry-sdk.gemspec
|
131
131
|
- lib/helios/opentelemetry/sdk.rb
|
132
132
|
- lib/helios/opentelemetry/sdk/instrumentations.rb
|
133
|
-
- lib/helios/opentelemetry/sdk/
|
133
|
+
- lib/helios/opentelemetry/sdk/patches/faraday_patch.rb
|
134
|
+
- lib/helios/opentelemetry/sdk/patches/net_http_patch.rb
|
135
|
+
- lib/helios/opentelemetry/sdk/patches/rack_patch.rb
|
134
136
|
- lib/helios/opentelemetry/sdk/version.rb
|
135
137
|
- lib/helios/opentelemetry/semantic_attributes.rb
|
136
138
|
homepage: https://gethelios.dev
|