This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/main by this push:
new 4f11dbad8 Merge bug-fix in 3.1 into main branch(#2553,#2548,#2551)
(#2571)
4f11dbad8 is described below
commit 4f11dbad88329de5a0e30660ff5e969a36c36ac8
Author: finalt <[email protected]>
AuthorDate: Sun Jan 14 12:38:41 2024 +0800
Merge bug-fix in 3.1 into main branch(#2553,#2548,#2551) (#2571)
---
common/constant/version.go | 6 +++---
config/application_config.go | 5 +++--
metadata/service/exporter/configurable/exporter.go | 18 +++++++++++++++++-
metrics/prometheus/registry.go | 2 +-
metrics/prometheus/registry_test.go | 4 ++--
5 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/common/constant/version.go b/common/constant/version.go
index fe4589144..883b09810 100644
--- a/common/constant/version.go
+++ b/common/constant/version.go
@@ -18,7 +18,7 @@
package constant
const (
- Version = "3.0.4" // apache/dubbo-go version
- Name = "dubbogo" // module name
- DATE = "2022/12/01" // release date
+ Version = "3.2.0" // apache/dubbo-go version
+ Name = "dubbogo" // module name
+ DATE = "2024/1/10" // release date
)
diff --git a/config/application_config.go b/config/application_config.go
index c9de915b4..69a7636e2 100644
--- a/config/application_config.go
+++ b/config/application_config.go
@@ -37,8 +37,9 @@ type ApplicationConfig struct {
Owner string `default:"dubbo-go" yaml:"owner"
json:"owner,omitempty" property:"owner"`
Environment string `yaml:"environment" json:"environment,omitempty"
property:"environment"`
// the metadata type. remote or local
- MetadataType string `default:"local" yaml:"metadata-type"
json:"metadataType,omitempty" property:"metadataType"`
- Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"`
+ MetadataType string `default:"local" yaml:"metadata-type"
json:"metadataType,omitempty" property:"metadataType"`
+ Tag string `yaml:"tag" json:"tag,omitempty"
property:"tag"`
+ MetadataServicePort string `yaml:"metadata-service-port"
json:"metadata-service-port,omitempty" property:"metadata-service-port"`
}
// Prefix dubbo.application
diff --git a/metadata/service/exporter/configurable/exporter.go
b/metadata/service/exporter/configurable/exporter.go
index b8e17422e..6fcdc444a 100644
--- a/metadata/service/exporter/configurable/exporter.go
+++ b/metadata/service/exporter/configurable/exporter.go
@@ -65,7 +65,7 @@ func (exporter *MetadataServiceExporter) Export(url
*common.URL) error {
SetServiceID(constant.SimpleMetadataServiceName).
SetProtocolIDs(constant.DefaultProtocol).
AddRCProtocol(constant.DefaultProtocol,
config.NewProtocolConfigBuilder().
- SetName(constant.DefaultProtocol).
+
SetName(constant.DefaultProtocol).SetPort(getMetadataPort()).
Build()).
SetRegistryIDs("N/A").
SetInterface(constant.MetadataServiceName).
@@ -84,6 +84,22 @@ func (exporter *MetadataServiceExporter) Export(url
*common.URL) error {
return nil
}
+func getMetadataPort() string {
+ rootConfig := config.GetRootConfig()
+ port := rootConfig.Application.MetadataServicePort
+ if port == "" {
+ protocolConfig, ok :=
rootConfig.Protocols[constant.DefaultProtocol]
+ if ok {
+ port = protocolConfig.Port
+ } else {
+ logger.Warnf("[Metadata Service] Dubbo-go %s version's
MetadataService only support dubbo protocol,"+
+ "MetadataService will use random port",
+ constant.Version)
+ }
+ }
+ return port
+}
+
// Unexport will unexport the metadataService
func (exporter *MetadataServiceExporter) Unexport() {
if exporter.IsExported() {
diff --git a/metrics/prometheus/registry.go b/metrics/prometheus/registry.go
index d108f8f9f..aed5b4f43 100644
--- a/metrics/prometheus/registry.go
+++ b/metrics/prometheus/registry.go
@@ -152,7 +152,7 @@ func (p *promMetricRegistry) Export() {
func (p *promMetricRegistry) exportHttp() {
mux := http.NewServeMux()
- path := p.url.GetParam(constant.PrometheusDefaultMetricsPath,
constant.PrometheusDefaultMetricsPath)
+ path := p.url.GetParam(constant.PrometheusExporterMetricsPathKey,
constant.PrometheusDefaultMetricsPath)
port := p.url.GetParam(constant.PrometheusExporterMetricsPortKey,
constant.PrometheusDefaultMetricsPort)
mux.Handle(path, promhttp.InstrumentMetricHandler(p.r,
promhttp.HandlerFor(p.gather, promhttp.HandlerOpts{})))
srv := &http.Server{Addr: ":" + port, Handler: mux}
diff --git a/metrics/prometheus/registry_test.go
b/metrics/prometheus/registry_test.go
index a3e5e6636..525b7c35b 100644
--- a/metrics/prometheus/registry_test.go
+++ b/metrics/prometheus/registry_test.go
@@ -43,8 +43,8 @@ var (
url = common.NewURLWithOptions(
common.WithProtocol(constant.ProtocolPrometheus),
common.WithParamsValue(constant.PrometheusExporterEnabledKey,
"true"),
-
common.WithParamsValue(constant.PrometheusExporterMetricsPortKey,
constant.PrometheusDefaultMetricsPort),
-
common.WithParamsValue(constant.PrometheusExporterMetricsPathKey,
constant.PrometheusDefaultMetricsPath),
+
common.WithParamsValue(constant.PrometheusExporterMetricsPortKey, "9999"),
+
common.WithParamsValue(constant.PrometheusExporterMetricsPathKey,
"/prometheus"),
common.WithParamsValue(constant.ApplicationKey, "dubbo"),
common.WithParamsValue(constant.AppVersionKey, "1.0.0"),
common.WithParamsValue(constant.PrometheusPushgatewayEnabledKey, "true"),