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

SQL tracing: Support safely capturing parameterized SQL queries #28

Open
grobmeier opened this issue Sep 16, 2018 · 7 comments
Open

SQL tracing: Support safely capturing parameterized SQL queries #28

grobmeier opened this issue Sep 16, 2018 · 7 comments

Comments

@grobmeier
Copy link

I am running a Spring webapp with this configuration:

dataSource.setJdbcInterceptors("com.amazonaws.xray.sql.mysql.TracingInterceptor;");

Debugging confirms I am running into the TracingInterceptor and inside that, I can even see the sql inside the TracingInterceptor.

However, in the AWS XRay Console I cannot see the SQL commandos fired, just some meta data (like connection information).

Am I supposed to see the raw SQL running against a database? If yes, is there any additional step I missed?

@awssandra
Copy link

awssandra commented Sep 18, 2018

Hi grobmeier,

Originally, we had a concern raised around the fact the query may contain sensitive data, and how recording this automatically to X-Ray could leak this data. We had experimented in making our own sanitizer (as seen in the commented out SanitizeTest) but this was deemed insufficient, and the sanitizer and 'sanitized_query' parameter were removed, pending investigation on a better solution.

You can see the MySQL parameters captured here.

Other SDKs do have the 'sanitized_query' parameter for specific drivers that have built-in support for sanitizing/filtering queries (such as SQLAlchemy for Python). But, we do not yet have a solution for the MySQL driver on Java.

Similar question posted in the Node SDK GitHub: aws/aws-xray-sdk-node#9

Let me know if you have any questions. Thanks!
Sandra

@haotianw465 haotianw465 changed the title SQL tracing: sql does not show in console SQL tracing: Support safely capturing parameterized SQL queries Oct 16, 2018
@svetozar02
Copy link

Any updates on this issue?
From my perspective, there isn't much value in tracing sql queries if you don't see the actual sql statement. At very least it should be mentioned at https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-java-sqlclients.html so users know what to expect.

@willarmiros
Copy link
Contributor

Hi @svetozar02,
Unfortunately it is still a security concern to capture arbitrary SQL query information in subsegments, and we cannot add this information at this time. I've put in a request to explicitly mention this on the documentation you linked.

@svetozar02
Copy link

Would it be possible for have an option of enabling it if users actually want it?

Other option is to look at how Datadog agent is obfuscating sql...

@softprops
Copy link

if not automatic, is there any guidance on a hook consumers can do in code to provide the instrumentation the sql manually?

@softprops
Copy link

The docs for the node sdk provided a tip that also works for the Java sdk https://docs.aws.amazon.com/xray/latest/devguide/xray-sdk-nodejs-sqlclients.html

@willarmiros
Copy link
Contributor

Hi all,

Sorry for the delay in response here. You can capture SQL queries automatically with the X-Ray Java Agent. You just have to opt-in by setting the collectSqlQueries parameter in the agent config file to true.

In the meantime, this small feature is in our backlog to add to the Java SDK, and we are also always open to pull requests. We need to make this opt in via an environment variable like AWS_XRAY_COLLECT_SQL_QUERIES.

stnor added a commit to stnor/aws-xray-sdk-java that referenced this issue May 1, 2021
willarmiros added a commit that referenced this issue Aug 4, 2021
* Opt-in support to collect SQL queries.
#28

* Update aws-xray-recorder-sdk-sql/src/main/java/com/amazonaws/xray/sql/TracingStatement.java

Changing name of system property to AWS XRAY standard.

Co-authored-by: William Armiros <54150514+willarmiros@users.noreply.github.com>

* Checkstyle line length fix.

* Documentation for opt-in SQL-recording.

Co-authored-by: stnor <stefan@selessia.com>
Co-authored-by: William Armiros <54150514+willarmiros@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants