Skip to content

Commit

Permalink
perf(instrumentation-pg): do not split query to determine operation n…
Browse files Browse the repository at this point in the history
…ame (#2029)

Co-authored-by: Amir Blum <[email protected]>
  • Loading branch information
Samuron and blumamir authored May 22, 2024
1 parent 8c578cd commit 816611e
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 @@ -86,7 +86,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 816611e

Please sign in to comment.