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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71228262be35fda8a5c39eb237ca42493837d315d9ae146dd69c04210905a731
|
4
|
+
data.tar.gz: 19125d421f0a1f086875a97f68b637d3b57df214a542e70c9cbdc9be472dd190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fac93ce1793b9e423f0b7c034e14367c69a64fc2be163a57dc6feb7035310d8a4dee2ddec29a56c962e52db0379375a71f660f88e00be019ded30c1431e6574
|
7
|
+
data.tar.gz: 5840af6374120b29742da322c7a0780907f293fb884a2892cb387c916fd54b6487c8da9747f5e1b9e0cb25f720724a6c2f96438fb047c530a097f07991b8f1f5
|
data/Gemfile.lock
CHANGED
@@ -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
|
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
|
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
|
@@ -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
|
-
|
42
|
-
|
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.
|
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-
|
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
|