Skip to content

Commit c090ce8

Browse files
Jeel-mehtaJeel Mehtayiyuan-hejj22ee
authored
UDP Exporter release workflow (#1049)
*Description of changes:* The validation steps for the GitHub workflow intended to manually trigger a UDP exporter release to Maven Central includes: The workflow will first build the UDP exporter. The workflow will then set up and run an instance of X-Ray daemon. Following setup, it will run a validation app to send traces to X-Ray daemon via UDP exporter. Finally, it will execute a validation step to verify that daemon received the traces. TODO: 1. Add a publish to Maven Central step to release workflow. Test workflow link: https://github.com/aws-observability/aws-otel-java-instrumentation/actions/runs/14043198263 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Jeel Mehta <jeelmm@amazon.com> Co-authored-by: Michael He <53622546+yiyuan-he@users.noreply.github.com> Co-authored-by: Jonathan Lee <107072447+jj22ee@users.noreply.github.com> Co-authored-by: jjllee <jjllee@amazon.com>
1 parent dfcb05f commit c090ce8

File tree

14 files changed

+300
-38
lines changed

14 files changed

+300
-38
lines changed

.github/workflows/pr-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ jobs:
8888
with:
8989
arguments: build integrationTests --stacktrace -PenableCoverage=true -PlocalDocker=true
9090

91+
- name: Build and Test UDP exporter
92+
run: |
93+
./gradlew build -p exporters/aws-opentelemetry-xray-udp-span-exporter
94+
9195
- name: Set up Java version for tests
9296
uses: actions/setup-java@v4
9397
with:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release ADOT X-Ray UDP Exporter
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: The version to tag the release with, e.g., 1.2.0
8+
required: true
9+
type: string
10+
11+
permissions:
12+
id-token: write
13+
14+
jobs:
15+
validate-udp-exporter-e2e-test:
16+
name: "Validate X-Ray UDP Exporter E2E Test Succeeds"
17+
uses: ./.github/workflows/udp-exporter-e2e-test.yml
18+
secrets: inherit
19+
permissions:
20+
id-token: write
21+
22+
release-udp-exporter:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout Repo @ SHA - ${{ github.sha }}
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Java
29+
uses: actions/setup-java@v3
30+
with:
31+
java-version: '17'
32+
distribution: 'temurin'
33+
cache: 'gradle'
34+
35+
- name: Build and Test UDP exporter
36+
run: |
37+
./gradlew build -p exporters/aws-opentelemetry-xray-udp-span-exporter
38+
39+
# TODO: Steps to publish to Maven Central
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Test ADOT X-Ray UDP Exporter
2+
on:
3+
workflow_call:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
id-token: write
10+
11+
jobs:
12+
udp-exporter-e2e-test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo @ SHA - ${{ github.sha }}
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Java
19+
uses: actions/setup-java@v3
20+
with:
21+
java-version: '17'
22+
distribution: 'temurin'
23+
cache: 'gradle'
24+
25+
- name: Configure AWS credentials for Testing Tracing
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
role-to-assume: ${{ secrets.XRAY_UDP_EXPORTER_TEST_ROLE }}
29+
aws-region: 'us-east-1'
30+
31+
- name: Download and run X-Ray Daemon
32+
run: |
33+
mkdir xray-daemon
34+
cd xray-daemon
35+
wget https://s3.us-east-2.amazonaws.com/aws-xray-assets.us-east-2/xray-daemon/aws-xray-daemon-linux-3.x.zip
36+
unzip aws-xray-daemon-linux-3.x.zip
37+
./xray -o -n us-east-2 -f ./daemon-logs.log --log-level debug &
38+
39+
- name: Publish UDP exporter to Maven Local
40+
id: build-udp-exporter
41+
working-directory: exporters/aws-opentelemetry-xray-udp-span-exporter
42+
run: |
43+
gradle build
44+
gradle publishToMavenLocal
45+
echo "xrayUdpSpanExporterVersion=$(gradle -q printVersion)" >> $GITHUB_OUTPUT
46+
47+
- name: Setup and Run Sample App in Background
48+
working-directory: sample-apps/integ-test-app
49+
run: |
50+
export XRAY_UDP_SPAN_EXPORTER_VERSION=${{ steps.build-udp-exporter.outputs.xrayUdpSpanExporterVersion }}
51+
echo "Running Sample App against X-Ray UDP Span Exporter version: $XRAY_UDP_SPAN_EXPORTER_VERSION"
52+
gradle build
53+
gradle bootRun &
54+
sleep 5
55+
56+
- name: Call Sample App Endpoint
57+
id: call-endpoint
58+
run: |
59+
echo "traceId=$(curl localhost:8080/test)" >> $GITHUB_OUTPUT
60+
61+
- name: Check if traces are successfully sent to AWS X-Ray
62+
run: |
63+
sleep 20
64+
# # Print Daemon Logs for debugging
65+
# cat xray-daemon/daemon-logs.log
66+
67+
traceId=${{ steps.call-endpoint.outputs.traceId }}
68+
numTracesFound=$(aws xray batch-get-traces --trace-ids $traceId --region us-east-2 | jq '.Traces' | jq length)
69+
if [[ numTracesFound -ne "1" ]]; then
70+
echo "TraceId $traceId not found in X-Ray."
71+
exit 1
72+
else
73+
echo "TraceId $traceId found in X-Ray."
74+
fi

exporters/aws-opentelemetry-xray-lambda-exporter/build.gradle.kts renamed to exporters/aws-opentelemetry-xray-udp-span-exporter/build.gradle.kts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ plugins {
1919
id("maven-publish")
2020
}
2121

22-
group = "software.amazon.distro.opentelemetry.exporter.xray.lambda"
22+
group = "software.amazon.distro.opentelemetry.exporter.xray.udp.trace"
2323
version = "0.1.0"
2424

2525
dependencies {
2626
implementation(platform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom:2.10.0"))
27-
compileOnly("io.opentelemetry:opentelemetry-api")
28-
compileOnly("io.opentelemetry:opentelemetry-sdk")
29-
compileOnly("io.opentelemetry:opentelemetry-exporter-otlp-common")
27+
implementation("io.opentelemetry:opentelemetry-sdk")
28+
implementation("io.opentelemetry:opentelemetry-exporter-otlp-common")
3029
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
31-
testImplementation("io.opentelemetry:opentelemetry-api")
3230
testImplementation("io.opentelemetry:opentelemetry-sdk")
3331
testImplementation("io.opentelemetry:opentelemetry-exporter-otlp-common")
3432
testImplementation(platform("org.junit:junit-bom:5.9.2"))
@@ -89,12 +87,18 @@ tasks.named<Jar>("sourcesJar") {
8987
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
9088
}
9189

90+
tasks.create("printVersion") {
91+
doLast {
92+
println(project.version.toString())
93+
}
94+
}
95+
9296
publishing {
9397
publications {
9498
create<MavenPublication>("mavenJava") {
9599
from(components["java"])
96100
groupId = project.group.toString()
97-
artifactId = "aws-opentelemetry-xray-lambda-exporter"
101+
artifactId = "aws-opentelemetry-xray-udp-span-exporter"
98102
version = project.version.toString()
99103
}
100104
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
rootProject.name = "aws-opentelemetry-xray-udp-span-exporter"
2+
3+
dependencyResolutionManagement {
4+
repositories {
5+
mavenCentral()
6+
mavenLocal()
7+
8+
maven {
9+
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
10+
}
11+
}
12+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
package software.amazon.distro.opentelemetry.exporter.xray.lambda;
16+
package software.amazon.distro.opentelemetry.exporter.xray.udp.trace;
1717

1818
import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler;
1919
import io.opentelemetry.sdk.common.CompletableResultCode;
@@ -37,16 +37,16 @@
3737
* specific information.
3838
*/
3939
@Immutable
40-
public class AwsXrayLambdaExporter implements SpanExporter {
40+
public class AwsXrayUdpSpanExporter implements SpanExporter {
4141

42-
private static final Logger logger = Logger.getLogger(AwsXrayLambdaExporter.class.getName());
42+
private static final Logger logger = Logger.getLogger(AwsXrayUdpSpanExporter.class.getName());
4343

4444
private final AtomicBoolean isShutdown = new AtomicBoolean();
4545

4646
private final UdpSender sender;
4747
private final String payloadPrefix;
4848

49-
AwsXrayLambdaExporter(UdpSender sender, String payloadPrefix) {
49+
AwsXrayUdpSpanExporter(UdpSender sender, String payloadPrefix) {
5050
this.sender = sender;
5151
this.payloadPrefix = payloadPrefix;
5252
}
@@ -94,4 +94,4 @@ UdpSender getSender() {
9494
String getPayloadPrefix() {
9595
return payloadPrefix;
9696
}
97-
}
97+
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
package software.amazon.distro.opentelemetry.exporter.xray.lambda;
16+
package software.amazon.distro.opentelemetry.exporter.xray.udp.trace;
1717

1818
import static java.util.Objects.requireNonNull;
1919

2020
import java.util.Map;
2121

22-
public final class AwsXrayLambdaExporterBuilder {
22+
public final class AwsXrayUdpSpanExporterBuilder {
2323

2424
private static final String DEFAULT_HOST = "127.0.0.1";
2525
private static final int DEFAULT_PORT = 2000;
@@ -41,7 +41,7 @@ public final class AwsXrayLambdaExporterBuilder {
4141
private static final String AWS_LAMBDA_FUNCTION_NAME_CONFIG = "AWS_LAMBDA_FUNCTION_NAME";
4242
private static final String AWS_XRAY_DAEMON_ADDRESS_CONFIG = "AWS_XRAY_DAEMON_ADDRESS";
4343

44-
public AwsXrayLambdaExporterBuilder setEndpoint(String endpoint) {
44+
public AwsXrayUdpSpanExporterBuilder setEndpoint(String endpoint) {
4545
requireNonNull(endpoint, "endpoint must not be null");
4646
try {
4747
this.sender = createSenderFromEndpoint(endpoint);
@@ -51,7 +51,7 @@ public AwsXrayLambdaExporterBuilder setEndpoint(String endpoint) {
5151
return this;
5252
}
5353

54-
public AwsXrayLambdaExporterBuilder setPayloadSampleDecision(TracePayloadSampleDecision decision) {
54+
public AwsXrayUdpSpanExporterBuilder setPayloadSampleDecision(TracePayloadSampleDecision decision) {
5555
this.tracePayloadPrefix =
5656
decision == TracePayloadSampleDecision.SAMPLED
5757
? FORMAT_OTEL_SAMPLED_TRACES_BINARY_PREFIX
@@ -67,7 +67,7 @@ private UdpSender createSenderFromEndpoint(String endpoint) {
6767
}
6868

6969
// For testing purposes
70-
AwsXrayLambdaExporterBuilder withEnvironmentVariables(Map<String, String> env) {
70+
AwsXrayUdpSpanExporterBuilder withEnvironmentVariables(Map<String, String> env) {
7171
this.environmentVariables = env;
7272
return this;
7373
}
@@ -77,7 +77,7 @@ Map<String, String> getEnvironmentVariables() {
7777
return environmentVariables;
7878
}
7979

80-
public AwsXrayLambdaExporter build() {
80+
public AwsXrayUdpSpanExporter build() {
8181
if (sender == null) {
8282
String endpoint = null;
8383

@@ -87,7 +87,7 @@ public AwsXrayLambdaExporter build() {
8787
if (endpoint != null && !endpoint.isEmpty()) {
8888
try {
8989
this.sender = createSenderFromEndpoint(endpoint);
90-
return new AwsXrayLambdaExporter(
90+
return new AwsXrayUdpSpanExporter(
9191
this.sender, PROTOCOL_HEADER + PROTOCOL_DELIMITER + tracePayloadPrefix);
9292
} catch (Exception e) {
9393
// Fallback to defaults if parsing fails
@@ -99,7 +99,7 @@ public AwsXrayLambdaExporter build() {
9999
// Use defaults if not in Lambda or if daemon address is invalid/unavailable
100100
this.sender = new UdpSender(DEFAULT_HOST, DEFAULT_PORT);
101101
}
102-
return new AwsXrayLambdaExporter(
102+
return new AwsXrayUdpSpanExporter(
103103
this.sender, PROTOCOL_HEADER + PROTOCOL_DELIMITER + tracePayloadPrefix);
104104
}
105105

@@ -109,7 +109,7 @@ private boolean isLambdaEnvironment() {
109109
}
110110

111111
// Only for testing
112-
AwsXrayLambdaExporterBuilder setSender(UdpSender sender) {
112+
AwsXrayUdpSpanExporterBuilder setSender(UdpSender sender) {
113113
this.sender = sender;
114114
return this;
115115
}
@@ -118,4 +118,4 @@ AwsXrayLambdaExporterBuilder setSender(UdpSender sender) {
118118
enum TracePayloadSampleDecision {
119119
SAMPLED,
120120
UNSAMPLED
121-
}
121+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* permissions and limitations under the License.
1414
*/
1515

16-
package software.amazon.distro.opentelemetry.exporter.xray.lambda;
16+
package software.amazon.distro.opentelemetry.exporter.xray.udp.trace;
1717

1818
import io.opentelemetry.sdk.common.CompletableResultCode;
1919
import java.io.IOException;

0 commit comments

Comments
 (0)