Skip to content

Commit

Permalink
Merge pull request #671 from aws-observability/merge_release_v1.32.x_…
Browse files Browse the repository at this point in the history
…to_main

Merge release v1.32.x to main
  • Loading branch information
PaurushGarg authored Dec 27, 2023
2 parents 6c223a3 + 10a13cc commit b5e7788
Show file tree
Hide file tree
Showing 218 changed files with 1,973 additions and 1,965 deletions.
25 changes: 25 additions & 0 deletions .github/patches/opentelemetry-java-instrumentation.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java
index a3e2d0e770..41c772692d 100644
--- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java
+++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java
@@ -137,7 +137,7 @@ final class SqsImpl {
}

static String getMessageId(Response<?> response) {
- if (response.getAwsResponse() instanceof SendMessageResult) {
+ if (response != null && response.getAwsResponse() instanceof SendMessageResult) {
return ((SendMessageResult) response.getAwsResponse()).getMessageId();
}
return null;
diff --git a/version.gradle.kts b/version.gradle.kts
index a2bacc6f04..0890062291 100644
--- a/version.gradle.kts
+++ b/version.gradle.kts
@@ -1,5 +1,5 @@
-val stableVersion = "1.32.0"
-val alphaVersion = "1.32.0-alpha"
+val stableVersion = "1.32.0-adot1"
+val alphaVersion = "1.32.0-adot1-alpha"

allprojects {
if (findProperty("otel.stable") != "true") {
1 change: 1 addition & 0 deletions .github/patches/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OTEL_JAVA_INSTRUMENTATION_VERSION=v1.32.0
8 changes: 8 additions & 0 deletions .github/workflows/appsignals-e2e-ec2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ jobs:
fi
done
# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }}

- name: Get the ec2 instance ami id
run: |
echo "EC2_INSTANCE_AMI=$(terraform output ec2_instance_ami)" >> $GITHUB_ENV
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/appsignals-e2e-eks-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ jobs:
kubectl get pods -n amazon-cloudwatch --output json | \
jq '.items[0].status.containerStatuses[0].imageID'
# cache local patch outputs
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository/io/opentelemetry/
key: ${{ runner.os }}-maven-local-${{ hashFiles('.github/patches/opentelemetry-java*.patch') }}

- name: Get the sample app endpoint
run: echo "APP_ENDPOINT=$(terraform output sample_app_endpoint)" >> $GITHUB_ENV
working-directory: testing/terraform/eks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ permissions:
jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: ubuntu-latest
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:
jobs:
testpatch:
name: Test patches applied to dependencies
runs-on: ubuntu-latest
runs-on: aws-otel-java-instrumentation_ubuntu-latest_32-core
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -75,6 +75,7 @@ jobs:

- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ matrix.os != 'windows-latest' }} # Skip patch on windows as it is not possible to build opentelemetry-java on windows
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}
Expand Down Expand Up @@ -127,7 +128,7 @@ jobs:

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
if: ${{ matrix.os != 'ubuntu-latest' }}
if: ${{ matrix.os != 'ubuntu-latest' && (hashFiles('.github/patches/opentelemetry-java*.patch') == '' || matrix.os != 'windows-latest' ) }} # build on windows as well unless a patch exists
with:
arguments: build --stacktrace -PenableCoverage=true
- uses: codecov/codecov-action@v3
2 changes: 0 additions & 2 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ jobs:

- name: Publish patched dependencies to maven local
uses: ./.github/actions/patch-dependencies
if: ${{ startsWith(github.ref_name, 'release/v') }}
with:
branch: ${{ github.ref_name }}
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_password: ${{ secrets.GPG_PASSPHRASE }}

Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ Select the branch and provide the version.

If you need to patch upstream dependencies, you need:

* Provide patch files for each repository that will need to be patched. These files should be located in `.github/patches/release/v<major>.<minor>.x` and should be named
* Provide patch files for each repository that will need to be patched. These files should be located in `.github/patches` and should be named
using the convention `<repository name>.patch`. The following repositories are supported: opentelemetry-java, opentelemetry-java-instrumentation and opentelemetry-java-contrib. Provide one patch file per repository. The adot patch version of each upstream dependency should be `<version>-adot<number>` where `version` is the version of the upstream dependency and `number` is the number of this patch that should be incremented from 1 per patch version.

* Create a `versions` file in the directory `.github/patches/release/v<major>.<minor>.x`. This file should contain shell variables with the versions of the tags of the repositories which will receive patches.
* Create a `versions` file in the directory `.github/patches/release`. This file should contain shell variables with the versions of the tags of the repositories which will receive patches.
This file should define the following variables:
* `OTEL_JAVA_VERSION`. Tag of the opentelemetry-java repository to use. E.g.: `JAVA_OTEL_JAVA_VERSION=v1.21.0`
* `OTEL_JAVA_INSTRUMENTATION_VERSION`. Tag of the opentelemetry-java-instrumentation repository to use, e.g.: `OTEL_JAVA_INSTRUMENTATION_VERSION=v1.21.0`
Expand Down
2 changes: 1 addition & 1 deletion appsignals-tests/contract-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dependencies {
testImplementation("software.amazon.awssdk:sts")
testImplementation(kotlin("test"))
implementation(project(":appsignals-tests:images:grpc:grpc-base"))
testImplementation("org.testcontainers:kafka:1.19.1")
testImplementation("org.testcontainers:kafka:1.19.3")
}

project.evaluationDependsOn(":otelagent")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,23 @@ private void assertSemanticConventionsAttributes(
.satisfiesOnlyOnce(assertKeyIsPresent(SemanticConventionsConstants.THREAD_ID));
}

/** All the spans of the AWS SDK Should have a RPC properties. */
private void assertSemanticConventionsSqsConsumerAttributes(
List<KeyValue> attributesList,
String service,
String method,
String peerName,
int peerPort,
String url) {
assertThat(attributesList)
.satisfiesOnlyOnce(assertAttribute(SemanticConventionsConstants.RPC_METHOD, method))
.satisfiesOnlyOnce(assertAttribute(SemanticConventionsConstants.RPC_SERVICE, service))
.satisfiesOnlyOnce(assertAttribute(SemanticConventionsConstants.NET_PEER_NAME, peerName))
.satisfiesOnlyOnce(assertAttribute(SemanticConventionsConstants.NET_PEER_PORT, peerPort))
.satisfiesOnlyOnce(assertAttributeStartsWith(SemanticConventionsConstants.HTTP_URL, url))
.satisfiesOnlyOnce(assertKeyIsPresent(SemanticConventionsConstants.THREAD_ID));
}

private void assertSpanClientAttributes(
List<ResourceScopeSpan> spans,
String spanName,
Expand Down Expand Up @@ -256,8 +273,8 @@ private void assertSpanConsumerAttributes(
var spanAttributes = span.getAttributesList();
assertThat(span.getKind()).isEqualTo(SpanKind.SPAN_KIND_CONSUMER);
assertThat(span.getName()).isEqualTo(spanName);
assertSemanticConventionsAttributes(
spanAttributes, rpcService, method, peerName, peerPort, url, statusCode);
assertSemanticConventionsSqsConsumerAttributes(
spanAttributes, rpcService, method, peerName, peerPort, url);
assertSqsConsumerAwsAttributes(span.getAttributesList(), operation);
for (var assertion : extraAssertions) {
assertThat(spanAttributes).satisfiesOnlyOnce(assertion);
Expand Down Expand Up @@ -291,7 +308,7 @@ private void assertSpanAttributes(
assertThat(span.getName()).isEqualTo(spanName);
assertSemanticConventionsAttributes(
spanAttributes, rpcService, method, peerName, peerPort, url, statusCode);
assertProducerOrClientAwsAttributes(
assertAwsAttributes(
spanAttributes,
localService,
localOperation,
Expand All @@ -305,7 +322,7 @@ private void assertSpanAttributes(
});
}

private void assertProducerOrClientAwsAttributes(
private void assertAwsAttributes(
List<KeyValue> attributesList,
String localService,
String localOperation,
Expand All @@ -327,22 +344,16 @@ private void assertProducerOrClientAwsAttributes(
}
}

private void assertConsumerAwsAttributes(
List<KeyValue> attributesList, String service, String operation) {
assertThat(attributesList)
.satisfiesOnlyOnce(assertAttribute(AppSignalsConstants.AWS_LOCAL_OPERATION, operation))
.satisfiesOnlyOnce(assertAttribute(AppSignalsConstants.AWS_LOCAL_SERVICE, service))
.satisfiesOnlyOnce(assertAttribute(AppSignalsConstants.AWS_SPAN_KIND, "LOCAL_ROOT"));
}

private void assertSqsConsumerAwsAttributes(List<KeyValue> attributesList, String operation) {
assertThat(attributesList)
// AWS_LOCAL_OPERATION Is propagated from the parent
.satisfiesOnlyOnce(assertAttribute(AppSignalsConstants.AWS_LOCAL_OPERATION, operation))
.noneSatisfy(assertKeyIsPresent(AppSignalsConstants.AWS_LOCAL_SERVICE))
.noneSatisfy(assertKeyIsPresent(AppSignalsConstants.AWS_REMOTE_OPERATION))
.noneSatisfy(assertKeyIsPresent(AppSignalsConstants.AWS_REMOTE_SERVICE))
.noneSatisfy(assertKeyIsPresent(AppSignalsConstants.AWS_SPAN_KIND));
.satisfiesOnlyOnce(
assertAttribute(AppSignalsConstants.AWS_LOCAL_SERVICE, getApplicationOtelServiceName()))
.satisfiesOnlyOnce(assertAttribute(AppSignalsConstants.AWS_SPAN_KIND, "LOCAL_ROOT"))
.satisfiesOnlyOnce(
assertAttribute(AppSignalsConstants.AWS_REMOTE_OPERATION, "ReceiveMessage"))
.satisfiesOnlyOnce(
assertAttribute(AppSignalsConstants.AWS_REMOTE_SERVICE, getSqsServiceName()));
}

protected void assertMetricClientAttributes(
Expand Down Expand Up @@ -387,6 +398,27 @@ protected void assertMetricProducerAttributes(
expectedSum);
}

protected void assertMetricConsumerAttributes(
List<ResourceScopeMetric> resourceScopeMetrics,
String metricName,
String localService,
String localOperation,
String service,
String method,
String target,
Double expectedSum) {
assertMetricAttributes(
resourceScopeMetrics,
metricName,
"CONSUMER",
localService,
localOperation,
service,
method,
target,
expectedSum);
}

protected void assertMetricAttributes(
List<ResourceScopeMetric> resourceScopeMetrics,
String metricName,
Expand All @@ -407,7 +439,7 @@ protected void assertMetricAttributes(
dataPoint -> {
List<KeyValue> attributes = dataPoint.getAttributesList();
assertThat(attributes).isNotNull();
assertProducerOrClientAwsAttributes(
assertAwsAttributes(
attributes,
localService,
localOperation,
Expand Down Expand Up @@ -1032,7 +1064,7 @@ protected void doTestSQSSendMessage() throws Exception {

assertSpanProducerAttributes(
traces,
sqsSpanName("SendMessage"),
"some-queue publish",
getSqsRpcServiceName(),
localService,
localOperation,
Expand Down Expand Up @@ -1088,11 +1120,15 @@ protected void doTestSQSReceiveMessage() throws Exception {
AppSignalsConstants.FAULT_METRIC,
AppSignalsConstants.LATENCY_METRIC));

var localService = getApplicationOtelServiceName();
var localOperation = "InternalOperation";
// ReceiveMessage does not capture aws.queue.name
String target = null;
// Consumer traces for SQS behave like a Server span (they create the local aws service
// attributes), but have RPC attributes like a client span.
assertSpanConsumerAttributes(
traces,
sqsSpanName("ReceiveMessage"),
"some-queue process",
getSqsRpcServiceName(),
"InternalOperation",
getApplicationOtelServiceName(),
Expand All @@ -1103,27 +1139,24 @@ protected void doTestSQSReceiveMessage() throws Exception {
200,
testSQSReceiveMessageExtraAssertions(response.contentUtf8()));

// SQS consumer spans do not produce metrics.
// Checking that there is no metric that has a datapoint with consumer attributes
assertThat(metrics)
.noneSatisfy(
metric -> {
var dataPoints = metric.getMetric().getExponentialHistogram().getDataPointsList();
assertThat(dataPoints)
.anySatisfy(
dataPoint -> {
List<KeyValue> attributes = dataPoint.getAttributesList();
assertThat(attributes).isNotNull();
assertThat(attributes)
.anySatisfy(
attribute -> {
assertConsumerAwsAttributes(
attributes,
getApplicationOtelServiceName(),
"InternalOperation");
});
});
});
assertMetricConsumerAttributes(
metrics,
AppSignalsConstants.LATENCY_METRIC,
localService,
localOperation,
getSqsServiceName(),
"ReceiveMessage",
target,
5000.0);
assertMetricConsumerAttributes(
metrics,
AppSignalsConstants.ERROR_METRIC,
localService,
localOperation,
getSqsServiceName(),
"ReceiveMessage",
target,
0.0);
}

protected void doTestSQSError() throws Exception {
Expand All @@ -1143,7 +1176,7 @@ protected void doTestSQSError() throws Exception {

assertSpanProducerAttributes(
traces,
sqsSpanName("SendMessage"),
"error.test:8080 publish",
getSqsRpcServiceName(),
localService,
localOperation,
Expand Down Expand Up @@ -1202,7 +1235,7 @@ protected void doTestSQSFault() throws Exception {

assertSpanProducerAttributes(
traces,
sqsSpanName("SendMessage"),
"fault.test:8080 publish",
getSqsRpcServiceName(),
localService,
localOperation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected List<Startable> getApplicationDependsOnContainers() {
.withEnv("KAFKA_AUTO_CREATE_TOPICS_ENABLE", "false")
.withNetworkAliases("kafkaBroker")
.withNetwork(network)
.waitingFor(Wait.forLogMessage(".*started (kafka.server.KafkaServer).*", 1))
.waitingFor(Wait.forLogMessage(".* Kafka Server started .*", 1))
.withKraft();
return List.of(kafka);
}
Expand Down
Loading

0 comments on commit b5e7788

Please sign in to comment.