helios-opentelemetry-sdk 0.1.19 → 0.1.21

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: e1333d4f45a6affbdc086bb2e8e98f8871e7a295a50e4dd87f624b60ca4be78e
4
- data.tar.gz: b50075cf28a40a5ccc36dd39c46d6c1323b8a6514e027f558f3fc1cb4439e0e6
3
+ metadata.gz: 71228262be35fda8a5c39eb237ca42493837d315d9ae146dd69c04210905a731
4
+ data.tar.gz: 19125d421f0a1f086875a97f68b637d3b57df214a542e70c9cbdc9be472dd190
5
5
  SHA512:
6
- metadata.gz: d6467ee1a6eabce6fb8a743e536c8e83ba3bbdb9705b62fd9793552ef163b9d69a43649e13d948f686d4d4a6cbb4da02ad3f90e5a65b59d66d497a7757d89a91
7
- data.tar.gz: 9b96c5e12e92befd75f0d5f650b2119e79279efe19e4b2aa4e1b69cceb7939a4f90f8eddc5ee495fa0bbfa72c435ae86ae4012634f6c514f93233aa00bf3337d
6
+ metadata.gz: 2fac93ce1793b9e423f0b7c034e14367c69a64fc2be163a57dc6feb7035310d8a4dee2ddec29a56c962e52db0379375a71f660f88e00be019ded30c1431e6574
7
+ data.tar.gz: 5840af6374120b29742da322c7a0780907f293fb884a2892cb387c916fd54b6487c8da9747f5e1b9e0cb25f720724a6c2f96438fb047c530a097f07991b8f1f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helios-opentelemetry-sdk (0.1.19)
4
+ helios-opentelemetry-sdk (0.1.20)
5
5
  opentelemetry-exporter-otlp (~> 0.22.0)
6
6
  opentelemetry-instrumentation-all (~> 0.25.0)
7
7
  opentelemetry-instrumentation-rspec (~> 0.2.0)
@@ -0,0 +1,12 @@
1
+ require 'opentelemetry/sdk'
2
+
3
+ HELIOS_TEST_TRIGGERED_TRACE = 'hs-triggered-test'.freeze
4
+
5
+ class HeliosProcessor < ::OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor
6
+ def on_start(span, parent_context)
7
+ baggage = ::OpenTelemetry::Baggage.values(context: parent_context)
8
+ return unless baggage.key?(HELIOS_TEST_TRIGGERED_TRACE)
9
+
10
+ span.set_attribute(HELIOS_TEST_TRIGGERED_TRACE, 'true')
11
+ end
12
+ end
@@ -7,18 +7,10 @@ module NetHttpPatch
7
7
  module Instrumentation
8
8
  def request(req, body = nil, &block)
9
9
  current_span = OpenTelemetry::Trace.current_span
10
- current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_HEADERS,
11
- collect_headers(req))
12
- current_span.set_attribute(OpenTelemetry::SemanticConventions::Trace::HTTP_URL, req.uri&.to_s)
13
- unless body.nil?
14
- current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
15
- body.is_a?(String) ? body : body.to_s)
16
- end
10
+ extract_request_attributes(current_span, req, body)
17
11
 
18
12
  super(req, body, &block).tap do |response|
19
- current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_HEADERS,
20
- collect_headers(response))
21
- current_span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_RESPONSE_BODY, response.body)
13
+ extract_response_attributes(current_span, response)
22
14
  end
23
15
  end
24
16
 
@@ -37,6 +29,17 @@ module NetHttpPatch
37
29
  span.set_attribute(Helios::OpenTelemetry::SemanticAttributes::HTTP_REQUEST_BODY,
38
30
  body.is_a?(String) ? body : body.to_s)
39
31
  end
32
+
33
+ url = req.uri&.to_s
34
+ sem_conv = OpenTelemetry::SemanticConventions::Trace
35
+ if url.nil?
36
+ scheme = span.attributes[sem_conv::HTTP_SCHEME]
37
+ hostname = span.attributes[sem_conv::HTTP_HOST] || span.attributes[sem_conv::NET_PEER_NAME]
38
+ target = span.attributes[sem_conv::HTTP_TARGET]
39
+ url = "#{scheme}://#{hostname}#{target}" if scheme && hostname && target
40
+ end
41
+
42
+ span.set_attribute(sem_conv::HTTP_URL, url) unless url.nil?
40
43
  rescue StandardError => e
41
44
  ::OpenTelemetry.logger.debug("Error extracting net http request attributes: #{e}")
42
45
  end
@@ -1,7 +1,7 @@
1
1
  module Helios
2
2
  module OpenTelemetry
3
3
  module SDK
4
- VERSION = '0.1.19'
4
+ VERSION = '0.1.21'
5
5
  end
6
6
  end
7
7
  end
@@ -3,6 +3,7 @@ require 'opentelemetry/exporter/otlp'
3
3
  require 'opentelemetry/instrumentation/all'
4
4
  require_relative 'sdk/version'
5
5
  require_relative 'sdk/instrumentations'
6
+ require_relative 'sdk/helios_processor'
6
7
 
7
8
  module Helios
8
9
  module OpenTelemetry
@@ -37,11 +38,11 @@ module Helios
37
38
  end
38
39
  c.resource = ::OpenTelemetry::SDK::Resources::Resource.create(resource_attrs)
39
40
  apply_instrumentations(c)
40
- c.add_span_processor(
41
- ::OpenTelemetry::SDK::Trace::Export::BatchSpanProcessor.new(
42
- get_span_exporter(helios_config)
43
- )
44
- )
41
+ c.add_span_processor(HeliosProcessor.new(get_span_exporter(helios_config)))
42
+ puts 'Helios tracing initialized (' \
43
+ "service: #{service_name}, " \
44
+ "token: #{api_token[0, 3]}*****, " \
45
+ "environment: #{environment})"
45
46
  end
46
47
 
47
48
  send_debug_span
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.19
4
+ version: 0.1.21
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-09-04 00:00:00.000000000 Z
11
+ date: 2022-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ files:
129
129
  - bin/setup
130
130
  - helios-opentelemetry-sdk.gemspec
131
131
  - lib/helios/opentelemetry/sdk.rb
132
+ - lib/helios/opentelemetry/sdk/helios_processor.rb
132
133
  - lib/helios/opentelemetry/sdk/instrumentations.rb
133
134
  - lib/helios/opentelemetry/sdk/patches/faraday_patch.rb
134
135
  - lib/helios/opentelemetry/sdk/patches/mongo_patch.rb