opentelemetry-python-contrib
opentelemetry-python-contrib copied to clipboard
Add optional traceback as spanattribute for psycopg2 instrumentation
trafficstars
Description
To help debug bad performance, I thought it would be useful to have the traceback of a call to a database. Especially for ORMs like Django's that make a lot of call that might not be wanted in the first place, it could help to find the code responsible for the calls. The changes are non breaking.
Type of change
- New feature (non-breaking change which adds functionality)
How Has This Been Tested?
I hadded tests to check that traceback would be indeed provided in the span (and not if the option is set to False).
- test_enable_traceback (line 298 in instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py)
- test_disabled_traceback (line 329 in instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py)
Does This PR Require a Core Repo Change?
- [ ] Yes. - Link to PR:
- [x] No.
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.
- [x] Followed the style guidelines of this project
- [ ] Changelogs have been updated (not sure there is one for psycopg2 ?)
- [x] Unit tests have been added
- [ ] Documentation has been updated (didn't found the doc to fill but I would happy to to)