Skip to content

Commit

Permalink
perf(instrumentation-pg): do not split query to determine span name
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuron authored and Ievgen Makukh committed Mar 21, 2024
1 parent 358345f commit 24e1ceb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/node/opentelemetry-instrumentation-pg/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ export function getQuerySpanName(
}

function parseNormalizedOperationName(queryText: string) {
const sqlCommand = queryText.split(' ')[0].toUpperCase();
const indexOfFirstSpace = queryText.indexOf(' ');
let sqlCommand =
indexOfFirstSpace === -1
? queryText
: queryText.slice(0, indexOfFirstSpace);
sqlCommand = sqlCommand.toUpperCase();

// Handle query text being "COMMIT;", which has an extra semicolon before the space.
return sqlCommand.endsWith(';') ? sqlCommand.slice(0, -1) : sqlCommand;
Expand Down

0 comments on commit 24e1ceb

Please sign in to comment.