Skip to content

[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

Merged
merged 6 commits into from
Apr 10, 2025

Conversation

yingh0ng
Copy link
Contributor

Purpose of the pull request

close #16929

Brief change log

  • Add new beans implements MetricsProvider which work on metrics-disabled.

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

@SbloodyS SbloodyS added the bug Something isn't working label Mar 29, 2025
@SbloodyS SbloodyS added this to the 3.3.1 milestone Mar 29, 2025
@@ -42,20 +43,28 @@
*/
@Configuration(proxyBeanMethods = false)
@EnableAspectJAutoProxy
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true")
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true")

Comment on lines 55 to 61
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "false", matchIfMissing = true)
public EmptyMetricsProvider emptyMetricsProvider() {
return new EmptyMetricsProvider();
}

@Bean
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@ConditionalOnProperty(prefix = "metrics", name = "enabled", havingValue = "true")

Comment on lines 1 to 27
/*
* 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();
}

}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/*
* 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")
Copy link
Member

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.

@yingh0ng
Copy link
Contributor Author

yingh0ng commented Apr 2, 2025

@ruanwenjun The OWASP dependency check failed. PTAL.
The error is:

io.github.jeremylong.openvulnerability.client.nvd.NvdApiException: Failed to parse NVD data

@SbloodyS
Copy link
Member

SbloodyS commented Apr 2, 2025

@ruanwenjun The OWASP dependency check failed. PTAL. The error is:

You don't need to pay attention to it at present. Just ignore it.

ruanwenjun
ruanwenjun previously approved these changes Apr 2, 2025
Copy link
Member

@ruanwenjun ruanwenjun left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

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

+1

@yingh0ng yingh0ng requested review from SbloodyS and ruanwenjun April 7, 2025 01:34
Copy link

sonarqubecloud bot commented Apr 8, 2025

@SbloodyS SbloodyS merged commit bb9b2d4 into apache:dev Apr 10, 2025
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend bug Something isn't working document e2e e2e test test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] [Metric] metrics switch can not work
4 participants