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 @@ -4,8 +4,6 @@ Gemspec/DevelopmentDependencies:
Enabled: false
Style/ExplicitBlockArgument:
Enabled: false
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Minitest/AssertPredicate:
Enabled: false
Minitest/RefutePredicate:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
ctx = propagator.extract(carrier, context: context) { |c, k| c[k] }
span_context = OpenTelemetry::Trace.current_span(ctx).context
_(span_context).must_be :remote?
_(span_context.trace_id).must_equal(("\0" * 15 + "\xaa").b)
_(span_context.span_id).must_equal(("\0" * 7 + "\xea").b)
_(span_context.trace_id).must_equal((("\0" * 15) + "\xaa").b)
_(span_context.span_id).must_equal((("\0" * 7) + "\xea").b)
_(span_context.trace_flags).must_be :sampled?
_(span_context.tracestate).must_equal(tracestate)
end
Expand All @@ -57,8 +57,8 @@
ctx = propagator.extract(carrier, context: context)
span_context = OpenTelemetry::Trace.current_span(ctx).context
_(span_context).must_be :remote?
_(span_context.trace_id).must_equal(("\0" * 15 + "\xaa").b)
_(span_context.span_id).must_equal(("\0" * 7 + "\xea").b)
_(span_context.trace_id).must_equal((("\0" * 15) + "\xaa").b)
_(span_context.span_id).must_equal((("\0" * 7) + "\xea").b)
_(span_context.trace_flags).must_be :sampled?
_(span_context.tracestate).must_equal(tracestate)
end
Expand Down
2 changes: 0 additions & 2 deletions common/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ inherit_from: ../contrib/rubocop.yml

Style/ExplicitBlockArgument:
Enabled: false
Lint/AmbiguousRange:
Enabled: false
Minitest/AssertPredicate:
Enabled: false
Minitest/RefutePredicate:
Expand Down
2 changes: 1 addition & 1 deletion common/lib/opentelemetry/common/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def utf8_encode(string, binary: false, placeholder: STRING_PLACEHOLDER)
#
# @return [String]
def truncate(string, size)
string.size > size ? "#{string[0...size - 3]}..." : string
string.size > size ? "#{string[0...(size - 3)]}..." : string
end

def truncate_attribute_value(value, limit)
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 @@ -9,10 +9,6 @@ Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def shutdown(timeout: nil)

private

# rubocop:disable Lint/DuplicateBranch
def fetch_ssl_verify_mode
if ENV.key?('OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER')
OpenSSL::SSL::VERIFY_PEER
Expand All @@ -95,6 +96,7 @@ def fetch_ssl_verify_mode
OpenSSL::SSL::VERIFY_PEER
end
end
# rubocop:enable Lint/DuplicateBranch

def http_connection(uri, ssl_verify_mode, certificate_file, client_certificate_file, client_key_file)
http = Net::HTTP.new(uri.hostname, uri.port)
Expand Down Expand Up @@ -227,11 +229,7 @@ def backoff?(retry_count:, reason:, retry_after: nil)
sleep_interval = nil
unless retry_after.nil?
sleep_interval =
begin
Integer(retry_after)
rescue ArgumentError
nil
end
Integer(retry_after, exception: false)
sleep_interval ||=
begin
Time.httpdate(retry_after) - Time.now
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 @@ -6,10 +6,6 @@ AllCops:
- "lib/opentelemetry/proto/**/*"
- "vendor/**/*"

Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class LogsExporter # rubocop:disable Metrics/ClassLength

DEFAULT_USER_AGENT = "OTel-OTLP-Exporter-Ruby/#{OpenTelemetry::Exporter::OTLP::Logs::VERSION} Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}/#{RUBY_ENGINE_VERSION})".freeze

# rubocop:disable Lint/DuplicateBranch
def self.ssl_verify_mode
if ENV['OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER'] == 'true'
OpenSSL::SSL::VERIFY_PEER
Expand All @@ -47,6 +48,7 @@ def self.ssl_verify_mode
OpenSSL::SSL::VERIFY_PEER
end
end
# rubocop:enable Lint/DuplicateBranch

