stack-service-base 0.0.74 → 0.0.75
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/lib/stack-service-base/open_telemetry.rb +12 -3
- data/lib/stack-service-base/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 42a684599ec2f5f4ce219ff383bb91f280f3551633c88e5c854971e358b4d40a
|
|
4
|
+
data.tar.gz: 900890a86bfc5070661c1dcf7b533994685cfd118197d960e16bff8fe2236722
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5d88abae4042bfbb7dff5a190c1d31c27fc8a712eda46984c47f4c5e301a56cf25484a6ae49ed573b066d9c7776d8fbc05d14c865651d70696daa8236f8dacf
|
|
7
|
+
data.tar.gz: 189b5f00ebb89a0d08e1d482c27795f95697ac8e00388940e073218790420d0fe8cd8ab329ed7a441d6450dec2e6b653899f111bc408aeddfdfb75a14ca46ddd
|
|
@@ -4,9 +4,18 @@ ENV['OTEL_LOG_LEVEL'] ||= 'debug'
|
|
|
4
4
|
ENV['OTEL_TRACES_EXPORTER'] ||= 'console,otlp'
|
|
5
5
|
ENV['OTEL_LOGS_EXPORTER'] ||= 'otlp,console'
|
|
6
6
|
|
|
7
|
+
class Otel
|
|
8
|
+
class << self
|
|
9
|
+
attr_accessor :enabled # To temporally disable Otel
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
unless defined? OTEL_ENABLED
|
|
8
14
|
OTEL_ENABLED = !ENV['OTEL_EXPORTER_OTLP_ENDPOINT'].to_s.empty?
|
|
9
15
|
end
|
|
16
|
+
|
|
17
|
+
Otel.enabled = OTEL_ENABLED
|
|
18
|
+
|
|
10
19
|
$stdout.puts "OTEL_ENABLED: #{OTEL_ENABLED}"
|
|
11
20
|
|
|
12
21
|
# require 'async'
|
|
@@ -142,7 +151,7 @@ end
|
|
|
142
151
|
|
|
143
152
|
def otl_span(name, attributes = {})
|
|
144
153
|
# span_ = OpenTelemetry::Trace.current_span
|
|
145
|
-
return yield(nil) unless OTEL_ENABLED
|
|
154
|
+
return yield(nil) unless OTEL_ENABLED && Otel.enabled
|
|
146
155
|
|
|
147
156
|
return yield(nil) unless $tracer_
|
|
148
157
|
$tracer_&.in_span(name, attributes: flatten_hash(attributes.transform_keys(&:to_s).transform_values{_1 || 'n/a'}) ) do |span|
|
|
@@ -151,7 +160,7 @@ def otl_span(name, attributes = {})
|
|
|
151
160
|
end
|
|
152
161
|
|
|
153
162
|
def otl_current_span
|
|
154
|
-
return unless OTEL_ENABLED
|
|
163
|
+
return unless OTEL_ENABLED && Otel.enabled
|
|
155
164
|
yield OpenTelemetry::Trace.current_span
|
|
156
165
|
end
|
|
157
166
|
|
|
@@ -161,7 +170,7 @@ end
|
|
|
161
170
|
# end
|
|
162
171
|
|
|
163
172
|
def otl_traceparent_id
|
|
164
|
-
return nil unless OTEL_ENABLED
|
|
173
|
+
return nil unless OTEL_ENABLED && Otel.enabled
|
|
165
174
|
|
|
166
175
|
span_context = OpenTelemetry::Trace.current_span.context
|
|
167
176
|
trace_id = span_context.trace_id.unpack1('H*')
|