@@ -290,270 +290,6 @@ describe('redis v2-v3', () => {
290290 } ) ;
291291 } ) ;
292292 } ) ;
293-
294- describe ( 'edge cases for semconv stability' , ( ) => {
295- it ( 'should handle missing address with OLD stability' , done => {
296- instrumentation . setConfig ( { semconvStability : SemconvStability . OLD } ) ;
297-
298- const originalAddress = client . address ;
299- delete client . address ;
300-
301- client . get ( 'test_no_address' , ( err : unknown ) => {
302- assert . ifError ( err ) ;
303-
304- client . address = originalAddress ;
305-
306- const spans = testUtils . getTestSpans ( ) ;
307- assert . strictEqual ( spans . length , 1 ) ;
308- const span = spans [ 0 ] ;
309-
310- assert . ok ( ! ( SEMATTRS_DB_CONNECTION_STRING in span . attributes ) ) ;
311-
312- assert . strictEqual (
313- span . attributes [ SEMATTRS_NET_PEER_NAME ] ,
314- CONFIG . host
315- ) ;
316- assert . strictEqual (
317- span . attributes [ SEMATTRS_NET_PEER_PORT ] ,
318- CONFIG . port
319- ) ;
320- done ( ) ;
321- } ) ;
322- } ) ;
323-
324- it ( 'should handle present address with OLD stability' , done => {
325- instrumentation . setConfig ( { semconvStability : SemconvStability . OLD } ) ;
326-
327- client . get ( 'test_with_address' , ( err : unknown ) => {
328- assert . ifError ( err ) ;
329-
330- const spans = testUtils . getTestSpans ( ) ;
331- assert . strictEqual ( spans . length , 1 ) ;
332- const span = spans [ 0 ] ;
333-
334- assert . strictEqual (
335- span . attributes [ SEMATTRS_DB_CONNECTION_STRING ] ,
336- URL
337- ) ;
338-
339- assert . strictEqual (
340- span . attributes [ SEMATTRS_NET_PEER_NAME ] ,
341- CONFIG . host
342- ) ;
343- assert . strictEqual (
344- span . attributes [ SEMATTRS_NET_PEER_PORT ] ,
345- CONFIG . port
346- ) ;
347- done ( ) ;
348- } ) ;
349- } ) ;
350-
351- it ( 'should handle present address with STABLE stability' , done => {
352- instrumentation . setConfig ( {
353- semconvStability : SemconvStability . STABLE ,
354- } ) ;
355-
356- client . get ( 'test_with_address_stable' , ( err : unknown ) => {
357- assert . ifError ( err ) ;
358-
359- const spans = testUtils . getTestSpans ( ) ;
360- assert . strictEqual ( spans . length , 1 ) ;
361- const span = spans [ 0 ] ;
362-
363- assert . ok ( ! ( SEMATTRS_DB_CONNECTION_STRING in span . attributes ) ) ;
364-
365- assert . strictEqual (
366- span . attributes [ ATTR_SERVER_ADDRESS ] ,
367- CONFIG . host
368- ) ;
369- assert . strictEqual ( span . attributes [ ATTR_SERVER_PORT ] , CONFIG . port ) ;
370- done ( ) ;
371- } ) ;
372- } ) ;
373-
374- it ( 'should handle missing address with DUPLICATE stability' , done => {
375- instrumentation . setConfig ( {
376- semconvStability : SemconvStability . DUPLICATE ,
377- } ) ;
378-
379- const originalAddress = client . address ;
380- delete client . address ;
381-
382- client . del ( 'test_dup_no_addr' , ( err : unknown ) => {
383- assert . ifError ( err ) ;
384-
385- client . address = originalAddress ;
386-
387- const spans = testUtils . getTestSpans ( ) ;
388- assert . strictEqual ( spans . length , 1 ) ;
389- const span = spans [ 0 ] ;
390-
391- assert . ok ( ! ( SEMATTRS_DB_CONNECTION_STRING in span . attributes ) ) ;
392-
393- assert . strictEqual (
394- span . attributes [ SEMATTRS_NET_PEER_NAME ] ,
395- CONFIG . host
396- ) ;
397- assert . strictEqual (
398- span . attributes [ SEMATTRS_NET_PEER_PORT ] ,
399- CONFIG . port
400- ) ;
401- assert . strictEqual (
402- span . attributes [ ATTR_SERVER_ADDRESS ] ,
403- CONFIG . host
404- ) ;
405- assert . strictEqual ( span . attributes [ ATTR_SERVER_PORT ] , CONFIG . port ) ;
406- done ( ) ;
407- } ) ;
408- } ) ;
409-
410- it ( 'should handle missing connection_options with STABLE stability' , done => {
411- instrumentation . setConfig ( {
412- semconvStability : SemconvStability . STABLE ,
413- } ) ;
414-
415- const originalConnectionOptions = client . connection_options ;
416- delete client . connection_options ;
417-
418- client . get ( 'test_no_connection' , ( err : unknown ) => {
419- assert . ifError ( err ) ;
420-
421- client . connection_options = originalConnectionOptions ;
422-
423- const spans = testUtils . getTestSpans ( ) ;
424- assert . strictEqual ( spans . length , 1 ) ;
425- const span = spans [ 0 ] ;
426-
427- assert . ok ( ! ( ATTR_SERVER_ADDRESS in span . attributes ) ) ;
428- assert . ok ( ! ( ATTR_SERVER_PORT in span . attributes ) ) ;
429-
430- assert . strictEqual ( span . attributes [ ATTR_DB_SYSTEM_NAME ] , 'redis' ) ;
431- assert . strictEqual ( span . attributes [ ATTR_DB_OPERATION_NAME ] , 'get' ) ;
432- done ( ) ;
433- } ) ;
434- } ) ;
435-
436- it ( 'should handle missing connection_options with DUPLICATE stability' , done => {
437- instrumentation . setConfig ( {
438- semconvStability : SemconvStability . DUPLICATE ,
439- } ) ;
440-
441- const originalConnectionOptions = client . connection_options ;
442- delete client . connection_options ;
443-
444- client . set ( 'test_dup_no_conn' , 'value' , ( err : any , result : any ) => {
445- assert . ifError ( err ) ;
446-
447- client . connection_options = originalConnectionOptions ;
448-
449- const spans = testUtils . getTestSpans ( ) ;
450- assert . strictEqual ( spans . length , 1 ) ;
451- const span = spans [ 0 ] ;
452-
453- assert . ok ( ! ( ATTR_SERVER_ADDRESS in span . attributes ) ) ;
454- assert . ok ( ! ( ATTR_SERVER_PORT in span . attributes ) ) ;
455- assert . ok ( ! ( SEMATTRS_NET_PEER_NAME in span . attributes ) ) ;
456- assert . ok ( ! ( SEMATTRS_NET_PEER_PORT in span . attributes ) ) ;
457-
458- assert . strictEqual ( span . attributes [ ATTR_DB_SYSTEM_NAME ] , 'redis' ) ;
459- assert . strictEqual ( span . attributes [ SEMATTRS_DB_SYSTEM ] , 'redis' ) ;
460- assert . strictEqual ( span . attributes [ ATTR_DB_OPERATION_NAME ] , 'set' ) ;
461- done ( ) ;
462- } ) ;
463- } ) ;
464-
465- it ( 'should handle present connection_options with STABLE stability' , done => {
466- instrumentation . setConfig ( {
467- semconvStability : SemconvStability . STABLE ,
468- } ) ;
469-
470- client . get ( 'test_with_connection_stable' , ( err : unknown ) => {
471- assert . ifError ( err ) ;
472-
473- const spans = testUtils . getTestSpans ( ) ;
474- assert . strictEqual ( spans . length , 1 ) ;
475- const span = spans [ 0 ] ;
476-
477- assert . strictEqual (
478- span . attributes [ ATTR_SERVER_ADDRESS ] ,
479- CONFIG . host
480- ) ;
481- assert . strictEqual ( span . attributes [ ATTR_SERVER_PORT ] , CONFIG . port ) ;
482-
483- assert . strictEqual ( span . attributes [ ATTR_DB_SYSTEM_NAME ] , 'redis' ) ;
484- assert . strictEqual ( span . attributes [ ATTR_DB_OPERATION_NAME ] , 'get' ) ;
485- done ( ) ;
486- } ) ;
487- } ) ;
488-
489- it ( 'should handle present connection_options with DUPLICATE stability' , done => {
490- instrumentation . setConfig ( {
491- semconvStability : SemconvStability . DUPLICATE ,
492- } ) ;
493-
494- client . get ( 'test_with_connection_dup' , ( err : unknown ) => {
495- assert . ifError ( err ) ;
496-
497- const spans = testUtils . getTestSpans ( ) ;
498- assert . strictEqual ( spans . length , 1 ) ;
499- const span = spans [ 0 ] ;
500-
501- assert . strictEqual (
502- span . attributes [ ATTR_SERVER_ADDRESS ] ,
503- CONFIG . host
504- ) ;
505- assert . strictEqual ( span . attributes [ ATTR_SERVER_PORT ] , CONFIG . port ) ;
506- assert . strictEqual (
507- span . attributes [ SEMATTRS_NET_PEER_NAME ] ,
508- CONFIG . host
509- ) ;
510- assert . strictEqual (
511- span . attributes [ SEMATTRS_NET_PEER_PORT ] ,
512- CONFIG . port
513- ) ;
514-
515- assert . strictEqual ( span . attributes [ ATTR_DB_SYSTEM_NAME ] , 'redis' ) ;
516- assert . strictEqual ( span . attributes [ SEMATTRS_DB_SYSTEM ] , 'redis' ) ;
517- assert . strictEqual ( span . attributes [ ATTR_DB_OPERATION_NAME ] , 'get' ) ;
518- done ( ) ;
519- } ) ;
520- } ) ;
521- } ) ;
522- describe ( 'update semconv stability config' , ( ) => {
523- it ( 'should update semconv stability when setConfig is called' , done => {
524- instrumentation . setConfig ( { semconvStability : SemconvStability . OLD } ) ;
525-
526- client . get ( 'test_setconfig_old' , ( err : unknown ) => {
527- assert . ifError ( err ) ;
528-
529- let spans = testUtils . getTestSpans ( ) ;
530- assert . strictEqual ( spans . length , 1 ) ;
531- let span = spans [ 0 ] ;
532-
533- assert . strictEqual ( span . attributes [ SEMATTRS_DB_SYSTEM ] , 'redis' ) ;
534- assert . ok ( ! ( ATTR_DB_SYSTEM_NAME in span . attributes ) ) ;
535-
536- testUtils . resetMemoryExporter ( ) ;
537-
538- instrumentation . setConfig ( {
539- semconvStability : SemconvStability . STABLE ,
540- } ) ;
541-
542- client . get ( 'test_setconfig_stable' , ( err : unknown ) => {
543- assert . ifError ( err ) ;
544-
545- spans = testUtils . getTestSpans ( ) ;
546- assert . strictEqual ( spans . length , 1 ) ;
547- span = spans [ 0 ] ;
548-
549- assert . strictEqual ( span . attributes [ ATTR_DB_SYSTEM_NAME ] , 'redis' ) ;
550- assert . ok ( ! ( SEMATTRS_DB_SYSTEM in span . attributes ) ) ;
551-
552- done ( ) ;
553- } ) ;
554- } ) ;
555- } ) ;
556- } ) ;
557293 } ) ;
558294
559295 describe ( 'Instrumenting query operations' , ( ) => {
0 commit comments