Skip to content

Commit 8b4a4d9

Browse files
committed
Code clean up + debug tomocat test.
1 parent da23e5c commit 8b4a4d9

File tree

13 files changed

+30
-109
lines changed

13 files changed

+30
-109
lines changed

.github/workflows/patch-release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
env:
1414
AWS_DEFAULT_REGION: us-east-1
15-
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
15+
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test-v2
1616

1717
permissions:
1818
id-token: write

.github/workflows/pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- main
66
- "release/v*"
77
env:
8-
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
8+
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test-v2
99

1010
jobs:
1111
testpatch:

.github/workflows/release-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
AWS_PUBLIC_ECR_REGION: us-east-1
1111
AWS_PRIVATE_ECR_REGION: us-west-2
12-
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test
12+
TEST_TAG: public.ecr.aws/aws-observability/adot-autoinstrumentation-java:test-v2
1313
PUBLIC_REPOSITORY: public.ecr.aws/aws-observability/adot-autoinstrumentation-java
1414
PRIVATE_REPOSITORY: 020628701572.dkr.ecr.us-west-2.amazonaws.com/adot-autoinstrumentation-java
1515
PRIVATE_REGISTRY: 020628701572.dkr.ecr.us-west-2.amazonaws.com

appsignals-tests/contract-tests/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ tasks {
7373
"-Dio.awsobservability.instrumentation.contracttests.agentPath=${otelAgentJarTask.get().archiveFile.get()
7474
.getAsFile().absolutePath}",
7575
)
76+
77+
testLogging {
78+
events("passed", "skipped", "failed")
79+
showStandardStreams = true
80+
}
7681
}
7782

7883
// Disable the test task from the java plugin

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/awssdk/base/AwsSdkBaseTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
import java.util.List;
2424
import java.util.Map;
2525
import java.util.Set;
26-
import java.util.logging.ConsoleHandler;
27-
import java.util.logging.Level;
28-
import java.util.logging.Logger;
2926
import org.assertj.core.api.ThrowingConsumer;
3027
import org.junit.jupiter.api.AfterAll;
3128
import org.junit.jupiter.api.BeforeAll;
@@ -39,16 +36,6 @@
3936

