Open TWI-Ben opened 5 years ago
Hello @TWI-Ben , Thanks for opening this issue. We have added the task to our backlog and will prioritize it.
@srprash Is there any update on this?
Hi @TWI-Ben , it’s still in our backlog and is being worked against other items in our backlog.
Thanks
My company would really benefit from this feature. Can you elaborate on whether this is being worked or not?
As a reference for anyone working this or looking to understand the scope, MiniProfiler essentially handles this through the use of a connection wrapper; see: https://github.com/MiniProfiler/dotnet/blob/master/src/MiniProfiler.Shared/Data/ProfiledDbConnection.cs.
Just started looking into x-ray, and ran into this problem. Since it is already in the backlog I would like to +1 this feature request.
This feature is certainly on our roadmap and we would definitely like to offer this feature as soon as possible. Please stay tuned for updates. We also welcome any PR towards this effort.
If you're using Entity Framework, you can implement IDbCommandInterceptor
and start a segment on the *Executing
methods, and end a segment on *Executed
. Set the namespace to remote
and use AWSXRayRecorder.Instance.AddSqlInformation
to annotate with properties like user
, database_type
, preparation
, sanitized_query
. The interception context will have a property to tell you if there was an exception that you can log also.
As this doesn't appear to have any more progress I'll throw my 2c of workarounds in. If you use the cs files from sdk/src/Handlers/SqlServer
but add the following to the top,
using SqlCommand = MySqlConnector.MySqlCommand;
using SqlConnection = MySqlConnector.MySqlConnection;
using SqlTransaction = MySqlConnector.MySqlTransaction;
using SqlParameter = MySqlConnector.MySqlParameter;
using SqlParameterCollection = MySqlConnector.MySqlParameterCollection;
using SqlDataReader = MySqlConnector.MySqlDataReader;
it will map the SqlServer
classes to the relevant MySqlConnector
classes. There are a few xml methods you need to also disable as they are not use in MySqlConnector
.
It's not great, it may have problems, but at least I have queries logged now.
Currently AWS X-Ray SDK for .NET only supports SQL Server for tracing SQL commands. The code should support any DbCommand, DbConnection, and DbTransaction regardless of what server it ultimately talks to.
Examples:
using (TraceableSqlCommand cmd = new TraceableSqlCommand<MySqlCommand>("SELECT * from test", conn)) { // ... Command code goes here }
orusing (TraceableSqlCommand cmd = new TraceableSqlCommand(new MySqlCommand("select * from test")) { // ... Command code goes here }