Skip to content

Commit

Permalink
Remove append error log (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimalekseev authored Aug 25, 2023
1 parent 7652707 commit 0db5d9f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion plugin/output/clickhouse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ If you need more types, please, create an issue.

<br>

**`strict_types`** *`bool`* *`default=true`*
**`strict_types`** *`bool`* *`default=false`*

If true, file.d fails when types are mismatched.

Expand Down
25 changes: 4 additions & 21 deletions plugin/output/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/atomic"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

/*{ introduction
Expand All @@ -39,8 +38,7 @@ type Clickhouse interface {
}

type Plugin struct {
logger *zap.Logger
samplerLogger *zap.Logger
logger *zap.Logger

config *Config
batcher *pipeline.Batcher
Expand Down Expand Up @@ -172,7 +170,7 @@ type Config struct {
// > In the non-strict mode, for String and Array(String) columns the value will be encoded to JSON.
// >
// > If the strict mode is enabled file.d fails (exit with code 1) in above examples.
StrictTypes bool `json:"strict_types" default:"true"` // *
StrictTypes bool `json:"strict_types" default:"false"` // *

// > @3@4@5@6
// >
Expand Down Expand Up @@ -283,10 +281,6 @@ func (p *Plugin) registerMetrics(ctl *metric.Ctl) {
func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginParams) {
p.logger = params.Logger.Desugar()

p.samplerLogger = p.logger.WithOptions(zap.WrapCore(func(core zapcore.Core) zapcore.Core {
return zapcore.NewSamplerWithOptions(p.logger.Core(), time.Second, 5, 0)
}))

p.config = config.(*Config)
p.registerMetrics(params.MetricCtl)
p.ctx, p.cancelFunc = context.WithCancel(context.Background())
Expand Down Expand Up @@ -418,11 +412,6 @@ func (p *Plugin) out(workerData *pipeline.WorkerData, batch *pipeline.Batch) {
data := (*workerData).(data)
data.reset()

lvl := zapcore.ErrorLevel
if p.config.StrictTypes {
lvl = zapcore.FatalLevel
}

for _, event := range batch.Events {
for _, col := range data.cols {
node := event.Root.Dig(col.Name)
Expand All @@ -435,14 +424,8 @@ func (p *Plugin) out(workerData *pipeline.WorkerData, batch *pipeline.Batch) {
}

if err := col.ColInput.Append(insaneNode); err != nil {
if ce := p.samplerLogger.Check(lvl, "can't append value in the batch"); ce != nil {
ce.Write(
zap.Error(err),
zap.String("column", col.Name),
zap.Any("event", json.RawMessage(event.Root.EncodeToByte())),
)
}

// we can't append the value to the column because of the node has wrong format,
// so append zero value
err := col.ColInput.Append(ZeroValueNode{})
if err != nil {
p.logger.Fatal("why err isn't nil?",
Expand Down

0 comments on commit 0db5d9f

Please sign in to comment.