Skip to content

Commit

Permalink
Apply to instrumentations
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Jul 28, 2022
1 parent 48bb76f commit ce625fa
Show file tree
Hide file tree
Showing 90 changed files with 381 additions and 598 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,4 @@ public String peerName(HttpRequest httpRequest, @Nullable HttpResponse httpRespo
public Integer peerPort(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) {
return httpRequest.uri().authority().port();
}

@Override
@Nullable
public String peerIp(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class RestCamelTest extends AgentInstrumentationSpecification implements RetryOn
"$SemanticAttributes.HTTP_USER_AGENT" String
"$SemanticAttributes.HTTP_FLAVOR" "1.1"
"$SemanticAttributes.HTTP_METHOD" "GET"
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" Long
"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}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ class TwoServicesWithDirectClientCamelTest extends AgentInstrumentationSpecifica
"$SemanticAttributes.HTTP_SCHEME" "http"
"$SemanticAttributes.HTTP_HOST" "127.0.0.1:$portTwo"
"$SemanticAttributes.HTTP_TARGET" "/serviceTwo"
"$SemanticAttributes.NET_PEER_PORT" Number
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$SemanticAttributes.NET_PEER_IP" String
"$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String }
"$SemanticAttributes.NET_PEER_PORT" Long
"net.sock.peer.addr" String
"net.sock.peer.port" Long
"net.sock.family" { it == "inet6" || it == null }
}
}
}
Expand Down Expand Up @@ -182,9 +182,9 @@ abstract class AbstractDubboTest extends InstrumentationSpecification {
"$SemanticAttributes.RPC_SYSTEM" "apache_dubbo"
"$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService"
"$SemanticAttributes.RPC_METHOD" "hello"
"$SemanticAttributes.NET_PEER_IP" String
"$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String }
"$SemanticAttributes.NET_PEER_PORT" Long
"net.sock.peer.addr" String
"net.sock.peer.port" Long
"net.sock.family" { it == "inet6" || it == null }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r
public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return request.getPeerPort();
}

@Override
@Nullable
public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,4 @@ public Integer peerPort(HttpMethod request, @Nullable HttpMethod response) {
HostConfiguration hostConfiguration = request.getHostConfiguration();
return hostConfiguration != null ? hostConfiguration.getPort() : null;
}

@Override
@Nullable
public String peerIp(HttpMethod request, @Nullable HttpMethod response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r
public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return request.getPeerPort();
}

@Override
@Nullable
public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r
public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return request.getPeerPort();
}

@Override
@Nullable
public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,4 @@ public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) {
return null;
}
}

@Override
@Nullable
public String peerIp(HttpRequest request, @Nullable HttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,4 @@ public String peerName(Request request, @Nullable Response response) {
public Integer peerPort(Request request, @Nullable Response response) {
return request.getUri().getPort();
}

@Override
@Nullable
public String peerIp(Request request, @Nullable Response response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,4 @@ public String peerName(Request<?> request, @Nullable Response<?> response) {
public Integer peerPort(Request<?> request, @Nullable Response<?> response) {
return request.getEndpoint().getPort();
}

@Override
@Nullable
public String peerIp(Request<?> request, @Nullable Response<?> response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,4 @@ public Integer peerPort(ExecutionAttributes request, @Nullable SdkHttpResponse r
request.getAttribute(TracingExecutionInterceptor.SDK_HTTP_REQUEST_ATTRIBUTE);
return httpRequest.port();
}

@Override
@Nullable
public String peerIp(ExecutionAttributes request, @Nullable SdkHttpResponse response) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CassandraClientTest extends AgentInstrumentationSpecification {

def setupSpec() {
cassandra = new GenericContainer("cassandra:3")
// limit memory usage
// limit memory usage
.withEnv("JVM_OPTS", "-Xmx128m -Xms128m")
.withExposedPorts(9042)
.withLogConsumer(new Slf4jLogConsumer(logger))
Expand Down Expand Up @@ -148,8 +148,8 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
}
attributes {
"$SemanticAttributes.NET_PEER_NAME" "localhost"
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" cassandraPort
"net.sock.peer.addr" "127.0.0.1"
"$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 @@ -32,7 +32,7 @@ class CassandraClientTest extends AgentInstrumentationSpecification {

def setupSpec() {
cassandra = new GenericContainer("cassandra:4.0")
// limit memory usage
// limit memory usage
.withEnv("JVM_OPTS", "-Xmx128m -Xms128m")
.withExposedPorts(9042)
.withLogConsumer(new Slf4jLogConsumer(logger))
Expand Down Expand Up @@ -121,8 +121,8 @@ class CassandraClientTest extends AgentInstrumentationSpecification {
}
attributes {
"$SemanticAttributes.NET_PEER_NAME" "localhost"
"$SemanticAttributes.NET_PEER_IP" "127.0.0.1"
"$SemanticAttributes.NET_PEER_PORT" cassandraPort
"net.sock.peer.addr" "127.0.0.1"
"$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 @@ -30,10 +30,4 @@ public String peerName(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unu
public Integer peerPort(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unused) {
return couchbaseRequest.getPeerPort();
}

@Nullable
@Override
public String peerIp(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unused) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.net.Inet6Address;
import javax.annotation.Nullable;
import org.elasticsearch.client.Response;

Expand Down Expand Up @@ -38,10 +39,20 @@ public Integer peerPort(ElasticsearchRestRequest request, @Nullable Response res

@Override
@Nullable
public String peerIp(ElasticsearchRestRequest request, @Nullable Response response) {
public String sockPeerAddr(ElasticsearchRestRequest request, @Nullable Response response) {
if (response != null && response.getHost().getAddress() != null) {
return response.getHost().getAddress().getHostAddress();
}
return null;
}

@Nullable
@Override
public String sockFamily(
ElasticsearchRestRequest elasticsearchRestRequest, @Nullable Response response) {
if (response != null && response.getHost().getAddress() instanceof Inet6Address) {
return "inet6";
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "ClusterHealthAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "ClusterHealthAction"
"elasticsearch.action" "ClusterHealthAction"
Expand Down Expand Up @@ -242,9 +243,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "CreateIndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "CreateIndexAction"
"elasticsearch.action" "CreateIndexAction"
Expand All @@ -258,9 +260,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down Expand Up @@ -289,9 +292,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "IndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "IndexAction"
"elasticsearch.action" "IndexAction"
Expand All @@ -310,9 +314,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$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,9 +131,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
kind CLIENT
childOf(span(0))
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "ClusterHealthAction"
"elasticsearch.action" "ClusterHealthAction"
Expand Down Expand Up @@ -247,9 +248,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "CreateIndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "CreateIndexAction"
"elasticsearch.action" "CreateIndexAction"
Expand All @@ -263,9 +265,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down Expand Up @@ -294,9 +297,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "IndexAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "IndexAction"
"elasticsearch.action" "IndexAction"
Expand All @@ -316,9 +320,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC
name "GetAction"
kind CLIENT
attributes {
"$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address
"$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address
"$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 }
"$SemanticAttributes.DB_SYSTEM" "elasticsearch"
"$SemanticAttributes.DB_OPERATION" "GetAction"
"elasticsearch.action" "GetAction"
Expand Down
Loading

0 comments on commit ce625fa

Please sign in to comment.