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

feat: add tracer support for async, escape hatch, and patch given modules #29

Merged
merged 36 commits into from
May 12, 2020

Conversation

heitorlessa
Copy link
Contributor

@heitorlessa heitorlessa commented May 4, 2020

Issue #, if available: #28, #11, #10

Description of changes:

UX for async

Customer needs to control the loop and await all coroutines

@tracer.capture_method      # will prime this coroutine
async def greeting_2(name, message):
    return dummy_response

@tracer.capture_method      # will prime this coroutine
async def greeting(name, message):
    blah = await greeting_2(name, message)
    return dummy_response, blah

def lambda_handler(evt, ctx):
    loop = asyncio.get_event_loop()
    loop.run_until_complete(greeting(name="Foo", message="Bar"))
   # or gather() if multiple need to be awaited

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

@heitorlessa heitorlessa self-assigned this May 4, 2020
Copy link
Contributor

@nmoutschen nmoutschen left a comment

Choose a reason for hiding this comment

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

Overall, it looks good but I have questions regarding whether the tracer implementation is not too specific to X-Ray.

python/aws_lambda_powertools/tracing/base.py Outdated Show resolved Hide resolved
python/aws_lambda_powertools/tracing/base.py Outdated Show resolved Hide resolved
python/aws_lambda_powertools/tracing/base.py Outdated Show resolved Hide resolved
@heitorlessa heitorlessa changed the title [WIP] Support custom tracing providers [WIP] Improv tracer patch, test coverage May 5, 2020
@heitorlessa heitorlessa changed the title [WIP] Improv tracer patch, test coverage [WIP] Improv tracer - async support, patch, test coverage and X-Ray escape hatch May 7, 2020
@heitorlessa heitorlessa changed the title [WIP] Improv tracer - async support, patch, test coverage and X-Ray escape hatch Improv tracer - async support, patch, test coverage and X-Ray escape hatch May 10, 2020
@heitorlessa
Copy link
Contributor Author

Overall, it looks good but I have questions regarding whether the tracer implementation is not too specific to X-Ray.

I dropped additional provider feature. Instead, this PR now tackles enhancements for Tracer - Async support, patch specific modules, and an escape hatch mechanism

python/README.md Show resolved Hide resolved
python/aws_lambda_powertools/tracing/tracer.py Outdated Show resolved Hide resolved
python/aws_lambda_powertools/tracing/tracer.py Outdated Show resolved Hide resolved
@heitorlessa
Copy link
Contributor Author

Thank you once again @nmoutschen for the review :) It's now published in 0.9.0

* develop:
  Bugfix: "per second" metric units (#27)
@heitorlessa heitorlessa merged commit 5ae7741 into develop May 12, 2020
heitorlessa added a commit that referenced this pull request May 16, 2020
* develop: (21 commits)
  bugfix: #32 Runtime Error for nested sync fns
  chore: renamed history to changelog dependabot
  bugfix: resolves #31 aiohttp lazy import
  chore: grammar issues
  improv: add project tenets
  Improv tracer - async support, patch, test coverage and X-Ray escape hatch (#29)
  Bugfix: "per second" metric units (#27)
  fix: #24 correct example test and docs
  chore: bump example to use 0.8.0 features
  Adopt logging best practices (#23)
  Decorator factory Feat: Create your own middleware (#17)
  chore: clean up CI workflows
  fix: CI attempt 4
  fix: CI attempt 3
  fix: CI attempt 3
  fix: CI attempt 2
  feat: add docs to CI
  chore: fix github badge typo
  chore: pypi monthly download badge
  fix: add missing single_metric example; test var name
  ...
@heitorlessa heitorlessa changed the title Improv tracer - async support, patch, test coverage and X-Ray escape hatch feat: add tracer support for async, escape hatch, and patch given modules Jun 3, 2020
@heitorlessa heitorlessa deleted the improv/tracer branch June 5, 2020 17:56
heitorlessa referenced this pull request in heitorlessa/aws-lambda-powertools-python Jun 17, 2020
…hatch (#29)

* feat: use new TraceProvider

* improv: update tests

* improv: update docs, linting

* improv: docstring readability and links

* improv: remove tracer provider

* fix: patch modules type

* improv: use client ctx_manager for race conditions

* improv: make disabling provider private again

* chore: linting

* fix: race condition annotation/metadata

* chore: linting

* feat: add async support for methods

* improv: document async use cases, and edge cases

* improv: upgrade xray, flex pinning

* chore: linting

* improv: update example for async, escape hatch

* fix: add example dev deps in project

* improv: add patch_modules example, formatting

* improv: break down concurrent async calls example

* docs: main doc clean up

* docs: document async, escape hatch usage

* chore: lint

* docs: update example SAM template comments

* chore: updates poetry lock file

* improv: example to use py 3.8

* fix: AsyncMockMixin not being awaitable in 3.8

* fix: 3.8 defaulting to AsyncMock

* improv: include x-ray bug for concurrent async calls

* fix: address nicolas's feedback

* improv: add security baseline as part of PR process

* improv: enforce lower code complexity

* chore: whitespace

* improv: add complexity baseline

* chore: bump version to 0.9.0

* chore: clean up history changes

Co-authored-by: heitorlessa <[email protected]>
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.

2 participants