labd / commercetools-python-sdk

Commercetools Python SDK
https://commercetools-python-sdk.readthedocs.io/en/latest/
MIT License
17 stars 16 forks source link

Add X-Correlation-ID to CT exception class and testing framework #58

Closed davidweterings closed 5 years ago

davidweterings commented 5 years ago

This will be enough to log it in Sentry (since correlation_id is a local variable, which are always logged).

Another solution would be to use something like https://github.com/jmcarp/requests-middleware and overwrite the HTTPAdapter in client.py line 131. Then pass in some kind of SentryMiddleware which sets a tag with the response header X-Correlation-ID https://docs.sentry.io/enriching-error-data/context/?platform=python#tagging-events

codecov[bot] commented 5 years ago

Codecov Report

Merging #58 into master will increase coverage by 0.03%. The diff coverage is 76.78%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #58      +/-   ##
=========================================
+ Coverage   74.46%   74.5%   +0.03%     
=========================================
  Files         152     154       +2     
  Lines       21881   21922      +41     
=========================================
+ Hits        16294   16333      +39     
- Misses       5587    5589       +2
Impacted Files Coverage Δ
src/commercetools/constants.py 100% <100%> (ø)
src/commercetools/testing/utils.py 68.86% <100%> (+2.2%) :arrow_up:
src/commercetools/exceptions.py 100% <100%> (ø) :arrow_up:
tests/test_testing_headers.py 100% <100%> (ø)
src/commercetools/client.py 95.56% <100%> (+0.05%) :arrow_up:
src/commercetools/testing/subscriptions.py 60% <33.33%> (ø) :arrow_up:
src/commercetools/testing/auth.py 82.97% <50%> (ø) :arrow_up:
src/commercetools/testing/product_projections.py 73.46% <57.14%> (ø) :arrow_up:
src/commercetools/testing/custom_objects.py 81.81% <60%> (ø) :arrow_up:
src/commercetools/testing/abstract.py 94.11% <75%> (-0.04%) :arrow_down:
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 91464b3...80386c5. Read the comment docs.