@@ -39,6 +39,7 @@ import {Instance, Spanner} from '../src';
39
39
import * as pfy from '@google-cloud/promisify' ;
40
40
import { grpc } from 'google-gax' ;
41
41
import { MockError } from '../test/mockserver/mockspanner' ;
42
+ const { generateWithAllSpansHaveDBName} = require ( './helper' ) ;
42
43
43
44
const fakePfy = extend ( { } , pfy , {
44
45
promisifyAll ( klass , options ) {
@@ -235,16 +236,20 @@ describe('Database', () => {
235
236
DatabaseCached = Object . assign ( { } , Database ) ;
236
237
} ) ;
237
238
239
+ const withAllSpansHaveDBName = generateWithAllSpansHaveDBName (
240
+ INSTANCE . formattedName_ + '/databases/' + NAME
241
+ ) ;
242
+
238
243
beforeEach ( ( ) => {
239
244
fakeCodec . encode = util . noop ;
240
245
extend ( Database , DatabaseCached ) ;
241
- database = new Database ( INSTANCE , NAME , POOL_OPTIONS ) ;
242
- database . parent = INSTANCE ;
243
- database . databaseRole = 'parent_role' ;
244
- database . _observabilityOptions = {
246
+ INSTANCE . _observabilityOptions = {
245
247
tracerProvider : provider ,
246
248
enableExtendedTracing : false ,
247
249
} ;
250
+ database = new Database ( INSTANCE , NAME , POOL_OPTIONS ) ;
251
+ database . parent = INSTANCE ;
252
+ database . databaseRole = 'parent_role' ;
248
253
const gaxOpts = { } ;
249
254
const options : {
250
255
a : string ;
@@ -285,6 +290,8 @@ describe('Database', () => {
285
290
const spans = traceExporter . getFinishedSpans ( ) ;
286
291
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
287
292
293
+ withAllSpansHaveDBName ( spans ) ;
294
+
288
295
const actualSpanNames : string [ ] = [ ] ;
289
296
const actualEventNames : string [ ] = [ ] ;
290
297
spans . forEach ( span => {
@@ -333,6 +340,7 @@ describe('Database', () => {
333
340
traceExporter . forceFlush ( ) ;
334
341
const spans = traceExporter . getFinishedSpans ( ) ;
335
342
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
343
+ withAllSpansHaveDBName ( spans ) ;
336
344
337
345
const actualSpanNames : string [ ] = [ ] ;
338
346
const actualEventNames : string [ ] = [ ] ;
@@ -523,6 +531,7 @@ describe('Database', () => {
523
531
traceExporter . forceFlush ( ) ;
524
532
const spans = traceExporter . getFinishedSpans ( ) ;
525
533
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
534
+ withAllSpansHaveDBName ( spans ) ;
526
535
527
536
const actualSpanNames : string [ ] = [ ] ;
528
537
const actualEventNames : string [ ] = [ ] ;
@@ -604,6 +613,7 @@ describe('Database', () => {
604
613
605
614
const spans = traceExporter . getFinishedSpans ( ) ;
606
615
assert . strictEqual ( spans . length , 2 , 'Exactly 2 spans expected' ) ;
616
+ withAllSpansHaveDBName ( spans ) ;
607
617
608
618
const actualSpanNames : string [ ] = [ ] ;
609
619
const actualEventNames : string [ ] = [ ] ;
@@ -706,6 +716,8 @@ describe('Database', () => {
706
716
707
717
const spans = traceExporter . getFinishedSpans ( ) ;
708
718
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
719
+ withAllSpansHaveDBName ( spans ) ;
720
+
709
721
const actualEventNames : string [ ] = [ ] ;
710
722
const actualSpanNames : string [ ] = [ ] ;
711
723
spans . forEach ( span => {
@@ -771,6 +783,7 @@ describe('Database', () => {
771
783
assert . strictEqual ( resp , RESPONSE ) ;
772
784
const spans = traceExporter . getFinishedSpans ( ) ;
773
785
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
786
+ withAllSpansHaveDBName ( spans ) ;
774
787
775
788
const actualEventNames : string [ ] = [ ] ;
776
789
const actualSpanNames : string [ ] = [ ] ;
@@ -836,6 +849,8 @@ describe('Database', () => {
836
849
837
850
const spans = traceExporter . getFinishedSpans ( ) ;
838
851
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
852
+ withAllSpansHaveDBName ( spans ) ;
853
+
839
854
const actualSpanNames : string [ ] = [ ] ;
840
855
const actualEventNames : string [ ] = [ ] ;
841
856
spans . forEach ( span => {
@@ -911,6 +926,8 @@ describe('Database', () => {
911
926
912
927
const spans = traceExporter . getFinishedSpans ( ) ;
913
928
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
929
+ withAllSpansHaveDBName ( spans ) ;
930
+
914
931
const actualEventNames : string [ ] = [ ] ;
915
932
const actualSpanNames : string [ ] = [ ] ;
916
933
spans . forEach ( span => {
@@ -958,6 +975,8 @@ describe('Database', () => {
958
975
assert . strictEqual ( transaction , fakeTransaction ) ;
959
976
960
977
const spans = traceExporter . getFinishedSpans ( ) ;
978
+ withAllSpansHaveDBName ( spans ) ;
979
+
961
980
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
962
981
const actualEventNames : string [ ] = [ ] ;
963
982
const actualSpanNames : string [ ] = [ ] ;
@@ -1037,6 +1056,7 @@ describe('Database', () => {
1037
1056
1038
1057
const spans = traceExporter . getFinishedSpans ( ) ;
1039
1058
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1059
+ withAllSpansHaveDBName ( spans ) ;
1040
1060
1041
1061
const actualEventNames : string [ ] = [ ] ;
1042
1062
const actualSpanNames : string [ ] = [ ] ;
@@ -1091,6 +1111,7 @@ describe('Database', () => {
1091
1111
1092
1112
const spans = traceExporter . getFinishedSpans ( ) ;
1093
1113
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1114
+ withAllSpansHaveDBName ( spans ) ;
1094
1115
1095
1116
const actualEventNames : string [ ] = [ ] ;
1096
1117
const actualSpanNames : string [ ] = [ ] ;
@@ -1148,6 +1169,8 @@ describe('Database', () => {
1148
1169
1149
1170
const spans = traceExporter . getFinishedSpans ( ) ;
1150
1171
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1172
+ withAllSpansHaveDBName ( spans ) ;
1173
+
1151
1174
const actualSpanNames : string [ ] = [ ] ;
1152
1175
const actualEventNames : string [ ] = [ ] ;
1153
1176
spans . forEach ( span => {
@@ -1222,6 +1245,8 @@ describe('Database', () => {
1222
1245
1223
1246
const spans = traceExporter . getFinishedSpans ( ) ;
1224
1247
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1248
+ withAllSpansHaveDBName ( spans ) ;
1249
+
1225
1250
const actualSpanNames : string [ ] = [ ] ;
1226
1251
const actualEventNames : string [ ] = [ ] ;
1227
1252
spans . forEach ( span => {
@@ -1273,6 +1298,8 @@ describe('Database', () => {
1273
1298
1274
1299
const spans = traceExporter . getFinishedSpans ( ) ;
1275
1300
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1301
+ withAllSpansHaveDBName ( spans ) ;
1302
+
1276
1303
const actualSpanNames : string [ ] = [ ] ;
1277
1304
const actualEventNames : string [ ] = [ ] ;
1278
1305
spans . forEach ( span => {
@@ -1376,6 +1403,8 @@ describe('Database', () => {
1376
1403
1377
1404
const spans = traceExporter . getFinishedSpans ( ) ;
1378
1405
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1406
+ withAllSpansHaveDBName ( spans ) ;
1407
+
1379
1408
const actualEventNames : string [ ] = [ ] ;
1380
1409
const actualSpanNames : string [ ] = [ ] ;
1381
1410
spans . forEach ( span => {
@@ -1427,6 +1456,8 @@ describe('Database', () => {
1427
1456
1428
1457
const spans = traceExporter . getFinishedSpans ( ) ;
1429
1458
assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1459
+ withAllSpansHaveDBName ( spans ) ;
1460
+
1430
1461
const actualEventNames : string [ ] = [ ] ;
1431
1462
const actualSpanNames : string [ ] = [ ] ;
1432
1463
spans . forEach ( span => {
@@ -1491,6 +1522,8 @@ describe('Database', () => {
1491
1522
1492
1523
const spans = traceExporter . getFinishedSpans ( ) ;
1493
1524
assert . strictEqual ( spans . length , 2 , 'Exactly 1 span expected' ) ;
1525
+ withAllSpansHaveDBName ( spans ) ;
1526
+
1494
1527
const actualSpanNames : string [ ] = [ ] ;
1495
1528
const actualEventNames : string [ ] = [ ] ;
1496
1529
spans . forEach ( span => {
0 commit comments