opentelemetry-instrumentation-base 0.18.3 → 0.21.0
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: 99e6450e5fe0a34262181644384ac289093fb11dc924dcdb44be21e46715cddb
|
4
|
+
data.tar.gz: 91dcb93efdcabe5db3619fe0fb962f0512373759aafb34bcabee9ea31f1092c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4da44cb456ec692d62577aee339c9bcf3b1cd57aa49d5e6a8e96b0a6ab2da1f8b3b367a10f8593751b1caa4c163c257d9760b8842d94bc66839816828456c2c
|
7
|
+
data.tar.gz: 54de81f111d50c53305054975bd43e6dbb8bebe3386eed876dc7a36ed4f42ef5416c5668f25962b1427a911fbdcde7ea1c87892f5fcc9fdb9407f83c4e392a65
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-base
|
2
2
|
|
3
|
+
### v0.21.0 / 2022-05-26
|
4
|
+
|
5
|
+
* BREAKING CHANGE: This requires upgrading both the SDK and Instrumentation gem in tandem
|
6
|
+
|
7
|
+
|
8
|
+
### v0.20.0 / 2022-05-02
|
9
|
+
|
10
|
+
* ADDED: Validate Using Enums
|
11
|
+
* FIXED: RubyGems Fallback
|
12
|
+
|
13
|
+
### v0.19.0 / 2021-12-01
|
14
|
+
|
15
|
+
* ADDED: Add default options config helper + env var config option support
|
16
|
+
|
3
17
|
### v0.18.3 / 2021-09-29
|
4
18
|
|
5
19
|
* (No significant changes)
|
@@ -32,7 +32,7 @@ module OpenTelemetry
|
|
32
32
|
#
|
33
33
|
# # if the target library is present, is it compatible?
|
34
34
|
# compatible do
|
35
|
-
# Gem.
|
35
|
+
# Gem::Version.new(Sinatra::VERSION)) > MIN_VERSION
|
36
36
|
# end
|
37
37
|
# end
|
38
38
|
# end
|
@@ -146,11 +146,20 @@ module OpenTelemetry
|
|
146
146
|
# a key in the VALIDATORS hash. The supported keys are, :array, :boolean,
|
147
147
|
# :callable, :integer, :string.
|
148
148
|
def option(name, default:, validate:)
|
149
|
-
|
150
|
-
raise ArgumentError, "validate must be #{VALIDATORS.keys.join(', ')}, or a callable" unless
|
149
|
+
validator = VALIDATORS[validate] || validate
|
150
|
+
raise ArgumentError, "validate must be #{VALIDATORS.keys.join(', ')}, or a callable" unless validator.respond_to?(:call) || validator.respond_to?(:include?)
|
151
151
|
|
152
152
|
@options ||= []
|
153
|
-
|
153
|
+
|
154
|
+
validation_type = if VALIDATORS[validate]
|
155
|
+
validate
|
156
|
+
elsif validate.respond_to?(:include?)
|
157
|
+
:enum
|
158
|
+
else
|
159
|
+
:callable
|
160
|
+
end
|
161
|
+
|
162
|
+
@options << { name: name, default: default, validator: validator, validation_type: validation_type }
|
154
163
|
end
|
155
164
|
|
156
165
|
def instance
|
@@ -257,16 +266,24 @@ module OpenTelemetry
|
|
257
266
|
# Invalid configuration values are logged, and replaced by the default.
|
258
267
|
#
|
259
268
|
# @param [Hash] user_config The user supplied configuration hash
|
260
|
-
def config_options(user_config) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
269
|
+
def config_options(user_config) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
261
270
|
@options ||= {}
|
262
271
|
user_config ||= {}
|
272
|
+
config_overrides = config_overrides_from_env
|
263
273
|
validated_config = @options.each_with_object({}) do |option, h|
|
264
274
|
option_name = option[:name]
|
265
275
|
config_value = user_config[option_name]
|
276
|
+
config_override = coerce_env_var(config_overrides[option_name], option[:validation_type]) if config_overrides[option_name]
|
266
277
|
|
267
|
-
value = if config_value.nil?
|
278
|
+
value = if config_value.nil? && config_override.nil?
|
268
279
|
option[:default]
|
269
|
-
elsif option[:
|
280
|
+
elsif option[:validator].respond_to?(:include?) && option[:validator].include?(config_override)
|
281
|
+
config_override
|
282
|
+
elsif option[:validator].respond_to?(:include?) && option[:validator].include?(config_value)
|
283
|
+
config_value
|
284
|
+
elsif option[:validator].respond_to?(:call) && option[:validator].call(config_override)
|
285
|
+
config_override
|
286
|
+
elsif option[:validator].respond_to?(:call) && option[:validator].call(config_value)
|
270
287
|
config_value
|
271
288
|
else
|
272
289
|
OpenTelemetry.logger.warn(
|
@@ -303,6 +320,49 @@ module OpenTelemetry
|
|
303
320
|
end
|
304
321
|
ENV[var_name] != 'false'
|
305
322
|
end
|
323
|
+
|
324
|
+
def config_overrides_from_env
|
325
|
+
var_name = name.dup.tap do |n|
|
326
|
+
n.upcase!
|
327
|
+
n.gsub!('::', '_')
|
328
|
+
n.gsub!('OPENTELEMETRY_', 'OTEL_RUBY_')
|
329
|
+
n << '_CONFIG_OPTS'
|
330
|
+
end
|
331
|
+
|
332
|
+
environment_config_overrides = {}
|
333
|
+
env_config_options = ENV[var_name]&.split(';')
|
334
|
+
|
335
|
+
return environment_config_overrides if env_config_options.nil?
|
336
|
+
|
337
|
+
env_config_options.each_with_object(environment_config_overrides) do |env_config_option, eco|
|
338
|
+
parts = env_config_option.split('=')
|
339
|
+
option_name = parts[0].to_sym
|
340
|
+
eco[option_name] = parts[1]
|
341
|
+
end
|
342
|
+
|
343
|
+
environment_config_overrides
|
344
|
+
end
|
345
|
+
|
346
|
+
def coerce_env_var(env_var, validation_type) # rubocop:disable Metrics/CyclomaticComplexity
|
347
|
+
case validation_type
|
348
|
+
when :array
|
349
|
+
env_var.split(',').map(&:strip)
|
350
|
+
when :boolean
|
351
|
+
env_var.to_s.strip.downcase == 'true'
|
352
|
+
when :integer
|
353
|
+
env_var.to_i
|
354
|
+
when :string
|
355
|
+
env_var.to_s.strip
|
356
|
+
when :enum
|
357
|
+
env_var.to_s.strip.to_sym
|
358
|
+
when :callable
|
359
|
+
OpenTelemetry.logger.warn(
|
360
|
+
"Instrumentation #{name} options that accept a callable are not " \
|
361
|
+
"configurable using environment variables. Ignoring raw value: #{env_var}"
|
362
|
+
)
|
363
|
+
nil
|
364
|
+
end
|
365
|
+
end
|
306
366
|
end
|
307
367
|
end
|
308
368
|
end
|
@@ -5,19 +5,12 @@
|
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
require 'opentelemetry'
|
8
|
-
require 'opentelemetry
|
8
|
+
require 'opentelemetry-registry'
|
9
9
|
require 'opentelemetry/instrumentation/base'
|
10
10
|
|
11
11
|
module OpenTelemetry
|
12
12
|
# The instrumentation module contains functionality to register and install
|
13
13
|
# instrumentation
|
14
14
|
module Instrumentation
|
15
|
-
extend self
|
16
|
-
|
17
|
-
# @return [Registry] registry containing all known
|
18
|
-
# instrumentation
|
19
|
-
def registry
|
20
|
-
@registry ||= Registry.new
|
21
|
-
end
|
22
15
|
end
|
23
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-registry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,20 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: opentelemetry-test-helpers
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rake
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,16 +164,15 @@ files:
|
|
136
164
|
- lib/opentelemetry-instrumentation-base.rb
|
137
165
|
- lib/opentelemetry/instrumentation.rb
|
138
166
|
- lib/opentelemetry/instrumentation/base.rb
|
139
|
-
- lib/opentelemetry/instrumentation/registry.rb
|
140
167
|
- lib/opentelemetry/instrumentation/version.rb
|
141
168
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
142
169
|
licenses:
|
143
170
|
- Apache-2.0
|
144
171
|
metadata:
|
145
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v0.
|
172
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v0.21.0/file.CHANGELOG.html
|
146
173
|
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/base
|
147
174
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
148
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v0.
|
175
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-base/v0.21.0
|
149
176
|
post_install_message:
|
150
177
|
rdoc_options: []
|
151
178
|
require_paths:
|
@@ -154,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
181
|
requirements:
|
155
182
|
- - ">="
|
156
183
|
- !ruby/object:Gem::Version
|
157
|
-
version: 2.
|
184
|
+
version: 2.6.0
|
158
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
186
|
requirements:
|
160
187
|
- - ">="
|
@@ -1,88 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright The OpenTelemetry Authors
|
4
|
-
#
|
5
|
-
# SPDX-License-Identifier: Apache-2.0
|
6
|
-
|
7
|
-
module OpenTelemetry
|
8
|
-
module Instrumentation
|
9
|
-
# The instrumentation Registry contains information about instrumentation
|
10
|
-
# available and facilitates discovery, installation and
|
11
|
-
# configuration. This functionality is primarily useful for SDK
|
12
|
-
# implementors.
|
13
|
-
class Registry
|
14
|
-
def initialize
|
15
|
-
@lock = Mutex.new
|
16
|
-
@instrumentation = []
|
17
|
-
end
|
18
|
-
|
19
|
-
# @api private
|
20
|
-
def register(instrumentation)
|
21
|
-
@lock.synchronize do
|
22
|
-
@instrumentation << instrumentation
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Lookup an instrumentation definition by name. Returns nil if +instrumentation_name+
|
27
|
-
# is not found.
|
28
|
-
#
|
29
|
-
# @param [String] instrumentation_name A stringified class name for an instrumentation
|
30
|
-
# @return [Instrumentation]
|
31
|
-
def lookup(instrumentation_name)
|
32
|
-
@lock.synchronize do
|
33
|
-
find_instrumentation(instrumentation_name)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Install the specified instrumentation with optionally specified configuration.
|
38
|
-
#
|
39
|
-
# @param [Array<String>] instrumentation_names An array of instrumentation names to
|
40
|
-
# install
|
41
|
-
# @param [optional Hash<String, Hash>] instrumentation_config_map A map of
|
42
|
-
# instrumentation_name to config. This argument is optional and config can be
|
43
|
-
# passed for as many or as few instrumentations as desired.
|
44
|
-
def install(instrumentation_names, instrumentation_config_map = {})
|
45
|
-
@lock.synchronize do
|
46
|
-
instrumentation_names.each do |instrumentation_name|
|
47
|
-
instrumentation = find_instrumentation(instrumentation_name)
|
48
|
-
if instrumentation.nil?
|
49
|
-
OpenTelemetry.logger.warn "Could not install #{instrumentation_name} because it was not found"
|
50
|
-
else
|
51
|
-
install_instrumentation(instrumentation, instrumentation_config_map[instrumentation.name])
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Install all instrumentation available and installable in this process.
|
58
|
-
#
|
59
|
-
# @param [optional Hash<String, Hash>] instrumentation_config_map A map of
|
60
|
-
# instrumentation_name to config. This argument is optional and config can be
|
61
|
-
# passed for as many or as few instrumentations as desired.
|
62
|
-
def install_all(instrumentation_config_map = {})
|
63
|
-
@lock.synchronize do
|
64
|
-
@instrumentation.map(&:instance).each do |instrumentation|
|
65
|
-
install_instrumentation(instrumentation, instrumentation_config_map[instrumentation.name])
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def find_instrumentation(instrumentation_name)
|
73
|
-
@instrumentation.detect { |a| a.instance.name == instrumentation_name }
|
74
|
-
&.instance
|
75
|
-
end
|
76
|
-
|
77
|
-
def install_instrumentation(instrumentation, config)
|
78
|
-
if instrumentation.install(config)
|
79
|
-
OpenTelemetry.logger.info "Instrumentation: #{instrumentation.name} was successfully installed"
|
80
|
-
else
|
81
|
-
OpenTelemetry.logger.warn "Instrumentation: #{instrumentation.name} failed to install"
|
82
|
-
end
|
83
|
-
rescue => e # rubocop:disable Style/RescueStandardError
|
84
|
-
OpenTelemetry.handle_error(exception: e, message: "Instrumentation: #{instrumentation.name} unhandled exception during install: #{e.backtrace}")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|