Skip to content

Commit

Permalink
Update exporters/prometheus/exporter.go
Browse files Browse the repository at this point in the history
Co-authored-by: David Ashpole <dashpole@google.com>
  • Loading branch information
pellared and dashpole authored Jun 29, 2023
1 parent e70b79f commit 4b5714d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions exporters/prometheus/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,15 @@ func (c *collector) Collect(ch chan<- prometheus.Metric) {

// Initialize (once) targetInfo and disableTargetInfo.
func() {
var err error
var targetInfo prometheus.Metric

c.mu.Lock()
defer func() {
c.mu.Unlock()
if err != nil {
otel.Handle(err)
}
}()
defer c.mu.Unlock()

if c.targetInfo == nil && !c.disableTargetInfo {
targetInfo, err = createInfoMetric(targetInfoMetricName, targetInfoDescription, metrics.Resource)
targetInfo, err := createInfoMetric(targetInfoMetricName, targetInfoDescription, metrics.Resource)
if err != nil {
// If the target info metric is invalid, disable sending it.
c.disableTargetInfo = true
otel.Handle(err)
return
}

Expand Down

0 comments on commit 4b5714d

Please sign in to comment.