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

Tracing capabilities for @sentry/serverless. #2945

Merged
merged 3 commits into from
Oct 12, 2020

Conversation

marshall-lee
Copy link
Contributor

@marshall-lee marshall-lee commented Sep 30, 2020

Add tracing support for AWS Lambda & Google Cloud Functions.

Also I believe it fixes #2956.

@marshall-lee marshall-lee marked this pull request as draft September 30, 2020 17:35
@kamilogorek
Copy link
Contributor

@marshall-lee ping me once it's done or just ready for a review (not sure how you personally use drafts)

@marshall-lee marshall-lee force-pushed the serverless/tracing branch 3 times, most recently from bc19693 to a3620c9 Compare October 5, 2020 16:52
@marshall-lee
Copy link
Contributor Author

@kamilogorek It's ready for review!

Few notes from me:

  • Not sure where to put awsresources module. Now it resides in packages/serverless but in general it could be used anywhere, it's not strictly required to use it only with aws lambda.
  • I wanted to re-define defaultIntegrations() for @sentry/serverless and put new AWSResources() there but @sentry/serverless is not just for aws lambda. What do you think about making @sentry/serverless/awslambda export all the @sentry/node stuff but with overridden defaultIntegrations()?

@marshall-lee marshall-lee marked this pull request as ready for review October 5, 2020 17:10
@ghost
Copy link

ghost commented Oct 5, 2020 via email

@marshall-lee marshall-lee force-pushed the serverless/tracing branch 3 times, most recently from 7a9bb4d to 19b6573 Compare October 7, 2020 14:34
packages/serverless/src/awslambda.ts Outdated Show resolved Hide resolved
packages/serverless/src/gcpfunction.ts Outdated Show resolved Hide resolved
packages/serverless/src/gcpfunction.ts Outdated Show resolved Hide resolved
packages/serverless/src/gcpfunction.ts Outdated Show resolved Hide resolved
@HazAT
Copy link
Member

HazAT commented Oct 9, 2020

@marshall-lee Can I give it another pass?

@marshall-lee marshall-lee force-pushed the serverless/tracing branch 2 times, most recently from 69d33a4 to f928566 Compare October 9, 2020 11:26
@marshall-lee
Copy link
Contributor Author

@HazAT

@marshall-lee Can I give it another pass?

yes

Copy link
Member

@HazAT HazAT left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Awesome stuff, especially the tests.

The only thing I would ask (since I don't have a test-setup now), could you provide screenshots of Transactions in Sentry to see this in action and how it looks like?

@marshall-lee
Copy link
Contributor Author

@HazAT Thanks! I will provide a series of screencasts later, I'm working on it.

@marshall-lee
Copy link
Contributor Author

Some demos:

  1. Simple transaction in AWS Lambda: https://imgur.com/a/pEubxuE

  2. Transaction in AWS Lambda with two sequentials nested spans: https://imgur.com/a/2MRNNW8

  3. Transaction in AWS Lambda with two concurrent nested spans: https://imgur.com/fvcCCk5

  4. GCP Function transaction: https://imgur.com/a/Lf9uLwL

  5. GCP Function error capture: https://imgur.com/a/amXdzoL

@HazAT HazAT changed the title [WIP] Tracing capabilities for @sentry/serverless. Tracing capabilities for @sentry/serverless. Oct 12, 2020
@marshall-lee marshall-lee force-pushed the serverless/tracing branch 3 times, most recently from 598aea5 to c8a90f0 Compare October 12, 2020 10:03
Copy link
Contributor

@kamilogorek kamilogorek left a comment

Choose a reason for hiding this comment

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

Awesome work, thank you! My questions are just nitpicking, so other than that this PR should be good to go.

If you also want to trace performance of all the incoming requests and also outgoing AWS service requests, just set the `tracesSampleRate` option.

```javascript
import * as Sentry from '@sentry/serverless/awslambda';
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it should either say:

import * as Sentry from '@sentry/serverless/awslambda';
Sentry.init(...);

or

import * as Sentry from '@sentry/serverless';
Sentry.AWSLambda.init(...);

What about tree-shaking? If one is using AWSLambda, will it strip the GCPFunction code down?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

import * as Sentry from '@sentry/serverless/awslambda' was a typo. It was intended to be:

import * as Sentry from '@sentry/serverless';
Sentry.AWSLambda.init(...);

As for tree-shaking, I need to check it.

packages/serverless/src/awslambda.ts Outdated Show resolved Hide resolved
packages/serverless/src/gcpfunction/http.ts Show resolved Hide resolved
@kamilogorek
Copy link
Contributor

@marshall-lee it tree-shakes perfectly, you don't need to verify it anymore. Thanks!

@kamilogorek kamilogorek merged commit af71624 into getsentry:master Oct 12, 2020
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.

Synchronous Lambda callback causes undesirable second captureException call
3 participants