File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed
plugins/node/opentelemetry-instrumentation-pg Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,9 @@ export function parseAndMaskConnectionString(connectionString: string): string {
122122 }
123123}
124124
125- export function getConnectionString ( params : PgParsedConnectionParams | PgPoolOptionsParams ) {
125+ export function getConnectionString (
126+ params : PgParsedConnectionParams | PgPoolOptionsParams
127+ ) {
126128 if ( 'connectionString' in params && params . connectionString ) {
127129 return parseAndMaskConnectionString ( params . connectionString ) ;
128130 }
@@ -157,14 +159,16 @@ export function getSemanticAttributesFromConnection(
157159}
158160
159161export function getSemanticAttributesFromPool ( params : PgPoolOptionsParams ) {
160- // const connectionParams = getConnectionParams(params);
162+ // const connectionParams = getConnectionParams(params);
161163
162- let url : URL | undefined ;
163- try {
164- url = params . connectionString ? new URL ( params . connectionString ) : undefined ;
165- } catch ( e ) {
166- url = undefined ;
167- }
164+ let url : URL | undefined ;
165+ try {
166+ url = params . connectionString
167+ ? new URL ( params . connectionString )
168+ : undefined ;
169+ } catch ( e ) {
170+ url = undefined ;
171+ }
168172
169173 return {
170174 [ SEMATTRS_DB_SYSTEM ] : DBSYSTEMVALUES_POSTGRESQL ,
Original file line number Diff line number Diff line change @@ -257,7 +257,8 @@ describe('utils.ts', () => {
257257
258258 describe ( '.parseAndMaskConnectionString()' , ( ) => {
259259 it ( 'should remove all auth information from connection string' , ( ) => {
260- const connectionString = 'postgresql://user:password123@localhost:5432/dbname' ;
260+ const connectionString =
261+ 'postgresql://user:password123@localhost:5432/dbname' ;
261262 assert . strictEqual (
262263 utils . parseAndMaskConnectionString ( connectionString ) ,
263264 'postgresql://localhost:5432/dbname'
@@ -281,7 +282,8 @@ describe('utils.ts', () => {
281282 } ) ;
282283
283284 it ( 'should preserve query parameters while removing auth' , ( ) => {
284- const connectionString = 'postgresql://user:pass@localhost/dbname?sslmode=verify-full&application_name=myapp' ;
285+ const connectionString =
286+ 'postgresql://user:pass@localhost/dbname?sslmode=verify-full&application_name=myapp' ;
285287 assert . strictEqual (
286288 utils . parseAndMaskConnectionString ( connectionString ) ,
287289 'postgresql://localhost/dbname?sslmode=verify-full&application_name=myapp'
You can’t perform that action at this time.
0 commit comments