logging: add "instance_name" label to detectedResource
Adds "instance_name" from metadata, as a label
to detectedResources when running on GCE.
Fixes
@@ -273,11 +273,16 @@ func detectResource() *mrpb.MonitoredResource {
if err != nil {
return
}
+ name, err := metadata.InstanceName()
+ if err != nil {
+ return
+ }
detectedResource.pb = &mrpb.MonitoredResource{
Type: "gce_instance",
Labels: map[string]string{
"project_id": projectID,
"instance_id": id,
+ "instance_name": name,
"zone": zone,
},
}
