Skip to content

chore(tracer): cdk examples + e2e tests #347

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

Merged
merged 19 commits into from
Dec 28, 2021
Merged

Conversation

dreamorosi
Copy link
Contributor

@dreamorosi dreamorosi commented Dec 23, 2021

Description of your changes

  • Extracted cdk resources to create NodejsFunction & invoke it in its own cdk Construct to avoid repetition
  • Added cdk examples for Tracer
  • Updated examples & docs to use correct case (camelCase) & fixed captureLambdaHandler references
  • Added e2e tests in cdk

How to verify this change

Pull & checkout the branch, then cdk deploy the stack & review the resources & traces created.

Related issues, RFCs

#332

PR status

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

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
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • 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 tracer This item relates to the Tracer Utility labels Dec 23, 2021
@dreamorosi dreamorosi added this to the beta-release milestone Dec 23, 2021
@dreamorosi dreamorosi self-assigned this Dec 23, 2021
@flochaz
Copy link
Contributor

flochaz commented Dec 27, 2021

For examples, wondering if we shouldn't have more realistic tests, reading at them first made me thought they were e2e tests. I think we should have a more concrete use case using most of the feature of tracer to show the potential (and maybe 3 variations of them : decorator/manual/middleware). But not that much a per feature example ? just wondering ...

@dreamorosi dreamorosi changed the title chore(tracer): cdk examples chore(tracer): cdk examples + e2e tests Dec 27, 2021
@dreamorosi
Copy link
Contributor Author

dreamorosi commented Dec 27, 2021

For examples, wondering if we shouldn't have more realistic tests, reading at them first made me thought they were e2e tests. I think we should have a more concrete use case using most of the feature of tracer to show the potential (and maybe 3 variations of them : decorator/manual/middleware). But not that much a per feature example ? just wondering ...

Happy to discuss this offline but please take a look at the e2e tests I've implemented and let me know if that's more similar to what you mean.

@dreamorosi dreamorosi marked this pull request as ready for review December 27, 2021 18:12
@flochaz
Copy link
Contributor

flochaz commented Dec 27, 2021

For examples, wondering if we shouldn't have more realistic tests, reading at them first made me thought they were e2e tests. I think we should have a more concrete use case using most of the feature of tracer to show the potential (and maybe 3 variations of them : decorator/manual/middleware). But not that much a per feature example ? just wondering ...

Happy to discuss this offline but please take a look at the e2e tests I've implemented and let me know if that's more similar to what you mean.

e2e are great ! was just wondering if examples were not too redundant . but fine for now. will open a discussion

flochaz
flochaz previously approved these changes Dec 27, 2021
Comment on lines 19 to 26
Tracer has three global settings that can be used to configure its behavior:

Setting | Description | Environment variable | Constructor parameter
------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------
**Trace Enabled** | Explicitly enables/disables tracing | `POWERTOOLS_TRACE_ENABLED` | `enabled`
**Capture Responses** | Captures Lambda or method return as metadata | `POWERTOOLS_TRACER_CAPTURE_RESPONSE` | N/A
**Capture Errors** | Captures Lambda or method exception as metadata | `POWERTOOLS_TRACER_CAPTURE_ERROR` | N/A

Copy link
Contributor

Choose a reason for hiding this comment

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

So this bit has been changed in main, getting started section + settings. How will it look like once you merge?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will resolve the conflict & accept the version on main since I made this change several days ago before your PR was merged.

import { captureLambdaHandler, Tracer } from '@aws-lambda-powertools/tracer';

// Set environment variable to disable capture response
process.env.POWERTOOLS_TRACER_ERROR_RESPONSE = 'false';
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: what about provisioning env variables in CDK? I think this is what developers would do in prod
https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-lambda.Function.html#environment

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW happy to address this as part of the prod release milestone, in case you also agree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially declared them this way because of how I am creating the functions in the test setup (see here) but you are right, Customers would do it as you suggest so in the latest commit (7caeb28) I have included this in the test setup & also removed some redundant files.

import { captureLambdaHandler, Tracer } from '@aws-lambda-powertools/tracer';

// Set environment variable to disable capture response
process.env.POWERTOOLS_TRACER_CAPTURE_RESPONSE = 'false';
Copy link
Contributor

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.

Addressed in 7caeb28, see this comment.

"@aws-lambda-powertools/logger": "^0.2.0-beta.6",
"@aws-lambda-powertools/metrics": "^0.2.0-beta.6",
"@aws-lambda-powertools/tracer": "^0.2.0-beta.6",
"@aws-sdk/client-sts": "^3.43.0",
Copy link
Contributor

@saragerion saragerion Dec 28, 2021

Choose a reason for hiding this comment

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

Based on the semantic versioning annotation used in this package.json, every time we have a minor or major breaking change like this:
X.Z.X or Z.X.X
We will have to manually update these dependencies numbers. Can we make them more loose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Relaxed to get all beta versions (1320cec), my reasoning is that currently we might be bumping up version quite often and might want to include / have reflected these changes in the examples; once we exit beta we'll lock examples only to major releases or similar..

saragerion
saragerion previously approved these changes Dec 28, 2021
Copy link
Contributor

@saragerion saragerion left a comment

Choose a reason for hiding this comment

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

Left some minor comments, but looks good already!

@dreamorosi dreamorosi dismissed stale reviews from saragerion and flochaz via 7caeb28 December 28, 2021 13:03
saragerion
saragerion previously approved these changes Dec 28, 2021
ijemmy
ijemmy previously approved these changes Dec 28, 2021
@dreamorosi dreamorosi dismissed stale reviews from ijemmy and saragerion via 92e4ee3 December 28, 2021 15:01
@dreamorosi dreamorosi merged commit b69cfdd into main Dec 28, 2021
@dreamorosi dreamorosi deleted the chore/tracer_examples branch December 28, 2021 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation tracer This item relates to the Tracer Utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants