Skip to content
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

refactor: change metric config to url like other module #2396

Merged
merged 2 commits into from
Sep 2, 2023

Conversation

FoghostCn
Copy link
Contributor

@FoghostCn FoghostCn commented Aug 25, 2023

  1. refactor: metric module use url as config class, metrics.ReporterConfig will be removed in the future
  2. split metric constant to a single file

The configuration class of the metric module is a copy of the configuration class of the config package. This commit will change the configuration of the metric module to be dependent on common.URL, in order to have a consistent style with other modules.

@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2023

Codecov Report

Merging #2396 (8b03a45) into main (0a02805) will increase coverage by 0.44%.
The diff coverage is 29.72%.

❗ Current head 8b03a45 differs from pull request most recent head 5e75c39. Consider uploading reports for the commit 5e75c39 to get more accurate results

@@            Coverage Diff             @@
##             main    #2396      +/-   ##
==========================================
+ Coverage   44.43%   44.88%   +0.44%     
==========================================
  Files         303      307       +4     
  Lines       18402    18795     +393     
==========================================
+ Hits         8177     8436     +259     
- Misses       9360     9479     +119     
- Partials      865      880      +15     
Files Changed Coverage Δ
config/root_config.go 66.34% <0.00%> (ø)
metrics/api.go 0.00% <0.00%> (ø)
metrics/common.go 0.00% <0.00%> (ø)
metrics/prometheus/registry.go 88.88% <0.00%> (-0.31%) ⬇️
config/metric_config.go 69.76% <100.00%> (+6.91%) ⬆️

... and 8 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@justxuewei
Copy link
Member

What is the benifit of using URL to init metrics config?

I am thinking the URL is abused. It makes others confused since it is used to registry, invoker, etc. And it don't have clear semantics. They are distinguished by its protocol. Think about it, if we don't know its protocol, we can't know what it's used for.

If you still want to use a type of URL, please consider defining a new type, like MetricsAddress, or something same like that.

@FoghostCn
Copy link
Contributor Author

FoghostCn commented Aug 29, 2023

What is the benifit of using URL to init metrics config?

I am thinking the URL is abused. It makes others confused since it is used to registry, invoker, etc. And it don't have clear semantics. They are distinguished by its protocol. Think about it, if we don't know its protocol, we can't know what it's used for.

If you still want to use a type of URL, please consider defining a new type, like MetricsAddress, or something same like that.

Thank you for your reply, the reason is

  1. metrics.ReporterConfig is a copy of config.MetricConfig,they have duplicate fields, if we add a config field for metric module in yaml, we have to add filed both in config.MetricConfig and metrics.ReporterConfig,this is ugly.
  2. common.URL is design to be a unified format for configuration information,All extension points carry configuration information by passing URL,so I think we should passing URL as configuration for metric module too.
  3. other module like logger、metadata、cluster etc all use URL for configuration, other language implementations, such as Java, also follow the same approach,I think this is a default behavior.

@FoghostCn FoghostCn marked this pull request as draft August 31, 2023 03:04
@sonarcloud
Copy link

sonarcloud bot commented Aug 31, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@FoghostCn FoghostCn marked this pull request as ready for review August 31, 2023 04:48
@chickenlj
Copy link
Contributor

Both ways can meet the requirements of passing metrics configurations for now. I think URL as the current unified design for now is acceptable.

We can revisit the design later in the following refactor plan.

Copy link
Contributor

@chickenlj chickenlj left a comment

Choose a reason for hiding this comment

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

LGTM.

@chickenlj chickenlj merged commit da40230 into apache:main Sep 2, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants