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 errcheck and gocritic lint issue for exporter splunk #10818

Merged

Conversation

fatsheep9146
Copy link
Contributor

Signed-off-by: Ziqi Zhao zhaoziqi9146@gmail.com

Description:
fix gocritic and gocritic issue for splunk exporter

the code is modified as following

_, _ = state.tmpBuf.WriteTo(state.buf)

because in function makeBlankBufferState, the tmpBuf is already initialized with smaller spaces than buf

func makeBlankBufferState(bufCap uint) bufferState {
	// Buffer of JSON encoded Splunk events, last record is expected to overflow bufCap, hence the padding
	var buf = bytes.NewBuffer(make([]byte, 0, bufCap+bufCapPadding))

	// Buffer for overflown records that do not fit in the main buffer
	var tmpBuf = bytes.NewBuffer(make([]byte, 0, bufCapPadding))

	return bufferState{
		buf:      buf,
		tmpBuf:   tmpBuf,
		bufFront: nil, // Index of the log record of the first unsent event in buffer.
		bufLen:   0,   // Length of data in buffer excluding the last record if it overflows bufCap
		resource: 0,   // Index of currently processed Resource
		library:  0,   // Index of currently processed Library
	}
}

Link to tracking Issue:
#10466 #9749

@fatsheep9146 fatsheep9146 requested a review from a team June 7, 2022 05:38
@fatsheep9146 fatsheep9146 requested a review from dmitryax as a code owner June 7, 2022 05:38
@dashpole dashpole added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Jun 7, 2022
Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

If those functions shouldn't ever return errors, why not check the error from those functions anyways? It seems like a generally a better practice to handle errors.

@fatsheep9146
Copy link
Contributor Author

If those functions shouldn't ever return errors, why not check the error from those functions anyways? It seems like a generally a better practice to handle errors.

It makes sense, I will change like this.

@fatsheep9146
Copy link
Contributor Author

ping @dashpole, please help review this again, thx

@fatsheep9146
Copy link
Contributor Author

ping @bogdandrutu, please review this again, thanks.

fatsheep9146 and others added 4 commits June 23, 2022 20:42
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
Co-authored-by: Bogdan Drutu <lazy@splunk.com>
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com>
@fatsheep9146 fatsheep9146 force-pushed the fix-lint-for-exporter-splunk branch from c128c89 to 41efa01 Compare June 23, 2022 12:42
@fatsheep9146
Copy link
Contributor Author

ping @bogdandrutu @djaglowski, I think this pr is ready to be merged, please help review this pr, thanks.

@bogdandrutu bogdandrutu merged commit e258b1e into open-telemetry:main Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants