@@ -39,6 +39,7 @@ import {Instance, Spanner} from '../src';
3939import * as pfy from '@google-cloud/promisify' ;
4040import { grpc } from 'google-gax' ;
4141import { MockError } from '../test/mockserver/mockspanner' ;
42+ const { generateWithAllSpansHaveDBName} = require ( './helper' ) ;
4243
4344const fakePfy = extend ( { } , pfy , {
4445 promisifyAll ( klass , options ) {
@@ -235,16 +236,20 @@ describe('Database', () => {
235236 DatabaseCached = Object . assign ( { } , Database ) ;
236237 } ) ;
237238
239+ const withAllSpansHaveDBName = generateWithAllSpansHaveDBName (
240+ INSTANCE . formattedName_ + '/databases/' + NAME
241+ ) ;
242+
238243 beforeEach ( ( ) => {
239244 fakeCodec . encode = util . noop ;
240245 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 = {
245247 tracerProvider : provider ,
246248 enableExtendedTracing : false ,
247249 } ;
250+ database = new Database ( INSTANCE , NAME , POOL_OPTIONS ) ;
251+ database . parent = INSTANCE ;
252+ database . databaseRole = 'parent_role' ;
248253 const gaxOpts = { } ;
249254 const options : {
250255 a : string ;
@@ -285,6 +290,8 @@ describe('Database', () => {
285290 const spans = traceExporter . getFinishedSpans ( ) ;
286291 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
287292
293+ withAllSpansHaveDBName ( spans ) ;
294+
288295 const actualSpanNames : string [ ] = [ ] ;
289296 const actualEventNames : string [ ] = [ ] ;
290297 spans . forEach ( span => {
@@ -333,6 +340,7 @@ describe('Database', () => {
333340 traceExporter . forceFlush ( ) ;
334341 const spans = traceExporter . getFinishedSpans ( ) ;
335342 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
343+ withAllSpansHaveDBName ( spans ) ;
336344
337345 const actualSpanNames : string [ ] = [ ] ;
338346 const actualEventNames : string [ ] = [ ] ;
@@ -523,6 +531,7 @@ describe('Database', () => {
523531 traceExporter . forceFlush ( ) ;
524532 const spans = traceExporter . getFinishedSpans ( ) ;
525533 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
534+ withAllSpansHaveDBName ( spans ) ;
526535
527536 const actualSpanNames : string [ ] = [ ] ;
528537 const actualEventNames : string [ ] = [ ] ;
@@ -604,6 +613,7 @@ describe('Database', () => {
604613
605614 const spans = traceExporter . getFinishedSpans ( ) ;
606615 assert . strictEqual ( spans . length , 2 , 'Exactly 2 spans expected' ) ;
616+ withAllSpansHaveDBName ( spans ) ;
607617
608618 const actualSpanNames : string [ ] = [ ] ;
609619 const actualEventNames : string [ ] = [ ] ;
@@ -706,6 +716,8 @@ describe('Database', () => {
706716
707717 const spans = traceExporter . getFinishedSpans ( ) ;
708718 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
719+ withAllSpansHaveDBName ( spans ) ;
720+
709721 const actualEventNames : string [ ] = [ ] ;
710722 const actualSpanNames : string [ ] = [ ] ;
711723 spans . forEach ( span => {
@@ -771,6 +783,7 @@ describe('Database', () => {
771783 assert . strictEqual ( resp , RESPONSE ) ;
772784 const spans = traceExporter . getFinishedSpans ( ) ;
773785 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
786+ withAllSpansHaveDBName ( spans ) ;
774787
775788 const actualEventNames : string [ ] = [ ] ;
776789 const actualSpanNames : string [ ] = [ ] ;
@@ -836,6 +849,8 @@ describe('Database', () => {
836849
837850 const spans = traceExporter . getFinishedSpans ( ) ;
838851 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
852+ withAllSpansHaveDBName ( spans ) ;
853+
839854 const actualSpanNames : string [ ] = [ ] ;
840855 const actualEventNames : string [ ] = [ ] ;
841856 spans . forEach ( span => {
@@ -911,6 +926,8 @@ describe('Database', () => {
911926
912927 const spans = traceExporter . getFinishedSpans ( ) ;
913928 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
929+ withAllSpansHaveDBName ( spans ) ;
930+
914931 const actualEventNames : string [ ] = [ ] ;
915932 const actualSpanNames : string [ ] = [ ] ;
916933 spans . forEach ( span => {
@@ -958,6 +975,8 @@ describe('Database', () => {
958975 assert . strictEqual ( transaction , fakeTransaction ) ;
959976
960977 const spans = traceExporter . getFinishedSpans ( ) ;
978+ withAllSpansHaveDBName ( spans ) ;
979+
961980 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
962981 const actualEventNames : string [ ] = [ ] ;
963982 const actualSpanNames : string [ ] = [ ] ;
@@ -1037,6 +1056,7 @@ describe('Database', () => {
10371056
10381057 const spans = traceExporter . getFinishedSpans ( ) ;
10391058 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1059+ withAllSpansHaveDBName ( spans ) ;
10401060
10411061 const actualEventNames : string [ ] = [ ] ;
10421062 const actualSpanNames : string [ ] = [ ] ;
@@ -1091,6 +1111,7 @@ describe('Database', () => {
10911111
10921112 const spans = traceExporter . getFinishedSpans ( ) ;
10931113 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1114+ withAllSpansHaveDBName ( spans ) ;
10941115
10951116 const actualEventNames : string [ ] = [ ] ;
10961117 const actualSpanNames : string [ ] = [ ] ;
@@ -1148,6 +1169,8 @@ describe('Database', () => {
11481169
11491170 const spans = traceExporter . getFinishedSpans ( ) ;
11501171 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1172+ withAllSpansHaveDBName ( spans ) ;
1173+
11511174 const actualSpanNames : string [ ] = [ ] ;
11521175 const actualEventNames : string [ ] = [ ] ;
11531176 spans . forEach ( span => {
@@ -1222,6 +1245,8 @@ describe('Database', () => {
12221245
12231246 const spans = traceExporter . getFinishedSpans ( ) ;
12241247 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1248+ withAllSpansHaveDBName ( spans ) ;
1249+
12251250 const actualSpanNames : string [ ] = [ ] ;
12261251 const actualEventNames : string [ ] = [ ] ;
12271252 spans . forEach ( span => {
@@ -1273,6 +1298,8 @@ describe('Database', () => {
12731298
12741299 const spans = traceExporter . getFinishedSpans ( ) ;
12751300 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1301+ withAllSpansHaveDBName ( spans ) ;
1302+
12761303 const actualSpanNames : string [ ] = [ ] ;
12771304 const actualEventNames : string [ ] = [ ] ;
12781305 spans . forEach ( span => {
@@ -1376,6 +1403,8 @@ describe('Database', () => {
13761403
13771404 const spans = traceExporter . getFinishedSpans ( ) ;
13781405 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1406+ withAllSpansHaveDBName ( spans ) ;
1407+
13791408 const actualEventNames : string [ ] = [ ] ;
13801409 const actualSpanNames : string [ ] = [ ] ;
13811410 spans . forEach ( span => {
@@ -1427,6 +1456,8 @@ describe('Database', () => {
14271456
14281457 const spans = traceExporter . getFinishedSpans ( ) ;
14291458 assert . strictEqual ( spans . length , 1 , 'Exactly 1 span expected' ) ;
1459+ withAllSpansHaveDBName ( spans ) ;
1460+
14301461 const actualEventNames : string [ ] = [ ] ;
14311462 const actualSpanNames : string [ ] = [ ] ;
14321463 spans . forEach ( span => {
@@ -1491,6 +1522,8 @@ describe('Database', () => {
14911522
14921523 const spans = traceExporter . getFinishedSpans ( ) ;
14931524 assert . strictEqual ( spans . length , 2 , 'Exactly 1 span expected' ) ;
1525+ withAllSpansHaveDBName ( spans ) ;
1526+
14941527 const actualSpanNames : string [ ] = [ ] ;
14951528 const actualEventNames : string [ ] = [ ] ;
14961529 spans . forEach ( span => {
0 commit comments