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 ca12e89
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions agent/hcp/telemetry_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ func (h *hcpProviderImpl) getUpdate(ctx context.Context) *dynamicConfig {
Labels: telemetryCfg.MetricsConfig.Labels,
RefreshInterval: newRefreshInterval,
}
// Success metric must be recorded before acquiring write lock.
// This will be registered in the OTELSink, which tries to get a read lock.
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 ca12e89

Please sign in to comment.