Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Monitored Resource: replace gke_container with k8s_container in SD exporter #1467

Merged
merged 3 commits into from
Sep 24, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- Add an API `Functions.returnToString()`.
- Add `opencensus-contrib-opencensus-proto-util` that has helper utilities to convert between
Java data models and protos.
- Migrate to new Stackdriver Kubernetes monitored resource. This could be a breaking change
if you are using `gke_container` resources. For more info,
https://cloud.google.com/monitoring/kubernetes-engine/migration#incompatible

## 0.16.1 - 2018-09-18
- Fix ClassCastException in Log4j log correlation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ final class StackdriverExportUtils {
@VisibleForTesting static final String LABEL_DESCRIPTION = "OpenCensus TagKey";
@VisibleForTesting static final String OPENCENSUS_TASK = "opencensus_task";
@VisibleForTesting static final String OPENCENSUS_TASK_DESCRIPTION = "Opencensus task identifier";
private static final String GCP_GKE_CONTAINER = "gke_container";
private static final String GCP_GKE_CONTAINER = "k8s_container";
private static final String GCP_GCE_INSTANCE = "gce_instance";
private static final String AWS_EC2_INSTANCE = "aws_ec2_instance";
private static final String GLOBAL = "global";
Expand Down Expand Up @@ -499,10 +499,9 @@ private static void setMonitoredResourceLabelsForBuilder(
builder.putLabels(PROJECT_ID_LABEL_KEY, gcpGkeContainerMonitoredResource.getAccount());
builder.putLabels("cluster_name", gcpGkeContainerMonitoredResource.getClusterName());
builder.putLabels("container_name", gcpGkeContainerMonitoredResource.getContainerName());
builder.putLabels("namespace_id", gcpGkeContainerMonitoredResource.getNamespaceId());
builder.putLabels("instance_id", gcpGkeContainerMonitoredResource.getInstanceId());
builder.putLabels("pod_id", gcpGkeContainerMonitoredResource.getPodId());
builder.putLabels("zone", gcpGkeContainerMonitoredResource.getZone());
builder.putLabels("namespace_name", gcpGkeContainerMonitoredResource.getNamespaceId());
builder.putLabels("pod_name", gcpGkeContainerMonitoredResource.getPodId());
builder.putLabels("location", gcpGkeContainerMonitoredResource.getZone());
return;
case AWS_EC2_INSTANCE:
AwsEc2InstanceMonitoredResource awsEc2InstanceMonitoredResource =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,7 @@ static Map<String, AttributeValue> getResourceLabels(
"project_id",
gcpGkeContainerMonitoredResource.getAccount());
putToResourceAttributeMap(
resourceLabels,
resourceType,
"instance_id",
gcpGkeContainerMonitoredResource.getInstanceId());
putToResourceAttributeMap(
resourceLabels, resourceType, "zone", gcpGkeContainerMonitoredResource.getZone());
resourceLabels, resourceType, "location", gcpGkeContainerMonitoredResource.getZone());
putToResourceAttributeMap(
resourceLabels,
resourceType,
Expand All @@ -362,10 +357,10 @@ static Map<String, AttributeValue> getResourceLabels(
putToResourceAttributeMap(
resourceLabels,
resourceType,
"namespace_id",
"namespace_name",
gcpGkeContainerMonitoredResource.getNamespaceId());
putToResourceAttributeMap(
resourceLabels, resourceType, "pod_id", gcpGkeContainerMonitoredResource.getPodId());
resourceLabels, resourceType, "pod_name", gcpGkeContainerMonitoredResource.getPodId());
return Collections.unmodifiableMap(resourceLabels);
}
return Collections.emptyMap();
Expand All @@ -391,7 +386,7 @@ private static String mapToStringResourceType(ResourceType resourceType) {
case GCP_GCE_INSTANCE:
return "gce_instance";
case GCP_GKE_CONTAINER:
return "gke_container";
return "k8s_container";
case AWS_EC2_INSTANCE:
return "aws_ec2_instance";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,13 @@ public final class StackdriverV2ExporterHandlerProtoTest {
createResourceLabelKey(GCP_GKE_CONTAINER, "container_name"),
toStringAttributeValueProto("container"))
.put(
createResourceLabelKey(GCP_GKE_CONTAINER, "namespace_id"),
createResourceLabelKey(GCP_GKE_CONTAINER, "namespace_name"),
toStringAttributeValueProto("namespace"))
.put(
createResourceLabelKey(GCP_GKE_CONTAINER, "instance_id"),
toStringAttributeValueProto("my-instance"))
.put(
createResourceLabelKey(GCP_GKE_CONTAINER, "pod_id"),
createResourceLabelKey(GCP_GKE_CONTAINER, "pod_name"),
toStringAttributeValueProto("pod"))
.put(
createResourceLabelKey(GCP_GKE_CONTAINER, "zone"),
createResourceLabelKey(GCP_GKE_CONTAINER, "location"),
toStringAttributeValueProto("us-east1"))
.build();

Expand Down