helios-opentelemetry-sdk 0.1.14 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +1 -1
- data/lib/helios/opentelemetry/sdk/patches/faraday_patch.rb +7 -2
- data/lib/helios/opentelemetry/sdk/patches/net_http_patch.rb +20 -1
- data/lib/helios/opentelemetry/sdk/patches/rack_patch.rb +19 -8
- data/lib/helios/opentelemetry/sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82426806e8d43f898618e45a8b6285f55911cfac228a3182570172c87507d905
|
4
|
+
data.tar.gz: 771fa774bc6f35b9594fa7b4079294bbef6a722cc6ec81fe65ff21d99f388638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58cf30a126082e5bc20893172165647a9cdbec2bea5dc2bd847293f1d8eb120d73620a8e676e5d6c38d7486511daf05652e7c46c18787b70cec4b354c54ef88a
|
7
|
+
data.tar.gz: 40fa5d278137ade4190316222108855bf7fea06fd24cc77c61a3ff063206d2246c22aacac99701a30a423a33e2e5e8a71b9b14bb53f970090b16e0ffe7295e0b
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -5,6 +5,11 @@ require_relative '../../semantic_attributes'
|
|
5
5
|
module FaradayPatch
|
6
6
|
module HeliosFaradayMiddleware
|
7
7
|
def trace_response(span, env)
|
8
|
+
extract_additional_attributes(span, env)
|
9
|
+
super(span, env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract_additional_attributes(span, env)
|
8
13
|
request_headers = env.request_headers
|
9
14
|
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
10
15
|
span.set_attribute(semantic_attributes::HTTP_REQUEST_HEADERS, request_headers.to_json)
|
@@ -12,8 +17,8 @@ module FaradayPatch
|
|
12
17
|
response_headers = env.response_headers
|
13
18
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, response_headers.to_json)
|
14
19
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, env.response_body) unless env.response_body.nil?
|
15
|
-
|
16
|
-
|
20
|
+
rescue StandardError
|
21
|
+
# Do nothing
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -6,7 +6,8 @@ module NetHttpPatch
|
|
6
6
|
module Instrumentation
|
7
7
|
def request(req, body = nil, &block)
|
8
8
|
current_span = OpenTelemetry::Trace.current_span
|
9
|
-
current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS,
|
9
|
+
current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS,
|
10
|
+
collect_headers(req))
|
10
11
|
unless body.nil?
|
11
12
|
current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
|
12
13
|
body.is_a?(String) ? body : body.to_s)
|
@@ -27,5 +28,23 @@ module NetHttpPatch
|
|
27
28
|
|
28
29
|
headers.to_json
|
29
30
|
end
|
31
|
+
|
32
|
+
def extract_request_attributes(span, req, body)
|
33
|
+
::OpenTelemetry.logger.warn('aaaaaaa')
|
34
|
+
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS, collect_headers(req))
|
35
|
+
unless body.nil?
|
36
|
+
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
|
37
|
+
body.is_a?(String) ? body : body.to_s)
|
38
|
+
end
|
39
|
+
rescue StandardError
|
40
|
+
# Do nothing
|
41
|
+
end
|
42
|
+
|
43
|
+
def extract_response_attributes(span, response)
|
44
|
+
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_HEADERS, collect_headers(response))
|
45
|
+
span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_BODY, response.body)
|
46
|
+
rescue StandardError
|
47
|
+
# Do nothing
|
48
|
+
end
|
30
49
|
end
|
31
50
|
end
|
@@ -6,24 +6,35 @@ module RackPatch
|
|
6
6
|
module HeliosRackMiddleware
|
7
7
|
def request_span_attributes(env:)
|
8
8
|
res = super(env: env)
|
9
|
+
extract_request_attributes(env, res)
|
10
|
+
res
|
11
|
+
end
|
12
|
+
|
13
|
+
def set_attributes_after_request(span, status, headers, response)
|
14
|
+
extract_response_attributes(span, headers, response)
|
15
|
+
super(span, status, headers, response)
|
16
|
+
end
|
17
|
+
|
18
|
+
def extract_request_attributes(env, res)
|
9
19
|
# Request headers are attributes in the env hash that start with HTTP_
|
10
20
|
request_headers = env.select { |k, _v| k.start_with? 'HTTP_' }.transform_keys { |k| k.sub(/^HTTP_/, '').downcase }
|
11
21
|
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
12
22
|
res[semantic_attributes::HTTP_REQUEST_HEADERS] = request_headers.to_json
|
13
23
|
request_body = env['rack.input']&.read
|
14
24
|
env['rack.input']&.rewind
|
15
|
-
if request_body&.length&.positive?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
res
|
25
|
+
res[semantic_attributes::HTTP_REQUEST_BODY] = request_body if request_body&.length&.positive?
|
26
|
+
rescue StandardError
|
27
|
+
# Do nothing
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
30
|
+
def extract_response_attributes(span, headers, response)
|
23
31
|
semantic_attributes = Helios::OpenTelemetry::SemanticAttributes
|
24
32
|
span.set_attribute(semantic_attributes::HTTP_RESPONSE_HEADERS, headers.to_json)
|
25
|
-
|
26
|
-
|
33
|
+
if response.respond_to?(:first) && response.first&.length&.positive?
|
34
|
+
span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, response.first)
|
35
|
+
end
|
36
|
+
rescue StandardError
|
37
|
+
# Do nothing
|
27
38
|
end
|
28
39
|
end
|
29
40
|
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.17
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|