-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat(tracer): allow disabling result capture for decorators and middleware #1065
feat(tracer): allow disabling result capture for decorators and middleware #1065
Conversation
Hi @misterjoshua thank you for opening this PR. While we appreciate your bias for action a lot, we would really appreciate if next time you could give yourself and us both, and opportunity to discuss the design of the feature and the scope of the changes. According to the contributing guidelines (point 3 of the Summary) the process for submitting a PR would be to first express interest under the issue and then to mutually agree on the design. Note: In your last PR I didn't mention this explicitly because we had this agreement in the Slack channel and I also recognise that maybe this is not extra clear from the guidelines nor it was clear in my wording under the issue you opened a couple of hours ago. Having this discussion beforehand would help both parties with understanding if anyone is already working on the feature but also to avoid you to do unnecessary changes (even though from a first quick review in this specific PR I agree with most of your changes / direction). Additionally, it allow us to budget the time necessary to review & support the PR. With that said, let's maybe discuss briefly the scope / requirements for this kind of feature before proceeding with the review:
Again, I really appreciate that you opened a PR for an issue that you opened. With the comments above I don't mean to put you off but simply I would like to establish some way of working that will hopefully result in a pleasant and productive collaboration on both parties. Thank you for your understanding! |
I appreciate your feedback on these procedural matters. It's critical to ensure that we're collaborating effectively. I take your points about understanding whether anyone is already working on the feature and allocating time for PR support and review. It seemed that because I didn't see any PRs and the issue was new, it was reasonable to conclude that nobody was working on it. My intention here was, as you say, based on a bias for action. I intended to tread a path and leave this PR open until your team had time to review and discuss it further. (i.e., not right away, because I understand that we're all busy and can't simply drop what we're doing.) I understand you want to discuss the scope/requirements for changes before diving in. Perhaps I assumed prematurely that this project would seek to replicate the AWS Lambda Powertools for Python decorator APIs, which were directly translatable. In the spirit of treading a path, I had taken a crack at translating these APIs to TypeScript before I started removing code in the last two commits. The work was uncomplicated, so I figured the easiest way to demonstrate it was to do it and wait until you were ready to review. I didn't intend to make you feel like you had to jump to my attention. Next time I'll take your comments into consideration. I'm not sure where that leaves us. Your three scope/requirement points are reasonable, and I can perform that work. But, would it be easier for your team if I were to close this PR in favour of further discussion in #1064? Alternatively, I could do the work and let the PR sit until you're ready. I'll wait until you let me know which way you want to go. Either way, here are my responses to your scope/requirements comments:
I had provided unit tests with 100% branch coverage, but I can also add integration test coverage.
Ok. I undid captureLambdaHandler in a separate commit (ae72d52) so that this change was easily reversible - I can revert that change and start from there.
Adding Middy support should be fine. The first thing that comes to my mind is to change const tracer = new Tracer();
export const handler = middy(lambdaHandler)
.use(captureLambdaHandler(tracer, { captureResponse: false })); But what do you think? |
I'm glad that we are on the same page! Indeed the expectation that no one was working on this PR was reasonable. I just wanted to convey the point in general and used the current issue and PR to do so. There's no need to close this PR, we're happy with you continuing to work on it if you would like to do so. From my side I'm looking forward to help with the review and iterations and you can move forward whenever it suits you. Regarding unit tests, indeed I noticed that coverage was already 100%, wanted to point out the integration ones purely for future reference. In this case given it's a new feature that will require adding some new assertions, maybe let's discuss a high level design beforehand - let me know if you're comfortable with extending a proposal or if you'd like me to share ideas. About the Middy implementation, the proposal looks sensible and aligns with my current thinking, let's move forward and see how it feels once implemented. Finally, you are also right in wanting to replicate Python's behavior whenever possible and at least for the three core utilities that we have now. At the same time we want to respect and appreciate the differences between languages and make sure this version feels idiomatic to JS/TS devs. I'm mentioning this only as reference, for the purposes of this feature you were already going in the right direction. Again, I want to thank you for being gracious about this interaction and understanding where I was coming from with my comment. Looking forward to continue working on this PR with you (or future ones if the opportunity arises), and if you need my input please let me know. I'll assign the PR to you, and also the issue. |
Sounds good. I'll get to work! :) |
I've pushed up some preliminary changes aimed at addressing the initial feedback. It all works according to my testing at this time, but I'll take another look tomorrow with fresh eyes. On the subject of assertions: I have proposed some new assertions as samples in the new e2e & unit tests. We can change all of that if you like. I tried a few odd things in the e2e tests to set up and test for what I believe the behaviour should be. But, I've separated these out so we can reverse the proposed e2e test changes if you have better ideas for how to test. Meanwhile, here's the e2e output: npm run test:e2e output in packages/tracer
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for all the changes & implementation so far.
I have left some comments - nothing major - on the implementation, docs, and unit tests.
I'm gonna need a bit more time to digest & think through the integration tests, I have also asked a second opinion to other maintainers.
We'll get in touch as soon as we have an opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @misterjoshua, back from the weekend and I have reviewed the changes. Thank you for addressing all the comments either with changes or comments. I'm happy with where we are at now.
I have left one minor comment about an import statement for a type, but other than that I'm already marking this as approved.
Will be waiting for a second review by another maintainer before merging.
Co-authored-by: Andrea Amorosi <[email protected]>
@dreamorosi Thanks! I applied your suggested change. It looks like by doing that, GitHub automatically dismissed your review - sorry about that. I'll keep an eye out for any more change requests. Thanks for your help so far. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks perfect to me now, comprehensive test cases, easy to ready, well-documented.
I find it interesting to use inheritance. in e2e decorator tests. I don't usually think about that option when writing tests. But it fits well here.
Thanks for your efforts @misterjoshua , @dreamorosi :)
Description of your changes
This PR adds options to
tracer.captureMethod()
,tracer.captureLambdaHandler()
and thecaptureLambdaHandler
middleware, allowing the user to disable response capture on a per-method basis. This change helps customers control when the tracer should capture information that might be sensitive or larger than 64K, but without disabling these capture mechanisms globally viaPOWERTOOLS_TRACER_CAPTURE_RESPONSE=false
environment variable.How to verify this change
I have added multiple unit tests that simulate adding
captureResponse: false
totracer.captureMethod()
,tracer.captureLambdaHandler()
, and the MiddycaptureLambdaHandler
middleware. I have also added e2e tests for all three.Related issues, RFCs
Issue number: #1064
PR status
Is this ready for review?: YES
Is it a breaking change?: NO
Checklist
Breaking change checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.