This repository was archived by the owner on Apr 7, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
main/java/com/google/cloud/spanner
test/java/com/google/cloud/spanner Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ class TraceWrapper {
5555 AttributeKey .stringKey ("gcp.client.version" );
5656 private static final AttributeKey <String > GCP_CLIENT_REPO_KEY =
5757 AttributeKey .stringKey ("gcp.client.repo" );
58+ private static final AttributeKey <String > GCP_RESOURCE_NAME_KEY =
59+ AttributeKey .stringKey ("gcp.resource.name" );
60+ private static final String GCP_RESOURCE_NAME_PREFIX = "//spanner.googleapis.com/" ;
5861 private static final AttributeKey <String > THREAD_NAME_KEY = AttributeKey .stringKey ("thread.name" );
5962
6063 private final Tracer openCensusTracer ;
@@ -219,6 +222,7 @@ Attributes createDatabaseAttributes(DatabaseId db) {
219222 AttributesBuilder builder = Attributes .builder ();
220223 builder .put (DB_NAME_KEY , db .getDatabase ());
221224 builder .put (INSTANCE_NAME_KEY , db .getInstanceId ().getInstance ());
225+ builder .put (GCP_RESOURCE_NAME_KEY , GCP_RESOURCE_NAME_PREFIX + db .getName ());
222226 return builder .build ();
223227 }
224228
Original file line number Diff line number Diff line change @@ -912,6 +912,11 @@ private static void verifyCommonAttributes(SpanData span) {
912912 assertEquals (
913913 span .getAttributes ().get (AttributeKey .stringKey ("gcp.client.version" )),
914914 GaxProperties .getLibraryVersion (TraceWrapper .class ));
915+ assertEquals (
916+ span .getAttributes ().get (AttributeKey .stringKey ("gcp.resource.name" )),
917+ String .format (
918+ "//spanner.googleapis.com/projects/%s/instances/%s/databases/%s" ,
919+ TEST_PROJECT , TEST_INSTANCE , TEST_DATABASE ));
915920 }
916921
917922 private static void verifyTableAttributes (SpanData span ) {
You can’t perform that action at this time.
0 commit comments