Serverless mode#2796
Merged
obenkenobi merged 95 commits intomainfrom Apr 1, 2026
Merged
Conversation
New DataSender impl that writes data to /tmp/newrelic-telemetry or st…
…ion-finishes Serverless POC: harvest data when transaction finishes
…erless Serverless POC: Disable JFR when serverless mode is enabled
Serverless Data Marshalling follows the agent spec
Serverless POC: All telemetry is combined into a single payload
…verless-enabled Serverless POC: Disable the jar collector when serverless mode is enabled
…rverless-constraints Add adaptive sampler changes for serverless mode
Serverless transaction naming, web transactions, and DT
…rless-api Refactor ServerlessApi to add ServerlessService
Add Implementation-Title-Alias to aws-lambda-java-core* instr modules
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2796 +/- ##
============================================
+ Coverage 70.32% 70.65% +0.33%
- Complexity 10457 10620 +163
============================================
Files 873 881 +8
Lines 42287 42913 +626
Branches 6419 6486 +67
============================================
+ Hits 29740 30322 +582
- Misses 9645 9668 +23
- Partials 2902 2923 +21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
All lambda core modules use same alias
…ic-java-agent into serverless-mode
jtduffy
previously approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Introduces serverless mode for the agent as according to the agent spec.
Enabling Serverless Node
You should only enable serverless mode in an AWS Lambda environment.
To enable serverless mode either
NEW_RELIC_SERVERLESS_MODE_ENABLEDis set to true or your AWS lambda environment already provides a setAWS_LAMBDA_FUNCTION_NAMEvariable.APM mode detection
The lambda detects if APM mode is available if
NEW_RELIC_APM_LAMBDA_MODEis set totrueTransaction Naming
Transaction naming is handled in our 2 instrumentation modules:
aws-lambda-java-core-1.2.0andaws-lambda-java-core-events-1.2.0. These target theaws-lambda-java-corelibrary if they are using theRequestHandlerinterface.Our
aws-lambda-java-core-1.2.0instrumentation module by default set the function name to be in the format:${WebTransaction or OtherTransaction}/Function/${functionName}Our
aws-lambda-java-core-events-1.2.0also sets the function name to be in the above format. However if APM mode is enabled, the format changes to:${WebTransaction or OtherTransaction}/Function/${eventSourceType} ${functionName}Web Transactions
If your event source is of the following:
The lambda will be treated as a web transaction.
Event Source Parsing
Our new
aws-lambda-java-core-events-1.2.0instrumentation parses event source information and extracts information added as agent attributes. Please refer to the agent spec for more detailsDistributed tracing
Our distributed tracing has not changed its functionality in serverless mode. However we do accept inbound headers in web transactions.
Adaptive Sampling Changes
The adaptive sampler now begins its cycle lazily when the first transaction is hit.
Metadata
Our
aws-lambda-java-core-1.2.0captures lambda ARNs and function version which is reported into both transaction agent attributes and as agent metadata.Harvest Cycle and Data Marshalling
The biggest change in serverless mode is its methodology of data marshalling.
Our harvest cycle is altered to only harvest if a transaction is finished.
When harvesting, our payloads are written to
/tmp/newrelic-telemetryand to STDOUT so it is picked up by Cloudwatch.You can refer to the agent spec regarding the payload's format. It is broken down into 2 major parts, metadata and encoded data and is formatted as a json string.
The metadata includes data about the function, agent, and environment. That portion is never compressed.
Here is an example json:
The encoded data is all other data (i.e. metrics, traces, and events). It is not compressed when sent to cloudwatch but it is when sent to
/tmp/newrelic-telemetry. When it is compressed, it is compressed using gzipn and then encoded with baset64.Here is an example pre-compression payload:
DIsabled Features
JFR and Jar Collection is currently disabled. This may be re-enabled per feature request.
What is not included?
We do not include a
lambda_handler/set_lambda_handlerAPI. This is because our auto-instrumentation handles that work for us. In the future we may want to support such API for slim lambda layers.In addition serverless mode alone does affect configuration for span event collection, logging, slow sql traces, and collecting transactions traces. This is handled in our lambda layer start scripts.
In our lambda layer start scripts, by default slow sql traces, span event collections, and collecting transaction traces are enabled.
Our lambda layer start scripts will also disable log forwarding. This is because analytic log events are ignored by the backend making it so such events provide unneeded overhead.
Related Github Issue
#2704