@@ -225,6 +225,49 @@ describe('instrumentation-sequelize', () => {
225225 'SELECT `id`, `firstName`, `createdAt`, `updatedAt` FROM `Users` AS `User`;'
226226 ) ;
227227 } ) ;
228+
229+ describe ( 'query is instrumented' , ( ) => {
230+ it ( 'with options not specified' , async ( ) => {
231+ try {
232+ await instance . query ( 'SELECT 1 + 1' ) ;
233+ } catch {
234+ // Do not care about the error
235+ }
236+ const spans = getSequelizeSpans ( ) ;
237+ expect ( spans . length ) . toBe ( 1 ) ;
238+ const attributes = spans [ 0 ] . attributes ;
239+
240+ expect ( attributes [ SemanticAttributes . DB_OPERATION ] ) . toBe ( 'SELECT' ) ;
241+ expect ( attributes [ SemanticAttributes . DB_STATEMENT ] ) . toBe ( 'SELECT 1 + 1' ) ;
242+ } ) ;
243+ it ( 'with type not specified in options' , async ( ) => {
244+ try {
245+ await instance . query ( 'SELECT 1 + 1' , { } ) ;
246+ } catch {
247+ // Do not care about the error
248+ }
249+ const spans = getSequelizeSpans ( ) ;
250+ expect ( spans . length ) . toBe ( 1 ) ;
251+ const attributes = spans [ 0 ] . attributes ;
252+
253+ expect ( attributes [ SemanticAttributes . DB_OPERATION ] ) . toBe ( 'SELECT' ) ;
254+ expect ( attributes [ SemanticAttributes . DB_STATEMENT ] ) . toBe ( 'SELECT 1 + 1' ) ;
255+ } ) ;
256+
257+ it ( 'with type specified in options' , async ( ) => {
258+ try {
259+ await instance . query ( 'SELECT 1 + 1' , { type : sequelize . QueryTypes . RAW } ) ;
260+ } catch {
261+ // Do not care about the error
262+ }
263+ const spans = getSequelizeSpans ( ) ;
264+ expect ( spans . length ) . toBe ( 1 ) ;
265+ const attributes = spans [ 0 ] . attributes ;
266+
267+ expect ( attributes [ SemanticAttributes . DB_OPERATION ] ) . toBe ( 'RAW' ) ;
268+ expect ( attributes [ SemanticAttributes . DB_STATEMENT ] ) . toBe ( 'SELECT 1 + 1' ) ;
269+ } ) ;
270+ } ) ;
228271 } ) ;
229272
230273 describe ( 'sqlite' , ( ) => {
0 commit comments