sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Automatically instrument profiling for Node and Python when Sentry is set up via the Lambda Layer

Open cstavitsky opened this issue 9 months ago • 5 comments

Problem Statement

Currently the Lambda Layer setup instructions for serverless functions suggest that errors and performance is automatically enabled:

You can configure Sentry by setting these environment variables for your Lambda function: SENTRY_INITIAL_HANDLER: The handler function of your AWS Lambda funtion. SENTRY_DSN: This is set to the DSN of your project SENTRY_TRACES_SAMPLE_RATE: This sets the sampling rate for transactions.

(I assume this applies to both Node and Python. The Node lambda layer docs are not explicit about what you get out of the box)

Beyond the above, though, it seems profiling has to be manually set up for Node lambdas and I believe also for Python lambdas. This manual step can be difficult when a customer has, say 1000 lambdas and doesn't want to instrument them all with profiling individually.

Solution Brainstorm

Add a configuration option for Node and Python profiling in the lambda layer.

Product Area

Profiling

cstavitsky avatar Apr 25 '24 16:04 cstavitsky

Assigning to @getsentry/support for routing ⏲️

getsantry[bot] avatar Apr 25 '24 16:04 getsantry[bot]

Routing to @getsentry/product-owners-profiling for triage ⏲️

getsantry[bot] avatar Apr 25 '24 16:04 getsantry[bot]

@AbhiPrasad I guess this would mean that we inject the profiling integration based on an env variable. Is this something that we do in any other SDK and would there be a reason not to do this?

JonasBa avatar Apr 25 '24 22:04 JonasBa

I guess this would mean that we inject the profiling integration based on an env variable

This is a little more complicated because this means we would have to bundle in @sentry/profiling-node with the lambda layer we upload to AWS (also all of this lambda layer code is scary to touch).

I think the environmental variable is a great idea, but the bundling will cause us complexities, especially because there are 0 tests. I'm going to transfer this to the Sentry JavaScript SDK repo, but backlog because we have higher priority items atm. Maybe after v8 releases we can revisit.

AbhiPrasad avatar Apr 26 '24 00:04 AbhiPrasad

I guess this would mean that we inject the profiling integration based on an env variable

This is a little more complicated because this means we would have to bundle in @sentry/profiling-node with the lambda layer we upload to AWS (also all of this lambda layer code is scary to touch).

I think the environmental variable is a great idea, but the bundling will cause us complexities, especially because there are 0 tests. I'm going to transfer this to the Sentry JavaScript SDK repo, but backlog because we have higher priority items atm. Maybe after v8 releases we can revisit.

Oh yes, I was assuming the user would have to ensure the binaries are there, so some manual work would be required anyways. Bundling the binaries with the package isnt a good idea imo, I'd rather defer to manual instrumentation

JonasBa avatar Apr 26 '24 00:04 JonasBa

Is this feature still on the radar?

joelbarnard avatar Jul 04 '24 02:07 joelbarnard

@joelbarnard this feature is still backlogged at the moment. PRs are welcome if you'd like to implement this though!

AbhiPrasad avatar Jul 04 '24 14:07 AbhiPrasad