|
@@ -6,8 +6,12 @@
|
|
|
package io.opentelemetry.instrumentation.api.instrumenter.http;
|
|
|
|
|
|
import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyActiveRequestsView;
|
|
|
-import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyClientDurationAndSizeView;
|
|
|
-import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyServerDurationAndSizeView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyClientRequestSizeView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyOldClientDurationView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyOldServerDurationView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyServerRequestSizeView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyStableClientDurationView;
|
|
|
+import static io.opentelemetry.instrumentation.api.instrumenter.http.TemporaryMetricsView.applyStableServerDurationView;
|
|
|
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
|
|
import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP;
|
|
|
import static org.assertj.core.api.Assertions.entry;
|
|
@@ -22,7 +26,7 @@ import org.junit.jupiter.api.Test;
|
|
|
class TemporaryMetricsViewTest {
|
|
|
|
|
|
@Test
|
|
|
- void shouldApplyClientDurationAndSizeView() {
|
|
|
+ void shouldApplyClientDurationView() {
|
|
|
Attributes startAttributes =
|
|
|
Attributes.builder()
|
|
|
.put(
|
|
@@ -47,7 +51,7 @@ class TemporaryMetricsViewTest {
|
|
|
.put(SemanticAttributes.NET_SOCK_PEER_PORT, 8080)
|
|
|
.build();
|
|
|
|
|
|
- assertThat(applyClientDurationAndSizeView(startAttributes, endAttributes))
|
|
|
+ assertThat(applyOldClientDurationView(startAttributes, endAttributes))
|
|
|
.containsOnly(
|
|
|
entry(SemanticAttributes.HTTP_METHOD, "GET"),
|
|
|
entry(SemanticAttributes.HTTP_STATUS_CODE, 500L),
|
|
@@ -59,7 +63,7 @@ class TemporaryMetricsViewTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void shouldApplyClientDurationAndSizeView_stableSemconv() {
|
|
|
+ void shouldApplyClientDurationView_stableSemconv() {
|
|
|
Attributes startAttributes =
|
|
|
Attributes.builder()
|
|
|
.put(
|
|
@@ -84,7 +88,7 @@ class TemporaryMetricsViewTest {
|
|
|
.put(NetworkAttributes.SERVER_SOCKET_PORT, 8080)
|
|
|
.build();
|
|
|
|
|
|
- assertThat(applyClientDurationAndSizeView(startAttributes, endAttributes))
|
|
|
+ assertThat(applyStableClientDurationView(startAttributes, endAttributes))
|
|
|
.containsOnly(
|
|
|
entry(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
|
|
|
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L),
|
|
@@ -96,7 +100,7 @@ class TemporaryMetricsViewTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void shouldApplyServerDurationAndSizeView() {
|
|
|
+ void shouldApplyServerDurationView() {
|
|
|
Attributes startAttributes =
|
|
|
Attributes.builder()
|
|
|
.put(SemanticAttributes.HTTP_METHOD, "GET")
|
|
@@ -125,7 +129,7 @@ class TemporaryMetricsViewTest {
|
|
|
.put(SemanticAttributes.NET_PEER_PORT, 443)
|
|
|
.build();
|
|
|
|
|
|
- assertThat(applyServerDurationAndSizeView(startAttributes, endAttributes))
|
|
|
+ assertThat(applyOldServerDurationView(startAttributes, endAttributes))
|
|
|
.containsOnly(
|
|
|
entry(SemanticAttributes.HTTP_METHOD, "GET"),
|
|
|
entry(SemanticAttributes.HTTP_STATUS_CODE, 500L),
|
|
@@ -138,7 +142,7 @@ class TemporaryMetricsViewTest {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- void shouldApplyServerDurationAndSizeView_stableSemconv() {
|
|
|
+ void shouldApplyServerDurationView_stableSemconv() {
|
|
|
Attributes startAttributes =
|
|
|
Attributes.builder()
|
|
|
.put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
|
|
@@ -167,7 +171,163 @@ class TemporaryMetricsViewTest {
|
|
|
.put(NetworkAttributes.CLIENT_SOCKET_PORT, 8080)
|
|
|
.build();
|
|
|
|
|
|
- assertThat(applyServerDurationAndSizeView(startAttributes, endAttributes))
|
|
|
+ assertThat(applyStableServerDurationView(startAttributes, endAttributes))
|
|
|
+ .containsOnly(
|
|
|
+ entry(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
|
|
|
+ entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L),
|
|
|
+ entry(SemanticAttributes.HTTP_ROUTE, "/somehost/high/{name}/{id}"),
|
|
|
+ entry(UrlAttributes.URL_SCHEME, "https"),
|
|
|
+ entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
|
|
|
+ entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void shouldApplyClientSizeView() {
|
|
|
+ Attributes startAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(
|
|
|
+ SemanticAttributes.HTTP_URL,
|
|
|
+ "https://somehost/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .put(SemanticAttributes.HTTP_METHOD, "GET")
|
|
|
+ .put(SemanticAttributes.HTTP_SCHEME, "https")
|
|
|
+ .put(SemanticAttributes.HTTP_TARGET, "/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Attributes endAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(SemanticAttributes.HTTP_STATUS_CODE, 500)
|
|
|
+ .put(SemanticAttributes.NET_TRANSPORT, IP_TCP)
|
|
|
+ .put(SemanticAttributes.NET_PROTOCOL_NAME, "http")
|
|
|
+ .put(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1")
|
|
|
+ .put(SemanticAttributes.NET_PEER_NAME, "somehost2")
|
|
|
+ .put(SemanticAttributes.NET_PEER_PORT, 443)
|
|
|
+ .put(SemanticAttributes.NET_SOCK_FAMILY, "inet")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_PEER_ADDR, "1.2.3.4")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_PEER_NAME, "somehost20")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_PEER_PORT, 8080)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ assertThat(applyClientRequestSizeView(startAttributes, endAttributes))
|
|
|
+ .containsOnly(
|
|
|
+ entry(SemanticAttributes.HTTP_METHOD, "GET"),
|
|
|
+ entry(SemanticAttributes.HTTP_STATUS_CODE, 500L),
|
|
|
+ entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"),
|
|
|
+ entry(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1"),
|
|
|
+ entry(SemanticAttributes.NET_PEER_NAME, "somehost2"),
|
|
|
+ entry(SemanticAttributes.NET_PEER_PORT, 443L),
|
|
|
+ entry(SemanticAttributes.NET_SOCK_PEER_ADDR, "1.2.3.4"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void shouldApplyClientSizeView_stableSemconv() {
|
|
|
+ Attributes startAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(
|
|
|
+ UrlAttributes.URL_FULL, "https://somehost/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
|
|
|
+ .put(UrlAttributes.URL_SCHEME, "https")
|
|
|
+ .put(UrlAttributes.URL_PATH, "/high/cardinality/12345")
|
|
|
+ .put(UrlAttributes.URL_QUERY, "jsessionId=121454")
|
|
|
+ .put(NetworkAttributes.SERVER_ADDRESS, "somehost2")
|
|
|
+ .put(NetworkAttributes.SERVER_PORT, 443)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Attributes endAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500)
|
|
|
+ .put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
|
|
|
+ .put(NetworkAttributes.NETWORK_TYPE, "ipv4")
|
|
|
+ .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
|
|
|
+ .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")
|
|
|
+ .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4")
|
|
|
+ .put(NetworkAttributes.SERVER_SOCKET_DOMAIN, "somehost20")
|
|
|
+ .put(NetworkAttributes.SERVER_SOCKET_PORT, 8080)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ assertThat(applyClientRequestSizeView(startAttributes, endAttributes))
|
|
|
+ .containsOnly(
|
|
|
+ entry(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
|
|
|
+ entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L),
|
|
|
+ entry(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http"),
|
|
|
+ entry(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
|
|
|
+ entry(NetworkAttributes.SERVER_ADDRESS, "somehost2"),
|
|
|
+ entry(NetworkAttributes.SERVER_PORT, 443L),
|
|
|
+ entry(NetworkAttributes.SERVER_SOCKET_ADDRESS, "1.2.3.4"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void shouldApplyServerSizeView() {
|
|
|
+ Attributes startAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(SemanticAttributes.HTTP_METHOD, "GET")
|
|
|
+ .put(
|
|
|
+ SemanticAttributes.HTTP_URL,
|
|
|
+ "https://somehost/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .put(SemanticAttributes.HTTP_TARGET, "/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .put(SemanticAttributes.HTTP_SCHEME, "https")
|
|
|
+ .put(SemanticAttributes.NET_TRANSPORT, IP_TCP)
|
|
|
+ .put(SemanticAttributes.NET_PROTOCOL_NAME, "http")
|
|
|
+ .put(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1")
|
|
|
+ .put(SemanticAttributes.NET_HOST_NAME, "somehost")
|
|
|
+ .put(SemanticAttributes.NET_HOST_PORT, 443)
|
|
|
+ .put(SemanticAttributes.NET_SOCK_FAMILY, "inet")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_PEER_ADDR, "1.2.3.4")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_PEER_PORT, 8080)
|
|
|
+ .put(SemanticAttributes.NET_SOCK_HOST_ADDR, "4.3.2.1")
|
|
|
+ .put(SemanticAttributes.NET_SOCK_HOST_PORT, 9090)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Attributes endAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(SemanticAttributes.HTTP_ROUTE, "/somehost/high/{name}/{id}")
|
|
|
+ .put(SemanticAttributes.HTTP_STATUS_CODE, 500)
|
|
|
+ .put(SemanticAttributes.NET_PEER_NAME, "somehost2")
|
|
|
+ .put(SemanticAttributes.NET_PEER_PORT, 443)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ assertThat(applyServerRequestSizeView(startAttributes, endAttributes))
|
|
|
+ .containsOnly(
|
|
|
+ entry(SemanticAttributes.HTTP_METHOD, "GET"),
|
|
|
+ entry(SemanticAttributes.HTTP_STATUS_CODE, 500L),
|
|
|
+ entry(SemanticAttributes.HTTP_SCHEME, "https"),
|
|
|
+ entry(SemanticAttributes.NET_PROTOCOL_NAME, "http"),
|
|
|
+ entry(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1"),
|
|
|
+ entry(SemanticAttributes.NET_HOST_NAME, "somehost"),
|
|
|
+ entry(SemanticAttributes.NET_HOST_PORT, 443L),
|
|
|
+ entry(SemanticAttributes.HTTP_ROUTE, "/somehost/high/{name}/{id}"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void shouldApplyServerSizeView_stableSemconv() {
|
|
|
+ Attributes startAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(HttpAttributes.HTTP_REQUEST_METHOD, "GET")
|
|
|
+ .put(
|
|
|
+ UrlAttributes.URL_FULL, "https://somehost/high/cardinality/12345?jsessionId=121454")
|
|
|
+ .put(UrlAttributes.URL_SCHEME, "https")
|
|
|
+ .put(UrlAttributes.URL_PATH, "/high/cardinality/12345")
|
|
|
+ .put(UrlAttributes.URL_QUERY, "jsessionId=121454")
|
|
|
+ .put(NetworkAttributes.SERVER_ADDRESS, "somehost")
|
|
|
+ .put(NetworkAttributes.SERVER_PORT, 443)
|
|
|
+ .put(NetworkAttributes.CLIENT_ADDRESS, "somehost2")
|
|
|
+ .put(NetworkAttributes.CLIENT_PORT, 443)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ Attributes endAttributes =
|
|
|
+ Attributes.builder()
|
|
|
+ .put(SemanticAttributes.HTTP_ROUTE, "/somehost/high/{name}/{id}")
|
|
|
+ .put(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500)
|
|
|
+ .put(NetworkAttributes.NETWORK_TRANSPORT, "tcp")
|
|
|
+ .put(NetworkAttributes.NETWORK_TYPE, "ipv4")
|
|
|
+ .put(NetworkAttributes.NETWORK_PROTOCOL_NAME, "http")
|
|
|
+ .put(NetworkAttributes.NETWORK_PROTOCOL_VERSION, "1.1")
|
|
|
+ .put(NetworkAttributes.SERVER_SOCKET_ADDRESS, "4.3.2.1")
|
|
|
+ .put(NetworkAttributes.SERVER_SOCKET_PORT, 9090)
|
|
|
+ .put(NetworkAttributes.CLIENT_SOCKET_ADDRESS, "1.2.3.4")
|
|
|
+ .put(NetworkAttributes.CLIENT_SOCKET_PORT, 8080)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ assertThat(applyServerRequestSizeView(startAttributes, endAttributes))
|
|
|
.containsOnly(
|
|
|
entry(HttpAttributes.HTTP_REQUEST_METHOD, "GET"),
|
|
|
entry(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 500L),
|