Skip to content

Commit

Permalink
implement change in instrumentation-mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
geotry committed Oct 11, 2024
1 parent 868ed59 commit d0fae7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export function getSpanName(query: string | Query | QueryOptions): string {
if (typeof query === 'object') {
return query.sql;
}
return query.split(' ')[0];
const firstSpace = query?.indexOf(' ');
if (typeof firstSpace === 'number' && firstSpace !== -1) {
return query?.substring(0, firstSpace);
}
return query;
}

export function arrayStringifyHelper(arr: Array<unknown> | undefined): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function getSpanName(query: string | Query | QueryOptions): string {
const rawQuery = typeof query === 'object' ? query.sql : query;
// Extract the SQL verb
const firstSpace = rawQuery?.indexOf(' ');
if (typeof firstSpace === "number" && firstSpace !== -1) {
if (typeof firstSpace === 'number' && firstSpace !== -1) {
return rawQuery?.substring(0, firstSpace);
}
return rawQuery;
Expand Down

0 comments on commit d0fae7c

Please sign in to comment.