Skip to content

Commit 39f1f4e

Browse files
committed
Add local patch script.
1 parent d685481 commit 39f1f4e

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ documentation, we really appreciate your help. Take a look through this document
55
experience with your contribution.
66

77

8+
## Build ADOT Java Agent Locally
9+
10+
This ADOT repository includes patching logic for OpenTelemetry upstream repositories. To build the ADOT Java agent locally, you need to run the patching script first:
11+
12+
```bash
13+
./scripts/local_patch.sh
14+
./gradlew build
15+
```
16+
17+
818
## Reporting Bugs/Feature Requests
919

1020
We're always happy to hear about any bugs or features requests using GitHub issues.

appsignals-tests/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ From the root of this project execute:
4545
## login to public ECR
4646
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
4747
48+
# Run the patching script
49+
./scripts/local_patch.sh
50+
4851
# Run the tests
4952
./gradlew appsignals-tests:contract-tests:contractTests
5053
```

scripts/local_patch.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# Enable debug mode, fail on any command that fail in this script and fail on unset variables
3+
set -x -e -u
4+
5+
if [[ ! -f .github/patches/versions ]]; then
6+
echo "No versions file found. Skipping patching"
7+
exit 0
8+
fi
9+
10+
rm -rf ~/.m2/repository/
11+
source .github/patches/versions
12+
13+
14+
# Patching opentelemetry-java
15+
OTEL_JAVA_PATCH=".github/patches/opentelemetry-java.patch"
16+
if [[ -f "$OTEL_JAVA_PATCH" ]]; then
17+
echo "Patching opentelemetry-java"
18+
git clone https://github.com/open-telemetry/opentelemetry-java.git
19+
cd opentelemetry-java
20+
21+
echo "Checking out tag ${OTEL_JAVA_VERSION}"
22+
git checkout ${OTEL_JAVA_VERSION} -b tag-${OTEL_JAVA_VERSION}
23+
patch -p1 < ../${OTEL_JAVA_PATCH}
24+
git commit -a -m "ADOT Patch release"
25+
26+
echo "Building patched opentelemetry-java"
27+
./gradlew clean assemble
28+
./gradlew publishToMavenLocal
29+
cd -
30+
31+
echo "Cleaning up opentelemetry-java"
32+
rm -rf opentelemetry-java
33+
else
34+
echo "Skiping patching opentelemetry-java"
35+
fi
36+
37+
38+
# Patching opentelemetry-java-contrib
39+
OTEL_JAVA_CONTRIB_PATCH=".github/patches/opentelemetry-java-contrib.patch"
40+
if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
41+
echo "Patching opentelemetry-java-contrib"
42+
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
43+
cd opentelemetry-java-contrib
44+
45+
echo "Checking out tag ${OTEL_JAVA_CONTRIB_VERSION}"
46+
git checkout ${OTEL_JAVA_CONTRIB_VERSION} -b tag-${OTEL_JAVA_CONTRIB_VERSION}
47+
patch -p1 < "../${OTEL_JAVA_CONTRIB_PATCH}"
48+
git commit -a -m "ADOT Patch release"
49+
50+
echo "Building patched opentelemetry-java-contrib"
51+
./gradlew clean assemble
52+
./gradlew publishToMavenLocal
53+
cd -
54+
55+
echo "Cleaning up opentelemetry-java-contrib"
56+
rm -rf opentelemetry-java-contrib
57+
else
58+
echo "Skipping patching opentelemetry-java-contrib"
59+
fi
60+
61+
62+
# Patching opentelemetry-java-instrumentation
63+
OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/opentelemetry-java-instrumentation.patch"
64+
if [[ -f "$OTEL_JAVA_INSTRUMENTATION_PATCH" ]]; then
65+
echo "Patching opentelemetry-java-instrumentation"
66+
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
67+
cd opentelemetry-java-instrumentation
68+
69+
echo "Checking out tag ${OTEL_JAVA_INSTRUMENTATION_VERSION}"
70+
git checkout ${OTEL_JAVA_INSTRUMENTATION_VERSION} -b tag-${OTEL_JAVA_INSTRUMENTATION_VERSION}
71+
patch -p1 < "../${OTEL_JAVA_INSTRUMENTATION_PATCH}"
72+
git commit -a -m "ADOT Patch release"
73+
74+
echo "Building patched opentelemetry-java-instrumentation"
75+
./gradlew clean assemble
76+
./gradlew publishToMavenLocal
77+
cd -
78+
79+
echo "Cleaning up opentelemetry-java-instrumentation"
80+
rm -rf opentelemetry-java-instrumentation
81+
else
82+
echo "Skipping patching opentelemetry-java-instrumentation"
83+
fi

0 commit comments

Comments
 (0)