diff --git a/build.gradle b/build.gradle
index dea1427d..dd2438c5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -170,7 +170,7 @@ subprojects {
junit5Version = '5.10.0'
mockitoVersion = '5.2.0'
pubSubVersion = '1.133.0'
- testContainersVersion = '1.15.1'
+ testContainersVersion = '1.15.3'
wiremockVersion = '2.35.0'
springVersion = '2.7.18'
springWebVersion = '2.4.5'
diff --git a/detectors/resources/README.md b/detectors/resources/README.md
deleted file mode 100644
index e47155a4..00000000
--- a/detectors/resources/README.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Resource Detectors for OpenTelemetry
-
-[![Maven Central][maven-image]][maven-url] ![Status][deprecated]
-
-> NOTE: This artifact has moved to [Opentelemetry Java Contrib](https://github.com/open-telemetry/opentelemetry-java-contrib/tree/eece7e8ef04170fb463ddf692f61d4527b50febf/gcp-resources) repository. All future releases/updates made to this artifact would be managed in the new repository. The code for this artifact is likely to be deleted from here in the near future.
-
-This package provides resource detectors for OpenTelemetry.
-
-The following OpenTelemetry semantic conventions will be detected:
-
-| Resource attribute | GCE | GKE | Cloud Run |
-| ------------------ | --- | --- | ----------|
-| cloud.platform | gce_compute_engine | gce_kubernetes_engine | |
-| cloud.provider | gcp | gcp | |
-| cloud.account.id | auto | auto | |
-| cloud.availability_zone | auto | auto | |
-| cloud.region | auto | auto | |
-| host.id | auto | auto | |
-| host.name | auto | auto | |
-| host.type | auto | auto | |
-| k8s.pod.name | | downward API or auto | |
-| k8s.namespace.name | | downward API | |
-| k8s.container.name | | hardcoded | |
-| k8s.cluster.name | | auto | |
-
-## Downward API
-
-For GKE applications, some values most be passed via the environment variable using k8s
-"downward API". For example, the following spec will ensure `k8s.namespace.name` and
-`k8s.pod.name` are correctly discovered:
-
-```yaml
-spec:
- containers:
- - name: my-application
- image: gcr.io/my-project/my-image:latest
- env:
- - name: POD_NAME
- valueFrom:
- fieldRef:
- fieldPath: metadata.name
- - name: NAMESPACE
- valueFrom:
- fieldRef:
- fieldPath: metadata.namespace
- - name: CONTAINER_NAME
- value: my-application
-```
-
-Additionally, the container name will only be discovered via the environment variable `CONTAINER_NAME`
-which much be included in the environment.
-
-[maven-image]: https://maven-badges.herokuapp.com/maven-central/com.google.cloud.opentelemetry/detector-resources/badge.svg
-[maven-url]: https://maven-badges.herokuapp.com/maven-central/com.google.cloud.opentelemetry/detector-resources
-[deprecated]: https://img.shields.io/badge/status-deprecated-red
\ No newline at end of file
diff --git a/detectors/resources/build.gradle b/detectors/resources/build.gradle
deleted file mode 100644
index 6c94b38c..00000000
--- a/detectors/resources/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-description = 'Google Cloud resource provider for OpenTelemetry'
-
-dependencies {
- implementation(libraries.opentelemetry_api)
- implementation(libraries.opentelemetry_sdk)
- implementation(libraries.opentelemetry_sdk_autoconf)
- implementation(libraries.opentelemetry_semconv)
- implementation(libraries.opentelemetry_semconv_incubating)
- implementation platform(libraries.opentelemetry_bom)
- implementation project(':detector-resources-support')
- testImplementation(testLibraries.junit5)
- testRuntimeOnly(testLibraries.junit5_runtime)
- testImplementation(testLibraries.mockito)
- compileOnly(libraries.opentelemetry_gcp_resources)
-}
-
-test {
- // required for discovering JUnit 5 tests
- useJUnitPlatform()
-}
diff --git a/detectors/resources/gradle.properties b/detectors/resources/gradle.properties
deleted file mode 100644
index 250f5ac6..00000000
--- a/detectors/resources/gradle.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-release.qualifier=alpha
-release.enabled=false
diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java
deleted file mode 100644
index e13289ee..00000000
--- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/AttributesExtractorUtil.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.opentelemetry.detectors;
-
-import io.opentelemetry.api.common.AttributesBuilder;
-import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
-
-/**
- * A utility class that contains method that facilitate extraction of attributes from environment
- * variables and metadata configurations.
- *
- *
This class only adds helper methods to extract {@link CloudIncubatingAttributes} and {@link
- * FaasIncubatingAttributes} that are common across all the supported compute environments.
- *
- * @deprecated Not for public use. This class is expected to be retained only as package private.
- */
-@Deprecated
-public class AttributesExtractorUtil {
-
- /**
- * Utility method to extract cloud availability zone from passed {@link GCPMetadataConfig}. The
- * method modifies the passed attributesBuilder by adding the extracted property to it. If the
- * zone cannot be found, calling this method has no effect.
- *
- *
- * - If the availability zone cannot be found, calling this method has no effect.
- *
- Calling this method will update {@link CloudIncubatingAttributes#CLOUD_AVAILABILITY_ZONE}
- * attribute.
- *
- *
- * Example zone: australia-southeast1-a
- *
- * @param attributesBuilder The {@link AttributesBuilder} to which the extracted property needs to
- * be added.
- * @param metadataConfig The {@link GCPMetadataConfig} from which the cloud availability zone
- * value is extracted.
- */
- public static void addAvailabilityZoneFromMetadata(
- AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
- String zone = metadataConfig.getZone();
- if (zone != null) {
- attributesBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone);
- }
- }
-
- /**
- * Utility method to extract the cloud region from passed {@link GCPMetadataConfig}. The method
- * modifies the passed attributesBuilder by adding the extracted property to it.
- *
- *
- * - If the cloud region cannot be found, calling this method has no effect.
- *
- Calling this method will update {@link CloudIncubatingAttributes#CLOUD_REGION} attribute.
- *
- This method uses zone attribute to parse region from it.
- *
- *
- * Example region: australia-southeast1
- *
- * @param attributesBuilder The {@link AttributesBuilder} to which the extracted property needs to
- * be added.
- * @param metadataConfig The {@link GCPMetadataConfig} from which the cloud region value is
- * extracted.
- */
- public static void addCloudRegionFromMetadataUsingZone(
- AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
- String zone = metadataConfig.getZone();
- if (zone != null) {
- // Parsing required to scope up to a region
- String[] splitArr = zone.split("-");
- if (splitArr.length > 2) {
- attributesBuilder.put(
- CloudIncubatingAttributes.CLOUD_REGION, splitArr[0] + "-" + splitArr[1]);
- }
- }
- }
-
- /**
- * Utility method to extract the cloud region from passed {@link GCPMetadataConfig}. The method
- * modifies the passed attributesBuilder by adding the extracted property to it.
- *
- *
- * - If the cloud region cannot be found, calling this method has no effect.
- *
- Calling this method will update {@link CloudIncubatingAttributes#CLOUD_REGION} attribute.
- *
- This method directly uses the region attribute from the metadata config.
- *
- *
- * Example region: australia-southeast1
- *
- * @param attributesBuilder The {@link AttributesBuilder} to which the extracted property needs to
- * be added.
- * @param metadataConfig The {@link GCPMetadataConfig} from which the cloud region value is
- * extracted.
- */
- public static void addCloudRegionFromMetadataUsingRegion(
- AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
- String region = metadataConfig.getRegion();
- if (region != null) {
- attributesBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region);
- }
- }
-
- /**
- * Utility method to extract the current compute instance ID from the passed {@link
- * GCPMetadataConfig}. The method modifies the passed attributesBuilder by adding the extracted
- * property to it.
- *
- *
- * - If the instance ID cannot be found, calling this method has no effect.
- *
- Calling this method will update {@link FaasIncubatingAttributes#FAAS_INSTANCE} attribute.
- *
- *
- * @param attributesBuilder The {@link AttributesBuilder} to which the extracted property needs to
- * be added.
- * @param metadataConfig The {@link GCPMetadataConfig} from which the instance ID value is
- * extracted.
- */
- public static void addInstanceIdFromMetadata(
- AttributesBuilder attributesBuilder, GCPMetadataConfig metadataConfig) {
- String instanceId = metadataConfig.getInstanceId();
- if (instanceId != null) {
- attributesBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, instanceId);
- }
- }
-}
diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/EnvVars.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/EnvVars.java
deleted file mode 100644
index e34f87da..00000000
--- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/EnvVars.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.opentelemetry.detectors;
-
-/**
- * Provides API to fetch environment variables. This is useful in order to create a mock class for
- * testing.
- *
- * @deprecated Not for public use. This interface is expected to be retained only as package
- * private.
- */
-@Deprecated
-public interface EnvVars {
- EnvVars DEFAULT_INSTANCE = System::getenv;
-
- /**
- * Grabs the system environment variable. Returns null on failure.
- *
- * @param key the key of the environment variable in {@code System.getenv()}
- * @return the value received by {@code System.getenv(key)}
- */
- String get(String key);
-}
diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPMetadataConfig.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPMetadataConfig.java
deleted file mode 100644
index 53f083ff..00000000
--- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPMetadataConfig.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.opentelemetry.detectors;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Retrieves Google Cloud project-id and a limited set of instance attributes from Metadata server.
- *
- * @see
- * https://cloud.google.com/compute/docs/storing-retrieving-metadata
- * @deprecated This class is no longer used, it is only maintained here to support {@link
- * AttributesExtractorUtil}.
- */
-@Deprecated
-final class GCPMetadataConfig {
- private static final String DEFAULT_URL = "http://metadata.google.internal/computeMetadata/v1/";
- public static final GCPMetadataConfig DEFAULT_INSTANCE = new GCPMetadataConfig(DEFAULT_URL);
-
- private final String url;
- private final Map cachedAttributes = new HashMap<>();
-
- // For testing only
- public GCPMetadataConfig(String url) {
- this.url = url;
- }
-
- boolean isRunningOnGcp() {
- return getProjectId() != null && !getProjectId().isEmpty();
- }
-
- // Returns null on failure to retrieve from metadata server
- String getProjectId() {
- return getAttribute("project/project-id");
- }
-
- // Example response: projects/640212054955/zones/australia-southeast1-a
- // Returns null on failure to retrieve from metadata server
- String getZone() {
- String zone = getAttribute("instance/zone");
- if (zone != null && zone.contains("/")) {
- zone = zone.substring(zone.lastIndexOf('/') + 1);
- }
- return zone;
- }
-
- // Use this method only when the region cannot be parsed from the zone. Known use-cases of this
- // method involve detecting region in GAE standard environment
- // Example response: projects/5689182099321/regions/us-central1
- // Returns null on failure to retrieve from metadata server
- String getRegion() {
- String region = getAttribute("instance/region");
- if (region != null && region.contains("/")) {
- region = region.substring(region.lastIndexOf('/') + 1);
- }
- return region;
- }
-
- // Example response: projects/640212054955/machineTypes/e2-medium
- String getMachineType() {
- String machineType = getAttribute("instance/machine-type");
- if (machineType != null && machineType.contains("/")) {
- machineType = machineType.substring(machineType.lastIndexOf('/') + 1);
- }
- return machineType;
- }
-
- // Returns null on failure to retrieve from metadata server
- String getInstanceId() {
- return getAttribute("instance/id");
- }
-
- // Returns null on failure to retrieve from metadata server
- String getClusterName() {
- return getAttribute("instance/attributes/cluster-name");
- }
-
- // Returns null on failure to retrieve from metadata server
- String getClusterLocation() {
- return getAttribute("instance/attributes/cluster-location");
- }
-
- // Returns null on failure to retrieve from metadata server
- String getInstanceHostName() {
- return getAttribute("instance/hostname");
- }
-
- // Returns null on failure to retrieve from metadata server
- String getInstanceName() {
- return getAttribute("instance/name");
- }
-
- // Returns null on failure to retrieve from metadata server
- private String getAttribute(String attributeName) {
- return cachedAttributes.computeIfAbsent(attributeName, this::fetchAttribute);
- }
-
- // Return the attribute received at relative path or null on failure
- private String fetchAttribute(String attributeName) {
- try {
- URL url = new URL(this.url + attributeName);
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- connection.setRequestProperty("Metadata-Flavor", "Google");
- if (connection.getResponseCode() == 200
- && ("Google").equals(connection.getHeaderField("Metadata-Flavor"))) {
- InputStream input = connection.getInputStream();
- try (BufferedReader reader =
- new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
- return reader.readLine();
- }
- }
- } catch (IOException ignore) {
- // ignore
- }
- return null;
- }
-}
diff --git a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java b/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java
deleted file mode 100644
index 56111035..00000000
--- a/detectors/resources/src/main/java/com/google/cloud/opentelemetry/detectors/GCPResource.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.opentelemetry.detectors;
-
-import static com.google.cloud.opentelemetry.detection.AttributeKeys.*;
-
-import com.google.cloud.opentelemetry.detection.DetectedPlatform;
-import com.google.cloud.opentelemetry.detection.GCPPlatformDetector;
-import io.opentelemetry.api.common.Attributes;
-import io.opentelemetry.api.common.AttributesBuilder;
-import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
-import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
-import io.opentelemetry.sdk.resources.Resource;
-import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.GcpIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.HostIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.K8sIncubatingAttributes;
-import java.util.Map;
-import java.util.Optional;
-import java.util.logging.Logger;
-
-/**
- * This class is used to detect the correct GCP compute platform resource. Supports detection of
- * Google Compute Engine (GCE), Google Kubernetes Engine (GKE), Google Cloud Functions (GCF), Google
- * App Engine (GAE) and Google Cloud Run (GCR).
- *
- * @deprecated Use {@link io.opentelemetry.contrib.gcp.resource.GCPResourceProvider} from io.opentelemetry.contrib:opentelemetry-gcp-resources
- * instead.
- */
-@Deprecated
-public class GCPResource implements ResourceProvider {
-
- private static final Logger LOGGER = Logger.getLogger(GCPResource.class.getSimpleName());
- private final GCPPlatformDetector detector;
-
- // for testing only
- GCPResource(GCPPlatformDetector detector) {
- this.detector = detector;
- }
-
- public GCPResource() {
- this.detector = GCPPlatformDetector.DEFAULT_INSTANCE;
- }
-
- /**
- * Generates and returns the attributes for the resource. The attributes vary depending on the
- * type of resource detected.
- *
- * @return The {@link Attributes} for the detected resource.
- */
- 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(
- CloudIncubatingAttributes.CLOUD_PROVIDER,
- CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP);
- attrBuilder.put(CloudIncubatingAttributes.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();
- }
-
- @Override
- public Resource createResource(ConfigProperties config) {
- return Resource.create(getAttributes());
- }
-
- /**
- * Updates the attributes builder with required attributes for GCE resource, if GCE resource is
- * applicable. By default, if the resource is running on GCP, it is assumed to be GCE. This means
- * additional attributes are added/overwritten if later on, the resource is identified to be some
- * other platform - like GKE, GAE, etc.
- */
- private void addGCEAttributes(AttributesBuilder attrBuilder, Map attributesMap) {
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_PLATFORM,
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_COMPUTE_ENGINE);
-
- Optional.ofNullable(attributesMap.get(GCE_AVAILABILITY_ZONE))
- .ifPresent(
- zone -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone));
- Optional.ofNullable(attributesMap.get(GCE_CLOUD_REGION))
- .ifPresent(region -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region));
- Optional.ofNullable(attributesMap.get(GCE_INSTANCE_ID))
- .ifPresent(instanceId -> attrBuilder.put(HostIncubatingAttributes.HOST_ID, instanceId));
- Optional.ofNullable(attributesMap.get(GCE_INSTANCE_NAME))
- .ifPresent(
- instanceName -> {
- attrBuilder.put(HostIncubatingAttributes.HOST_NAME, instanceName);
- attrBuilder.put(GcpIncubatingAttributes.GCP_GCE_INSTANCE_NAME, instanceName);
- });
- Optional.ofNullable(attributesMap.get(GCE_INSTANCE_HOSTNAME))
- .ifPresent(
- instanceHostname ->
- attrBuilder.put(
- GcpIncubatingAttributes.GCP_GCE_INSTANCE_HOSTNAME, instanceHostname));
- Optional.ofNullable(attributesMap.get(GCE_MACHINE_TYPE))
- .ifPresent(machineType -> attrBuilder.put(HostIncubatingAttributes.HOST_TYPE, machineType));
- }
-
- /**
- * Updates the attributes with the required keys for a GKE (Google Kubernetes Engine) environment.
- * The attributes are not updated in case the environment is not deemed to be GKE.
- *
- * @param attrBuilder The {@link AttributesBuilder} object that needs to be updated with the
- * necessary keys.
- */
- private void addGKEAttributes(AttributesBuilder attrBuilder, Map attributesMap) {
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_PLATFORM,
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_KUBERNETES_ENGINE);
-
- Optional.ofNullable(attributesMap.get(GKE_CLUSTER_NAME))
- .ifPresent(
- clusterName -> attrBuilder.put(K8sIncubatingAttributes.K8S_CLUSTER_NAME, clusterName));
- Optional.ofNullable(attributesMap.get(GKE_HOST_ID))
- .ifPresent(hostId -> attrBuilder.put(HostIncubatingAttributes.HOST_ID, hostId));
- Optional.ofNullable(attributesMap.get(GKE_CLUSTER_LOCATION_TYPE))
- .ifPresent(
- locationType -> {
- if (attributesMap.get(GKE_CLUSTER_LOCATION) != null) {
- switch (locationType) {
- case GKE_LOCATION_TYPE_REGION:
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_REGION,
- attributesMap.get(GKE_CLUSTER_LOCATION));
- break;
- case GKE_LOCATION_TYPE_ZONE:
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE,
- attributesMap.get(GKE_CLUSTER_LOCATION));
- default:
- // TODO: Figure out how to handle unexpected conditions like this - Issue #183
- LOGGER.severe(
- String.format(
- "Unrecognized format for cluster location: %s",
- attributesMap.get(GKE_CLUSTER_LOCATION)));
- }
- }
- });
- }
-
- /**
- * Updates the attributes with the required keys for a GCR (Google Cloud Run) environment. The
- * attributes are not updated in case the environment is not deemed to be GCR.
- *
- * @param attrBuilder The {@link AttributesBuilder} object that needs to be updated with the
- * necessary keys.
- */
- private void addGCRAttributes(AttributesBuilder attrBuilder, Map attributesMap) {
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_PLATFORM,
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_RUN);
- addCommonAttributesForServerlessCompute(attrBuilder, attributesMap);
- }
-
- /**
- * Updates the attributes with the required keys for a GCF (Google Cloud Functions) environment.
- * The attributes are not updated in case the environment is not deemed to be GCF.
- *
- * @param attrBuilder The {@link AttributesBuilder} object that needs to be updated with the
- * necessary keys.
- */
- private void addGCFAttributes(AttributesBuilder attrBuilder, Map attributesMap) {
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_PLATFORM,
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_FUNCTIONS);
- addCommonAttributesForServerlessCompute(attrBuilder, attributesMap);
- }
-
- /**
- * Updates the attributes with the required keys for a GAE (Google App Engine) environment. The
- * attributes are not updated in case the environment is not deemed to be GAE.
- *
- * @param attrBuilder The {@link AttributesBuilder} object that needs to be updated with the
- * necessary keys.
- */
- private void addGAEAttributes(AttributesBuilder attrBuilder, Map attributesMap) {
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_PLATFORM,
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_APP_ENGINE);
- Optional.ofNullable(attributesMap.get(GAE_MODULE_NAME))
- .ifPresent(appName -> attrBuilder.put(FaasIncubatingAttributes.FAAS_NAME, appName));
- Optional.ofNullable(attributesMap.get(GAE_APP_VERSION))
- .ifPresent(
- appVersion -> attrBuilder.put(FaasIncubatingAttributes.FAAS_VERSION, appVersion));
- Optional.ofNullable(attributesMap.get(GAE_INSTANCE_ID))
- .ifPresent(
- appInstanceId ->
- attrBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, appInstanceId));
- Optional.ofNullable(attributesMap.get(GAE_CLOUD_REGION))
- .ifPresent(
- cloudRegion -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, cloudRegion));
- Optional.ofNullable(attributesMap.get(GAE_AVAILABILITY_ZONE))
- .ifPresent(
- cloudAvailabilityZone ->
- attrBuilder.put(
- CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, cloudAvailabilityZone));
- }
-
- /**
- * This function adds common attributes required for most serverless compute platforms within GCP.
- * Currently, these attributes are required for both GCF and GCR.
- *
- * @param attrBuilder The {@link AttributesBuilder} object that needs to be updated with the
- * necessary keys.
- */
- private void addCommonAttributesForServerlessCompute(
- AttributesBuilder attrBuilder, Map attributesMap) {
- Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_NAME))
- .ifPresent(name -> attrBuilder.put(FaasIncubatingAttributes.FAAS_NAME, name));
- Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_REVISION))
- .ifPresent(revision -> attrBuilder.put(FaasIncubatingAttributes.FAAS_VERSION, revision));
- Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_INSTANCE_ID))
- .ifPresent(
- instanceId -> attrBuilder.put(FaasIncubatingAttributes.FAAS_INSTANCE, instanceId));
- Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_AVAILABILITY_ZONE))
- .ifPresent(
- zone -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE, zone));
- Optional.ofNullable(attributesMap.get(SERVERLESS_COMPUTE_CLOUD_REGION))
- .ifPresent(region -> attrBuilder.put(CloudIncubatingAttributes.CLOUD_REGION, region));
- }
-}
diff --git a/detectors/resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider b/detectors/resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
deleted file mode 100644
index a5d52a5c..00000000
--- a/detectors/resources/src/main/resources/META-INF/services/io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider
+++ /dev/null
@@ -1 +0,0 @@
-com.google.cloud.opentelemetry.detectors.GCPResource
diff --git a/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java b/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java
deleted file mode 100644
index 16adb2a0..00000000
--- a/detectors/resources/src/test/java/com/google/cloud/opentelemetry/detectors/GCPResourceTest.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright 2023 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.cloud.opentelemetry.detectors;
-
-import static com.google.cloud.opentelemetry.detection.AttributeKeys.*;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import com.google.cloud.opentelemetry.detection.DetectedPlatform;
-import com.google.cloud.opentelemetry.detection.GCPPlatformDetector;
-import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
-import io.opentelemetry.sdk.autoconfigure.spi.ResourceProvider;
-import io.opentelemetry.sdk.resources.Resource;
-import io.opentelemetry.semconv.incubating.CloudIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.FaasIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.GcpIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.HostIncubatingAttributes;
-import io.opentelemetry.semconv.incubating.K8sIncubatingAttributes;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ServiceLoader;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-public class GCPResourceTest {
- private static final String DUMMY_PROJECT_ID = "google-pid";
- private final ConfigProperties mockConfigProps = Mockito.mock(ConfigProperties.class);
- private final Map mockGKECommonAttributes =
- new HashMap<>() {
- {
- put(GKE_CLUSTER_NAME, "gke-cluster");
- put(GKE_HOST_ID, "host1");
- }
- };
-
- // Mock Platforms
- private DetectedPlatform generateMockGCEPlatform() {
- Map mockAttributes =
- new HashMap<>() {
- {
- put(GCE_CLOUD_REGION, "australia-southeast1");
- put(GCE_AVAILABILITY_ZONE, "australia-southeast1-b");
- put(GCE_INSTANCE_ID, "random-id");
- put(GCE_INSTANCE_NAME, "instance-name");
- put(GCE_MACHINE_TYPE, "gce-m2");
- put(GCE_INSTANCE_HOSTNAME, "instance-hostname");
- }
- };
- DetectedPlatform mockGCEPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockGCEPlatform.getSupportedPlatform())
- .thenReturn(GCPPlatformDetector.SupportedPlatform.GOOGLE_COMPUTE_ENGINE);
- Mockito.when(mockGCEPlatform.getAttributes()).thenReturn(mockAttributes);
- Mockito.when(mockGCEPlatform.getProjectId()).thenReturn(DUMMY_PROJECT_ID);
- return mockGCEPlatform;
- }
-
- private DetectedPlatform generateMockGKEPlatform(String gkeClusterLocationType) {
- Map mockAttributes = new HashMap<>(mockGKECommonAttributes);
- if (gkeClusterLocationType.equals(GKE_LOCATION_TYPE_ZONE)) {
- mockAttributes.put(GKE_CLUSTER_LOCATION, "australia-southeast1-a");
- } else if (gkeClusterLocationType.equals(GKE_LOCATION_TYPE_REGION)) {
- mockAttributes.put(GKE_CLUSTER_LOCATION, "australia-southeast1");
- }
- mockAttributes.put(GKE_CLUSTER_LOCATION_TYPE, gkeClusterLocationType);
-
- DetectedPlatform mockGKEPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockGKEPlatform.getSupportedPlatform())
- .thenReturn(GCPPlatformDetector.SupportedPlatform.GOOGLE_KUBERNETES_ENGINE);
- Mockito.when(mockGKEPlatform.getAttributes()).thenReturn(mockAttributes);
- Mockito.when(mockGKEPlatform.getProjectId()).thenReturn(DUMMY_PROJECT_ID);
- return mockGKEPlatform;
- }
-
- private DetectedPlatform generateMockServerlessPlatform(
- GCPPlatformDetector.SupportedPlatform platform) {
- final EnumSet serverlessPlatforms =
- EnumSet.of(
- GCPPlatformDetector.SupportedPlatform.GOOGLE_CLOUD_RUN,
- GCPPlatformDetector.SupportedPlatform.GOOGLE_CLOUD_FUNCTIONS);
- if (!serverlessPlatforms.contains(platform)) {
- throw new IllegalArgumentException();
- }
- Map mockAttributes =
- new HashMap<>() {
- {
- put(SERVERLESS_COMPUTE_NAME, "serverless-app");
- put(SERVERLESS_COMPUTE_REVISION, "v2");
- put(SERVERLESS_COMPUTE_INSTANCE_ID, "serverless-instance-id");
- put(SERVERLESS_COMPUTE_CLOUD_REGION, "us-central1");
- put(SERVERLESS_COMPUTE_AVAILABILITY_ZONE, "us-central1-b");
- }
- };
- DetectedPlatform mockServerlessPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockServerlessPlatform.getSupportedPlatform()).thenReturn(platform);
- Mockito.when(mockServerlessPlatform.getAttributes()).thenReturn(mockAttributes);
- Mockito.when(mockServerlessPlatform.getProjectId()).thenReturn(DUMMY_PROJECT_ID);
- return mockServerlessPlatform;
- }
-
- private DetectedPlatform generateMockGAEPlatform() {
- Map mockAttributes =
- new HashMap<>() {
- {
- put(GAE_MODULE_NAME, "gae-app");
- put(GAE_APP_VERSION, "v1");
- put(GAE_INSTANCE_ID, "gae-instance-id");
- put(GAE_CLOUD_REGION, "us-central1");
- put(GAE_AVAILABILITY_ZONE, "us-central1-b");
- }
- };
- DetectedPlatform mockGAEPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockGAEPlatform.getSupportedPlatform())
- .thenReturn(GCPPlatformDetector.SupportedPlatform.GOOGLE_APP_ENGINE);
- Mockito.when(mockGAEPlatform.getAttributes()).thenReturn(mockAttributes);
- Mockito.when(mockGAEPlatform.getProjectId()).thenReturn(DUMMY_PROJECT_ID);
- return mockGAEPlatform;
- }
-
- private DetectedPlatform generateMockUnknownPlatform() {
- Map mockAttributes =
- new HashMap<>() {
- {
- put(GCE_INSTANCE_ID, "instance-id");
- put(GCE_CLOUD_REGION, "australia-southeast1");
- }
- };
-
- DetectedPlatform mockUnknownPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockUnknownPlatform.getSupportedPlatform())
- .thenReturn(GCPPlatformDetector.SupportedPlatform.UNKNOWN_PLATFORM);
- Mockito.when(mockUnknownPlatform.getAttributes()).thenReturn(mockAttributes);
- return mockUnknownPlatform;
- }
-
- @Test
- public void testGCECloudIncubatingAttributesMapping() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockGCEPlatform();
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
-
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertEquals(
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_COMPUTE_ENGINE,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PLATFORM));
- assertEquals(
- CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PROVIDER));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_INSTANCE_ID),
- gotResource.getAttributes().get(HostIncubatingAttributes.HOST_ID));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_INSTANCE_NAME),
- gotResource.getAttributes().get(HostIncubatingAttributes.HOST_NAME));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_INSTANCE_NAME),
- gotResource.getAttributes().get(GcpIncubatingAttributes.GCP_GCE_INSTANCE_NAME));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_INSTANCE_HOSTNAME),
- gotResource.getAttributes().get(GcpIncubatingAttributes.GCP_GCE_INSTANCE_HOSTNAME));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_MACHINE_TYPE),
- gotResource.getAttributes().get(HostIncubatingAttributes.HOST_TYPE));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_AVAILABILITY_ZONE),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(
- mockPlatform.getAttributes().get(GCE_CLOUD_REGION),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertEquals(10, gotResource.getAttributes().size());
- }
-
- @Test
- public void testGKECloudIncubatingAttributesMapping_LocationTypeRegion() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockGKEPlatform(GKE_LOCATION_TYPE_REGION);
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
-
- verifyGKEMapping(gotResource, mockPlatform);
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(
- mockPlatform.getAttributes().get(GKE_CLUSTER_LOCATION),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertEquals(6, gotResource.getAttributes().size());
- }
-
- @Test
- public void testGKECloudIncubatingAttributesMapping_LocationTypeZone() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockGKEPlatform(GKE_LOCATION_TYPE_ZONE);
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
-
- verifyGKEMapping(gotResource, mockPlatform);
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertEquals(
- mockPlatform.getAttributes().get(GKE_CLUSTER_LOCATION),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(6, gotResource.getAttributes().size());
- }
-
- @Test
- public void testGKECloudIncubatingAttributesMapping_LocationTypeInvalid() {
- Map mockGKEAttributes = new HashMap<>(mockGKECommonAttributes);
- mockGKEAttributes.put(GKE_CLUSTER_LOCATION_TYPE, "INVALID");
- mockGKEAttributes.put(GKE_CLUSTER_LOCATION, "some-location");
-
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = Mockito.mock(DetectedPlatform.class);
- Mockito.when(mockPlatform.getSupportedPlatform())
- .thenReturn(GCPPlatformDetector.SupportedPlatform.GOOGLE_KUBERNETES_ENGINE);
- Mockito.when(mockPlatform.getProjectId()).thenReturn(DUMMY_PROJECT_ID);
- Mockito.when(mockPlatform.getAttributes()).thenReturn(mockGKEAttributes);
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
-
- verifyGKEMapping(gotResource, mockPlatform);
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(5, gotResource.getAttributes().size());
- }
-
- @Test
- public void testGKECloudIncubatingAttributesMapping_LocationMissing() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockGKEPlatform("");
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
-
- verifyGKEMapping(gotResource, mockPlatform);
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertNull(gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(5, gotResource.getAttributes().size());
- }
-
- private void verifyGKEMapping(Resource gotResource, DetectedPlatform detectedPlatform) {
- assertEquals(
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_KUBERNETES_ENGINE,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PLATFORM));
- assertEquals(
- CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PROVIDER));
- assertEquals(
- detectedPlatform.getAttributes().get(GKE_HOST_ID),
- gotResource.getAttributes().get(HostIncubatingAttributes.HOST_ID));
- assertEquals(
- detectedPlatform.getAttributes().get(GKE_CLUSTER_NAME),
- gotResource.getAttributes().get(K8sIncubatingAttributes.K8S_CLUSTER_NAME));
- }
-
- @Test
- public void testGCRCloudIncubatingAttributesMapping() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform =
- generateMockServerlessPlatform(GCPPlatformDetector.SupportedPlatform.GOOGLE_CLOUD_RUN);
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
- assertEquals(
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_RUN,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PLATFORM));
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- verifyServerlessMapping(gotResource, mockPlatform);
- assertEquals(8, gotResource.getAttributes().size());
- }
-
- @Test
- public void testGCFResourceAttributeMapping() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform =
- generateMockServerlessPlatform(
- GCPPlatformDetector.SupportedPlatform.GOOGLE_CLOUD_FUNCTIONS);
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
- assertEquals(
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_CLOUD_FUNCTIONS,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PLATFORM));
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- verifyServerlessMapping(gotResource, mockPlatform);
- assertEquals(8, gotResource.getAttributes().size());
- }
-
- private void verifyServerlessMapping(Resource gotResource, DetectedPlatform detectedPlatform) {
- assertEquals(
- CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PROVIDER));
- assertEquals(
- detectedPlatform.getAttributes().get(SERVERLESS_COMPUTE_NAME),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_NAME));
- assertEquals(
- detectedPlatform.getAttributes().get(SERVERLESS_COMPUTE_REVISION),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_VERSION));
- assertEquals(
- detectedPlatform.getAttributes().get(SERVERLESS_COMPUTE_INSTANCE_ID),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_INSTANCE));
- assertEquals(
- detectedPlatform.getAttributes().get(SERVERLESS_COMPUTE_AVAILABILITY_ZONE),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(
- detectedPlatform.getAttributes().get(SERVERLESS_COMPUTE_CLOUD_REGION),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- }
-
- @Test
- public void testGAEResourceAttributeMapping() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockGAEPlatform();
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
- assertEquals(
- CloudIncubatingAttributes.CloudPlatformIncubatingValues.GCP_APP_ENGINE,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PLATFORM));
- assertEquals(
- CloudIncubatingAttributes.CloudProviderIncubatingValues.GCP,
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_PROVIDER));
- assertEquals(
- mockPlatform.getProjectId(),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_ACCOUNT_ID));
- assertEquals(
- mockPlatform.getAttributes().get(GAE_MODULE_NAME),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_NAME));
- assertEquals(
- mockPlatform.getAttributes().get(GAE_APP_VERSION),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_VERSION));
- assertEquals(
- mockPlatform.getAttributes().get(GAE_INSTANCE_ID),
- gotResource.getAttributes().get(FaasIncubatingAttributes.FAAS_INSTANCE));
- assertEquals(
- mockPlatform.getAttributes().get(GAE_AVAILABILITY_ZONE),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_AVAILABILITY_ZONE));
- assertEquals(
- mockPlatform.getAttributes().get(GAE_CLOUD_REGION),
- gotResource.getAttributes().get(CloudIncubatingAttributes.CLOUD_REGION));
- assertEquals(8, gotResource.getAttributes().size());
- }
-
- @Test
- public void testUnknownPlatformCloudIncubatingAttributesMapping() {
- GCPPlatformDetector mockDetector = Mockito.mock(GCPPlatformDetector.class);
- DetectedPlatform mockPlatform = generateMockUnknownPlatform();
- Mockito.when(mockDetector.detectPlatform()).thenReturn(mockPlatform);
-
- Resource gotResource = new GCPResource(mockDetector).createResource(mockConfigProps);
- assertTrue(gotResource.getAttributes().isEmpty(), "no attributes for unknown platform");
- }
-
- @Test
- public void findsWithServiceLoader() {
- ServiceLoader services =
- ServiceLoader.load(ResourceProvider.class, getClass().getClassLoader());
- assertTrue(
- services.stream().anyMatch(provider -> provider.type().equals(GCPResource.class)),
- "Could not load GCP Resource detector using serviceloader, found: " + services);
- }
-}
diff --git a/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/EndToEndTest.java b/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/EndToEndTest.java
index 6aaac474..cc7fa036 100644
--- a/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/EndToEndTest.java
+++ b/exporters/metrics/src/test/java/com/google/cloud/opentelemetry/metric/EndToEndTest.java
@@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableList;
import io.opentelemetry.sdk.metrics.export.MetricExporter;
-import java.io.IOException;
import java.util.ArrayList;
import org.junit.Rule;
import org.junit.Test;
@@ -60,7 +59,7 @@ public String getMetricServiceEndpoint() {
@Rule public CloudOperationsMockContainer mockContainer = new CloudOperationsMockContainer();
@Test
- public void testExportMockMetricsDataList() throws IOException {
+ public void testExportMockMetricsDataList() {
exporter =
GoogleCloudMetricExporter.createWithConfiguration(
MetricConfiguration.builder()
@@ -73,7 +72,7 @@ public void testExportMockMetricsDataList() throws IOException {
}
@Test
- public void testExportEmptyMetricsList() throws IOException {
+ public void testExportEmptyMetricsList() {
exporter =
GoogleCloudMetricExporter.createWithConfiguration(
MetricConfiguration.builder()
diff --git a/settings.gradle b/settings.gradle
index 82214cee..adad9150 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -37,7 +37,6 @@ include ":exporter-auto"
include ":examples-autoconf"
include ":examples-autoinstrument"
include ":examples-resource"
-include ":detector-resources"
include ":detector-resources-support"
include ":e2e-test-server"
include ":examples-spring-sleuth"
@@ -73,9 +72,6 @@ project(':examples-metrics').projectDir =
project(':exporter-auto').projectDir =
"$rootDir/exporters/auto" as File
-project(':detector-resources').projectDir =
- "$rootDir/detectors/resources" as File
-
project(':detector-resources-support').projectDir =
"$rootDir/detectors/resources-support" as File