Skip to content

Commit c1687ef

Browse files
authored
Merge branch 'main' into trentm-markdown-table-linting-nope
2 parents 4dcb97c + 1102cfa commit c1687ef

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

.github/workflows/release-please.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
run: |
3030
npm ci --ignore-scripts
3131
32-
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
32+
- uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
3333
id: otelbot-token
3434
with:
3535
app-id: ${{ vars.OTELBOT_JS_CONTRIB_APP_ID }}

.github/workflows/survey-on-merged-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
if: github.event.pull_request.merged == true
1919
steps:
20-
- uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
20+
- uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
2121
id: otelbot-token
2222
with:
2323
app-id: ${{ vars.OTELBOT_APP_ID }}

.github/workflows/update-otel-deps.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
create-or-update-deps-pr:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
13+
- uses: actions/create-github-app-token@7e473efe3cb98aa54f8d4bac15400b15fad77d94 # v2.2.0
1414
id: otelbot-token
1515
with:
1616
app-id: ${{ vars.OTELBOT_JS_CONTRIB_APP_ID }}

packages/instrumentation-pg/src/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ export function getQuerySpanName(
104104
}
105105

106106
export function parseNormalizedOperationName(queryText: string) {
107-
const indexOfFirstSpace = queryText.indexOf(' ');
107+
// Trim the query text to handle leading/trailing whitespace
108+
const trimmedQuery = queryText.trim();
109+
const indexOfFirstSpace = trimmedQuery.indexOf(' ');
108110
let sqlCommand =
109111
indexOfFirstSpace === -1
110-
? queryText
111-
: queryText.slice(0, indexOfFirstSpace);
112+
? trimmedQuery
113+
: trimmedQuery.slice(0, indexOfFirstSpace);
112114
sqlCommand = sqlCommand.toUpperCase();
113115

114116
// Handle query text being "COMMIT;", which has an extra semicolon before the space.

packages/instrumentation-pg/test/utils.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,27 @@ describe('utils.ts', () => {
108108
);
109109
});
110110

111+
it('remove leading whitespaces when parsing operation names', () => {
112+
assert.strictEqual(
113+
utils.getQuerySpanName('dbName', { text: ' SELECT $1' }),
114+
'pg.query:SELECT dbName'
115+
);
116+
});
117+
118+
it('remove trailing whitespaces when parsing operation names', () => {
119+
assert.strictEqual(
120+
utils.getQuerySpanName('dbName', { text: 'SELECT $1 ' }),
121+
'pg.query:SELECT dbName'
122+
);
123+
});
124+
125+
it('remove leading and trailing whitespace when parsing operation names', () => {
126+
assert.strictEqual(
127+
utils.getQuerySpanName('dbName', { text: ' SELECT $1 ' }),
128+
'pg.query:SELECT dbName'
129+
);
130+
});
131+
111132
it('omits db name if missing', () => {
112133
assert.strictEqual(
113134
utils.getQuerySpanName(undefined, dummyQuery),

0 commit comments

Comments
 (0)