File tree Expand file tree Collapse file tree 3 files changed +27
-74
lines changed
plugins/node/opentelemetry-instrumentation-pg/test Expand file tree Collapse file tree 3 files changed +27
-74
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ const sdk = createTestNodeSdk({
4040sdk . start ( ) ;
4141
4242import pg from 'pg' ;
43-
4443const client = new pg . Client ( CONFIG ) ;
4544
4645await client . connect ( ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -1087,4 +1087,31 @@ describe('pg', () => {
10871087 } ) ;
10881088 } ) ;
10891089 } ) ;
1090+
1091+ it ( 'should work with ESM usage' , async ( ) => {
1092+ await testUtils . runTestFixture ( {
1093+ cwd : __dirname ,
1094+ argv : [ 'fixtures/use-pg.mjs' ] ,
1095+ env : {
1096+ NODE_OPTIONS :
1097+ '--experimental-loader=@opentelemetry/instrumentation/hook.mjs' ,
1098+ NODE_NO_WARNINGS : '1' ,
1099+ } ,
1100+ checkResult : ( err , stdout , stderr ) => {
1101+ assert . ifError ( err ) ;
1102+ } ,
1103+ checkCollector : ( collector : testUtils . TestCollector ) => {
1104+ const spans = collector . sortedSpans ;
1105+
1106+ assert . strictEqual ( spans . length , 3 ) ;
1107+
1108+ assert . strictEqual ( spans [ 0 ] . name , 'pg.connect' ) ;
1109+ assert . strictEqual ( spans [ 0 ] . kind , 3 ) ;
1110+ assert . strictEqual ( spans [ 1 ] . name , 'test-span' ) ;
1111+ assert . strictEqual ( spans [ 1 ] . kind , 1 ) ;
1112+ assert . strictEqual ( spans [ 2 ] . name , 'pg.query:SELECT postgres' ) ;
1113+ assert . strictEqual ( spans [ 2 ] . kind , 3 ) ;
1114+ } ,
1115+ } ) ;
1116+ } ) ;
10901117} ) ;
You can’t perform that action at this time.
0 commit comments