-
Notifications
You must be signed in to change notification settings - Fork 5k
[Chore][libbeat] Replace global logger with single logger instance #43356
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
Conversation
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
rdner
left a comment
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.
A few comments / questions. The changes look good so far.
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
|
This PR needs backport labels, at least 8.x and 9.0. It should be straightforward to backport to all 8 releases as well. |
Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
|
@mauri870 I would not be so sure. This is only the first PR to address the global logger problem. If we continue to refactor the rest of the code base it might cause conflicts between branches and with this kind of refactoring it's rather backport all or nothing. Having this backport would not bring any benefit to our users from my standpoint. |
Good point! I'm mainly concerned about the receivers having data races which will make them untrustworthy for use in current versions. If that is ok then I'm fine with no backports. |
|
@mauri870 the receivers are still in development and not released. I would not worry about it. |
mauri870
left a comment
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.
Thanks!
leehinman
left a comment
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 still see some references to logp.L and logp.Warn etc in libbeat.
examples:
conditions/conditions.go: logp.L().Named(logName).Debugf("New condition %v", condition)
conditions/range.go: logp.L().Named(logName).Warnf(err.Error())
conditions/equals.go: logger := logp.L().Named(logName)
conditions/matcher.go: logp.L().Named(logName).Debugf("unexpected type %T in %v condition as it accepts only strings; value=%#v", value, c.name, value)
publisher/pipeline/module.go: log = logp.L()
template/template.go: logp.L().Infof("remote instance is serverless, number_of_shards and max_docvalue_fields_search will be skipped in index template")
idxmgmt/lifecycle/es_client_handler.go: logp.L().Warnf("setup.dsl.data_stream_pattern is %s, but setup.template.name is %s; under serverless, non-default template and DSL pattern names should be the same. Additional updates & overwrites to this config will not work.", name, cfg.TemplateName)
idxmgmt/lifecycle/file_client_handler.go: logp.L().Infof("No lifecycle config has been explicitly enabled, defauling to ILM")
autodiscover/providers/kubernetes/config.go: logp.L().Warnf("can not set scope to node when using resource %s. resetting scope to cluster", c.Resource)
autodiscover/providers/kubernetes/config.go: logp.L().Warnf("can only set unique when scope is cluster")
statestore/backend/memlog/store.go: logp.Info("Finished loading transaction log file for '%v'. Active transaction id=%v", home, txid)
statestore/backend/memlog/store.go: logp.Warn("Incomplete or corrupted log file in %v. Continue with last known complete and consistent state. Reason: %v", home, err)
Pretty sure we have to address the ones in conditions, publisher, statestore, autodiscover (all used in filebeat/metricbeat). But I don't think we have to worry about idxmgmt right now.
belimawr
left a comment
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.
LGMT, but I agree with @leehinman there are still some instances that should be addressed.
|
I aimed to keep this PR short for easy review. There are many places that still need to be fixed - the follow up PR's will take care |
|
Do we have verification that "normal" beats logs are exactly the same before and after this commit? |
Only the existing tests that rely on log assertions. That should do I believe |
|
Is there any plan to backport this to 8.x ? |
Being paranoid, I ran an experiment and I am seeing differences. Before: After: notice "EXTRA string" part Also, it looks like the level changed on this one from warn to info?: before: after: This one had a 'log.logger' field before the change: before: after: There may be others, this is just what I spotted with a minimal filebeat config. @khushijain21 can you open up an issue to fix these and develop a method for comparing the logs before and after. What I did was very crude, have filebeat ingest a file, then use jq to remove the @timestamp from the logs as well as sort the keys. That allowed for a diff, but it wasn't very clean and could be improved. |
…43356) * [Chore] Use single logger instance * Update x-pack/filebeat/fbreceiver/receiver_test.go Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> * Update x-pack/filebeat/fbreceiver/receiver_test.go Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> * libbeat/cmd is complete * keep only libbeat changes * keep only libbeat changes * add libbeat/monitoring/report package * add my fork * use beat.Info.Logger * remove cloudid * remove println * fix tests * add libbeat/idxmgmt * add libbeat/monitoring/report * go mod tidy * fix idxmgmt tests * fixing and finishing things * fix tests * fix tests * fix tests * debugging statement * stringify debug statement * fixing tests * fixing tests * add libbeat/instrumentation * update ea-libs * fix lint * fix tests and lint * golangci lint * initialize logger before using in instrumentation * address review comments * address review comments 2 --------- Co-authored-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> (cherry picked from commit 019fe1d) # Conflicts: # NOTICE.txt # go.mod # go.sum # libbeat/cmd/instance/beat.go # libbeat/cmd/instance/beat_test.go # x-pack/filebeat/fbreceiver/receiver_test.go
…ted (#44470) * [beat_receivers] move when monitoring is started (#44438) * [beat_receivers] move when monitoring is started (cherry picked from commit 82f47f7) * switch to global logger #43356 was not backported * Fix register of input handler for /inputs/ in filebeat --------- Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com> Co-authored-by: Lee E. Hinman <lee.e.hinman@elastic.co>
Proposed commit message
See https://github.com/elastic/ingest-dev/issues/5251
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
Run this test in
x-pack/filebeat/fbreceivergo test -run ^TestMultipleReceivers$ ./x-pack/filebeat/fbreceiver -vRelated issues
Checklist
✅ libbeat Directories Checklist