Skip to content

Commit

Permalink
add javadoc to public classes
Browse files Browse the repository at this point in the history
  • Loading branch information
psx95 committed Jan 6, 2024
1 parent 8ab8080 commit 601b4f0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package com.google.cloud.opentelemetry.detectors;

/**
* Contains constants that act as keys for the known attributes for {@link
* com.google.cloud.opentelemetry.detectors.GCPPlatformDetector.SupportedPlatform}s.
*/
public final class AttributeKeys {
// GCE Attributes
public static final String GCE_PROJECT_ID = AttributeKeys.PROJECT_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@

import java.util.Map;

/** Represents a GCP specific platform on which a cloud application can run. */
public interface DetectedPlatform {
/**
* Method to retrieve the underlying compute platform on which application is running.
*
* @return the {@link GCPPlatformDetector.SupportedPlatform} representing the Google Cloud
* platform on which application is running.
*/
GCPPlatformDetector.SupportedPlatform getSupportedPlatform();

/**
* Method to retrieve the attributes associated with the compute platform on which the application
* is running as key-value pairs.
*
* @return a {@link Map} of attributes specific to the underlying compute platform.
*/
Map<String, String> getAttributes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ private GCPPlatformDetector() {
this.environmentVariables = EnvironmentVariables.DEFAULT_INSTANCE;
}

// Detects the GCP platform on which the application is running
/**
* Detects the GCP platform on which the application is running.
*
* @return the specific GCP platform on which the application is running.
*/
public DetectedPlatform detectPlatform() {
return generateDetectedPlatform(detectSupportedPlatform());
}
Expand Down Expand Up @@ -83,12 +87,22 @@ private DetectedPlatform generateDetectedPlatform(SupportedPlatform platform) {
return detectedPlatform;
}

/**
* SupportedPlatform represents the GCP platforms that can currently be detected by the
* resource-detector.
*/
public enum SupportedPlatform {
/** Represents the Google Compute Engine platform. */
GOOGLE_COMPUTE_ENGINE,
/** Represents the Google Kubernetes Engine platform. */
GOOGLE_KUBERNETES_ENGINE,
/** Represents the Google App Engine platform. Could either be flex or standard. */
GOOGLE_APP_ENGINE,
/** Represents the Google Cloud Run platform. */
GOOGLE_CLOUD_RUN,
/** Represents the Google Cloud Functions platform. */
GOOGLE_CLOUD_FUNCTIONS,
UNKNOWN_PLATFORM, // Not running on GCP
/** Represents the case when the application is not running on GCP. */
UNKNOWN_PLATFORM,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Map;
import java.util.Optional;

/** Utility class to help add GKE specific attributes to a given resource */
final class GoogleKubernetesEngine implements DetectedPlatform {
private final EnvironmentVariables environmentVariables;
private final GCPMetadataConfig metadataConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.util.Map;

/**
* Utility class to help add attributes applicable to serverless compute in GCP to a given resource.
* GoogleServerlessCompute adds attributes applicable to all serverless compute platforms in GCP.
* Currently, this includes Google Cloud Functions & Google Cloud Run.
*/
abstract class GoogleServerlessCompute implements DetectedPlatform {
private final EnvironmentVariables environmentVariables;
Expand Down

0 comments on commit 601b4f0

Please sign in to comment.