4037
public abstract class AwsSdkBaseTest extends ContractTestBase {
4138

42-
protected static final Logger LOGGER = Logger.getLogger(AwsSdkBaseTest.class.getName());
43-
44-
static {
45-
ConsoleHandler handler = new ConsoleHandler();
46-
handler.setLevel(Level.INFO);
47-
LOGGER.addHandler(handler);
48-
LOGGER.setLevel(Level.INFO);
49-
LOGGER.setUseParentHandlers(false);
50-
}
51-
5239
private final LocalStackContainer localstack =
5340
new LocalStackContainer(DockerImageName.parse("localstack/localstack:3.5.0"))
5441
.withServices(
@@ -620,7 +607,6 @@ protected void assertMetricAttributes(
620607
}
621608

622609
protected void doTestS3CreateBucket() throws Exception {
623-
LOGGER.info("doTestS3CreateBucket!!!!!!: ");
624610
appClient.get("/s3/createbucket/create-bucket").aggregate().join();
625611

626612
var traces = mockCollectorClient.getTraces();

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/base/ContractTestBase.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ protected Map<String, String> getApplicationEnvironmentVariables() {
153153
COLLECTOR_HTTP_ENDPOINT,
154154
"OTEL_RESOURCE_ATTRIBUTES",
155155
getApplicationOtelResourceAttributes(),
156-
// // The default OTLP protocol has been changed from grpc to
157-
// http/protobuf in
158-
// order
159-
// // to align with the specification. You can switch to the grpc protocol using
160-
// // OTEL_EXPORTER_OTLP_PROTOCOL=grpc or -Dotel.exporter.otlp.protocol=grpc.
161156
"OTEL_EXPORTER_OTLP_PROTOCOL",
162157
"grpc");
163158
}

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/base/JMXMetricsContractTestBase.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,22 @@
2222
import java.util.Map;
2323
import java.util.Set;
2424
import java.util.function.Consumer;
25+
import java.util.logging.ConsoleHandler;
26+
import java.util.logging.Level;
27+
import java.util.logging.Logger;
2528
import software.amazon.opentelemetry.appsignals.test.utils.JMXMetricsConstants;
2629

2730
public abstract class JMXMetricsContractTestBase extends ContractTestBase {
31+
protected static final Logger LOGGER =
32+
Logger.getLogger(JMXMetricsContractTestBase.class.getName());
33+
34+
static {
35+
ConsoleHandler handler = new ConsoleHandler();
36+
handler.setLevel(Level.INFO);
37+
LOGGER.addHandler(handler);
38+
LOGGER.setLevel(Level.INFO);
39+
LOGGER.setUseParentHandlers(false);
40+
}
2841

2942
@Override
3043
protected Map<String, String> getApplicationEnvironmentVariables() {
@@ -50,7 +63,15 @@ protected void assertMetrics() {
5063
var metrics = mockCollectorClient.getRuntimeMetrics(getExpectedMetrics());
5164
metrics.forEach(
5265
metric -> {
66+
var metricName = metric.getMetric().getName();
67+
long threshold = getThreshold(metricName);
5368
var dataPoints = metric.getMetric().getGauge().getDataPointsList();
69+
dataPoints.forEach(
70+
dp ->
71+
LOGGER.info(
72+
String.format(
73+
"Debug tomocat tests assertMetrics here !!!!: Data Point - Metric name: %s, Value: %d, Threshold: %d",
74+
metricName, dp.getAsInt(), threshold)));
5475
assertGreaterThanOrEqual(dataPoints, getThreshold(metric.getMetric().getName()));
5576
});
5677
}

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/httpclients/base/BaseHttpClientTest.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,11 @@ protected void assertSemanticConventionsAttributes(
145145
.isEqualTo(SemanticConventionsConstants.HTTP_REQUEST_METHOD);
146146
assertThat(attribute.getValue().getStringValue()).isEqualTo(method);
147147
})
148-
// network.protocol.name has marked as Conditionally required if not http and
149-
// network.protocol.version is set:
150-
//
151-
// https://opentelemetry.io/blog/2023/http-conventions-declared-stable/#summary-of-changes
152-
// .satisfiesOnlyOnce(
153-
// attribute -> {
154-
// assertThat(attribute.getKey())
155-
// .isEqualTo(SemanticConventionsConstants.NETWORK_PROTOCOL_NAME);
156-
// assertThat(attribute.getValue().getStringValue()).isEqualTo("http");
157-
// })
158148
.satisfiesOnlyOnce(
159149
attribute -> {
160150
assertThat(attribute.getKey())
161151
.isEqualTo(SemanticConventionsConstants.NETWORK_PROTOCOL_VERSION);
162152
})
163-
// HttpClientPeerServiceAttributesExtractor is removed from netty instrumentation:
164-
//
165-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/12083/files
166-
//
167-
// instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterFactory.java
168-
// .satisfiesOnlyOnce(
169-
// attribute -> {
170-
//
171-
// assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.PEER_SERVICE);
172-
// assertThat(attribute.getValue().getStringValue()).isEqualTo("backend:8080");
173-
// })
174153
.satisfiesOnlyOnce(
175154
attribute -> {
176155
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.THREAD_ID);
@@ -179,7 +158,7 @@ protected void assertSemanticConventionsAttributes(
179158
attribute -> {
180159
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.THREAD_NAME);
181160
});
182-
// Conditionally include PEER_SERVICE assertio
161+
183162
if (!getApplicationImageName().equals("aws-appsignals-tests-netty-http-client-app")) {
184163
assertThat(attributesList)
185164
.satisfiesOnlyOnce(

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/httpservers/base/BaseHttpServerTest.java

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,6 @@ protected void assertSemanticConventionsAttributes(
9999
attribute -> {
100100
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.SERVER_PORT);
101101
})
102-
// --------------------------------------
103-
// nettey utilize ServerAttributesExtractor which doesn't extract local socket
104-
// attributes: getNetworkLocalAddress(), getNetworkLocalPort()
105-
//
106-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ebb81b8a8ac0e5b3c9f2e175b847a3d0b12251f/instrumentation/netty/netty-4-common/library/src/main/java/io/opentelemetry/instrumentation/netty/v4/common/internal/client/NettyClientInstrumenterFactory.java#L64
107-
//
108-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ebb81b8a8ac0e5b3c9f2e175b847a3d0b12251f/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/ServerAttributesExtractor.java#L24
109-
// HttpServerAttributesExtractorBuilder dosen't extract local socket attributes
110-
//
111-
// https://opentelemetry.io/docs/specs/semconv/general/attributes/#networkpeer-and-networklocal-attributes
112-
//
113-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ebb81b8a8ac0e5b3c9f2e175b847a3d0b12251f/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorBuilder.java#L141
114-
// .satisfiesOnlyOnce(
115-
// attribute -> {
116-
// assertThat(attribute.getKey())
117-
// .isEqualTo(SemanticConventionsConstants.NETWORK_LOCAL_ADDRESS);
118-
// })
119-
// --------------------------------------
120-
// .satisfiesOnlyOnce(
121-
// attribute -> {
122-
// assertThat(attribute.getKey())
123-
// .isEqualTo(SemanticConventionsConstants.NETWORK_LOCAL_PORT);
124-
// assertThat(attribute.getValue().getIntValue()).isEqualTo(8080L);
125-
// })
126102
.satisfiesOnlyOnce(
127103
attribute -> {
128104
assertThat(attribute.getKey())
@@ -139,16 +115,6 @@ protected void assertSemanticConventionsAttributes(
139115
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.URL_SCHEME);
140116
assertThat(attribute.getValue().getStringValue()).isEqualTo("http");
141117
})
142-
// HTTP_RESPONSE_HEADER_CONTENT_LENGTH -> need an explicit configuration
143-
//
144-
// https://opentelemetry.io/docs/specs/semconv/attributes-registry/http/#http-attributes
145-
// --------------------------------------
146-
// .satisfiesOnlyOnce(
147-
// attribute -> {
148-
// assertThat(attribute.getKey())
149-
//
150-
// .isEqualTo(SemanticConventionsConstants.HTTP_RESPONSE_HEADER_CONTENT_LENGTH);
151-
// })
152118
.satisfiesOnlyOnce(
153119
attribute -> {
154120
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.HTTP_ROUTE);
@@ -171,18 +137,6 @@ protected void assertSemanticConventionsAttributes(
171137
.isEqualTo(SemanticConventionsConstants.HTTP_REQUEST_METHOD);
172138
assertThat(attribute.getValue().getStringValue()).isEqualTo(method);
173139
})
174-
// --------------------------------------
175-
// network.protocol.name has marked as Conditionally required if not http and
176-
// network.protocol.version is set:
177-
// HttpServerAttributesExtractorBuilder dosen't extract protocol attributes
178-
//
179-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ebb81b8a8ac0e5b3c9f2e175b847a3d0b12251f/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorBuilder.java#L141
180-
// .satisfiesOnlyOnce(
181-
// attribute -> {
182-
// assertThat(attribute.getKey())
183-
// .isEqualTo(SemanticConventionsConstants.NETWORK_PROTOCOL_NAME);
184-
// assertThat(attribute.getValue().getStringValue()).isEqualTo("http");
185-
// })
186140
.satisfiesOnlyOnce(
187141
attribute -> {
188142
assertThat(attribute.getKey())

appsignals-tests/contract-tests/src/test/java/software/amazon/opentelemetry/appsignals/test/httpservers/springmvc/SpringMvc.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,6 @@ protected void assertSemanticConventionsAttributes(
8787
assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.HTTP_ROUTE);
8888
assertThat(attribute.getValue().getStringValue()).isEqualTo(route);
8989
})
90-
// springmvc 4.1 dosen't support getUrlPath, only support in newer version:
91-
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/5ebb81b8a8ac0e5b3c9f2e175b847a3d0b12251f/instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/v5_3/SpringWebMvcHttpAttributesGetter.java#L74
92-
// .satisfiesOnlyOnce(
93-
// attribute -> {
94-
//
95-
// assertThat(attribute.getKey()).isEqualTo(SemanticConventionsConstants.URL_PATH);
96-
// assertThat(attribute.getValue().getStringValue()).isEqualTo(target);
97-
// })
9890
.satisfiesOnlyOnce(
9991
attribute -> {
10092
assertThat(attribute.getKey())

0 commit comments

Comments
 (0)