Skip to content

Commit

Permalink
Net attributes getters changes: test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Aug 30, 2022
1 parent 1fdc3dc commit 312cc62
Show file tree
Hide file tree
Showing 52 changed files with 627 additions and 367 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ class RestCamelTest extends AgentInstrumentationSpecification implements RetryOn
"$SemanticAttributes.HTTP_USER_AGENT" String
"$SemanticAttributes.HTTP_FLAVOR" "1.1"
"$SemanticAttributes.HTTP_METHOD" "GET"
"$SemanticAttributes.HTTP_ROUTE" "/api/{module}/unit/{unitId}"
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"net.host.name" "localhost"
"net.host.port" port
"net.sock.peer.addr" "127.0.0.1"
"net.sock.peer.port" Long
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.HTTP_ROUTE" "/api/{module}/unit/{unitId}"
"net.sock.host.name" String
"net.sock.host.addr" "127.0.0.1"
}
}
it.span(3) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ class TwoServicesWithDirectClientCamelTest extends AgentInstrumentationSpecifica
"$SemanticAttributes.HTTP_SCHEME" "http"
"$SemanticAttributes.HTTP_HOST" "127.0.0.1:$portTwo"
"$SemanticAttributes.HTTP_TARGET" "/serviceTwo"
"net.sock.peer.port" Number
"net.sock.peer.addr" "127.0.0.1"
"$SemanticAttributes.HTTP_USER_AGENT" "Jakarta Commons-HttpClient/3.1"
"$SemanticAttributes.HTTP_FLAVOR" "1.1"
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"$SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH" Long
"$SemanticAttributes.HTTP_ROUTE" "/serviceTwo"
"$SemanticAttributes.NET_TRANSPORT" IP_TCP
"net.host.name" "127.0.0.1"
"net.host.port" portTwo
"net.sock.peer.addr" "127.0.0.1"
"net.sock.peer.port" Long
}
}
it.span(5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
childOf((SpanData) parentSpan)
}
attributes {
"$SemanticAttributes.NET_PEER_NAME" "localhost"
"$SemanticAttributes.NET_PEER_PORT" cassandraPort
"net.sock.peer.addr" "127.0.0.1"
"net.sock.peer.name" "localhost"
"net.sock.peer.port" cassandraPort
"$SemanticAttributes.DB_SYSTEM" "cassandra"
"$SemanticAttributes.DB_NAME" keyspace
"$SemanticAttributes.DB_STATEMENT" statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
childOf((SpanData) parentSpan)
}
attributes {
"$SemanticAttributes.NET_PEER_NAME" "localhost"
"$SemanticAttributes.NET_PEER_PORT" cassandraPort
"net.sock.peer.addr" "127.0.0.1"
"net.sock.peer.name" "localhost"
"net.sock.peer.port" cassandraPort
"$SemanticAttributes.DB_SYSTEM" "cassandra"
"$SemanticAttributes.DB_NAME" keyspace
"$SemanticAttributes.DB_STATEMENT" statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class CouchbaseSpanUtil {

"$SemanticAttributes.NET_TRANSPORT" { it == null || it == IP_TCP }
// Because of caching, not all requests hit the server so these attributes may be absent
"$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == null }
"$SemanticAttributes.NET_PEER_PORT" { it == null || Number }
"net.sock.peer.addr" { it == "127.0.0.1" || it == null }
"net.sock.peer.name" { it == "localhost" || it == null }
"net.sock.peer.port" { it == null || Number }

// Because of caching, not all requests hit the server so this tag may be absent
"couchbase.local.address" { it == null || String }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "ClusterHealthAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "ClusterHealthAction"
"elasticsearch.action" "ClusterHealthAction"
Expand Down Expand Up @@ -243,10 +243,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "CreateIndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "CreateIndexAction"
"elasticsearch.action" "CreateIndexAction"
Expand All @@ -260,10 +260,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down Expand Up @@ -292,10 +292,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "IndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "IndexAction"
"elasticsearch.action" "IndexAction"
Expand All @@ -314,10 +314,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
kind CLIENT
childOf(span(0))
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "ClusterHealthAction"
"elasticsearch.action" "ClusterHealthAction"
Expand Down Expand Up @@ -248,10 +248,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "CreateIndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "CreateIndexAction"
"elasticsearch.action" "CreateIndexAction"
Expand All @@ -265,10 +265,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down Expand Up @@ -297,10 +297,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "IndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "IndexAction"
"elasticsearch.action" "IndexAction"
Expand All @@ -320,10 +320,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.host
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl
kind CLIENT
childOf(span(0))
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.address().hostString
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "ClusterHealthAction"
"elasticsearch.action" "ClusterHealthAction"
Expand Down Expand Up @@ -223,8 +225,10 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl
name "CreateIndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.address().hostString
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "CreateIndexAction"
"elasticsearch.action" "CreateIndexAction"
Expand All @@ -238,8 +242,10 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.address().hostString
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down Expand Up @@ -268,8 +274,10 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl
name "IndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.address().hostString
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "IndexAction"
"elasticsearch.action" "IndexAction"
Expand All @@ -289,8 +297,10 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port
"net.sock.family" { it == "inet6" || it == null }
"net.sock.peer.addr" tcpPublishAddress.address
"net.sock.peer.name" tcpPublishAddress.address().hostString
"net.sock.peer.port" tcpPublishAddress.port
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ public void onCompleted() {
equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"),
equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"),
equalTo(SemanticAttributes.RPC_METHOD, "Conversation"),
equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"),
satisfies(
AttributeKey.longKey("net.sock.peer.port"),
val -> assertThat(val).isNotNull()),
equalTo(
SemanticAttributes.RPC_GRPC_STATUS_CODE,
(long) Status.Code.OK.value()),
equalTo(
SemanticAttributes.NET_TRANSPORT,
SemanticAttributes.NetTransportValues.IP_TCP),
equalTo(
SemanticAttributes.RPC_GRPC_STATUS_CODE,
(long) Status.Code.OK.value()))
equalTo(SemanticAttributes.NET_HOST_NAME, "localhost"),
equalTo(SemanticAttributes.NET_HOST_PORT, server.getPort()),
equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"),
satisfies(
AttributeKey.longKey("net.sock.peer.port"),
val -> assertThat(val).isNotNull()))
.hasEventsSatisfyingExactly(events.toArray(new Consumer[0]))));
testing()
.waitAndAssertMetrics(
Expand All @@ -222,6 +224,8 @@ public void onCompleted() {
point ->
point.hasAttributesSatisfying(
equalTo(SemanticAttributes.NET_TRANSPORT, "ip_tcp"),
equalTo(
SemanticAttributes.NET_HOST_NAME, "localhost"),
equalTo(
SemanticAttributes.RPC_METHOD, "Conversation"),
equalTo(
Expand Down
Loading

0 comments on commit 312cc62

Please sign in to comment.