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

fix: updated CDK examples to remove old references & improve comments #439

Merged
merged 6 commits into from Jan 17, 2022

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Jan 6, 2022

Description of your changes

This PR sets up #425 and aims at:

How to verify this change

After #416 has been merged, checkout the branch, go to examples/cdk & run cdk deploy.

Related issues, RFCs

#435
#425

PR status

Is this ready for review?: YES
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

Breaking change checklist

N/A


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dreamorosi dreamorosi added documentation Improvements or additions to documentation all labels Jan 6, 2022
@dreamorosi dreamorosi added this to the production-ready-release milestone Jan 6, 2022
@dreamorosi dreamorosi added this to Pull Requests - Work in progress in Pull Requests via automation Jan 6, 2022
@dreamorosi dreamorosi self-assigned this Jan 6, 2022
@github-actions github-actions bot added the bug Something isn't working label Jan 6, 2022
@dreamorosi dreamorosi moved this from Pull Requests - Work in progress to Pull Requests - Review needed in Pull Requests Jan 6, 2022
Copy link
Contributor

@ijemmy ijemmy left a comment

Choose a reason for hiding this comment

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

The only major one is that we have try/catch without throwing an error. I am willing approve if that is addressed.

The rest are either minor/nit.

Comment on lines 54 to 56
try {
throw new Error('test');
// Add the response as metadata
res = { foo: 'bar' };
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. Why try/catch without throw?

Copy link
Contributor Author

@dreamorosi dreamorosi Jan 7, 2022

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one has the throw at L57.

examples/cdk/lib/example-function.MyFunctionWithMiddy.ts Outdated Show resolved Hide resolved
const sts = tracer.captureAWSClient(new STS());

// Here we are showing an example with manual instrumentation but you can do the same also with the captureLambdaHandler Middy Middleware and Class decorator
Copy link
Contributor

Choose a reason for hiding this comment

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

(minor) I am not aware of this. O.o

AFAI see, this is not mentioned in the documentation. Can we add it to the list in this section . Another PR is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The actual example, in this file, is from L4 to L11 since this example wants to demonstrate how to instrument an AWS SDK v2 client.

What I wanted to say with this comment is that even though this example uses manual instrumentation, you don't need to use this method specifically over others (Middy middleware, decorator). Essentially, as long as you instrument the AWS SDK client with tracer.capture* it'll be traced & appear as custom subsegment on X-Ray no matter how you write your function.

That's why in the docs the AWS SDK patching example only has these lines.

I included a function in the example just because otherwise the lines above alone wouldn't run as a Lambda function and the lines from L15 onwards are similar to manual method in the section you linked.

@michaelbrewer
Copy link
Contributor

As CDK V2 is GA, would it make sense to just start using it from the get go @dreamorosi ?

@dreamorosi
Copy link
Contributor Author

As CDK V2 is GA, would it make sense to just start using it from the get go @dreamorosi ?

Would love to, but at the moment we are relying on some classes that are not exported in v2, see this issue I've opened on the CDK repo.

Pull Requests automation moved this from Pull Requests - Review needed to Pull Requests - Approved and ready to be merged Jan 17, 2022
@dreamorosi dreamorosi merged commit 4cdaaea into main Jan 17, 2022
Pull Requests automation moved this from Pull Requests - Approved and ready to be merged to Pull Requests - Merged or Closed Jan 17, 2022
@dreamorosi dreamorosi deleted the fix/cdk_examples branch January 17, 2022 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
No open projects
Pull Requests
Pull Requests - Merged or Closed
Development

Successfully merging this pull request may close these issues.

Docs: CDK examples (metrics & tracer) have outdated references
4 participants