def initialize(endpoint: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_LOGS_ENDPOINT', 'OTEL_EXPORTER_OTLP_ENDPOINT', default: 'http://localhost:4318/v1/logs'),
certificate_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_LOGS_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
Expand Down Expand Up @@ -156,6 +158,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/CyclomaticComplexity,
timeout ||= @timeout
start_time = OpenTelemetry::Common::Utilities.timeout_timestamp

# rubocop:disable Lint/DuplicateBranch
around_request do
remaining_timeout = OpenTelemetry::Common::Utilities.maybe_timeout(timeout, start_time)
return FAILURE if remaining_timeout.zero?
Expand Down Expand Up @@ -223,6 +226,7 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/CyclomaticComplexity,
OpenTelemetry.handle_error(exception: e, message: 'unexpected error in OTLP::Exporter#send_bytes')
return FAILURE
end
# rubocop:enable Lint/DuplicateBranch
ensure
# Reset timeouts to defaults for the next call.
@http.open_timeout = @timeout
Expand All @@ -245,17 +249,13 @@ def log_status(body)
OpenTelemetry.handle_error(exception: e, message: 'unexpected error decoding rpc.Status in OTLP::Exporter#log_status')
end

def backoff?(retry_count:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def backoff?(retry_count:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity
return false if retry_count > RETRY_COUNT

sleep_interval = nil
unless retry_after.nil?
sleep_interval =
begin
Integer(retry_after)
rescue ArgumentError
nil
end
Integer(retry_after, exception: false)
sleep_interval ||=
begin
Time.httpdate(retry_after) - Time.now
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 @@ -13,10 +13,6 @@ Metrics/MethodLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class MetricsExporter < ::OpenTelemetry::SDK::Metrics::Export::MetricReader
FAILURE = OpenTelemetry::SDK::Metrics::Export::FAILURE
private_constant(:SUCCESS, :FAILURE)

# rubocop:disable Lint/DuplicateBranch
def self.ssl_verify_mode
if ENV.key?('OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER')
OpenSSL::SSL::VERIFY_PEER
Expand All @@ -44,6 +45,7 @@ def self.ssl_verify_mode
OpenSSL::SSL::VERIFY_PEER
end
end
# rubocop:enable Lint/DuplicateBranch

def initialize(endpoint: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_ENDPOINT', 'OTEL_EXPORTER_OTLP_ENDPOINT', default: 'http://localhost:4318/v1/metrics'),
certificate_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_METRICS_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Exporter
module OTLP
module Metrics
# Util module provide essential functionality for exporter
module Util # rubocop:disable Metrics/ModuleLength
module Util
KEEP_ALIVE_TIMEOUT = 30
RETRY_COUNT = 5
ERROR_MESSAGE_INVALID_HEADERS = 'headers must be a String with comma-separated URL Encoded UTF-8 k=v pairs or a Hash'
Expand Down Expand Up @@ -95,11 +95,7 @@ def backoff?(retry_count:, reason:, retry_after: nil)
sleep_interval = nil
unless retry_after.nil?
sleep_interval =
begin
Integer(retry_after)
rescue ArgumentError
nil
end
Integer(retry_after, exception: false)
sleep_interval ||=
begin
Time.httpdate(retry_after) - Time.now
Expand Down
4 changes: 0 additions & 4 deletions exporter/otlp/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ AllCops:
- "lib/opentelemetry/proto/**/*"
- "vendor/**/*"

Lint/DuplicateBranch:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Performance/MapCompact:
Enabled: false
Performance/MethodObjectAsBlock:
Expand Down
10 changes: 4 additions & 6 deletions exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Exporter # rubocop:disable Metrics/ClassLength

DEFAULT_USER_AGENT = "OTel-OTLP-Exporter-Ruby/#{OpenTelemetry::Exporter::OTLP::VERSION} Ruby/#{RUBY_VERSION} (#{RUBY_PLATFORM}; #{RUBY_ENGINE}/#{RUBY_ENGINE_VERSION})".freeze

# rubocop:disable Lint/DuplicateBranch
def self.ssl_verify_mode
if ENV.key?('OTEL_RUBY_EXPORTER_OTLP_SSL_VERIFY_PEER')
OpenSSL::SSL::VERIFY_PEER
Expand All @@ -44,6 +45,7 @@ def self.ssl_verify_mode
OpenSSL::SSL::VERIFY_PEER
end
end
# rubocop:enable Lint/DuplicateBranch

def initialize(endpoint: nil,
certificate_file: OpenTelemetry::Common::Utilities.config_opt('OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE', 'OTEL_EXPORTER_OTLP_CERTIFICATE'),
Expand Down Expand Up @@ -268,18 +270,14 @@ def measure_request_duration
end
end

def backoff?(retry_count:, reason:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def backoff?(retry_count:, reason:, retry_after: nil) # rubocop:disable Metrics/CyclomaticComplexity
@metrics_reporter.add_to_counter('otel.otlp_exporter.failure', labels: { 'reason' => reason })
return false if retry_count > RETRY_COUNT

sleep_interval = nil
unless retry_after.nil?
sleep_interval =
begin
Integer(retry_after)
rescue ArgumentError
nil
end
Integer(retry_after, exception: false)
sleep_interval ||=
begin
Time.httpdate(retry_after) - Time.now
Expand Down
4 changes: 0 additions & 4 deletions exporter/zipkin/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ Metrics/CyclomaticComplexity:
Enabled: false
Style/ExplicitBlockArgument:
Enabled: false
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Lint/SuppressedExceptionInNumberConversion:
Enabled: false
Minitest/SkipEnsure:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ def backoff?(retry_count:, reason:, retry_after: nil)
sleep_interval = nil
unless retry_after.nil?
sleep_interval =
begin
Integer(retry_after)
rescue ArgumentError
nil
end
Integer(retry_after, exception: false)
sleep_interval ||=
begin
Time.httpdate(retry_after) - Time.now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module Transformer

def to_zipkin_span(span_d, resource)
start_time = span_d.start_timestamp / 1_000
duration = span_d.end_timestamp / 1_000 - start_time
duration = (span_d.end_timestamp / 1_000) - start_time
tags = {}
service_name = DEFAULT_SERVICE_NAME
resource.attribute_enumerator.select do |key, value|
Expand Down
3 changes: 2 additions & 1 deletion logs_api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Metrics/CyclomaticComplexity:
Max: 20

Lint/EmptyClass:
Enabled: false
Exclude:
- 'lib/opentelemetry/logs/log_record.rb'
Style/ReduceToHash:
Enabled: false
6 changes: 0 additions & 6 deletions metrics_sdk/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ Metrics/PerceivedComplexity:
Max: 30
Metrics/CyclomaticComplexity:
Max: 20
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Lint/AmbiguousRange:
Enabled: false
Naming/BlockForwarding:
Enabled: false
Naming/PredicateMethod:
Expand All @@ -32,5 +28,3 @@ Style/NilLambda:
Enabled: false
Style/SuperArguments:
Enabled: false
Lint/SymbolConversion:
Enabled: false
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def reset
end

def find_histogram_bucket
@num_measurements_seen < @max_size ? @num_measurements_seen : rand(0..@num_measurements_seen - 1)
@num_measurements_seen < @max_size ? @num_measurements_seen : rand(0..(@num_measurements_seen - 1))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def expect_balanced(hdp, count)
expbh.update(2**100, {}, data_points, cardinality_limit)

hdp = data_points[{}]
expected_sum = 2**100 + 2**-100
expected_sum = (2**100) + (2**-100)
_(hdp.sum).must_be_within_epsilon(expected_sum, 1e-5)
_(hdp.count).must_equal(2)
_(hdp.scale).must_equal(-7)
Expand Down Expand Up @@ -995,9 +995,9 @@ def skip_on_windows
metric_data = metrics_data[0]

_(metric_data.start_time_unix_nano).must_equal(start_time_unix_nano)
_(metric_data.min).must_equal(TEST_VALUES[0..index + 1].min)
_(metric_data.max).must_equal(TEST_VALUES[0..index + 1].max)
_(metric_data.sum).must_be_within_epsilon(TEST_VALUES[0..index + 1].sum, 1e-10)
_(metric_data.min).must_equal(TEST_VALUES[0..(index + 1)].min)
_(metric_data.max).must_equal(TEST_VALUES[0..(index + 1)].max)
_(metric_data.sum).must_be_within_epsilon(TEST_VALUES[0..(index + 1)].sum, 1e-10)
end

expected_bucket_counts = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
_(logarithm_mapping.map_to_index(MIN_NORMAL_VALUE / 100)).must_equal(correct_min_index)
_(logarithm_mapping.map_to_index(2**-1050)).must_equal(correct_min_index)
_(logarithm_mapping.map_to_index(2**-1073)).must_equal(correct_min_index)
_(logarithm_mapping.map_to_index(1.1 * 2**-1073)).must_equal(correct_min_index)
_(logarithm_mapping.map_to_index(1.1 * (2**-1073))).must_equal(correct_min_index)
_(logarithm_mapping.map_to_index(2**-1074)).must_equal(correct_min_index)

mapped_lower = logarithm_mapping.get_lower_boundary(min_index)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
)
end
let(:timestamp) { 123_456_789 }
let(:attributes) { { 'test': 'test' } }
let(:attributes) { { test: 'test' } }

it 'always true for always on exemplar filter' do
result = OpenTelemetry::SDK::Metrics::Exemplar::AlwaysOnExemplarFilter.should_sample?(1, timestamp, attributes, context)
Expand Down
5 changes: 0 additions & 5 deletions propagator/jaeger/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/MixedRegexpCaptureTypes:
Exclude:
- 'lib/opentelemetry/propagator/jaeger/text_map_propagator.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/SlicingWithRange:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class TextMapPropagator
SAMPLED_FLAG_BIT = 0x01
DEBUG_FLAG_BIT = 0x02
FIELDS = [IDENTITY_KEY].freeze
TRACE_SPAN_IDENTITY_REGEX = /\A(?<trace_id>(?:[0-9a-f]){1,32}):(?<span_id>([0-9a-f]){1,16}):[0-9a-f]{1,16}:(?<sampling_flags>[0-9a-f]{1,2})\z/
TRACE_SPAN_IDENTITY_REGEX = /\A(?<trace_id>(?:[0-9a-f]){1,32}):(?<span_id>(?:[0-9a-f]){1,16}):(?:[0-9a-f]){1,16}:(?<sampling_flags>[0-9a-f]{1,2})\z/
ZERO_ID_REGEX = /^0+$/

private_constant \
Expand Down
5 changes: 2 additions & 3 deletions sdk/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ inherit_from:

Style/ExplicitBlockArgument:
Enabled: false
Lint/AmbiguousOperatorPrecedence:
Enabled: false
Lint/EmptyClass:
Enabled: false
Exclude:
- 'test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb'
Minitest/UselessAssertion:
Enabled: false
Naming/BlockForwarding:
Expand Down
Loading
Loading