Skip to content

MySQL span name truncated to "/*" with inline comments in query #4490

@ben-queenlive

Description

@ben-queenlive

Describe the bug

When using inline comments in MySQL queries, the APM span name only shows /* instead of the actual SQL query. This makes it difficult to identify and monitor specific database operations in the APM UI.

To Reproduce

Steps to reproduce the behavior:

  1. Configure Elastic APM Node.js agent and set up MySQL connection
  2. Execute a query with inline comment like:
/* GetUserProfile */ SELECT * FROM users WHERE id = 1
  1. Check the transaction in APM UI
  2. Transaction name is shown generically as '/* ', ignoring the inline comment 'SELECT * FROM users'
    Expected behavior

The span name should display the actual SQL query (e.g., "SELECT * FROM users") rather than just showing /*. This would provide proper visibility into the database operations being performed and make it easier to monitor and debug database queries.

Environment (please complete the following information)

  • OS: macOS 14.3
  • Node.js version: 22.7.0
  • APM Server version: 8.12.0
  • Agent version: 4.11.0

How are you starting the agent? (please tick one of the boxes)

  • Calling agent.start() directly (e.g. require('elastic-apm-node').start(...))
  • Requiring elastic-apm-node/start from within the source code
  • Starting node with -r elastic-apm-node/start

Additional context

Agent config options:

Click to expand
ELASTIC_APM_SERVER_URL=
ELASTIC_APM_SECRET_TOKEN=
ELASTIC_APM_CAPTURE_BODY=error
ELASTIC_APM_TRANSACTION_SAMPLE_RATE=1.0
ELASTIC_APM_ACTIVE=true 

package.json dependencies:

Click to expand
{
  "dependencies": {
    "elastic-apm-node": "^4.11.0",
    "mysql2": "^3.12.0",
    "@nestjs/common": "^11.0.0",
    "@nestjs/core": "^11.0.0",
    "@nestjs/typeorm": "^11.0.0",
    "typeorm": "^0.3.20"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions