in exporters/metrics/src/main/java/com/google/cloud/opentelemetry/metric/ResourceTranslator.java [57:71]
static MonitoredResource mapResource(
Resource resource, MonitoredResourceDescription mrDescription) {
String mrTypeToMap = resource.getAttributes().get(AttributeKey.stringKey(CUSTOM_MR_KEY));
if (Strings.isNullOrEmpty(mrTypeToMap)) {
return mapResourceUsingCustomerMappings(resource);
} else if (!mrTypeToMap.equals(mrDescription.getMonitoredResourceType())) {
LOGGER.warning(
String.format(
"MonitoredResource type mismatch: Description provided for %s, but found %s in resource attributes. Defaulting to standard mappings.",
mrDescription.getMonitoredResourceType(), mrTypeToMap));
return mapResourceUsingCustomerMappings(resource);
} else {
return mapResourceUsingPlatformMappings(resource, mrTypeToMap, mrDescription);
}
}