Skip to content

Feature request: Add support for captureMySQL #749

Closed as not planned
Closed as not planned
@cortexcompiler

Description

@cortexcompiler

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):

  1. Automatically Trace MySQL calls, either by default or enabled with a setting, similar to tracing-http-requests
  2. Manually trace MySQL calls by wrapping the library with a tracer.captureMySQL(mysqlLib) similar to patching-aws-sdk-clients
  3. 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

No one assigned

    Labels

    feature-requestThis item refers to a feature request for an existing or new utilityrejectedThis is something we will not be working on. At least, not in the measurable futuretracerThis item relates to the Tracer Utility

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions