Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputs.kinesis - log record error count #8817

Conversation

JeffAshton
Copy link
Contributor

@JeffAshton JeffAshton commented Feb 5, 2021

Step 1 for Issue #8818 - outputs.kinesis silently drops metrics

Required for all PRs:

  • Associated README.md updated.
  • Has appropriate unit tests.

Copy link
Contributor

@telegraf-tiger telegraf-tiger bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤝 ✅ CLA has been signed. Thank you!

resp, err := k.svc.PutRecords(payload)
if err != nil {
log.Printf("E! kinesis: Unable to write to Kinesis : %s", err.Error())
return time.Since(start)
Copy link
Contributor Author

@JeffAshton JeffAshton Feb 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the request failed, then resp will not be set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you saying resp needs a nil check in addition to an err check?

Copy link
Contributor Author

@JeffAshton JeffAshton Feb 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm just giving helpful insight into how the AWS APIs tend to work.

}
var failed = *resp.FailedRecordCount
if failed > 0 {
log.Printf("E! kinesis: Unable to write %+v of %+v record(s) to Kinesis", failed, len(r))
Copy link
Contributor Author

@JeffAshton JeffAshton Feb 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously it was silently dropping metrics

2021-02-05T22:39:24Z D! [outputs.kinesis] Wrote batch of 1000 metrics in 1.725811502s
2021-02-05T22:39:24Z D! [outputs.kinesis] Buffer fullness: 33 / 1000 metrics
2021-02-05T22:39:24Z E! kinesis: Unable to write 250 of 500 record(s) to Kinesis
2021-02-05T22:39:24Z D! Wrote a 500 point batch to Kinesis in 578.672453ms.
2021-02-05T22:39:24Z D! [outputs.kinesis] Wrote batch of 1000 metrics in 1.888566606s
2021-02-05T22:39:24Z D! [outputs.kinesis] Buffer fullness: 33 / 1000 metrics

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great if someone updated this plugin to use

  Log telegraf.Logger `toml:"-"`

then the code could use k.Log.Debug() without conditionals, etc.
tests can set the logger with testutil.Logger{}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to do a few more PRs after this one. Be glad to tackle that for you.

func (m *mockKinesisPutRecords) AssertRequests(
assert *assert.Assertions,
expected []*kinesis.PutRecordsInput,
) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not overly exciting assertions for this PR, but this will be helpful for testing batching behavior in future PRs. The current test coverage is lacking, so if I can set a good precedent. :)

@JeffAshton JeffAshton changed the title Kinesis output log record error count outputs.kinesis - log record error count Feb 5, 2021
@JeffAshton JeffAshton force-pushed the kinesis-output-log-record-error-count branch from b05945a to c7b44e1 Compare February 5, 2021 18:28
@JeffAshton JeffAshton marked this pull request as ready for review February 5, 2021 18:39
Copy link
Member

@helenosheaa helenosheaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change around logs and errors looks good. I've left a few comments with minor things and questions around the kinesis api mock.

CHANGELOG.md Outdated
@@ -2,6 +2,7 @@

#### Bugfixes

- [#8817](https://github.com/influxdata/telegraf/pull/8817) `outputs.kinesis` Log when PutRecords unsuccessfully processes records
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please remove this line? We update the changelog at the time when prs make it into a release/patch.

if err != nil {
log.Printf("E! kinesis: Unable to write to Kinesis : %s", err.Error())
}
var failed = *resp.FailedRecordCount
Copy link
Member

@helenosheaa helenosheaa Feb 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be just short var declaration instead so failed := &resp.FailedRecordCount{}

@@ -154,26 +155,33 @@ func (k *KinesisOutput) SetSerializer(serializer serializers.Serializer) {
k.serializer = serializer
}

func writekinesis(k *KinesisOutput, r []*kinesis.PutRecordsRequestEntry) time.Duration {
func (k *KinesisOutput) mockKinesisService(svc kinesisiface.KinesisAPI) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about adding a mockservice into the plugin code. Is there a way to mock this just within the test?

@helenosheaa helenosheaa self-assigned this Feb 10, 2021
Copy link
Member

@helenosheaa helenosheaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, thanks for doing that so quickly!

@JeffAshton
Copy link
Contributor Author

@helenosheaa, Are you waiting on anything from me for this PR?

@helenosheaa
Copy link
Member

@JeffAshton no looks good, happy to merge. Would be great if you could change this in your next pr to use telegraf.Logger instead :)

@helenosheaa helenosheaa merged commit a65a305 into influxdata:master Mar 1, 2021
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants