Skip to content

Java agent layer#460

Merged
obenkenobi merged 22 commits intomasterfrom
java-agent-layer
Apr 9, 2026
Merged

Java agent layer#460
obenkenobi merged 22 commits intomasterfrom
java-agent-layer

Conversation

@obenkenobi
Copy link
Copy Markdown
Contributor

@obenkenobi obenkenobi commented Mar 25, 2026

Description

New lambda layer publish workflow that attatches the New Relic Java Agent.
This acts as an alternative Java solution to the Open Tracing layer.

There will be a full agent layer and a slim agent layer which has less visibility to improve cold start performance.

This deploys lambda layers with the expected ARNs (version section will increment and region can be changed):

arn:aws:us-east-1:451483290750:layer:NewRelicAgentJava:1

arn:aws:us-east-1:451483290750:layer:NewRelicAgentJavaARM64:1

arn:aws:us-east-1:451483290750:layer:NewRelicAgentJava-slim:1

arn:aws:us-east-1:451483290750:layer:NewRelicAgentJavaARM64-slim:1

Releases with the tag format v**_java-agent should trigger deploying the Java Agent layer.

Github Issues

newrelic/newrelic-java-agent#2725
newrelic/newrelic-java-agent#2658

Comment on lines +10 to +30
runs-on: ubuntu-latest
steps:
- name: Check Tag
id: java-agent-check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+(\.[0-9]+)*_java-agent ]]; then
echo "match=true" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64, amd64
- name: Publish Java Agent Layer
if: steps.java-agent-check-tag.outputs.match == 'true'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
cd java-agent
./publish-layers.sh No newline at end of file

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 19 days ago

In general, the problem is fixed by defining explicit permissions for the workflow or specific job, limiting the GITHUB_TOKEN to only what is required. For this workflow, the steps only need to read repository contents (for actions/checkout) and do not require any write operations via GITHUB_TOKEN. Therefore, we can safely set contents: read as the job (or workflow) permissions.

The best minimal change without altering functionality is to add a permissions: block at the job level for publish-java-agent. This keeps the change tightly scoped and clearly associated with the job CodeQL flagged. We will insert:

    permissions:
      contents: read

directly under runs-on: ubuntu-latest in .github/workflows/publish-java-agent.yml. No additional imports or methods are required, because this is purely a YAML configuration change for GitHub Actions.

Suggested changeset 1
.github/workflows/publish-java-agent.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-java-agent.yml b/.github/workflows/publish-java-agent.yml
--- a/.github/workflows/publish-java-agent.yml
+++ b/.github/workflows/publish-java-agent.yml
@@ -8,6 +8,8 @@
 jobs:
   publish-java-agent:
     runs-on: ubuntu-latest
+    permissions:
+      contents: read
     steps:
       - name: Check Tag
         id: java-agent-check-tag
EOF
@@ -8,6 +8,8 @@
jobs:
publish-java-agent:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check Tag
id: java-agent-check-tag
Copilot is powered by AI and may make mistakes. Always verify output.
@obenkenobi obenkenobi marked this pull request as ready for review March 30, 2026 17:39
Copilot AI review requested due to automatic review settings March 30, 2026 17:39
@obenkenobi obenkenobi changed the title Java agent layer [DO NOT MERGE] Java agent layer Mar 30, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new AWS Lambda layer packaging/publishing path for attaching the New Relic Java Agent (as an alternative to the existing OpenTracing Java layer approach).

Changes:

  • Extend libBuild.sh to support a new java runtime for layer naming, S3 prefixing, compatible runtimes, and ECR publishing flags.
  • Introduce java-agent/ scripts to build (full + slim) and publish the Java agent layers, plus handler wrappers and defaults.
  • Add a GitHub Actions workflow to publish the Java agent layers on v*_java-agent tags.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
libBuild.sh Adds java (agent) runtime handling for naming, S3 prefix, compatible runtimes, and ECR publishing.
java-agent/versions.sh Pins the Java agent version used for downloads/builds.
java-agent/build-layers.sh Builds full/slim Java agent layer zip artifacts.
java-agent/publish-layers.sh Publishes the built layer zips to all regions + ECR.
java-agent/lib-handler.sh Wrapper logic to detect Java version and set JAVA_TOOL_OPTIONS + New Relic env defaults.
java-agent/java-handler-slim Slim handler wrapper enabling lite-mode-related settings.
java-agent/java-handler-full Full handler wrapper to attach the agent.
java-agent/README.md Local build/publish instructions for the new Java agent layer.
.github/workflows/publish-java-agent.yml CI workflow to publish Java agent layers on tag pushes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@Sashwatdas123 Sashwatdas123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for raising this pr

@obenkenobi obenkenobi merged commit 1a58482 into master Apr 9, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants