Skip to content

Commit 3b7c9a6

Browse files
authored
add version.gradle.kts (#1122)
Issue #, if available: Description of changes: (copied from #1121) The current version for ADOT SDK and Lambda Layer releases is only provided manually in the release workflow and auto-generated by the nebula release plugin based on previous tags, but never specified in the code. Adding a version file will provide explicit version management and make it easier to track upcoming releases. adotVersion is currently set to 2.11.1-dev0, following the convention used by our other ADOT projects ([Python](https://github.com/aws-observability/aws-otel-python-instrumentation/blob/main/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/version.py), [.NET](https://github.com/aws-observability/aws-otel-dotnet-instrumentation/blob/main/src/AWS.Distro.OpenTelemetry.AutoInstrumentation/Version.cs), [NodeJS](https://github.com/aws-observability/aws-otel-js-instrumentation/blob/629faf5d1608e6fd803f9b2c2e15d8c26ff7b40a/package.json#L3)). The ADOT Lambda layer was previously given a version name after the upstream OpenTelemetry instrumentation. For example, for the most recent 2.11.1 release -- which still depends on OpenTelemetry Java Instrumentation 2.11.0 -- logs the following upon startup: ``` INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.11.0-adot-lambda1-aws ``` This change has the Lambda layer's Otel agent consume the version provided in version.gradle.kts. For example, after building locally, the layer will now log: ``` INFO io.opentelemetry.javaagent.tooling.VersionLogger - opentelemetry-javaagent - version: 2.11.1-dev0-adot-lambda1-aws ``` which is the accurate version. Soon we will add pre-release and post-release workflows like the other language ADOT repos to automatically bump the version number. This is part of our work to align the release process for all 4 languages and streamline releases for future engineers. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent fb742d5 commit 3b7c9a6

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ nebulaRelease {
3737
addReleaseBranchPattern("""v\d+\.\d+\.x""")
3838
}
3939

40+
apply(from = "version.gradle.kts")
41+
4042
nexusPublishing {
4143
repositories {
4244
sonatype {
@@ -71,7 +73,7 @@ allprojects {
7173
ktlint("1.4.0").editorConfigOverride(mapOf("indent_size" to "2", "continuation_indent_size" to "2"))
7274

7375
// Doesn't support pluginManagement block
74-
targetExclude("settings.gradle.kts")
76+
targetExclude("settings.gradle.kts", "version.gradle.kts")
7577

7678
if (!project.path.startsWith(":sample-apps:")) {
7779
licenseHeaderFile("${rootProject.projectDir}/config/license/header.java", "plugins|include|import")

lambda-layer/build-layer.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,20 @@ set -e
44
SOURCEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
55

66

7+
## Get ADOT version
8+
echo "Info: Getting ADOT Version"
9+
pushd "$SOURCEDIR"/..
10+
version=$(./gradlew -q printVersion)
11+
echo "Found ADOT Version: ${version}"
12+
popd
13+
714
## Get OTel version
815
echo "Info: Getting OTEL Version"
916
file="$SOURCEDIR/../.github/patches/versions"
10-
version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file")
11-
echo "Found OTEL Version: ${version}"
17+
otel_instrumentation_version=$(awk -F'=v' '/OTEL_JAVA_INSTRUMENTATION_VERSION/ {print $2}' "$file")
18+
echo "Found OTEL Version: ${otel_instrumentation_version}"
1219
# Exit if the version is empty or null
13-
if [[ -z "$version" ]]; then
20+
if [[ -z "$otel_instrumentation_version" ]]; then
1421
echo "Error: Version could not be found in ${file}."
1522
exit 1
1623
fi
@@ -20,7 +27,7 @@ fi
2027
echo "Info: Cloning and Patching OpenTelemetry Java Instrumentation Repository"
2128
git clone https://github.com/open-telemetry/opentelemetry-java-instrumentation.git
2229
pushd opentelemetry-java-instrumentation
23-
git checkout v${version} -b tag-v${version}
30+
git checkout v${otel_instrumentation_version} -b tag-v${otel_instrumentation_version}
2431

2532
# This patch is for Lambda related context propagation
2633
patch -p1 < "$SOURCEDIR"/patches/opentelemetry-java-instrumentation.patch
@@ -56,7 +63,7 @@ popd
5663

5764
## Build ADOT Lambda Java SDK Layer Code
5865
echo "Info: Building ADOT Lambda Java SDK Layer Code"
59-
./gradlew build -PotelVersion=${version}
66+
./gradlew build -PotelVersion=${otel_instrumentation_version} -Pversion=${version}
6067

6168

6269
## Copy ADOT Java Agent downloaded using Gradle task and bundle it with the Lambda handler script

lambda-layer/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ val javaagentDependency by configurations.creating {
2727
extendsFrom()
2828
}
2929

30+
val version: String by project
3031
val otelVersion: String by project
3132

3233
dependencies {
@@ -35,7 +36,7 @@ dependencies {
3536
// Already included in wrapper so compileOnly
3637
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
3738
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-aws")
38-
javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:$otelVersion-adot-lambda1")
39+
javaagentDependency("software.amazon.opentelemetry:aws-opentelemetry-agent:$version-adot-lambda1")
3940
}
4041

4142
tasks.register<Copy>("download") {

version.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
val adotVersion = "2.18.0-dev0"
17+
18+
allprojects {
19+
version = if (project.hasProperty("release.version")) {
20+
project.property("release.version") as String
21+
} else {
22+
adotVersion
23+
}
24+
}

0 commit comments

Comments
 (0)