Skip to content

Commit 97d51b7

Browse files
add agent and extension version to layer description (#326)
* add agent and extension version to layer description * update serverless
1 parent c6ffcbe commit 97d51b7

File tree

6 files changed

+12311
-2740
lines changed

6 files changed

+12311
-2740
lines changed

extension/publish-layer.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function publish-layer-x86 {
3232
fi
3333

3434
for region in "${REGIONS_X86[@]}"; do
35-
publish_layer $EXTENSION_DIST_ZIP_X86_64 $region provided x86_64
35+
publish_layer $EXTENSION_DIST_ZIP_X86_64 $region provided x86_64 provided
3636
done
3737
}
3838

@@ -43,7 +43,7 @@ function publish-layer-arm64 {
4343
fi
4444

4545
for region in "${REGIONS_ARM[@]}"; do
46-
publish_layer $EXTENSION_DIST_ZIP_ARM64 $region provided arm64
46+
publish_layer $EXTENSION_DIST_ZIP_ARM64 $region provided arm64 provided
4747
done
4848
}
4949

libBuild.sh

+48-2
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,34 @@ function s3_prefix() {
205205
echo $name
206206
}
207207

208+
function agent_name_str() {
209+
local runtime=$1
210+
local agent_name
211+
212+
case $runtime in
213+
"provided")
214+
agent_name="provided"
215+
;;
216+
"nodejs18.x"|"nodejs20.x"|"nodejs22.x")
217+
agent_name="Node"
218+
;;
219+
"ruby3.2"|"ruby3.3")
220+
agent_name="Ruby"
221+
;;
222+
"java8.al2"|"java11"|"java17"|"java21")
223+
agent_name="Java"
224+
;;
225+
"python3.8"|"python3.9"|"python3.10"|"python3.11"|"python3.12"|"python3.13")
226+
agent_name="Python"
227+
;;
228+
*)
229+
agent_name="none"
230+
;;
231+
esac
232+
233+
echo $agent_name
234+
}
235+
208236
function hash_file() {
209237
if command -v md5sum &> /dev/null ; then
210238
md5sum $1 | awk '{ print $1 }'
@@ -218,7 +246,8 @@ function publish_layer {
218246
region=$2
219247
runtime_name=$3
220248
arch=$4
221-
249+
newrelic_agent_version=${5:-"none"}
250+
agent_name=$( agent_name_str $runtime_name )
222251
layer_name=$( layer_name_str $runtime_name $arch )
223252

224253
hash=$( hash_file $layer_archive | awk '{ print $1 }' )
@@ -243,11 +272,28 @@ function publish_layer {
243272
else arch_flag=""
244273
fi
245274

275+
base_description="New Relic Layer for ${runtime_name} (${arch})"
276+
277+
if [[ $newrelic_agent_version != "none" ]]; then
278+
extension_info=" with New Relic Extension v${EXTENSION_VERSION}"
279+
280+
if [[ $agent_name != "provided" ]]; then
281+
agent_info=" and ${agent_name} agent v${newrelic_agent_version}"
282+
else
283+
base_description="New Relic Layer for OS only runtime (${arch})"
284+
agent_info=""
285+
fi
286+
287+
description="${base_description}${extension_info}${agent_info}"
288+
else
289+
description="${base_description}."
290+
fi
291+
246292
echo "Publishing ${runtime_name} layer to ${region}"
247293
layer_version=$(aws lambda publish-layer-version \
248294
--layer-name ${layer_name} \
249295
--content "S3Bucket=${bucket_name},S3Key=${s3_key}" \
250-
--description "New Relic Layer for ${runtime_name} (${arch})" \
296+
--description "${description}"\
251297
--license-info "Apache-2.0" $arch_flag \
252298
--compatible-runtimes ${compat_list[*]} \
253299
--region "$region" \

nodejs/publish-layers.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ function build_wrapper {
2828
rm -rf $BUILD_DIR $ZIP
2929
mkdir -p $DIST_DIR
3030
npm install --prefix $BUILD_DIR newrelic@latest
31+
NEWRELIC_AGENT_VERSION=$(npm list newrelic --prefix $BUILD_DIR | grep newrelic@ | awk -F '@' '{print $2}')
32+
touch $DIST_DIR/nr-env
33+
echo "NEWRELIC_AGENT_VERSION=$NEWRELIC_AGENT_VERSION" > $DIST_DIR/nr-env
3134
mkdir -p $BUILD_DIR/node_modules/newrelic-lambda-wrapper
3235
cp index.js $BUILD_DIR/node_modules/newrelic-lambda-wrapper
3336
mkdir -p $BUILD_DIR/node_modules/newrelic-esm-lambda-wrapper
@@ -44,13 +47,14 @@ function publish_wrapper {
4447
node_version=$1
4548
arch=$2
4649
ZIP=$DIST_DIR/nodejs${node_version}x.${arch}.zip
50+
source $DIST_DIR/nr-env
4751
if [ ! -f $ZIP ]; then
4852
echo "Package not found: ${ZIP}"
4953
exit 1
5054
fi
5155

5256
for region in "${REGIONS_ARM[@]}"; do
53-
publish_layer $ZIP $region nodejs${node_version}.x ${arch}
57+
publish_layer $ZIP $region nodejs${node_version}.x ${arch} $NEWRELIC_AGENT_VERSION
5458
done
5559
}
5660

0 commit comments

Comments
 (0)