fix(aws-lambda): reduced cold start duration#2321
Open
aryamohanan wants to merge 18 commits intomainfrom
Open
Conversation
aryamohanan
commented
Feb 2, 2026
kirrg001
reviewed
Feb 2, 2026
kirrg001
reviewed
Feb 2, 2026
kirrg001
reviewed
Feb 2, 2026
kirrg001
reviewed
Feb 2, 2026
packages/core/src/tracing/opentelemetry-instrumentations/index.js
Outdated
Show resolved
Hide resolved
kirrg001
reviewed
Feb 3, 2026
kirrg001
reviewed
Feb 3, 2026
| const { AsyncHooksContextManager } = require('@opentelemetry/context-async-hooks'); | ||
| const { W3CTraceContextPropagator, hrTimeDuration, hrTimeToMilliseconds } = require('@opentelemetry/core'); | ||
| const api = require('@opentelemetry/api'); | ||
| const { BasicTracerProvider } = require('@opentelemetry/sdk-trace-base'); |
Contributor
There was a problem hiding this comment.
tracing/index.js
exports.preinit
otelIntegration.preInit()
wrap.js
exports.preInit(config)
if (config.preloadOpentelemetry)
AsyncHooksContextManager = require(@opentelemetry/context-async-hooks)
...
instrumentations.forEach
instrumentation.preInit()
exports.init
....
AsyncHooksContextManager = AsyncHooksContextManager || require(@opentelemetry/context-async-hooks)
fs.js
exports.preInit
fs = require(@opentelemetry/instrumentation-fs)
The goal should be that the instrumentation owns the name. IMO the instrumentation.js file is not needed rn.
kirrg001
reviewed
Feb 4, 2026
kirrg001
reviewed
Feb 4, 2026
Contributor
kirrg001
left a comment
There was a problem hiding this comment.
Commit suggestion:
fix(aws-lambda): reduced cold start duration
109cac9 to
3eeba1b
Compare
4accef3 to
70f9bf4
Compare
|
kirrg001
reviewed
Feb 6, 2026
Comment on lines
78
to
83
| Object.keys(instrumentations).forEach(k => { | ||
| const value = instrumentations[k]; | ||
| const instrumentation = require(`./${value.name}`); | ||
| instrumentation.init({ cls, api: api }); | ||
| value.module = instrumentation; | ||
| }); |
Contributor
There was a problem hiding this comment.
Can't we reuse initInstrumentations?
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.



This PR avoids lazy loading OpenTelemetry instrumentations in the AWS Lambda environment.
In AWS Lambda, lazy loading causes OpenTelemetry instrumentations to be initialized during the first invocation, which adds 1900–2100 ms of latency to cold starts and increases billable execution time.
To address this, instrumentations are preloaded during the Lambda initialization step instead of being loaded lazily at runtime.
With this change, cold start overhead is significantly reduced, bringing initialization time down from approximately 1900 ms to 500 ms, resulting in faster executions and lower costs in AWS Lambda environments.
Ref: https://ibm.ent.box.com/notes/2107188531951
https://jsw.ibm.com/browse/INSTA-74767