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

fix: mysql: type conversion follow-up #9966

Merged
merged 6 commits into from
Nov 9, 2021

Conversation

fxedel
Copy link
Contributor

@fxedel fxedel commented Oct 20, 2021

Required for all PRs:

follow-up to #9403:

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Oct 20, 2021
@fxedel fxedel changed the title mysql: type conversion follow-up fix: mysql: type conversion follow-up Oct 20, 2021
@sjwang90
Copy link
Contributor

Resolves #5055

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@fxedel thanks for this nice PR. I have two small comments in the code. Please take a look.

plugins/inputs/mysql/mysql.go Outdated Show resolved Hide resolved
plugins/inputs/mysql/mysql.go Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Oct 28, 2021
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Very nice update @fxedel! Only one more comment about the log-level. I think you should use acc.AddError() there to make the error visible. The only exception could be an "expected" error which occurs often in certain setups, but I think that's not the case there.


value, err := m.parseValueByDatabaseTypeName(colValue, col.DatabaseTypeName())
if err != nil {
m.Log.Debugf("Error parsing %s=%q: %v", colName, string(colValue), err)
Copy link
Member

Choose a reason for hiding this comment

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

If this is really an error please use acc.AddError() to make those visible. In any case, I think debugging is too invisible as you can only see those when starting telegraf in debug mode. So either acc.AddError() or m.Log.Errorf() here.

Comment on lines 1363 to 1364
m.Log.Debugf("Error parsing %s=%q: %v", key, string(val), err)
continue
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@fxedel
Copy link
Contributor Author

fxedel commented Nov 2, 2021

@srebhan Thanks for your reply. Adding errors to the accumulator to make them visible seems like a good idea.

However, since v1.ParseValue returns an error for string values, this would be too verbose on v1. So I only added the errors to the accumulator only when using metric version 2.

Plus, I changed gatherInnodbMetric to use parseValueByDatabaseTypeName(val, "BIGINT") instead of parseValue since the COUNT column in information_schema.INNODB_METRICS is of type BIGINT.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks for your work @fxedel!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/mysql fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mysql input: Slave_IO_Running can have values other than Yes and No
4 participants