-
Notifications
You must be signed in to change notification settings - Fork 818
Description
Describe your environment
I have a custom distro that extends BaseDistro and overrides load_instrumentor so that I can pass in custom args during auto-instrumentation such as enable_commenter and commenter_options for sqlalchemy instrumentation (described here). This is with OTel 1.18.0/0.39b0. I am instrumenting a simple Flask app that uses sqlalchemy to query a MySQL database, all running in Docker.
I found that _wrap_create_engine and _wrap_create_async_engine do accept enable_commenter but not commenter_options. This means sqlcommenting can be enabled but not customized. This is an issue during auto-instrumentation, but not during all manual instrumentation scenarios because sometimes the latter uses EngineTracer which does accept and use both configs.
Steps to reproduce
- Create a custom distro that extends
BaseDistro. - Implement
load_instrumentorso thatkwargsatinstrumentor().instrument(**kwargs)includes"enable_commenter": Trueand"commenter_options": {"opentelemetry_values": False}. - Install the custom distro and auto-instrument a service with
opentelemetry-instrument. - Request the service to use sqlalchemy to query a MySQL database.
- Check mysqld general logs for record of the query, which will include the comments added by OTel instrumentation.
What is the expected behavior?
The query log should not include OTel values because of "commenter_options": {"opentelemetry_values": False}.
2023-06-23T23:26:12.022041Z 13 Query SELECT city.id, city.name, city.district, city.population, city.countrycode
FROM city
WHERE city.id = 1818 /*controller='request_manual',db_driver='mysqldb',db_framework='sqlalchemy%3A0.39b0.dev',framework='flask%3A2.2.5',route='/manual/'*/
What is the actual behavior?
OTel values are included despite config. There is traceparent included in the comment:
2023-06-23T21:49:04.124802Z 10 Query SELECT city.id, city.name, city.district, city.population, city.countrycode
FROM city
WHERE city.id = 1818 /*controller='request_manual',db_driver='mysqldb',db_framework='sqlalchemy%3A0.39b0',framework='flask%3A2.2.5',route='/manual/',traceparent='00-a660c32a7b8b72ece19376208a0afe36-be03b8409682a4c6-01'*/