Skip to content

Commit

Permalink
Send success metric before modifying config
Browse files Browse the repository at this point in the history
  • Loading branch information
Achooo committed Aug 1, 2023
1 parent 7ea6280 commit d3522ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions agent/hcp/telemetry_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,17 @@ func (h *hcpProviderImpl) getUpdate(ctx context.Context) *dynamicConfig {
Labels: telemetryCfg.MetricsConfig.Labels,
RefreshInterval: newRefreshInterval,
}
// Any success metric must be recorded before acquiring a write lock for config modifications
// to avoid a deadlock. The metric gets registered in the OTELSink via the FanoutSink of Go Metrics.
// The OTELSink tries to acquire a read lock to determine the metric filters using GetFilters().
metrics.IncrCounter(internalMetricRefreshSuccess, 1)

// Acquire write lock to update new configuration.
h.rw.Lock()
defer h.rw.Unlock()

h.cfg = newDynamicConfig

metrics.IncrCounter(internalMetricRefreshSuccess, 1)

return newDynamicConfig
}

Expand Down

0 comments on commit d3522ee

Please sign in to comment.