-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add parameter to make sure that log of updating IndexSetting be more detailed #49969
Conversation
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 @kkewwei, I think a better approach would be to adjust the logger
that this AbstractScopedSettings
uses. See e.g.
elasticsearch/server/src/main/java/org/elasticsearch/index/AbstractIndexComponent.java
Line 36 in 5c624bc
this.logger = Loggers.getLogger(getClass(), indexSettings.getIndex()); |
for the pattern we usually use to create a per-index logger.
You will also need to supply a test that demonstrates that the messages logged now include the index name.
Pinging @elastic/es-core-infra (:Core/Infra/Settings) |
@DaveCTurner, your suggestion is very helpful. TBR |
final Setting.Property scope) { | ||
final Setting.Property scope, | ||
final String prefix) { | ||
this.logger = Loggers.getLogger(this.getClass(), prefix); |
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 think it'd be better to allow subclasses to provide their own logger
rather than just a String
, because I don't think we should be changing the behaviour for the logging of cluster-level settings.
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.
Sorry @kkewwei, I still think this is not quite the right approach. I don't think applySettings
should take a Logger
, I think we should be using the AbstractScopedSettings#logger
field. Something like the following.
diff --git a/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java
index 81b3b92844d..54a272e0715 100644
--- a/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java
+++ b/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java
@@ -57,3 +57,3 @@ public abstract class AbstractScopedSettings {
- protected final Logger logger = LogManager.getLogger(this.getClass());
+ private final Logger logger;
@@ -72,2 +72,3 @@ public abstract class AbstractScopedSettings {
final Setting.Property scope) {
+ this.logger = LogManager.getLogger(getClass());
this.settings = settings;
@@ -112,3 +113,4 @@ public abstract class AbstractScopedSettings {
- protected AbstractScopedSettings(Settings nodeSettings, Settings scopeSettings, AbstractScopedSettings other) {
+ protected AbstractScopedSettings(Settings nodeSettings, Settings scopeSettings, AbstractScopedSettings other, Logger logger) {
+ this.logger = logger;
this.settings = nodeSettings;
diff --git a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
index f83012f2db3..29e78f53fc6 100644
--- a/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
+++ b/server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
@@ -20,2 +20,3 @@ package org.elasticsearch.common.settings;
+import org.apache.logging.log4j.LogManager;
import org.elasticsearch.cluster.metadata.IndexMetaData;
@@ -26,2 +27,3 @@ import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDe
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
+import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Setting.Property;
@@ -188,3 +190,3 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
private IndexScopedSettings(Settings settings, IndexScopedSettings other, IndexMetaData metaData) {
- super(settings, metaData.getSettings(), other);
+ super(settings, metaData.getSettings(), other, Loggers.getLogger(IndexScopedSettings.class, metaData.getIndex()));
}
Thank you very much for sharing code, It‘ simpler and more reasonable. |
server/src/test/java/org/elasticsearch/common/settings/SettingTests.java
Outdated
Show resolved
Hide resolved
It's very kind of your suggestion. |
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 @kkewwei, one final comment about a now-unused class.
@@ -49,6 +62,27 @@ | |||
|
|||
public class SettingTests extends ESTestCase { | |||
|
|||
public static class MockAppender extends AbstractAppender { |
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.
This class is now unused
@elasticmachine test this please |
@elasticmachine update branch |
@elasticmachine test this please |
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.
LGTM
Today we log changes to index settings like this: updating [index.setting.blah] from [A] to [B] The identity of the index whose settings were updated is conspicuously absent from this message. This commit addresses this by adding the index name to these messages. Fixes #49818.
Today we log changes to index settings like this: updating [index.setting.blah] from [A] to [B] The identity of the index whose settings were updated is conspicuously absent from this message. This commit addresses this by adding the index name to these messages. Fixes elastic#49818.
Relates #49818
Add the parameter: target, meaning whose setting will be changed