Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Next.js] Mark Cold Start When Deployed To Vercel #7925

Open
Tracked by #9620
souredoutlook opened this issue Apr 20, 2023 · 4 comments
Open
Tracked by #9620

[Next.js] Mark Cold Start When Deployed To Vercel #7925

souredoutlook opened this issue Apr 20, 2023 · 4 comments
Assignees
Labels

Comments

@souredoutlook
Copy link
Member

Problem Statement

Customers would like to be able to differentiate events based on whether or not they are associated with a cold-start of a severless function.

The initial request specifically mentions Next.js when deployed to vercel.

Solution Brainstorm

Identifying whether or not the event context is from a cold-start using a tag may be very helpful.

Examples:

  • alerting on % change for transaction duration only when considering a hot-start
  • knowing whether an error is associated only with cold starts

cc @lforst

@lforst
Copy link
Member

lforst commented Apr 21, 2023

Generally, this would work by having a global variable (e.g. let visited) initialized to false. In our handler wrapper code, we would look at that variable and say if visited == false then coldStart else notColdStart. Right after we set visited to true.

I think this is a great idea but I still have my doubts about whether we can reliably do this from within the SDK:

  • Per definition, the global must be truly global so all handlers really share this global variable
  • What happens if one handler calls another one? The first one will examine coldStart the second one notColdStart.
  • Maybe we attach the context to the req object so that the case above is handled?

Anyhow I think this would be a banger blog post.

@github-actions
Copy link
Contributor

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@mydea
Copy link
Member

mydea commented Dec 10, 2024

Not sure if relevant, but this was recently implemented for the aws-lambda instrumentation here: open-telemetry/opentelemetry-js-contrib#2403 maybe we can find inspiration there. cc @lforst / @chargome

@chargome
Copy link
Member

Looks interesting, I guess we could port this implementation to our instrumentation as well if we can access process.env.AWS_LAMBDA_INITIALIZATION_TYPE 🤔

@linear linear bot added the Migrated label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants