Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public static String getClusterName() {
return getAttribute("instance/attributes/cluster-name");
}

public static String getContainerName(){
return getAttribute("instance/attributes/container-name");
}

public static String getNamespaceId(){
return getAttribute("instance/attributes/namespace-id");
}

public static String getAttribute(String attributeName) {
try {
URL url = new URL(METADATA_URL + attributeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ public class MonitoredResourceUtil {
private enum Label {
AppId("app_id"),
ClusterName("cluster_name"),
ContainerName("container_name"),
InstanceId("instance_id"),
InstanceName("instance_name"),
ModuleId("module_id"),
NamespaceId("namespace_id"),
PodId("pod_id"),
ProjectId("project_id"),
VersionId("version_id"),
Expand Down Expand Up @@ -84,7 +86,9 @@ String getKey() {
.putAll(
Resource.Container.getKey(),
Label.ClusterName,
Label.ContainerName,
Label.InstanceId,
Label.NamespaceId,
Label.PodId,
Label.Zone)
.putAll(Resource.GceInstance.getKey(), Label.InstanceId, Label.Zone)
Expand Down Expand Up @@ -135,6 +139,9 @@ private static String getValue(Label label) {
case ClusterName:
value = MetadataConfig.getClusterName();
break;
case ContainerName:
value = MetadataConfig.getContainerName();
break;
case InstanceId:
value = MetadataConfig.getInstanceId();
break;
Expand All @@ -144,6 +151,9 @@ private static String getValue(Label label) {
case ModuleId:
value = getAppEngineModuleId();
break;
case NamespaceId:
value = MetadataConfig.getNamespaceId();
break;
case PodId:
value = System.getenv("HOSTNAME");
break;
Expand Down