-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[fileconsumer] Generlize emit function #24036
Merged
djaglowski
merged 2 commits into
open-telemetry:main
from
djaglowski:fileconsumer-emitfunc-generalize
Jul 14, 2023
Merged
[fileconsumer] Generlize emit function #24036
djaglowski
merged 2 commits into
open-telemetry:main
from
djaglowski:fileconsumer-emitfunc-generalize
Jul 14, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Jul 7, 2023
djaglowski
force-pushed
the
fileconsumer-emitfunc-generalize
branch
2 times, most recently
from
July 10, 2023 15:33
f1ed6c7
to
354683a
Compare
jpkrohling
pushed a commit
that referenced
this pull request
Jul 11, 2023
djaglowski
force-pushed
the
fileconsumer-emitfunc-generalize
branch
5 times, most recently
from
July 12, 2023 19:45
b6238a8
to
a946d59
Compare
djaglowski
force-pushed
the
fileconsumer-emitfunc-generalize
branch
from
July 12, 2023 20:15
a946d59
to
6de04b3
Compare
djaglowski
force-pushed
the
fileconsumer-emitfunc-generalize
branch
from
July 13, 2023 20:29
6de04b3
to
89dda18
Compare
djaglowski
force-pushed
the
fileconsumer-emitfunc-generalize
branch
from
July 13, 2023 20:39
89dda18
to
58234b6
Compare
evan-bradley
approved these changes
Jul 14, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the way this cleans up the API. I'm fairly unfamiliar with this package, but overall everything checks out to me. Just one non-blocking question.
djaglowski
added a commit
that referenced
this pull request
Jul 25, 2023
This continues from #24036 by moving additional complexity into an internal package. Some files contain headers that are different than the rest of the file. In such cases, we may need to extract file attributes that will be applied to logs from that file.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is part of an effort to make
fileconsumer.Reader
more testable. I'd eventually like to move that struct into its own internal package. However, there is a dependency on theEmitFunc
which is part of thefileconsumer
package. Therefore, theEmitFunc
will need to move into a separate package fromfileconsumer
.Since this will be a breaking change (Go API only), I would like to take the opportunity to replace the emit function altogether with something more generic. The current
EmitFunc
includes aFileAttributes
struct, the purpose of which is to pass along attributes describing the file from which a log is read. TheFileAttributes
struct may in turn contain aHeaderAttributes
struct describing elements parsed from the header of a file.If the emit function instead passes along all these attributes as a
map[string]any
, theReader
struct will be simpler and more testable, and dependencies between packages will be simpler as well. This PR is a proposal to make this change.There are a few complicating factors here.
Reader
's. This in turn means that theFileAttributes
struct is encoded as well. However, only theHeaderAttributes
struct is included in this encoded representation. The idea here was that these attributes need to be attached to any log read from the file, even if we are resuming after a restart or upgrade. Conversely, the other fields (file name/path, etc) are omitted from the encoding because the file may have moved. Since this PR would encode these values, we need to be sure to overwrite them when we reconstruct theReader
. This is accomplished in the reader factory by resolving the fields after copying the previously known values. A new test verified that these fields are updated appropriately.Reader
from before this change, we need to handle this during decoding. This is handled in a single block of code which can be removed in a future version. I've tested this manually.file_input
operator used theFileAttributes
struct in a specific way, but this is made redundant by the approach described in 1.Benchmarks for this change show no notable impact: