Description
Description of the feature request
Add captureMySQL
support to the Tracer or add it to the ProviderServiceInterface
Problem statement
As a user I would like to trace MySQL queries leveraging the powertools Tracer.
Summary of the feature
I appreciate the encapsulation of X-Ray that is enabled through Tracer and would like to use it more fully. Rather than using captureMySQL
from aws-xray-sdk-mysql
, I would prefer to do one of the following (in order of preference):
- Automatically Trace MySQL calls, either by default or enabled with a setting, similar to tracing-http-requests
- Manually trace MySQL calls by wrapping the library with a
tracer.captureMySQL(mysqlLib)
similar to patching-aws-sdk-clients - Leverage the escape hatch mechanism to access the
tracer.provider.captureMySQL()
as is eluded to in the escape-hatch-mechanism that refers to SQL queries tracing
Code examples
Current approach
// current approach 1
const AWSXRay = require('aws-xray-sdk');
const mysql = AWSXRay.captureMySQL(require('mysql'));
// current approach 2
const captureMySQL = require('aws-xray-sdk-mysql');
captureMySQL(require('mysql2'));
Options
import { Tracer } from '@aws-lambda-powertools/tracer';
const tracer = new Tracer({ serviceName: 'myService' });
// Option 1 - automatic
const mysql = require('mysql');
// Option 2 - similar to patching AWS SDK
const mysql2 = tracer.captureMySQL(require('mysql'));
// Option 3 - escape hatch
const mysql3 = tracer.provider.captureMySQL(require('mysql'));
Benefits for you and the wider AWS community
Uniformly using the powertools Tracer abstraction rather than directly using X-Ray. This would allow users to benefit from the continued improvements added to the powertools without the need to modify tracing code.
Describe alternatives you've considered
Continue to use the x-ray sdk directly.
Additional context
Related issues, RFCs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status