-
Notifications
You must be signed in to change notification settings - Fork 4.8k
[Fix-16929][Meter] Fix startup failed when metrics is disabled. #17094
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
@@ -42,20 +43,28 @@ | |||
*/ | |||
@Configuration(proxyBeanMethods = false) | |||
@EnableAspectJAutoProxy | |||
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
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.
Can we remove this config? Then we will enable the metrics in all times.
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.
Do you mean, users are not allowed to disable metrics?
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.
Can we remove this config? Then we will enable the metrics in all times.
LGTM. Enabling metric is a better practice, but why do users need to turn it off?
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.
Do you mean, users are not allowed to disable metrics?
Yes, the server heartbeat rely on the metrics provider, so this is must.
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.
Yes, the server heartbeat rely on the metrics provider, so this is must.
LGTM. Fix it later.
public class MeterAutoConfiguration { | ||
|
||
@Bean | ||
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
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.
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "false", matchIfMissing = true) | ||
public EmptyMetricsProvider emptyMetricsProvider() { | ||
return new EmptyMetricsProvider(); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
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.
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "false", matchIfMissing = true) | |
public EmptyMetricsProvider emptyMetricsProvider() { | |
return new EmptyMetricsProvider(); | |
} | |
@Bean | |
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
public TimedAspect timedAspect(MeterRegistry registry) { | ||
return new TimedAspect(registry); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
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.
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dolphinscheduler.meter.metrics; | ||
|
||
public class EmptyMetricsProvider implements MetricsProvider { | ||
|
||
@Override | ||
public SystemMetrics getSystemMetrics() { | ||
return new SystemMetrics(); | ||
} | ||
|
||
} |
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.
/* | |
* Licensed to the Apache Software Foundation (ASF) under one or more | |
* contributor license agreements. See the NOTICE file distributed with | |
* this work for additional information regarding copyright ownership. | |
* The ASF licenses this file to You under the Apache License, Version 2.0 | |
* (the "License"); you may not use this file except in compliance with | |
* the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
* See the License for the specific language governing permissions and | |
* limitations under the License. | |
*/ | |
package org.apache.dolphinscheduler.meter.metrics; | |
public class EmptyMetricsProvider implements MetricsProvider { | |
@Override | |
public SystemMetrics getSystemMetrics() { | |
return new SystemMetrics(); | |
} | |
} |
@@ -42,20 +43,28 @@ | |||
*/ | |||
@Configuration(proxyBeanMethods = false) | |||
@EnableAspectJAutoProxy | |||
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true") |
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.
Do you mean, users are not allowed to disable metrics?
Yes, the server heartbeat rely on the metrics provider, so this is must.
@ruanwenjun The OWASP dependency check failed. PTAL.
|
You don't need to pay attention to it at present. Just ignore it. |
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
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.
+1
|
Purpose of the pull request
close #16929
Brief change log
Verify this pull request
This pull request is already covered by existing tests, such as (please describe tests).
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md