Skip to content

Commit

Permalink
Merge bug-fix in 3.1 into main branch(#2553,#2548,#2551) (#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalT authored Jan 14, 2024
1 parent d21e699 commit 4f11dba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
6 changes: 3 additions & 3 deletions common/constant/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
5 changes: 3 additions & 2 deletions config/application_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion metadata/service/exporter/configurable/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion metrics/prometheus/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions metrics/prometheus/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 4f11dba

Please sign in to comment.