elastic / elastic/apm-agent-nodejs
MySQL span name truncated to "/*" with inline comments in query
- Dominant language
- JavaScript
- Stars
- 594
- Forks
- 244
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 16
Description
**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
```
3. Check the transaction in APM UI
4. 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(...)`)
- [x] 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"
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.