Skip to content

Commit

Permalink
added missing fields googleapis#3559
Browse files Browse the repository at this point in the history
  • Loading branch information
praful committed Nov 15, 2018
1 parent 5e5336d commit 8427193
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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

0 comments on commit 8427193

Please sign in to comment.