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'