feat(mysql2): Instrument mysql2 >= 3.20.0 via native tracing channels#21824
Draft
logaretm wants to merge 2 commits into
Draft
feat(mysql2): Instrument mysql2 >= 3.20.0 via native tracing channels#21824logaretm wants to merge 2 commits into
logaretm wants to merge 2 commits into
Conversation
mysql2 >= 3.20.0 publishes its operations over node:diagnostics_channel (mysql2:query / :execute / :connect / :pool:connect), so the SDK can subscribe to those channels instead of monkey-patching, the same way we did for redis/ioredis and mongoose. The subscription lives in server-utils as mysql2Integration, and the node mysql2Integration extends it (via extendIntegration) while keeping the vendored OTel patcher for mysql2 < 3.20.0, which is now gated to that range so the two paths never double-instrument. The channel path emits the stable DB semconv (db.system.name, db.query.text, db.operation.name, db.namespace, server.address, server.port), so there's the same attribute drift we accepted for redis/mongoose. mysql2 publishes already-formatted SQL, so db.query.text is run through the OTel sanitizer and raw values are never attached.
Contributor
size-limit report 📦
|
The mysql2-tracing-channel docker-compose bound host port 3307, which collides with the knex/mysql2 suite. When both run in parallel the second container fails with 'port is already allocated'. Switch to 3308.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instruments mysql2 >= 3.20.0 through its native
diagnostics_channeltracing channels instead of monkey-patching, the same way we did for redis/ioredis and mongoose. mysql2 publishes onmysql2:query,mysql2:execute,mysql2:connectandmysql2:pool:connect.The channel path emits the stable DB semconv (
db.system.name,db.query.text,db.operation.name,db.namespace,server.address,server.port), so there's an attribute drift here. We could match the legacy attributes and drop them at v11 instead if that's what we want.One mysql2-specific thing: the
mysql2:querychannel publishes the already-formatted SQL with values inlined, so I run it through the OTeldb.query.textsanitizer.