@@ -425,9 +425,14 @@ def test_list_projects_defaults(self):
425425 creds = _make_credentials ()
426426 client = self ._make_one (PROJECT_1 , creds )
427427 conn = client ._connection = make_connection (DATA )
428-
429428 iterator = client .list_projects ()
430- page = six .next (iterator .pages )
429+
430+ with mock .patch (
431+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
432+ ) as final_attributes :
433+ page = six .next (iterator .pages )
434+
435+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
431436 projects = list (page )
432437 token = iterator .next_page_token
433438
@@ -455,7 +460,13 @@ def test_list_projects_w_timeout(self):
455460 conn = client ._connection = make_connection (DATA )
456461
457462 iterator = client .list_projects (timeout = 7.5 )
458- six .next (iterator .pages )
463+
464+ with mock .patch (
465+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
466+ ) as final_attributes :
467+ six .next (iterator .pages )
468+
469+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
459470
460471 conn .api_request .assert_called_once_with (
461472 method = "GET" , path = "/projects" , query_params = {}, timeout = 7.5
@@ -469,7 +480,13 @@ def test_list_projects_explicit_response_missing_projects_key(self):
469480 conn = client ._connection = make_connection (DATA )
470481
471482 iterator = client .list_projects (max_results = 3 , page_token = TOKEN )
472- page = six .next (iterator .pages )
483+
484+ with mock .patch (
485+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
486+ ) as final_attributes :
487+ page = six .next (iterator .pages )
488+
489+ final_attributes .assert_called_once_with ({"path" : "/projects" }, client , None )
473490 projects = list (page )
474491 token = iterator .next_page_token
475492
@@ -518,7 +535,12 @@ def test_list_datasets_defaults(self):
518535 conn = client ._connection = make_connection (DATA )
519536
520537 iterator = client .list_datasets ()
521- page = six .next (iterator .pages )
538+ with mock .patch (
539+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
540+ ) as final_attributes :
541+ page = six .next (iterator .pages )
542+
543+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
522544 datasets = list (page )
523545 token = iterator .next_page_token
524546
@@ -538,7 +560,14 @@ def test_list_datasets_w_project_and_timeout(self):
538560 client = self ._make_one (self .PROJECT , creds )
539561 conn = client ._connection = make_connection ({})
540562
541- list (client .list_datasets (project = "other-project" , timeout = 7.5 ))
563+ with mock .patch (
564+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
565+ ) as final_attributes :
566+ list (client .list_datasets (project = "other-project" , timeout = 7.5 ))
567+
568+ final_attributes .assert_called_once_with (
569+ {"path" : "/projects/other-project/datasets" }, client , None
570+ )
542571
543572 conn .api_request .assert_called_once_with (
544573 method = "GET" ,
@@ -559,7 +588,12 @@ def test_list_datasets_explicit_response_missing_datasets_key(self):
559588 iterator = client .list_datasets (
560589 include_all = True , filter = FILTER , max_results = 3 , page_token = TOKEN
561590 )
562- page = six .next (iterator .pages )
591+ with mock .patch (
592+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
593+ ) as final_attributes :
594+ page = six .next (iterator .pages )
595+
596+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
563597 datasets = list (page )
564598 token = iterator .next_page_token
565599
@@ -2838,7 +2872,12 @@ def test_list_tables_empty_w_timeout(self):
28382872 dataset = DatasetReference (self .PROJECT , self .DS_ID )
28392873 iterator = client .list_tables (dataset , timeout = 7.5 )
28402874 self .assertIs (iterator .dataset , dataset )
2841- page = six .next (iterator .pages )
2875+ with mock .patch (
2876+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2877+ ) as final_attributes :
2878+ page = six .next (iterator .pages )
2879+
2880+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
28422881 tables = list (page )
28432882 token = iterator .next_page_token
28442883
@@ -2856,7 +2895,12 @@ def test_list_models_empty_w_timeout(self):
28562895
28572896 dataset_id = "{}.{}" .format (self .PROJECT , self .DS_ID )
28582897 iterator = client .list_models (dataset_id , timeout = 7.5 )
2859- page = six .next (iterator .pages )
2898+ with mock .patch (
2899+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2900+ ) as final_attributes :
2901+ page = six .next (iterator .pages )
2902+
2903+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
28602904 models = list (page )
28612905 token = iterator .next_page_token
28622906
@@ -2900,7 +2944,12 @@ def test_list_models_defaults(self):
29002944
29012945 iterator = client .list_models (dataset )
29022946 self .assertIs (iterator .dataset , dataset )
2903- page = six .next (iterator .pages )
2947+ with mock .patch (
2948+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2949+ ) as final_attributes :
2950+ page = six .next (iterator .pages )
2951+
2952+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
29042953 models = list (page )
29052954 token = iterator .next_page_token
29062955
@@ -2926,7 +2975,16 @@ def test_list_routines_empty_w_timeout(self):
29262975 conn = client ._connection = make_connection ({})
29272976
29282977 iterator = client .list_routines ("test-routines.test_routines" , timeout = 7.5 )
2929- page = six .next (iterator .pages )
2978+ with mock .patch (
2979+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
2980+ ) as final_attributes :
2981+ page = six .next (iterator .pages )
2982+
2983+ final_attributes .assert_called_once_with (
2984+ {"path" : "/projects/test-routines/datasets/test_routines/routines" },
2985+ client ,
2986+ None ,
2987+ )
29302988 routines = list (page )
29312989 token = iterator .next_page_token
29322990
@@ -2975,7 +3033,12 @@ def test_list_routines_defaults(self):
29753033
29763034 iterator = client .list_routines (dataset )
29773035 self .assertIs (iterator .dataset , dataset )
2978- page = six .next (iterator .pages )
3036+ with mock .patch (
3037+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3038+ ) as final_attributes :
3039+ page = six .next (iterator .pages )
3040+
3041+ final_attributes .assert_called_once_with ({"path" : path }, client , None )
29793042 routines = list (page )
29803043 actual_token = iterator .next_page_token
29813044
@@ -3039,7 +3102,12 @@ def test_list_tables_defaults(self):
30393102
30403103 iterator = client .list_tables (dataset )
30413104 self .assertIs (iterator .dataset , dataset )
3042- page = six .next (iterator .pages )
3105+ with mock .patch (
3106+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3107+ ) as final_attributes :
3108+ page = six .next (iterator .pages )
3109+
3110+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
30433111 tables = list (page )
30443112 token = iterator .next_page_token
30453113
@@ -3098,7 +3166,12 @@ def test_list_tables_explicit(self):
30983166 page_token = TOKEN ,
30993167 )
31003168 self .assertEqual (iterator .dataset , dataset )
3101- page = six .next (iterator .pages )
3169+ with mock .patch (
3170+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3171+ ) as final_attributes :
3172+ page = six .next (iterator .pages )
3173+
3174+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
31023175 tables = list (page )
31033176 token = iterator .next_page_token
31043177
@@ -3921,7 +3994,12 @@ def test_list_jobs_defaults(self):
39213994 conn = client ._connection = make_connection (DATA )
39223995
39233996 iterator = client .list_jobs ()
3924- page = six .next (iterator .pages )
3997+ with mock .patch (
3998+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
3999+ ) as final_attributes :
4000+ page = six .next (iterator .pages )
4001+
4002+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
39254003 jobs = list (page )
39264004 token = iterator .next_page_token
39274005
@@ -3966,7 +4044,12 @@ def test_list_jobs_load_job_wo_sourceUris(self):
39664044 conn = client ._connection = make_connection (DATA )
39674045
39684046 iterator = client .list_jobs ()
3969- page = six .next (iterator .pages )
4047+ with mock .patch (
4048+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
4049+ ) as final_attributes :
4050+ page = six .next (iterator .pages )
4051+
4052+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
39704053 jobs = list (page )
39714054 token = iterator .next_page_token
39724055
@@ -3995,7 +4078,12 @@ def test_list_jobs_explicit_missing(self):
39954078 iterator = client .list_jobs (
39964079 max_results = 1000 , page_token = TOKEN , all_users = True , state_filter = "done"
39974080 )
3998- page = six .next (iterator .pages )
4081+ with mock .patch (
4082+ "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
4083+ ) as final_attributes :
4084+ page = six .next (iterator .pages )
4085+
4086+ final_attributes .assert_called_once_with ({"path" : "/%s" % PATH }, client , None )
39994087 jobs = list (page )
40004088 token = iterator .next_page_token
40014089
0 commit comments