Skip to content

Commit 4739860

Browse files
authored
test(gapic): reuse _DEFAULT_SPAN_ATTRIBUTES and remove unused alias
Remove obsolete _BASE_SPAN_ATTRIBUTES alias and reuse _DEFAULT_SPAN_ATTRIBUTES across custom client options and no-service method tests.
1 parent df33807 commit 4739860

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

packages/google-api-core/tests/unit/gapic/test_method.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ def test__deduplicate_metadata_tokens(headers, expected):
355355
"rpc.system.name": "grpc",
356356
"rpc.method": "google.cloud.secretmanager.v1.SecretManagerService/ListSecrets",
357357
}
358-
_BASE_SPAN_ATTRIBUTES = _DEFAULT_SPAN_ATTRIBUTES
359358

360359

361360
@pytest.mark.parametrize(
@@ -473,19 +472,16 @@ def test_wrap_method_otel_tracing_custom_client_options(mock_otel):
473472
wrapped = google.api_core.gapic_v1.method.wrap_method(
474473
mock_target,
475474
client_options=client_options,
476-
method_name="google.test.Service/TestMethod",
475+
method_name="/google.cloud.secretmanager.v1.SecretManagerService/ListSecrets",
477476
)
478477
result = wrapped()
479478

480479
assert result == "success"
481480
mock_provider.get_tracer.assert_called_once_with("google.api_core")
482481
mock_otel.tracer.start_as_current_span.assert_called_once_with(
483-
"google.test.Service/TestMethod",
482+
"google.cloud.secretmanager.v1.SecretManagerService/ListSecrets",
484483
kind="CLIENT",
485-
attributes={
486-
"rpc.system.name": "grpc",
487-
"rpc.method": "google.test.Service/TestMethod",
488-
},
484+
attributes=_DEFAULT_SPAN_ATTRIBUTES,
489485
)
490486
mock_otel.span.set_attribute.assert_called_with("rpc.response.status_code", "OK")
491487

@@ -658,7 +654,7 @@ def test_wrap_method_otel_tracing_attributes_no_service(mock_otel):
658654
"ListSecrets",
659655
kind="CLIENT",
660656
attributes={
661-
"rpc.system.name": "grpc",
657+
**_DEFAULT_SPAN_ATTRIBUTES,
662658
"rpc.method": "ListSecrets",
663659
},
664660
)

0 commit comments

Comments
 (0)