Skip to content

Commit

Permalink
Merge branch 'main' into router-enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenlj authored Nov 2, 2023
2 parents eee3001 + 3d97d4c commit 9498a4f
Show file tree
Hide file tree
Showing 64 changed files with 2,212 additions and 1,873 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: CI

on:
push:
branches: "*"
branches:
- main
- 'release-*'
pull_request:
branches: "*"

Expand Down Expand Up @@ -75,12 +77,10 @@ jobs:
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
chmod +x integrate_test.sh \
&& [[ -n "${{github.event.pull_request.head.repo.full_name}}" ]] \
&& [[ -n "${{github.event.pull_request.head.sha}}" ]] \
&& [[ -n "${{github.base_ref}}" ]] \
&& ./integrate_test.sh ${{github.event.pull_request.head.repo.full_name}} ${{github.event.pull_request.head.sha}} ${{github.base_ref}}
elif [ "$GITHUB_EVENT_NAME" == "push" ]; then
chmod +x integrate_test.sh && ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_BASE_REF
chmod +x integrate_test.sh \
&& ./integrate_test.sh $GITHUB_REPOSITORY $GITHUB_SHA $GITHUB_REF_NAME
else
echo "$GITHUB_EVENT_NAME is an unsupported event type."
exit 1
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ license: clean prepareLic
.PHONY: verify
verify: clean license test

.PHONE: fmt
fmt:
$(GO_GET) -u github.com/dubbogo/tools/cmd/imports-formatter
imports-formatter

