NH-46327 APM Python accepts OTEL_SQLCOMMENTER_OPTIONS #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates APM Python custom distro to read and parse
OTEL_SQLCOMMENTER_OPTIONS
if set by customer and ifOTEL_SQLCOMMENTER_ENABLED=true
. The options are used to init all Otel Python instrumentors that have a sqlcommenting feature. For more details please see "How the two env vars work" section.This also refactors existing
ApmConfig.convert_to_bool
as a class method so the distro class can also use it. Not ideal so let me know if it should be in its own class or some other way.Unit tests added and updated.
Tested manually with results starting in "Results" section. It seems to work as all only the KVs enabled by options are added to sqlcomments, for example this for Flask with SQLAlchemy and MySQL only has
db_driver
andtraceparent
when all other options areFalse
:2023-07-24T23:55:39.935228Z 16 Query SELECT * FROM city WHERE id='1818' /*db_driver='mysqldb',traceparent='00-6268896697b0a44f98575a72d606120b-263f08ace2b0ddfc-01'*/
Please let me know if any questions or comments! 😺