in detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java [62:95]
public Attributes getAttributes() {
DetectedPlatform detectedPlatform = detector.detectPlatform();
if (detectedPlatform.getSupportedPlatform()
== GCPPlatformDetector.SupportedPlatform.UNKNOWN_PLATFORM) {
return Attributes.empty();
}
// This is running on some sort of GCPCompute - figure out the platform
AttributesBuilder attrBuilder = Attributes.builder();
attrBuilder.put(ResourceAttributes.CLOUD_PROVIDER, ResourceAttributes.CloudProviderValues.GCP);
attrBuilder.put(ResourceAttributes.CLOUD_ACCOUNT_ID, detectedPlatform.getProjectId());
switch (detectedPlatform.getSupportedPlatform()) {
case GOOGLE_KUBERNETES_ENGINE:
addGKEAttributes(attrBuilder, detectedPlatform.getAttributes());
break;
case GOOGLE_CLOUD_RUN:
addGCRAttributes(attrBuilder, detectedPlatform.getAttributes());
break;
case GOOGLE_CLOUD_FUNCTIONS:
addGCFAttributes(attrBuilder, detectedPlatform.getAttributes());
break;
case GOOGLE_APP_ENGINE:
addGAEAttributes(attrBuilder, detectedPlatform.getAttributes());
break;
case GOOGLE_COMPUTE_ENGINE:
addGCEAttributes(attrBuilder, detectedPlatform.getAttributes());
break;
default:
// We don't support this platform yet, so just return with what we have
}
return attrBuilder.build();
}