(id string)
| 251 | } |
| 252 | |
| 253 | func (g *Generator) createInstance(id string) (*instance, error) { |
| 254 | // Duplicate metrics generation errors occur when creating |
| 255 | // the wal for a tenant twice. This happens if the wal is |
| 256 | // create successfully, but the instance is not. On the |
| 257 | // next push it will panic. |
| 258 | // We prevent the panic by using a temporary registry |
| 259 | // for wal and instance creation, and merge it with the |
| 260 | // main registry only if successful. |
| 261 | reg := prometheus.NewRegistry() |
| 262 | |
| 263 | wal, err := storage.New(&g.cfg.Storage, g.overrides, id, reg, g.logger) |
| 264 | if err != nil { |
| 265 | return nil, err |
| 266 | } |
| 267 | |
| 268 | inst, err := newInstance(g.cfg, id, g.overrides, wal, g.logger) |
| 269 | if err != nil { |
| 270 | _ = wal.Close() |
| 271 | return nil, err |
| 272 | } |
| 273 | |
| 274 | err = g.reg.Register(reg) |
| 275 | if err != nil { |
| 276 | inst.shutdown() |
| 277 | return nil, err |
| 278 | } |
| 279 | |
| 280 | return inst, nil |
| 281 | } |
| 282 | |
| 283 | func (g *Generator) CheckReady(_ context.Context) error { |
| 284 | if g.cfg.ConsumeFromKafka && g.kafkaClient == nil { |
no test coverage detected