Skip to content

Commit

Permalink
Fix priority of conflict labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Sep 21, 2023
1 parent 00b0b66 commit 9f01fd4
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions exporters/prometheus/src/exporter_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,6 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me
break;
}

opentelemetry::sdk::resource::ResourceAttributes::const_iterator prometheus_job_it =
resource->GetAttributes().find(kPrometheusJob);
if (prometheus_job_it != resource->GetAttributes().end())
{
AddPrometheusLabel(kPrometheusJob, AttributeValueToString(prometheus_job_it->second),
&metric.label);
break;
}

opentelemetry::sdk::resource::ResourceAttributes::const_iterator service_name_it =
resource->GetAttributes().find(
opentelemetry::sdk::resource::SemanticConventions::kServiceName);
Expand All @@ -433,22 +424,32 @@ void PrometheusExporterUtils::SetMetricBasic(prometheus_client::ClientMetric &me
AttributeValueToString(service_namespace_it->second) + "/" +
AttributeValueToString(service_name_it->second),
&metric.label);
break;
}
else if (service_name_it != resource->GetAttributes().end())
{
AddPrometheusLabel(kPrometheusJob, AttributeValueToString(service_name_it->second),
&metric.label);
break;
}

opentelemetry::sdk::resource::ResourceAttributes::const_iterator prometheus_job_it =
resource->GetAttributes().find(kPrometheusJob);
if (prometheus_job_it != resource->GetAttributes().end())
{
AddPrometheusLabel(kPrometheusJob, AttributeValueToString(prometheus_job_it->second),
&metric.label);
}
} while (false);

if (!has_instance_label)
{
opentelemetry::sdk::resource::ResourceAttributes::const_iterator service_instance_id_it =
resource->GetAttributes().find(kPrometheusInstance);
resource->GetAttributes().find(
opentelemetry::sdk::resource::SemanticConventions::kServiceInstanceId);
if (service_instance_id_it == resource->GetAttributes().end())
{
service_instance_id_it = resource->GetAttributes().find(
opentelemetry::sdk::resource::SemanticConventions::kServiceInstanceId);
service_instance_id_it = resource->GetAttributes().find(kPrometheusInstance);
}
if (service_instance_id_it != resource->GetAttributes().end())
{
Expand Down

0 comments on commit 9f01fd4

Please sign in to comment.