From 505d0ddf1070a353ae581954f7c5982ba3454e6e Mon Sep 17 00:00:00 2001 From: Michael Nikitochkin Date: Tue, 26 Oct 2021 15:06:52 +0200 Subject: [PATCH 1/7] fix: [Instruentation Rack] Log content type http header (#992) Rack env uses `CONTENT_TYPE` key for HTTP Header `Content-Type`. There is not common as for other headers. https://github.com/rack/rack/blob/e0993d47096d36535dbe725091963a7e0f5aab52/lib/rack/content_type.rb#L24 Update allowed_request_headers to support `CONTENT_TYPE` and `CONTENT_LENGTH`. Related to https://github.com/rack/rack/issues/1311 and https://github.com/DataDog/dd-trace-rb/issues/1659. --- .../rack/middlewares/tracer_middleware.rb | 8 ++++++- .../middlewares/tracer_middleware_test.rb | 24 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb index bcf3f0734..dbfbebe6d 100644 --- a/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb +++ b/instrumentation/rack/lib/opentelemetry/instrumentation/rack/middlewares/tracer_middleware.rb @@ -18,7 +18,13 @@ class TracerMiddleware # rubocop:disable Metrics/ClassLength class << self def allowed_rack_request_headers @allowed_rack_request_headers ||= Array(config[:allowed_request_headers]).each_with_object({}) do |header, memo| - memo["HTTP_#{header.to_s.upcase.gsub(/[-\s]/, '_')}"] = build_attribute_name('http.request.headers.', header) + key = header.to_s.upcase.gsub(/[-\s]/, '_') + case key + when 'CONTENT_TYPE', 'CONTENT_LENGTH' + memo[key] = build_attribute_name('http.request.headers.', header) + else + memo["HTTP_#{key}"] = build_attribute_name('http.request.headers.', header) + end end end diff --git a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb index 00b62f00a..d5d9d6b6f 100644 --- a/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb +++ b/instrumentation/rack/test/opentelemetry/instrumentation/rack/middlewares/tracer_middleware_test.rb @@ -162,7 +162,13 @@ end describe 'config[:allowed_request_headers]' do - let(:env) { Hash('HTTP_FOO_BAR' => 'http foo bar value') } + let(:env) do + Hash( + 'CONTENT_LENGTH' => '123', + 'CONTENT_TYPE' => 'application/json', + 'HTTP_FOO_BAR' => 'http foo bar value' + ) + end it 'defaults to nil' do _(first_span.attributes['http.request.headers.foo_bar']).must_be_nil @@ -175,6 +181,22 @@ _(first_span.attributes['http.request.headers.foo_bar']).must_equal 'http foo bar value' end end + + describe 'when content-type' do + let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_TYPE']) } + + it 'returns attribute' do + _(first_span.attributes['http.request.headers.content_type']).must_equal 'application/json' + end + end + + describe 'when content-length' do + let(:config) { default_config.merge(allowed_request_headers: ['CONTENT_LENGTH']) } + + it 'returns attribute' do + _(first_span.attributes['http.request.headers.content_length']).must_equal '123' + end + end end describe 'config[:allowed_response_headers]' do From 0a36c5300f3d000873f41350a42df173cc459448 Mon Sep 17 00:00:00 2001 From: Ariel Valentin Date: Fri, 29 Oct 2021 11:36:17 -0500 Subject: [PATCH 2/7] fix: Add Support fo OTTrace Bit Encoded Sampled Flags (#990) The `ot-tracer-sampled` header is a `boolean` encoded string however the Golang SDK incorrectly sets the `ot-tracer-sampled` header to a `bit` flag. This and other language SDKs compensate for this by supporting both a `bit` and `boolean` encoded strings upon extraction: - [Java](https://github.com/open-telemetry/opentelemetry-java/blob/9cea4ef1f92d3186b1bd8296e9daac4281c0f759/extensions/trace-propagators/src/main/java/io/opentelemetry/extension/trace/propagation/Common.java#L41) - [Golang](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/b72c2cd63b9a9917554cbcd709e61f5d8541eea5/propagators/ot/ot_propagator.go#L118) This issue was [fixed](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/1358) however this SDK supports both for backward compatibility with older versions of the Golang propagator. Co-authored-by: Francis Bogsanyi --- propagator/ottrace/README.md | 12 ++++++- .../propagator/ottrace/text_map_propagator.rb | 11 ++++++- .../ottrace/text_map_propagator_test.rb | 32 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/propagator/ottrace/README.md b/propagator/ottrace/README.md index 040a2abfb..03959aebe 100644 --- a/propagator/ottrace/README.md +++ b/propagator/ottrace/README.md @@ -9,9 +9,19 @@ The `opentelemetry-propagator-ottrace` gem contains injectors and extractors for | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | | `ot-tracer-traceid` | uint64 encoded as a string of 16 hex characters | yes | | `ot-tracer-spanid` | uint64 encoded as a string of 16 hex characters | yes | -| `ot-tracer-sampled` | boolean encoded as a string with the values `'true'` or `'false'` | no | +| `ot-tracer-sampled` | boolean or bit encoded as a string with the values `'true'`,`'false'`, `'1'`, or `'0'` | no | | `ot-baggage-*` | repeated string to string key-value baggage items; keys are prefixed with `ot-baggage-` and the corresponding value is the raw string. | if baggage is present | +### Sampled Flag vs Bit + +The `ot-tracer-sampled` header is a `boolean` encoded string however the Golang SDK incorrectly sets the `ot-tracer-sampled` header to a `bit` flag. +This and other language SDKs compensate for this by supporting both a `bit` and `boolean` encoded strings upon extraction: + +- [Java](https://github.com/open-telemetry/opentelemetry-java/blob/9cea4ef1f92d3186b1bd8296e9daac4281c0f759/extensions/trace-propagators/src/main/java/io/opentelemetry/extension/trace/propagation/Common.java#L41) +- [Golang](https://github.com/open-telemetry/opentelemetry-go-contrib/blob/b72c2cd63b9a9917554cbcd709e61f5d8541eea5/propagators/ot/ot_propagator.go#L118) + +This issue was [fixed](https://github.com/open-telemetry/opentelemetry-go-contrib/pull/1358) however this SDK supports both for backward compatibility with older versions of the Golang propagator. + ### Interop and trace ids The OT trace propagation format expects trace ids to be 64-bits. In order to diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb index 0cef24e1e..5d23ea5b6 100644 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb +++ b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/text_map_propagator.rb @@ -56,7 +56,7 @@ def extract(carrier, context: Context.current, getter: Context::Propagation.text span_context = Trace::SpanContext.new( trace_id: Array(trace_id).pack('H*'), span_id: Array(span_id).pack('H*'), - trace_flags: sampled == 'true' ? Trace::TraceFlags::SAMPLED : Trace::TraceFlags::DEFAULT, + trace_flags: as_trace_flags(sampled), remote: true ) @@ -89,6 +89,15 @@ def fields private + def as_trace_flags(sampled) + case sampled + when 'true', '1' + Trace::TraceFlags::SAMPLED + else + Trace::TraceFlags::DEFAULT + end + end + def valid?(trace_id:, span_id:) !(VALID_TRACE_ID_REGEX !~ trace_id || VALID_SPAN_ID_REGEX !~ span_id) end diff --git a/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb b/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb index 9031b2c64..fa7775464 100644 --- a/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb +++ b/propagator/ottrace/test/opentelemetry/propagator/ottrace/text_map_propagator_test.rb @@ -153,6 +153,38 @@ def set(carrier, key, value) end end + describe 'given a context with sampling bit set to enabled' do + let(:sampled_header) do + '1' + end + + it 'extracts sampled trace flag' do + context = propagator.extract(carrier, context: parent_context) + extracted_context = OpenTelemetry::Trace.current_span(context).context + + _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') + _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') + _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::SAMPLED) + _(extracted_context).must_be(:remote?) + end + end + + describe 'given a context with a sampling bit set to disabled' do + let(:sampled_header) do + '0' + end + + it 'extracts a default trace flag' do + context = propagator.extract(carrier, context: parent_context) + extracted_context = OpenTelemetry::Trace.current_span(context).context + + _(extracted_context.hex_trace_id).must_equal('80f198ee56343ba864fe8b2a57d3eff7') + _(extracted_context.hex_span_id).must_equal('e457b5a2e4d86bd1') + _(extracted_context.trace_flags).must_equal(OpenTelemetry::Trace::TraceFlags::DEFAULT) + _(extracted_context).must_be(:remote?) + end + end + describe 'given context with a 64 bit/16 HEXDIGIT trace id' do let(:trace_id_header) do '64fe8b2a57d3eff7' From d11cbd1ed101280d0c64d38709c16eab0e92fc9d Mon Sep 17 00:00:00 2001 From: Robert Date: Fri, 29 Oct 2021 14:09:03 -0500 Subject: [PATCH 3/7] Fix: Add unexpected error handlign in BSP and OTLP exporter (#995) * Fix: Add unexpected error handling in BSP and OTLP exporter Co-authored-by: Francis Bogsanyi --- .../opentelemetry/exporter/otlp/exporter.rb | 11 ++++- .../exporter/otlp/exporter_test.rb | 37 ++++++++++++++ .../sdk/trace/export/batch_span_processor.rb | 4 ++ .../trace/export/batch_span_processor_test.rb | 48 ++++++++++++++++++- 4 files changed, 98 insertions(+), 2 deletions(-) diff --git a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb index c5c5a9d2e..e17d8731e 100644 --- a/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb +++ b/exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb @@ -143,6 +143,8 @@ def around_request end def send_bytes(bytes, timeout:) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity + return FAILURE if bytes.nil? + retry_count = 0 timeout ||= @timeout start_time = OpenTelemetry::Common::Utilities.timeout_timestamp @@ -209,6 +211,10 @@ def send_bytes(bytes, timeout:) # rubocop:disable Metrics/AbcSize, Metrics/Cyclo rescue Zlib::DataError retry if backoff?(retry_count: retry_count += 1, reason: 'zlib_error') return FAILURE + rescue StandardError => e + OpenTelemetry.handle_error(exception: e, message: 'unexpected error in OTLP::Exporter#send_bytes') + @metrics_reporter.add_to_counter('otel.otlp_exporter.failure', labels: { 'reason' => e.class.to_s }) + return FAILURE end ensure # Reset timeouts to defaults for the next call. @@ -260,7 +266,7 @@ def backoff?(retry_after: nil, retry_count:, reason:) true end - def encode(span_data) # rubocop:disable Metrics/MethodLength + def encode(span_data) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.encode( Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.new( resource_spans: span_data @@ -285,6 +291,9 @@ def encode(span_data) # rubocop:disable Metrics/MethodLength end ) ) + rescue StandardError => e + OpenTelemetry.handle_error(exception: e, message: 'unexpected error in OTLP::Exporter#encode') + nil end def as_otlp_span(span_data) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength diff --git a/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb b/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb index 6948b07cb..ac262aec0 100644 --- a/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb +++ b/exporter/otlp/test/opentelemetry/exporter/otlp/exporter_test.rb @@ -285,6 +285,43 @@ _(result).must_equal(TIMEOUT) end + it 'returns FAILURE on unexpected exceptions' do + log_stream = StringIO.new + logger = OpenTelemetry.logger + OpenTelemetry.logger = ::Logger.new(log_stream) + + stub_request(:post, 'https://localhost:4318/v1/traces').to_raise('something unexpected') + span_data = create_span_data + result = exporter.export([span_data], timeout: 1) + + _(log_stream.string).must_match( + /ERROR -- : OpenTelemetry error: unexpected error in OTLP::Exporter#send_bytes - something unexpected/ + ) + + _(result).must_equal(FAILURE) + ensure + OpenTelemetry.logger = logger + end + + it 'handles encoding failures' do + log_stream = StringIO.new + logger = OpenTelemetry.logger + OpenTelemetry.logger = ::Logger.new(log_stream) + + stub_request(:post, 'https://localhost:4318/v1/traces').to_return(status: 200) + span_data = create_span_data + + Opentelemetry::Proto::Collector::Trace::V1::ExportTraceServiceRequest.stub(:encode, ->(_) { raise 'a little hell' }) do + _(exporter.export([span_data], timeout: 1)).must_equal(FAILURE) + end + + _(log_stream.string).must_match( + /ERROR -- : OpenTelemetry error: unexpected error in OTLP::Exporter#encode - a little hell/ + ) + ensure + OpenTelemetry.logger = logger + end + it 'returns TIMEOUT on timeout after retrying' do stub_request(:post, 'https://localhost:4318/v1/traces').to_timeout.then.to_raise('this should not be reached') span_data = create_span_data diff --git a/sdk/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb b/sdk/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb index 0518ad29b..038e121f4 100644 --- a/sdk/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb +++ b/sdk/lib/opentelemetry/sdk/trace/export/batch_span_processor.rb @@ -187,6 +187,10 @@ def export_batch(batch, timeout: @exporter_timeout_seconds) result_code = @export_mutex.synchronize { @exporter.export(batch, timeout: timeout) } report_result(result_code, batch) result_code + rescue StandardError => e + report_result(FAILURE, batch) + @metrics_reporter.add_to_counter('otel.bsp.error', labels: { 'reason' => e.class.to_s }) + FAILURE end def report_result(result_code, batch) diff --git a/sdk/test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb b/sdk/test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb index db44a89a5..779362ed8 100644 --- a/sdk/test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb +++ b/sdk/test/opentelemetry/sdk/trace/export/batch_span_processor_test.rb @@ -39,6 +39,36 @@ def shutdown(timeout: nil); end def force_flush(timeout: nil); end end + class NotAnExporter + end + + class RaisingExporter + def export(batch, timeout: nil) + raise 'boom!' + end + + def shutdown(timeout: nil); end + + def force_flush(timeout: nil); end + end + + class TestMetricsReporter + attr_reader :reported_metrics + + def initialize + @reported_metrics = {} + end + + def add_to_counter(metric, increment: 1, labels: {}) + @reported_metrics[metric] ||= [] + @reported_metrics[metric] << [increment, labels] + end + + def record_value(metric, value:, labels: {}); end + + def observe_value(metric, value:, labels: {}); end + end + class TestSpan def initialize(id = nil, recording = true) trace_flags = recording ? OpenTelemetry::Trace::TraceFlags::SAMPLED : OpenTelemetry::Trace::TraceFlags::DEFAULT @@ -78,7 +108,7 @@ def to_span_data end it 'raises if exporter is not an exporter' do - _(-> { BatchSpanProcessor.new(exporter: TestExporter.new) }).must_raise(ArgumentError) + _(-> { BatchSpanProcessor.new(NotAnExporter.new) }).must_raise(ArgumentError) end it 'sets parameters from the environment' do @@ -341,6 +371,22 @@ def shutdown(timeout: nil) end end + describe 'faulty exporter' do + let(:exporter) { RaisingExporter.new } + let(:bsp) { BatchSpanProcessor.new(exporter, metrics_reporter: metrics_reporter) } + let(:metrics_reporter) { TestMetricsReporter.new } + + it 'reports export failures' do + tss = [TestSpan.new, TestSpan.new, TestSpan.new, TestSpan.new] + tss.each { |ts| bsp.on_finish(ts) } + bsp.shutdown + + _(metrics_reporter.reported_metrics['otel.bsp.error']).wont_be_nil + _(metrics_reporter.reported_metrics['otel.bsp.error'][0][0]).must_equal(1) + _(metrics_reporter.reported_metrics['otel.bsp.error'][0][1]).must_equal('reason' => 'RuntimeError') + end + end + describe 'fork safety test' do let(:exporter) { TestExporter.new } let(:bsp) do From 651d9d84b43309d6dca9b39c2b17d721929eee06 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 10:33:41 -0400 Subject: [PATCH 4/7] release: Release opentelemetry-propagator-ottrace 0.19.3 (#997) Co-authored-by: Daniel Azuma --- propagator/ottrace/CHANGELOG.md | 4 ++++ .../ottrace/lib/opentelemetry/propagator/ottrace/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/propagator/ottrace/CHANGELOG.md b/propagator/ottrace/CHANGELOG.md index 3f9fad2a6..1390aa2ac 100644 --- a/propagator/ottrace/CHANGELOG.md +++ b/propagator/ottrace/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-propagator-ottrace +### v0.19.3 / 2021-10-29 + +* FIXED: Add Support fo OTTrace Bit Encoded Sampled Flags + ### v0.19.2 / 2021-09-29 * (No significant changes) diff --git a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb index 203c29b4f..348c2b3c2 100644 --- a/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb +++ b/propagator/ottrace/lib/opentelemetry/propagator/ottrace/version.rb @@ -15,7 +15,7 @@ module OpenTelemetry module Propagator # Namespace for OpenTelemetry OTTrace propagation module OTTrace - VERSION = '0.19.2' + VERSION = '0.19.3' end end end From 0b1d16efa565f50d465dda957f78e327d6c97d91 Mon Sep 17 00:00:00 2001 From: Amir Blum Date: Mon, 1 Nov 2021 16:39:56 +0200 Subject: [PATCH 5/7] fix: change net attribute names to match the semantic conventions spec for http (#999) * fix: change net attribute names in net_http instrumentation to match spec * fix: change net attribute names to match specification * fix: add files not staged in previous commit * fix: change net attribute names to match spec in zipkin exporter Co-authored-by: Francis Bogsanyi --- common/README.md | 4 ++-- .../exporter/zipkin/transformer.rb | 8 +++---- .../instrumentation/http/patches/client.rb | 4 ++-- .../http/patches/connection.rb | 4 ++-- .../http/patches/client_test.rb | 16 ++++++------- .../http/patches/connection_test.rb | 4 ++-- .../http_client/patches/client.rb | 4 ++-- .../http_client/patches/client_test.rb | 16 ++++++------- .../net/http/patches/instrumentation.rb | 8 +++---- .../net/http/instrumentation_test.rb | 24 +++++++++---------- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/common/README.md b/common/README.md index 59198a16b..8e1535ea3 100644 --- a/common/README.md +++ b/common/README.md @@ -40,8 +40,8 @@ tracer.in_span( 'http.method' => req.method, 'http.scheme' => USE_SSL_TO_SCHEME[use_ssl?], 'http.target' => req.path, - 'peer.hostname' => @address, - 'peer.port' => @port + 'net.peer.name' => @address, + 'net.peer.port' => @port ), kind: :client ) do |span| diff --git a/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb b/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb index e4b397ca3..526e0fb11 100644 --- a/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb +++ b/exporter/zipkin/lib/opentelemetry/exporter/zipkin/transformer.rb @@ -29,10 +29,10 @@ module Transformer STATUS_ERROR = 'ERROR' STATUS_OK = 'OK' ATTRIBUTE_PEER_SERVICE = 'peer.service' - ATTRIBUTE_NET_PEER_IP = 'peer.ip' - ATTRIBUTE_NET_PEER_PORT = 'peer.port' - ATTRIBUTE_NET_HOST_IP = 'host.ip' - ATTRIBUTE_NET_HOST_PORT = 'host.port' + ATTRIBUTE_NET_PEER_IP = 'net.peer.ip' + ATTRIBUTE_NET_PEER_PORT = 'net.peer.port' + ATTRIBUTE_NET_HOST_IP = 'net.host.ip' + ATTRIBUTE_NET_HOST_PORT = 'net.host.port' DEFAULT_SERVICE_NAME = OpenTelemetry::SDK::Resources::Resource.default.attribute_enumerator.find { |k, _| k == SERVICE_NAME_ATTRIBUTE_KEY }&.last || 'unknown_service' private_constant(:KIND_MAP, :DEFAULT_SERVICE_NAME, :SERVICE_NAME_ATTRIBUTE_KEY, :ERROR_TAG_KEY, :STATUS_CODE_NAME, :STATUS_ERROR, :STATUS_OK, :ATTRIBUTE_PEER_SERVICE, :ATTRIBUTE_NET_PEER_IP, :ATTRIBUTE_NET_PEER_PORT, :ATTRIBUTE_NET_HOST_IP, :ATTRIBUTE_NET_HOST_PORT) diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb index b23869d04..11f203195 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/client.rb @@ -19,8 +19,8 @@ def perform(req, options) # rubocop:disable Metrics/AbcSize 'http.scheme' => uri.scheme, 'http.target' => uri.path, 'http.url' => "#{uri.scheme}://#{uri.host}", - 'peer.hostname' => uri.host, - 'peer.port' => uri.port + 'net.peer.name' => uri.host, + 'net.peer.port' => uri.port }.merge(OpenTelemetry::Common::HTTP::ClientContext.attributes) tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span| diff --git a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb index f1dce5527..885c0f213 100644 --- a/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb +++ b/instrumentation/http/lib/opentelemetry/instrumentation/http/patches/connection.rb @@ -12,8 +12,8 @@ module Patches module Connection def initialize(req, options) attributes = OpenTelemetry::Common::HTTP::ClientContext.attributes.merge( - 'peer.hostname' => req.uri.host, - 'peer.port' => req.uri.port + 'net.peer.name' => req.uri.host, + 'net.peer.port' => req.uri.port ) tracer.in_span('HTTP CONNECT', attributes: attributes) do diff --git a/instrumentation/http/test/instrumentation/http/patches/client_test.rb b/instrumentation/http/test/instrumentation/http/patches/client_test.rb index ce75c0b13..665c47e2b 100644 --- a/instrumentation/http/test/instrumentation/http/patches/client_test.rb +++ b/instrumentation/http/test/instrumentation/http/patches/client_test.rb @@ -42,8 +42,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :get, 'http://example.com/success', @@ -60,8 +60,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 500 _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :post, 'http://example.com/failure', @@ -80,8 +80,8 @@ _(span.attributes['http.scheme']).must_equal 'https' _(span.attributes['http.status_code']).must_be_nil _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 443 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 443 _(span.status.code).must_equal( OpenTelemetry::Trace::Status::ERROR ) @@ -106,8 +106,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 _(span.attributes['peer.service']).must_equal 'foo' assert_requested( :get, diff --git a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb b/instrumentation/http/test/instrumentation/http/patches/connection_test.rb index c8c1ed52a..1e3ca2a65 100644 --- a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb +++ b/instrumentation/http/test/instrumentation/http/patches/connection_test.rb @@ -36,8 +36,8 @@ _(exporter.finished_spans.size).must_equal(2) _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['peer.hostname']).must_equal('localhost') - _(span.attributes['peer.port']).wont_be_nil + _(span.attributes['net.peer.name']).must_equal('localhost') + _(span.attributes['net.peer.port']).wont_be_nil ensure WebMock.disable_net_connect! end diff --git a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb index 1684101f4..99b1a51d9 100644 --- a/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb +++ b/instrumentation/http_client/lib/opentelemetry/instrumentation/http_client/patches/client.rb @@ -21,8 +21,8 @@ def do_get_block(req, proxy, conn, &block) # rubocop:disable Metrics/AbcSize 'http.scheme' => uri.scheme, 'http.target' => uri.path, 'http.url' => url, - 'peer.hostname' => uri.host, - 'peer.port' => uri.port + 'net.peer.name' => uri.host, + 'net.peer.port' => uri.port }.merge(OpenTelemetry::Common::HTTP::ClientContext.attributes) tracer.in_span("HTTP #{request_method}", attributes: attributes, kind: :client) do |span| diff --git a/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb b/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb index 67af8d262..d71d2555c 100644 --- a/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb +++ b/instrumentation/http_client/test/instrumentation/http_client/patches/client_test.rb @@ -44,8 +44,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :get, 'http://example.com/success', @@ -64,8 +64,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 500 _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :post, 'http://example.com/failure', @@ -86,8 +86,8 @@ _(span.attributes['http.scheme']).must_equal 'https' _(span.attributes['http.status_code']).must_be_nil _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 443 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 443 _(span.status.code).must_equal( OpenTelemetry::Trace::Status::ERROR ) @@ -114,8 +114,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 _(span.attributes['peer.service']).must_equal 'foo' assert_requested( :get, diff --git a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb index 7f8de900d..f24d64543 100644 --- a/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb +++ b/instrumentation/net_http/lib/opentelemetry/instrumentation/net/http/patches/instrumentation.rb @@ -25,8 +25,8 @@ def request(req, body = nil, &block) 'http.method' => req.method, 'http.scheme' => USE_SSL_TO_SCHEME[use_ssl?], 'http.target' => req.path, - 'peer.hostname' => @address, - 'peer.port' => @port + 'net.peer.name' => @address, + 'net.peer.port' => @port ), kind: :client ) do |span| @@ -51,8 +51,8 @@ def connect attributes = OpenTelemetry::Common::HTTP::ClientContext.attributes tracer.in_span('HTTP CONNECT', attributes: attributes.merge( - 'peer.hostname' => conn_address, - 'peer.port' => conn_port + 'net.peer.name' => conn_address, + 'net.peer.port' => conn_port )) do super end diff --git a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb index 3b1cad426..2bb424f2b 100644 --- a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb +++ b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb @@ -48,8 +48,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :get, 'http://example.com/success', @@ -66,8 +66,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 500 _(span.attributes['http.target']).must_equal '/failure' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 assert_requested( :post, 'http://example.com/failure', @@ -86,8 +86,8 @@ _(span.attributes['http.scheme']).must_equal 'https' _(span.attributes['http.status_code']).must_be_nil _(span.attributes['http.target']).must_equal '/timeout' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 443 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 443 _(span.status.code).must_equal( OpenTelemetry::Trace::Status::ERROR ) @@ -112,8 +112,8 @@ _(span.attributes['http.scheme']).must_equal 'http' _(span.attributes['http.status_code']).must_equal 200 _(span.attributes['http.target']).must_equal '/success' - _(span.attributes['peer.hostname']).must_equal 'example.com' - _(span.attributes['peer.port']).must_equal 80 + _(span.attributes['net.peer.name']).must_equal 'example.com' + _(span.attributes['net.peer.port']).must_equal 80 _(span.attributes['peer.service']).must_equal 'foo' assert_requested( :get, @@ -138,8 +138,8 @@ _(exporter.finished_spans.size).must_equal(2) _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['peer.hostname']).must_equal('localhost') - _(span.attributes['peer.port']).wont_be_nil + _(span.attributes['net.peer.name']).must_equal('localhost') + _(span.attributes['net.peer.port']).wont_be_nil ensure WebMock.disable_net_connect! end @@ -153,8 +153,8 @@ _(exporter.finished_spans.size).must_equal(1) _(span.name).must_equal 'HTTP CONNECT' - _(span.attributes['peer.hostname']).must_equal('localhost') - _(span.attributes['peer.port']).must_equal(99_999) + _(span.attributes['net.peer.name']).must_equal('localhost') + _(span.attributes['net.peer.port']).must_equal(99_999) span_event = span.events.first _(span_event.name).must_equal 'exception' From 467dc091520dc3f308d40ccb0a216810a5ff051b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 1 Nov 2021 10:41:38 -0400 Subject: [PATCH 6/7] release: Release 2 gems (#996) * release: Release 2 gems * chore: trigger ci * fix: add missing changelog entries Co-authored-by: Daniel Azuma Co-authored-by: Robert Laurin Co-authored-by: Francis Bogsanyi --- exporter/otlp/CHANGELOG.md | 5 +++++ exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb | 2 +- sdk/CHANGELOG.md | 4 ++++ sdk/lib/opentelemetry/sdk/version.rb | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/exporter/otlp/CHANGELOG.md b/exporter/otlp/CHANGELOG.md index cd2e18537..9bab72698 100644 --- a/exporter/otlp/CHANGELOG.md +++ b/exporter/otlp/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History: opentelemetry-exporter-otlp +### v0.20.6 / 2021-10-29 + +* FIXED: Add unexpected error handlign in BSP and OTLP exporter (#995) +* FIXED: Handle otlp exporter race condition gzip errors with retry + ### v0.20.5 / 2021-09-29 * (No significant changes) diff --git a/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb b/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb index 41fc0dc89..4e7a2f770 100644 --- a/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb +++ b/exporter/otlp/lib/opentelemetry/exporter/otlp/version.rb @@ -8,7 +8,7 @@ module OpenTelemetry module Exporter module OTLP ## Current OpenTelemetry OTLP exporter version - VERSION = '0.20.5' + VERSION = '0.20.6' end end end diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 0f73a6f17..67ac0dec6 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History: opentelemetry-sdk +### v1.0.1 / 2021-10-29 + +* FIXED: Add unexpected error handlign in BSP and OTLP exporter (#995) + ### v1.0.0 / 2021-09-29 * (No significant changes) diff --git a/sdk/lib/opentelemetry/sdk/version.rb b/sdk/lib/opentelemetry/sdk/version.rb index af1ebd40c..904dad8a6 100644 --- a/sdk/lib/opentelemetry/sdk/version.rb +++ b/sdk/lib/opentelemetry/sdk/version.rb @@ -7,6 +7,6 @@ module OpenTelemetry module SDK ## Current OpenTelemetry version - VERSION = '1.0.0' + VERSION = '1.0.1' end end From 47172f85cb5f2f7e8e7160426e01636ee8327418 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 1 Nov 2021 18:12:53 -0500 Subject: [PATCH 7/7] Fix: Sidekiq dependabot warning (#1003) --- .../sidekiq/opentelemetry-instrumentation-sidekiq.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec index b8e9bf329..010f255c0 100644 --- a/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec +++ b/instrumentation/sidekiq/opentelemetry-instrumentation-sidekiq.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'minitest', '~> 5.0' spec.add_development_dependency 'opentelemetry-sdk', '~> 1.0' spec.add_development_dependency 'rubocop', '~> 0.73.0' - spec.add_development_dependency 'sidekiq', '~> 5.0.0' + spec.add_development_dependency 'sidekiq', '~> 5.2.0' spec.add_development_dependency 'simplecov', '~> 0.17.1' spec.add_development_dependency 'yard', '~> 0.9' spec.add_development_dependency 'yard-doctest', '~> 0.1.6'