Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Minitest/AssertPredicate:
Enabled: false
Minitest/RefutePredicate:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Style/BitwisePredicate:
Enabled: false
Style/EmptyClassDefinition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def extract(carrier, context: Context.current, getter: Context::Propagation.text
# the W3C spec where it's referred to as properties. We preserve
# the properties (as-is) so that they can be propagated elsewhere.
kv, meta = entry.split(';', 2)
k, v = kv.split('=').map!(&URI.method(:decode_uri_component))
k, v = kv.split('=').map! { |part| URI.decode_uri_component(part) }
builder.set_value(k, v, metadata: meta)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get(carrier, key)
# form to the original. The resulting keys will be lowercase and
# underscores will be replaced with dashes.
def keys(carrier)
carrier.keys.map(&method(:from_rack_key))
carrier.keys.map { |k| from_rack_key(k) }
end

private
Expand Down
2 changes: 0 additions & 2 deletions common/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ Minitest/AssertPredicate:
Enabled: false
Minitest/RefutePredicate:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get(carrier, key)
# form to the original. The resulting keys will be lowercase and
# underscores will be replaced with dashes.
def keys(carrier)
carrier.keys.map(&method(:from_rack_key))
carrier.keys.map { |k| from_rack_key(k) }
end

private
Expand Down
4 changes: 0 additions & 4 deletions exporter/otlp-http/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,11 @@ def handle_redirect(location)

def log_status(body)
status = Google::Rpc::Status.decode(body)
details = status.details.map do |detail|
klass_or_nil = ::Google::Protobuf::DescriptorPool.generated_pool.lookup(detail.type_name).msgclass
detail.unpack(klass_or_nil) if klass_or_nil
end.compact
pool = ::Google::Protobuf::DescriptorPool.generated_pool
details = status.details.filter_map do |detail|
klass = pool.lookup(detail.type_name).msgclass
detail.unpack(klass) if klass
end
OpenTelemetry.handle_error(message: "OTLP exporter received rpc.Status{message=#{status.message}, details=#{details}}")
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: 'unexpected error decoding rpc.Status in OTLP::Exporter#log_status')
Expand Down Expand Up @@ -279,7 +280,7 @@ def parse_headers(raw)
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS if entries.empty?

entries.each_with_object({}) do |entry, headers|
k, v = entry.split('=', 2).map(&URI.method(:decode_uri_component))
k, v = entry.split('=', 2).map { |part| URI.decode_uri_component(part) }
begin
k = k.to_s.strip
v = v.to_s.strip
Expand Down
4 changes: 0 additions & 4 deletions exporter/otlp-logs/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,3 @@ Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,11 @@ def handle_redirect(location)

def log_status(body)
status = Google::Rpc::Status.decode(body)
details = status.details.map do |detail|
klass_or_nil = ::Google::Protobuf::DescriptorPool.generated_pool.lookup(detail.type_name).msgclass
detail.unpack(klass_or_nil) if klass_or_nil
end.compact
pool = ::Google::Protobuf::DescriptorPool.generated_pool
details = status.details.filter_map do |detail|
klass = pool.lookup(detail.type_name).msgclass
detail.unpack(klass) if klass
end
OpenTelemetry.handle_error(message: "OTLP logs exporter received rpc.Status{message=#{status.message}, details=#{details}}")
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: 'unexpected error decoding rpc.Status in OTLP::Exporter#log_status')
Expand Down Expand Up @@ -363,7 +364,7 @@ def parse_headers(raw)
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS if entries.empty?

entries.each_with_object({}) do |entry, headers|
k, v = entry.split('=', 2).map(&URI.method(:decode_uri_component))
k, v = entry.split('=', 2).map { |part| URI.decode_uri_component part }
begin
k = k.to_s.strip
v = v.to_s.strip
Expand Down
4 changes: 0 additions & 4 deletions exporter/otlp-metrics/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,3 @@ Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def parse_headers(raw)
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS if entries.empty?

