Module: OpenTelemetry::SDK::Internal Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Internal contains helpers used by the reference implementation.
Instance Method Summary collapse
- #boolean?(value) ⇒ Boolean private
- #numeric?(value) ⇒ Boolean private
- #valid_array_value?(value) ⇒ Boolean private
- #valid_attributes?(owner, kind, attrs) ⇒ Boolean private
- #valid_key?(key) ⇒ Boolean private
- #valid_simple_value?(value) ⇒ Boolean private
- #valid_value?(value) ⇒ Boolean private
Instance Method Details
#boolean?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/opentelemetry/sdk/internal.rb', line 15 def boolean?(value) value.instance_of?(TrueClass) || value.instance_of?(FalseClass) end |
#numeric?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 |
# File 'lib/opentelemetry/sdk/internal.rb', line 23 def numeric?(value) value.instance_of?(Integer) || value.instance_of?(Float) end |
#valid_array_value?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/opentelemetry/sdk/internal.rb', line 31 def valid_array_value?(value) return false unless value.is_a?(Array) return true if value.empty? case value.first when String value.all? { |v| v.instance_of?(String) } when TrueClass, FalseClass value.all? { |v| boolean?(v) } when Numeric value.all? { |v| numeric?(v) } else false end end |
#valid_attributes?(owner, kind, attrs) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/opentelemetry/sdk/internal.rb', line 51 def valid_attributes?(owner, kind, attrs) attrs.nil? || attrs.all? do |k, v| if !valid_key?(k) OpenTelemetry.handle_error(message: "invalid #{kind} attribute key type #{k.class} on span '#{owner}'") false elsif !valid_value?(v) OpenTelemetry.handle_error(message: "invalid #{kind} attribute value type #{v.class} for key '#{k}' on span '#{owner}'") false else true end end end |
#valid_key?(key) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 |
# File 'lib/opentelemetry/sdk/internal.rb', line 19 def valid_key?(key) key.instance_of?(String) end |
#valid_simple_value?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/opentelemetry/sdk/internal.rb', line 27 def valid_simple_value?(value) value.instance_of?(String) || boolean?(value) || numeric?(value) end |
#valid_value?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
47 48 49 |
# File 'lib/opentelemetry/sdk/internal.rb', line 47 def valid_value?(value) valid_simple_value?(value) || valid_array_value?(value) end |