Skip to content

Commit

Permalink
switch to struct for set
Browse files Browse the repository at this point in the history
  • Loading branch information
dashpole committed Apr 23, 2024
1 parent 03140b8 commit 4698662
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions exporter/collector/googlemanagedprometheus/extra_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (c Config) addTargetInfoMetric(m pmetric.Metrics) {
if !c.ExtraMetricsConfig.EnableTargetInfo {
return
}
ids := make(map[resourceID]bool)
ids := make(map[resourceID]struct{})
rms := m.ResourceMetrics()
// loop over input (original) resource metrics
for i := 0; i < rms.Len(); i++ {
Expand Down Expand Up @@ -188,11 +188,11 @@ func (c Config) addTargetInfoMetric(m pmetric.Metrics) {
serviceNamespace: getResourceAttr(semconv.AttributeServiceNamespace),
serviceInstanceID: getResourceAttr(semconv.AttributeServiceInstanceID),
}
if ids[id] {
if _, ok := ids[id]; ok {
// We've already added a resource with the same ID before, so skip this one.
continue
}
ids[id] = true
ids[id] = struct{}{}

// create the target_info metric as a Gauge with value 1
targetInfoMetric := rm.ScopeMetrics().AppendEmpty().Metrics().AppendEmpty()
Expand Down Expand Up @@ -238,7 +238,7 @@ func (c Config) addScopeInfoMetric(m pmetric.Metrics) {
if !c.ExtraMetricsConfig.EnableScopeInfo {
return
}
ids := make(map[scopeID]bool)
ids := make(map[scopeID]struct{})
rms := m.ResourceMetrics()
for i := 0; i < rms.Len(); i++ {
rm := rms.At(i)
Expand Down Expand Up @@ -328,11 +328,11 @@ func (c Config) addScopeInfoMetric(m pmetric.Metrics) {
name: sm.Scope().Name(),
version: sm.Scope().Version(),
}
if ids[id] {
if _, ok := ids[id]; ok {
// We've already added a scope with the same ID before, so skip this one.
continue
}
ids[id] = true
ids[id] = struct{}{}

// Add otel_scope_info metric
scopeInfoMetric := sm.Metrics().AppendEmpty()
Expand Down

0 comments on commit 4698662

Please sign in to comment.