Skip to content

Commit

Permalink
add db.name span attribute to mysql & pg (#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Apr 26, 2024
1 parent f363af0 commit e7d1607
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/sql-mysql2/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,22 @@ export const make = (
(conn) => new ConnectionImpl(conn)
)

const spanAttributes: Array<[string, unknown]> = [
["db.system", "mysql"],
["server.address", options.host ?? "localhost"],
["server.port", options.port ?? 3306]
]

if (options.database) {
spanAttributes.push(["db.name", options.database])
}

return Object.assign(
Client.make({
acquirer: Effect.succeed(poolConnection),
transactionAcquirer,
compiler,
spanAttributes: [
["db.system", "mysql"],
["server.address", options.host ?? "localhost"],
["server.port", options.port ?? 3306]
]
spanAttributes
}),
{ config: options }
)
Expand Down
1 change: 1 addition & 0 deletions packages/sql-pg/src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export const make = (
compiler,
spanAttributes: [
["db.system", "postgresql"],
["db.name", opts.database ?? options.username ?? "postgres"],
["server.address", opts.host ?? "localhost"],
["server.port", opts.port ?? 5432]
]
Expand Down

0 comments on commit e7d1607

Please sign in to comment.