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

sqlalchemy instrumentation wrappers don't use sqlcommenter options #1872

Closed
tammy-baylis-swi opened this issue Jun 23, 2023 · 1 comment · Fixed by #1873
Closed

sqlalchemy instrumentation wrappers don't use sqlcommenter options #1872

tammy-baylis-swi opened this issue Jun 23, 2023 · 1 comment · Fixed by #1873
Assignees
Labels
bug Something isn't working

Comments

@tammy-baylis-swi
Copy link
Contributor

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

  1. Create a custom distro that extends BaseDistro.
  2. Implement load_instrumentor so that kwargs at instrumentor().instrument(**kwargs) includes "enable_commenter": True and "commenter_options": {"opentelemetry_values": False}.
  3. Install the custom distro and auto-instrument a service with opentelemetry-instrument.
  4. Request the service to use sqlalchemy to query a MySQL database.
  5. 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'*/
@tammy-baylis-swi
Copy link
Contributor Author

May I please be assigned to this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant