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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e7f2f77a8b66880739f7a053fd1e0ac0ed6a9330d9d9068ccbeb060460ba7db
4
- data.tar.gz: 806da26e71661cb27095bcc616d098b1a36af5ffbb4699e461cdeae5d0e077f4
3
+ metadata.gz: 82426806e8d43f898618e45a8b6285f55911cfac228a3182570172c87507d905
4
+ data.tar.gz: 771fa774bc6f35b9594fa7b4079294bbef6a722cc6ec81fe65ff21d99f388638
5
5
  SHA512:
6
- metadata.gz: 4dd2dac65944039de49814d7958161bcd5317864bc1bc3b35c89024691739ce4dd4bdfbd168fcd9a2a2df75212dea7c7a7c81e716156880c5e5ce6bc8618aee0
7
- data.tar.gz: f5ae7746690135bf149d897fcb61fe53709a5b7bc0f8f7ed32c48116b686a2a74e4b3d79f762ce0c16425cbfb5b7cc760da4f9d23c69a848c97fa03132e03df5
6
+ metadata.gz: 58cf30a126082e5bc20893172165647a9cdbec2bea5dc2bd847293f1d8eb120d73620a8e676e5d6c38d7486511daf05652e7c46c18787b70cec4b354c54ef88a
7
+ data.tar.gz: 40fa5d278137ade4190316222108855bf7fea06fd24cc77c61a3ff063206d2246c22aacac99701a30a423a33e2e5e8a71b9b14bb53f970090b16e0ffe7295e0b
data/.rubocop.yml CHANGED
@@ -21,3 +21,9 @@ Style/HashSyntax:
21
21
 
22
22
  Metrics/BlockLength:
23
23
  Enabled: false
24
+
25
+ Metrics/CyclomaticComplexity:
26
+ Enabled: false
27
+
28
+ Metrics/PerceivedComplexity:
29
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helios-opentelemetry-sdk (0.1.14)
4
+ helios-opentelemetry-sdk (0.1.17)
5
5
  opentelemetry-exporter-otlp (~> 0.22.0)
6
6
  opentelemetry-instrumentation-all (~> 0.25.0)
7
7
  opentelemetry-instrumentation-rspec (~> 0.2.0)
@@ -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
- super(span, env)
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, collect_headers(req))
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
- res[semantic_attributes::HTTP_REQUEST_BODY] = request_body
17
- end
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 set_attributes_after_request(span, status, headers, response)
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
- span.set_attribute(semantic_attributes::HTTP_RESPONSE_BODY, response[0]) if response[0]&.length&.positive?
26
- super(span, status, headers, response)
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
@@ -1,7 +1,7 @@
1
1
  module Helios
2
2
  module OpenTelemetry
3
3
  module SDK
4
- VERSION = '0.1.14'
4
+ VERSION = '0.1.17'
5
5
  end
6
6
  end
7
7
  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.14
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-23 00:00:00.000000000 Z
11
+ date: 2022-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler