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

NH-5774: Trace context in sql query #25

Merged
merged 12 commits into from
Feb 28, 2022
Merged

Conversation

ghost
Copy link
Contributor

@ghost ghost commented Jan 18, 2022

This PR injects the trace context into the comment of the SQL statements.
See also https://swicloud.atlassian.net/browse/NH-5774

Test result

It has been tested against MySQL database and JDBC

2022-01-18T17:32:45.370606Z	   72 Query	/* mysql-connector-java-8.0.22 (Revision: d64b664fa93e81296a377de031b8123a67e6def2) */SELECT  @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_write_timeout AS net_write_timeout, @@performance_schema AS performance_schema, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@transaction_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout
2022-01-18T17:32:45.391508Z	   72 Query	SET NAMES utf8mb4
2022-01-18T17:32:45.391858Z	   72 Query	SET character_set_results = NULL
2022-01-18T17:32:45.392319Z	   72 Query	SET autocommit=1
2022-01-18T17:32:45.418215Z	   72 Query	/*traceparent:'00-7ee80f56c4eb6fc48f985993240cecac-9585dd1d2b5728ae-01'*/ select * from mytable


2022-01-18T17:33:02.853832Z	   73 Connect	newuser@localhost on test using SSL/TLS
2022-01-18T17:33:02.854635Z	   73 Query	/* mysql-connector-java-8.0.22 (Revision: d64b664fa93e81296a377de031b8123a67e6def2) */SELECT  @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_write_timeout AS net_write_timeout, @@performance_schema AS performance_schema, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@transaction_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout
2022-01-18T17:33:02.855470Z	   73 Query	SET NAMES utf8mb4
2022-01-18T17:33:02.855814Z	   73 Query	SET character_set_results = NULL
2022-01-18T17:33:02.856204Z	   73 Query	SET autocommit=1
2022-01-18T17:33:02.869377Z	   73 Query	SELECT @@session.transaction_read_only
2022-01-18T17:33:02.869885Z	   73 Query	/*traceparent:'00-455c9deec1560df84b924e4b3c725da2-d00e61039b4b6516-01'*/ insert into mytable values('hello World')

Repository owner changed the title Nh 5774 trace context in sql query NH-5774: Trace context in sql query Jan 18, 2022
Repository owner requested a review from tingfung-leung_swi February 28, 2022 21:03
Copy link
Mannequin

@tingfung-leung_swi tingfung-leung_swi mannequin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Repository owner merged commit cf37db8 into main Feb 28, 2022
Repository owner deleted the NH-5774-trace-context-in-sql-query branch February 28, 2022 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants