MCPcopy
hub / github.com/grafana/tempo / createInstance

Method createInstance

modules/generator/generator.go:253–281  ·  view source on GitHub ↗
(id string)

Source from the content-addressed store, hash-verified

251}
252
253func (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
283func (g *Generator) CheckReady(_ context.Context) error {
284 if g.cfg.ConsumeFromKafka && g.kafkaClient == nil {

Callers 1

getOrCreateInstanceMethod · 0.95

Calls 5

NewFunction · 0.92
RegisterMethod · 0.80
newInstanceFunction · 0.70
CloseMethod · 0.65
shutdownMethod · 0.45

Tested by

no test coverage detected