Skip to content

Commit 9ad9b35

Browse files
committed
test: include tests of resource name and url.full
1 parent 4ec963c commit 9ad9b35

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

java-compute/google-cloud-compute/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,18 @@
146146
<scope>test</scope>
147147
</dependency>
148148
</dependencies>
149+
150+
<build>
151+
<plugins>
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-surefire-plugin</artifactId>
155+
<configuration>
156+
<environmentVariables>
157+
<GOOGLE_SDK_JAVA_LOGGING>true</GOOGLE_SDK_JAVA_LOGGING>
158+
</environmentVariables>
159+
</configuration>
160+
</plugin>
161+
</plugins>
162+
</build>
149163
</project>

java-compute/google-cloud-compute/src/test/java/com/google/cloud/compute/v1/integration/ITComputeGoldenSignals.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,18 @@ private void fetchAndValidateTrace(String traceId, boolean expectError) throws E
257257
.isEqualTo("googleapis/google-cloud-java");
258258
assertThat(span.getLabelsMap().get(ObservabilityAttributes.HTTP_URL_TEMPLATE_ATTRIBUTE))
259259
.isEqualTo("compute/v1/projects/{project=*}/zones/{zone=*}/instances");
260+
String expectedDestinationResource;
261+
if (expectError) {
262+
expectedDestinationResource = "//compute.googleapis.com/projects/invalid-project-";
263+
} else {
264+
expectedDestinationResource =
265+
"//compute.googleapis.com/projects/" + DEFAULT_PROJECT + "/zones/us-central1-a";
266+
}
260267
assertThat(span.getLabelsMap().get(ObservabilityAttributes.DESTINATION_RESOURCE_ID_ATTRIBUTE))
261-
.isEqualTo("//compute.googleapis.com/projects/" + DEFAULT_PROJECT + "/zones/us-central1-a");
262-
268+
.startsWith(expectedDestinationResource);
269+
263270
// These might fail if not supported in HTTP/REST yet
264271
assertThat(span.getLabelsMap()).containsKey(ObservabilityAttributes.HTTP_URL_FULL_ATTRIBUTE);
265-
assertThat(span.getLabelsMap()).containsKey(ObservabilityAttributes.HTTP_RESPONSE_BODY_SIZE);
266272

267273
if (expectError) {
268274
assertThat(span.getLabelsMap().get(ObservabilityAttributes.HTTP_RESPONSE_STATUS_ATTRIBUTE))

sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/CompositeTracer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,11 @@ public void injectTraceContext(java.util.Map<String, String> carrier) {
220220
child.injectTraceContext(carrier);
221221
}
222222
}
223+
224+
@Override
225+
public void requestUrlResolved(String requestUrl) {
226+
for (ApiTracer child : children) {
227+
child.requestUrlResolved(requestUrl);
228+
}
229+
}
223230
}

0 commit comments

Comments
 (0)