influxdata / influxdata/telegraf
Define an error handling behavior of Serializer.SerializeBatch function
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
## Feature Request
Currently, the serializer interface doesn't define error handling behavior of [SerializeBatch function](https://github.com/influxdata/telegraf/blob/master/plugins/serializers/registry.go#L43).
If an error is occurred in the middle of processing multiple metrics, whether of not return the rest of succeeded metrics is up to the implementation.
### Proposal:
Define the expected behaviour and add it in the comment/document.
### Current behavior:
Undefined.
It made each serializer uses different strategy.
For example,
* `influx`: https://github.com/influxdata/telegraf/blob/master/plugins/serializers/influx/influx.go#L114-L122
* Ignore certain type of error and return nil if others
* `graphite`: https://github.com/influxdata/telegraf/blob/master/plugins/serializers/graphite/graphite.go#L102-L111
* returns nil for any single error
* `wavefront`: https://github.com/influxdata/telegraf/blob/master/plugins/serializers/wavefront/wavefront.go#L102-L105
* A little unclear but it looks like it ignores all the errors
### Desired behavior:
Having well defined set of behavior including
* Whether of not stop processing all the metrics if error occurs from one of the metrics
* Whether of not log the error if we ignore the error
* Maybe we can change the return error type to `[]error`
* Possibly having a config flag for changing the behavior
### Use case:
This is important to reduce possible confusions of end users and plugin writers.
Contributor guide
Research direction
Start with the SerializeBatch interface in plugins/serializers/registry.go, then compare the referenced influx, graphite, and wavefront implementations. First resolve the expected behavior for partial errors, stopping, and logging; done means the chosen contract is documented and the serializer strategies no longer diverge from it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100