Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

fix iteration #413

Merged
merged 3 commits into from
Feb 25, 2022
Merged

Conversation

rockb1017
Copy link
Contributor

Fixes #391
with this change, data duplication is gone.
it is iterating over an array, but we are removing elements from that very array, so it causes to skip the next element after removing.

@rockb1017 rockb1017 requested a review from a team February 23, 2022 22:43
@rockb1017
Copy link
Contributor Author

image

@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #413 (9d2414e) into main (26aeee9) will increase coverage by 0.0%.
The diff coverage is 66.6%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #413   +/-   ##
=====================================
  Coverage   75.1%   75.2%           
=====================================
  Files         83      83           
  Lines       4022    4025    +3     
=====================================
+ Hits        3023    3028    +5     
+ Misses       696     694    -2     
  Partials     303     303           
Impacted Files Coverage Δ
operator/input/file/file.go 70.1% <66.6%> (-0.1%) ⬇️
operator/transformer/recombine/recombine.go 76.3% <0.0%> (+2.0%) ⬆️

Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

@rockb1017 This is a great find and fix.

Two things:

  1. See comment on the if condition. If I'm right, we can remove it and have a much clearer diff.
  2. Do you have any way to reproduce the unwanted behavior in tests? I would hate for a future change to undo this fix. (I acknowledge this function is doing too much and should be pulled apart to make it more testable, but perhaps a higher level test can catch it for now.)

operator/input/file/file.go Outdated Show resolved Hide resolved
@rockb1017
Copy link
Contributor Author

i have applied your suggestion. Thank you.
And I have added a test case.
When i comment out i-- line, the test fails, but with it, it doesn't fail.

Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @rockb1017

@djaglowski djaglowski merged commit 9d6d419 into open-telemetry:main Feb 25, 2022
@rockb1017 rockb1017 deleted the filelog_fix_iteration branch February 27, 2022 07:53
jsirianni pushed a commit to jsirianni/opentelemetry-log-collection that referenced this pull request Mar 28, 2022
* fix iteration

* remove unneccesary if

* add a test case
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

data duplication at the beginning of log file
2 participants