.PHONY: clean
clean: prepare
rm -rf coverage.txt
Expand Down
2 changes: 1 addition & 1 deletion common/constant/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const (
// DefaultServiceFilters defines default service filters, it is highly recommended
// that put the AdaptiveServiceProviderFilterKey at the end.
DefaultServiceFilters = EchoFilterKey + "," +
MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," +
TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," +
GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey

DefaultReferenceFilters = GracefulShutdownConsumerFilterKey
Expand Down
30 changes: 18 additions & 12 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ const (

const (
ApplicationKey = "application"
ApplicationNameKey = "application_name"
ApplicationVersionKey = "application_version"
HostnameKey = "hostname"
IpKey = "ip"
OrganizationKey = "organization"
NameKey = "name"
ModuleKey = "module"
Expand All @@ -198,10 +194,6 @@ const (
ProvidersCategory = "providers"
RouterKey = "router"
ExportKey = "export"
GitCommitIdKey = "git_commit_id"
ConfigCenterKey = "config_center"
ChangeTypeKey = "change_type"
KeyKey = "key"
)

// config center keys
Expand Down Expand Up @@ -412,14 +404,28 @@ const (

// metrics key
const (
MetricsRegistry = "dubbo.metrics.registry"
MetricsMetadata = "dubbo.metrics.metadata"
MetricApp = "dubbo.metrics.app"
MetadataEnabledKey = "metrics.metadata.enabled"
RegistryEnabledKey = "metrics.registry.enabled"
ConfigCenterEnabledKey = "metrics.config-center.enabled"
RpcEnabledKey = "metrics.rpc.enabled"
AggregationEnabledKey = "aggregation.enabled"
AggregationBucketNumKey = "aggregation.bucket.num"
AggregationTimeWindowSecondsKey = "aggregation.time.window.seconds"
HistogramEnabledKey = "histogram.enabled"
PrometheusExporterEnabledKey = "prometheus.exporter.enabled"
PrometheusExporterMetricsPortKey = "prometheus.exporter.metrics.port"
PrometheusExporterMetricsPathKey = "prometheus.exporter.metrics.path"
PrometheusPushgatewayEnabledKey = "prometheus.pushgateway.enabled"
PrometheusPushgatewayBaseUrlKey = "prometheus.pushgateway.base.url"
PrometheusPushgatewayUsernameKey = "prometheus.pushgateway.username"
PrometheusPushgatewayPasswordKey = "prometheus.pushgateway.password"
PrometheusPushgatewayPushIntervalKey = "prometheus.pushgateway.push.interval"
PrometheusPushgatewayJobKey = "prometheus.pushgateway.job"
)

// default meta cache config
const (
DefaultMetaCacheName = "dubbo.meta"
DefaultMetaFileName = "dubbo.metadata"
DefaultMetaFileName = "dubbo.metadata."
DefaultEntrySize = 100
)
62 changes: 62 additions & 0 deletions common/constant/metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* 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 constant

// metrics type
const (
MetricsRegistry = "dubbo.metrics.registry"
MetricsMetadata = "dubbo.metrics.metadata"
MetricsApp = "dubbo.metrics.app"
MetricsConfigCenter = "dubbo.metrics.configCenter"
MetricsRpc = "dubbo.metrics.rpc"
)

const (
TagApplicationName = "application_name"
TagApplicationVersion = "application_version"
TagHostname = "hostname"
TagIp = "ip"
TagGitCommitId = "git_commit_id"
TagConfigCenter = "config_center"
TagChangeType = "change_type"
TagKey = "key"
TagPid = "pid"
TagInterface = "interface"
TagMethod = "method"
TagGroup = "group"
TagVersion = "version"
TagErrorCode = "error"
)
const (
MetricNamespace = "dubbo"
ProtocolPrometheus = "prometheus"
ProtocolDefault = ProtocolPrometheus
AggregationCollectorKey = "aggregation"
AggregationDefaultBucketNum = 10
AggregationDefaultTimeWindowSeconds = 120
PrometheusDefaultMetricsPath = "/metrics"
PrometheusDefaultMetricsPort = "9090"
PrometheusDefaultPushInterval = 30
PrometheusDefaultJobName = "default_dubbo_job"
MetricFilterStartTime = "metric_filter_start_time"
)

const (
SideProvider = "provider"
SideConsumer = "consumer"
)
17 changes: 4 additions & 13 deletions filter/otel/trace/version.go → common/constant/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,9 @@
* limitations under the License.
*/

package trace
package constant

import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
const (
OtelPackageName = "go.opentelemetry.io/otel"
OtelPackageVersion = "v1.10.0"
)

// Version is the current release version of the dubbogo instrumentation.
func Version() string {
return constant.Version
}

// SemVersion is the semantic version to be supplied to tracer/meter creation.
func SemVersion() string {
return "semver:" + Version()
}
42 changes: 0 additions & 42 deletions common/extension/metrics.go

This file was deleted.

52 changes: 0 additions & 52 deletions common/extension/metrics_test.go

This file was deleted.

58 changes: 58 additions & 0 deletions common/extension/otel_trace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 extension

import (
"context"
)

import (
"dubbo.apache.org/dubbo-go/v3/otel/trace"
)

import (
"github.com/dubbogo/gost/log/logger"
)

var traceExporterMap = make(map[string]func(config *trace.ExporterConfig) (trace.Exporter, error), 4)

func SetTraceExporter(name string, createFunc func(config *trace.ExporterConfig) (trace.Exporter, error)) {
traceExporterMap[name] = createFunc
}

func GetTraceExporter(name string, config *trace.ExporterConfig) (trace.Exporter, error) {
createFunc, ok := traceExporterMap[name]
if !ok {
panic("Cannot find the trace provider with name " + name)
}
return createFunc(config)
}

func GetTraceShutdownCallback() func() {
return func() {
for name, createFunc := range traceExporterMap {
if exporter, err := createFunc(nil); err == nil {
if err := exporter.GetTracerProvider().Shutdown(context.Background()); err != nil {
logger.Errorf("Graceful shutdown --- Failed to shutdown trace provider %s, error: %s", name, err.Error())
} else {
logger.Infof("Graceful shutdown --- Tracer provider of %s", name)
}
}
}
}
}
3 changes: 3 additions & 0 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ func NewURL(urlString string, opts ...Option) (*URL, error) {
for _, opt := range opts {
opt(&s)
}
if s.params.Get(constant.RegistryGroupKey) != "" {
s.PrimitiveURL = strings.Join([]string{s.PrimitiveURL, s.params.Get(constant.RegistryGroupKey)}, constant.PathSeparator)
}
return &s, nil
}

Expand Down
Loading

0 comments on commit 9498a4f

Please sign in to comment.