Skip to content

Commit

Permalink
replicate: fix panic: duplicate metrics collector registration attempted
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgough committed Aug 1, 2023
1 parent a35a5b2 commit 08c7350
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkg/replicate/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,16 @@ func RunReplicate(
if err != nil {
return err
}

fromReg := prometheus.NewRegistry()
fromBkt := objstoretracing.WrapWithTraces(
objstore.WrapWithMetrics(
bkt,
prometheus.WrapRegistererWithPrefix("thanos_", prometheus.WrapRegistererWith(prometheus.Labels{"replicate": "from"}, reg)),
prometheus.WrapRegistererWithPrefix("thanos_", prometheus.WrapRegistererWith(prometheus.Labels{"replicate": "from"}, fromReg)),
bkt.Name(),
),
)
reg.Register(fromReg)

toConfContentYaml, err := toObjStoreConfig.Content()
if err != nil {
Expand All @@ -140,13 +143,15 @@ func RunReplicate(
if err != nil {
return err
}
toReg := prometheus.NewRegistry()
toBkt = objstoretracing.WrapWithTraces(
objstore.WrapWithMetrics(
toBkt,
prometheus.WrapRegistererWithPrefix("thanos_", prometheus.WrapRegistererWith(prometheus.Labels{"replicate": "from"}, reg)),
prometheus.WrapRegistererWithPrefix("thanos_", prometheus.WrapRegistererWith(prometheus.Labels{"replicate": "from"}, toReg)),
toBkt.Name(),
),
)
reg.Register(toReg)

replicationRunCounter := promauto.With(reg).NewCounterVec(prometheus.CounterOpts{
Name: "thanos_replicate_replication_runs_total",
Expand Down

0 comments on commit 08c7350

Please sign in to comment.