Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added missing fields on MonitoredResource #3887

Merged
merged 2 commits into from
Nov 28, 2018
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