Skip to content

Commit 899f40e

Browse files
[AdaptiveSampling] Improve sampling rule propagation + improvements (#1186)
1 parent 22a807b commit 899f40e

File tree

9 files changed

+398
-164
lines changed

9 files changed

+398
-164
lines changed

.github/actions/patch-dependencies/action.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ runs:
4949
if [[ -f .github/patches/opentelemetry-java.patch ]]; then
5050
echo 'patch_otel_java=true' >> $GITHUB_ENV
5151
fi
52+
if [[ -f .github/patches/opentelemetry-java-instrumentation.patch ]]; then
53+
echo 'patch_otel_java_instrumentation=true' >> $GITHUB_ENV
54+
fi
5255
if [[ -f .github/patches/opentelemetry-java-contrib.patch ]]; then
5356
echo 'patch_otel_java_contrib=true' >> $GITHUB_ENV
5457
fi
@@ -97,3 +100,22 @@ runs:
97100
run: rm -rf opentelemetry-java-contrib
98101
if: ${{ env.patch_otel_java_contrib == 'true' }}
99102
shell: bash
103+
104+
- name: Build opentelemetry-java-instrumentation with tests
105+
uses: gradle/gradle-build-action@v2
106+
if: ${{ env.patch_otel_java_instrumentation == 'true' && inputs.run_tests != 'false' }}
107+
with:
108+
arguments: check -x spotlessCheck publishToMavenLocal
109+
build-root-directory: opentelemetry-java-instrumentation
110+
111+
- name: Build opentelemetry java instrumentation
112+
uses: gradle/gradle-build-action@v2
113+
if: ${{ env.patch_otel_java_instrumentation == 'true' && inputs.run_tests == 'false' }}
114+
with:
115+
arguments: publishToMavenLocal
116+
build-root-directory: opentelemetry-java-instrumentation
117+
118+
- name: cleanup opentelmetry-java-instrumentation
119+
run: rm -rf opentelemetry-java-instrumentation
120+
if: ${{ env.patch_otel_java_instrumentation == 'true' }}
121+
shell: bash

.github/patches/opentelemetry-java-contrib.patch

Lines changed: 287 additions & 142 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts
2+
index d020848503..88f0a60ac6 100644
3+
--- a/dependencyManagement/build.gradle.kts
4+
+++ b/dependencyManagement/build.gradle.kts
5+
@@ -100,7 +100,7 @@ val DEPENDENCIES = listOf(
6+
"commons-validator:commons-validator:1.9.0",
7+
"io.netty:netty:3.10.6.Final",
8+
"io.opentelemetry.contrib:opentelemetry-aws-resources:${otelContribVersion}",
9+
- "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:${otelContribVersion}",
10+
+ "io.opentelemetry.contrib:opentelemetry-aws-xray-propagator:1.39.0-alpha-adot1",
11+
"io.opentelemetry.contrib:opentelemetry-gcp-resources:${otelContribVersion}",
12+
"io.opentelemetry.contrib:opentelemetry-baggage-processor:${otelContribVersion}",
13+
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha",
14+
diff --git a/version.gradle.kts b/version.gradle.kts
15+
index a1cae43b4b..c1520e9947 100644
16+
--- a/version.gradle.kts
17+
+++ b/version.gradle.kts
18+
@@ -1,5 +1,5 @@
19+
-val stableVersion = "2.11.0"
20+
-val alphaVersion = "2.11.0-alpha"
21+
+val stableVersion = "2.11.0-adot1"
22+
+val alphaVersion = "2.11.0-adot1-alpha"
23+
24+
allprojects {
25+
if (findProperty("otel.stable") != "true") {
26+
--
27+
2.45.1
28+

.github/scripts/patch.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,16 @@ if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
4444
else
4545
echo "Skipping patching opentelemetry-java-contrib"
4646
fi
47+
48+
49+
OTEL_JAVA_INSTRUMENTATION_PATCH=".github/patches/opentelemetry-java-instrumentation.patch"
50+
if [[ -f "$OTEL_JAVA_INSTRUMENTATION_PATCH" ]]; then
51+
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
52+
cd opentelemetry-java-instrumentation
53+
git checkout ${OTEL_JAVA_INSTRUMENTATION_VERSION} -b tag-${OTEL_JAVA_INSTRUMENTATION_VERSION}
54+
patch -p1 < "../${OTEL_JAVA_INSTRUMENTATION_PATCH}"
55+
git commit -a -m "ADOT Patch release"
56+
cd -
57+
else
58+
echo "Skipping patching opentelemetry-java-instrumentation"
59+
fi

dependencyManagement/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data class DependencySet(val group: String, val version: String, val modules: Li
2727
val testSnapshots = rootProject.findProperty("testUpstreamSnapshots") == "true"
2828

2929
// This is the version of the upstream instrumentation BOM
30-
val otelVersion = "2.11.0"
30+
val otelVersion = "2.11.0-adot1"
3131
val otelSnapshotVersion = "2.12.0"
3232
val otelAlphaVersion = if (!testSnapshots) "$otelVersion-alpha" else "$otelSnapshotVersion-alpha-SNAPSHOT"
3333
val otelJavaAgentVersion = if (!testSnapshots) otelVersion else "$otelSnapshotVersion-SNAPSHOT"

lambda-layer/build-layer.sh

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22
set -e
33

44
SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
file="$SOURCEDIR/../.github/patches/versions"
6+
7+
contrib_version=$(awk -F'=v' '/OTEL_JAVA_CONTRIB_VERSION/ {print $2}' "$file")
8+
if [[ -n "$contrib_version" ]]; then
9+
echo "Found OTEL Contrib Version: ${contrib_version}"
10+
## Clone and Patch the OpenTelemetry Java contrib Repository
11+
echo "Info: Cloning and Patching OpenTelemetry Java contrib Repository"
12+
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
13+
pushd opentelemetry-java-contrib
14+
git checkout v${contrib_version} -b tag-v${contrib_version}
515

16+
# There is another patch in the .github/patches directory for other changes. We should apply them too for consistency.
17+
patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-contrib.patch
18+
19+
./gradlew publishToMavenLocal
20+
popd
21+
rm -rf opentelemetry-java-contrib
22+
fi
623

724
## Get OTel version
825
echo "Info: Getting OTEL Version"
9-
file="$SOURCEDIR/../.github/patches/versions"
1026
version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file")
1127
echo "Found OTEL Version: ${version}"
1228
# Exit if the version is empty or null
@@ -22,6 +38,9 @@ git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.g
2238
pushd opentelemetry-java-instrumentation
2339
git checkout v${version} -b tag-v${version}
2440

41+
# There is another patch in the .github/patches directory for other changes. We should apply them too for consistency.
42+
patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-instrumentation.patch
43+
2544
# This patch is for Lambda related context propagation
2645
patch -p1 < "$SOURCEDIR"/patches/opentelemetry-java-instrumentation.patch
2746

@@ -31,23 +50,6 @@ patch -p1 < "$SOURCEDIR"/patches/StreamHandlerInstrumentation.patch
3150
popd
3251
rm -rf opentelemetry-java-instrumentation
3352

34-
contrib_version=$(awk -F'=v' '/OTEL_JAVA_CONTRIB_VERSION/ {print $2}' "$file")
35-
if [[ -n "$contrib_version" ]]; then
36-
echo "Found OTEL Contrib Version: ${contrib_version}"
37-
## Clone and Patch the OpenTelemetry Java contrib Repository
38-
echo "Info: Cloning and Patching OpenTelemetry Java contrib Repository"
39-
git clone https://github.com/open-telemetry/opentelemetry-java-contrib.git
40-
pushd opentelemetry-java-contrib
41-
git checkout v${contrib_version} -b tag-v${contrib_version}
42-
43-
# There is another patch in the .github/patches directory for other changes. We should apply them too for consistency.
44-
patch -p1 < "$SOURCEDIR"/../.github/patches/opentelemetry-java-contrib.patch
45-
46-
./gradlew publishToMavenLocal
47-
popd
48-
rm -rf opentelemetry-java-contrib
49-
fi
50-
5153
## Build the ADOT Java from current source
5254
echo "Info: Building ADOT Java from current source"
5355
pushd "$SOURCEDIR"/..

lambda-layer/patches/aws-otel-java-instrumentation.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ index 9493189..6090207 100644
66
val testSnapshots = rootProject.findProperty("testUpstreamSnapshots") == "true"
77

88
// This is the version of the upstream instrumentation BOM
9-
-val otelVersion = "2.11.0"
9+
-val otelVersion = "2.11.0-adot1"
1010
+val otelVersion = "2.11.0-adot-lambda1"
1111
val otelSnapshotVersion = "2.12.0"
1212
val otelAlphaVersion = if (!testSnapshots) "$otelVersion-alpha" else "$otelSnapshotVersion-alpha-SNAPSHOT"

lambda-layer/patches/opentelemetry-java-instrumentation.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ index 7900c9a4d9..80383d7c22 100644
310310
--- a/version.gradle.kts
311311
+++ b/version.gradle.kts
312312
@@ -1,5 +1,5 @@
313-
-val stableVersion = "2.11.0"
314-
-val alphaVersion = "2.11.0-alpha"
313+
-val stableVersion = "2.11.0-adot1"
314+
-val alphaVersion = "2.11.0-adot1-alpha"
315315
+val stableVersion = "2.11.0-adot-lambda1"
316316
+val alphaVersion = "2.11.0-adot-lambda1-alpha"
317317

scripts/local_patch.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,28 @@ if [[ -f "$OTEL_JAVA_CONTRIB_PATCH" ]]; then
5656
rm -rf opentelemetry-java-contrib
5757
else
5858
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"
5983
fi

0 commit comments

Comments
 (0)