entries.each_with_object({}) do |entry, headers|
k, v = entry.split('=', 2).map(&URI.method(:decode_uri_component))
k, v = entry.split('=', 2).map { |part| URI.decode_uri_component part }
begin
k = k.to_s.strip
v = v.to_s.strip
Expand Down Expand Up @@ -116,11 +116,12 @@ def backoff?(retry_count:, reason:, retry_after: nil)

def log_status(body)
status = Google::Rpc::Status.decode(body)
details = status.details.map do |detail|
pool = ::Google::Protobuf::DescriptorPool.generated_pool
details = status.details.filter_map do |detail|
type_name = detail.type_url.to_s.split('/').last.to_s
klass_or_nil = ::Google::Protobuf::DescriptorPool.generated_pool.lookup(type_name)&.msgclass
detail.unpack(klass_or_nil) if klass_or_nil
end.compact
klass = pool.lookup(type_name)&.msgclass
detail.unpack(klass) if klass
end
OpenTelemetry.handle_error(message: "OTLP metrics_exporter received rpc.Status{message=#{status.message}, details=#{details}}")
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: 'unexpected error decoding rpc.Status in OTLP::MetricsExporter#log_status')
Expand Down
4 changes: 0 additions & 4 deletions exporter/otlp/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,5 @@ Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Enabled: false
Style/ObjectThen:
Enabled: false
11 changes: 6 additions & 5 deletions exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ def handle_redirect(location)

def log_status(body)
status = Google::Rpc::Status.decode(body)
details = status.details.map do |detail|
klass_or_nil = ::Google::Protobuf::DescriptorPool.generated_pool.lookup(detail.type_name).msgclass
detail.unpack(klass_or_nil) if klass_or_nil
end.compact
pool = ::Google::Protobuf::DescriptorPool.generated_pool
details = status.details.filter_map do |detail|
klass = pool.lookup(detail.type_name).msgclass
detail.unpack(klass) if klass
end
OpenTelemetry.handle_error(message: "OTLP exporter received rpc.Status{message=#{status.message}, details=#{details}} for uri=#{@uri}")
rescue StandardError => e
OpenTelemetry.handle_error(exception: e, message: 'unexpected error decoding rpc.Status in OTLP::Exporter#log_status')
Expand Down Expand Up @@ -450,7 +451,7 @@ def parse_headers(raw)
raise ArgumentError, ERROR_MESSAGE_INVALID_HEADERS if entries.empty?

entries.each_with_object({}) do |entry, headers|
k, v = entry.split('=', 2).map(&URI.method(:decode_uri_component))
k, v = entry.split('=', 2).map { |part| URI.decode_uri_component(part) }
begin
k = k.to_s.strip
v = v.to_s.strip
Expand Down
2 changes: 0 additions & 2 deletions metrics_sdk/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Naming/BlockForwarding:
Enabled: false
Naming/PredicateMethod:
Enabled: false
Performance/CollectionLiteralInLoop:
Enabled: false
Style/ArgumentsForwarding:
Enabled: false
Style/CollectionQuerying:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ def ascending_sequence_test(max_size, offset, init_scale)
end

it 'test_ascending_sequence' do
[3, 4, 6, 9].each do |max_size|
MAX_SIZES = [3, 4, 6, 9].freeze
INIT_SCALES = [0, 4].freeze
MAX_SIZES.each do |max_size|
(-5..5).each do |offset|
[0, 4].each do |init_scale|
INIT_SCALES.each do |init_scale|
ascending_sequence_test(max_size, offset, init_scale)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@
end

it 'test_logarithm_boundary' do
[1, 2, 3, 4, 10, 15].each do |scale|
SCALES = [1, 2, 3, 4, 10, 15].freeze
INDS_VALUES = [-100, -10, -1, 0, 1, 10, 100].freeze

SCALES.each do |scale|
logarithm_mapping = OpenTelemetry::SDK::Metrics::Aggregation::ExponentialHistogram::LogarithmMapping.new(scale)

[-100, -10, -1, 0, 1, 10, 100].each do |inds|
INDS_VALUES.each do |inds|
lower_boundary = logarithm_mapping.get_lower_boundary(inds)
mapped_index = logarithm_mapping.map_to_index(lower_boundary)

Expand Down
Loading