Skip to content

Commit

Permalink
Merge pull request #846 from zzhlogin/otel_patch
Browse files Browse the repository at this point in the history
Add local patch script.
  • Loading branch information
srprash authored Jul 17, 2024
2 parents d685481 + 7df2595 commit e5428dd
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ documentation, we really appreciate your help. Take a look through this document
experience with your contribution.


## Build ADOT Java Agent Locally

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:

```bash
./scripts/local_patch.sh
./gradlew build
```


## Reporting Bugs/Feature Requests

We're always happy to hear about any bugs or features requests using GitHub issues.
Expand Down
3 changes: 3 additions & 0 deletions appsignals-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ From the root of this project execute:
## login to public ECR
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
# Run the patching script
./scripts/local_patch.sh
# Run the tests
./gradlew appsignals-tests:contract-tests:contractTests
```
83 changes: 83 additions & 0 deletions scripts/local_patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash
# Enable debug mode, fail on any command that fail in this script and fail on unset variables
set -x -e -u

if [[ ! -f .github/patches/versions ]]; then
echo "No versions file found. Skipping patching"
exit 0
fi

rm -rf ~/.m2/repository/
source .github/patches/versions


# Patching opentelemetry-java
OTEL_JAVA_PATCH=".github/patches/opentelemetry-java.patch"
if [[ -f "$OTEL_JAVA_PATCH" ]]; then
echo "Patching opentelemetry-java"
git clone https://github.com/open-telemetry/opentelemetry-java.git
cd opentelemetry-java

echo "Checking out tag ${OTEL_JAVA_VERSION}"
git checkout ${OTEL_JAVA_VERSION} -b tag-${OTEL_JAVA_VERSION}
patch -p1 < ../${OTEL_JAVA_PATCH}
git commit -a -m "ADOT Patch release"

echo "Building patched opentelemetry-java"
./gradlew clean assemble
./gradlew publishToMavenLocal
cd -

echo "Cleaning up opentelemetry-java"
rm -rf opentelemetry-java
else
echo "Skiping patching opentelemetry-java"
fi


# Patching opentelemetry-java-contrib
OTEL_JAVA_CONTRIB_PATCH=".github/patches/opentelemetry-java-contrib.patch"
if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
echo "Patching opentelemetry-java-contrib"
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
cd opentelemetry-java-contrib

echo "Checking out tag ${OTEL_JAVA_CONTRIB_VERSION}"
git checkout ${OTEL_JAVA_CONTRIB_VERSION} -b tag-${OTEL_JAVA_CONTRIB_VERSION}
patch -p1 < "../${OTEL_JAVA_CONTRIB_PATCH}"
git commit -a -m "ADOT Patch release"

echo "Building patched opentelemetry-java-contrib"
./gradlew clean assemble
./gradlew publishToMavenLocal
cd -

echo "Cleaning up opentelemetry-java-contrib"
rm -rf opentelemetry-java-contrib
else
echo "Skipping patching opentelemetry-java-contrib"
fi


# Patching opentelemetry-java-instrumentation
OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/opentelemetry-java-instrumentation.patch"
if [[ -f "$OTEL_JAVA_INSTRUMENTATION_PATCH" ]]; then
echo "Patching opentelemetry-java-instrumentation"
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
cd opentelemetry-java-instrumentation

echo "Checking out tag ${OTEL_JAVA_INSTRUMENTATION_VERSION}"
git checkout ${OTEL_JAVA_INSTRUMENTATION_VERSION} -b tag-${OTEL_JAVA_INSTRUMENTATION_VERSION}
patch -p1 < "../${OTEL_JAVA_INSTRUMENTATION_PATCH}"
git commit -a -m "ADOT Patch release"

echo "Building patched opentelemetry-java-instrumentation"
./gradlew clean assemble
./gradlew publishToMavenLocal
cd -

echo "Cleaning up opentelemetry-java-instrumentation"
rm -rf opentelemetry-java-instrumentation
else
echo "Skipping patching opentelemetry-java-instrumentation"
fi

0 comments on commit e5428dd

Please sign in to comment.