add log with start/end times, close blocks before end of func
Signed-off-by: jessicagreben <jessicagrebens@gmail.com>
This commit is contained in:
parent
8de4da3716
commit
d89a1d999f
|
@ -57,6 +57,7 @@ type ruleImporterConfig struct {
|
||||||
// newRuleImporter creates a new rule importer that can be used to parse and evaluate recording rule files and create new series
|
// newRuleImporter creates a new rule importer that can be used to parse and evaluate recording rule files and create new series
|
||||||
// written to disk in blocks.
|
// written to disk in blocks.
|
||||||
func newRuleImporter(logger log.Logger, config ruleImporterConfig, apiClient queryRangeAPI) *ruleImporter {
|
func newRuleImporter(logger log.Logger, config ruleImporterConfig, apiClient queryRangeAPI) *ruleImporter {
|
||||||
|
level.Info(logger).Log("backfiller", "new rule importer from start", config.start.Format(time.RFC822), " to end", config.end.Format(time.RFC822))
|
||||||
return &ruleImporter{
|
return &ruleImporter{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
config: config,
|
config: config,
|
||||||
|
@ -127,8 +128,11 @@ func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "new block writer")
|
return errors.Wrap(err, "new block writer")
|
||||||
}
|
}
|
||||||
|
var closed bool
|
||||||
defer func() {
|
defer func() {
|
||||||
|
if !closed {
|
||||||
err = tsdb_errors.NewMulti(err, w.Close()).Err()
|
err = tsdb_errors.NewMulti(err, w.Close()).Err()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
app := newMultipleAppender(ctx, w)
|
app := newMultipleAppender(ctx, w)
|
||||||
var matrix model.Matrix
|
var matrix model.Matrix
|
||||||
|
@ -160,6 +164,8 @@ func (importer *ruleImporter) importRule(ctx context.Context, ruleExpr, ruleName
|
||||||
default:
|
default:
|
||||||
return errors.New(fmt.Sprintf("rule result is wrong type %s", val.Type().String()))
|
return errors.New(fmt.Sprintf("rule result is wrong type %s", val.Type().String()))
|
||||||
}
|
}
|
||||||
|
err = tsdb_errors.NewMulti(err, w.Close()).Err()
|
||||||
|
closed = true
|
||||||
|
|
||||||
if err := app.flushAndCommit(ctx); err != nil {
|
if err := app.flushAndCommit(ctx); err != nil {
|
||||||
return errors.Wrap(err, "flush and commit")
|
return errors.Wrap(err, "flush and commit")
|
||||||
|
|
Loading…
Reference in New Issue