Skip to content

Commit

Permalink
Add host.id as a fallback for instance (#852)
Browse files Browse the repository at this point in the history
* add host.id as a fallback for instance

* add additional test for service instance id override
  • Loading branch information
dashpole committed May 22, 2024
1 parent f2ec3e7 commit 4c2cadc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var promTargetKeys = map[string][]string{
semconv.AttributeServiceInstanceID,
semconv.AttributeFaaSInstance,
semconv.AttributeK8SPodName,
semconv.AttributeHostID,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,31 @@ func TestMapToPrometheusTarget(t *testing.T) {
},
{
desc: "Attributes from GCE with environment label",
resourceLabels: map[string]string{
"cloud.platform": "gcp_compute_engine",
"cloud.region": "us-central1",
"service.name": "service-name",
"host.id": "1234759430923053489543203",
},
expected: &monitoredrespb.MonitoredResource{
Type: "prometheus_target",
Labels: map[string]string{
"location": "us-central1",
"cluster": "__gce__",
"namespace": "",
"job": "service-name",
"instance": "1234759430923053489543203",
},
},
},
{
desc: "Attributes from GCE with instance ID override",
resourceLabels: map[string]string{
"cloud.platform": "gcp_compute_engine",
"cloud.region": "us-central1",
"service.name": "service-name",
"service.instance.id": "1234759430923053489543203",
"service.instance.id": "service-instance-id",
"host.id": "1234759430923053489543203",
},
expected: &monitoredrespb.MonitoredResource{
Type: "prometheus_target",
Expand All @@ -332,7 +352,7 @@ func TestMapToPrometheusTarget(t *testing.T) {
"cluster": "__gce__",
"namespace": "",
"job": "service-name",
"instance": "1234759430923053489543203",
"instance": "service-instance-id",
},
},
},
Expand Down

0 comments on commit 4c2cadc

Please sign in to comment.