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

disable EnableMetricInterceptor by default #365

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/ehttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Config struct {
PathRelabel []Relabel // path 重命名 (metric 用)
cookieJar http.CookieJar // 用于缓存cookie
httpClient *http.Client // 自定义http client
EnableMetricsInterceptor bool // 是否开启监控,默认开启
EnableMetricInterceptor bool // 是否开启Metric采集,默认禁用,开启metrics采集,可能造成metrics在prometheus中膨胀会导致占用大量的prometheus内存
}

// Relabel ...
Expand All @@ -50,6 +50,6 @@ func DefaultConfig() *Config {
EnableTraceInterceptor: true,
EnableAccessInterceptor: false,
EnableAccessInterceptorRes: false,
EnableMetricsInterceptor: true,
EnableMetricInterceptor: false,
}
}
5 changes: 3 additions & 2 deletions client/ehttp/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
"time"

"github.com/go-resty/resty/v2"
"github.com/gotomicro/ego/client/ehttp/resolver"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"go.opentelemetry.io/otel/trace"

"github.com/gotomicro/ego/client/ehttp/resolver"

"github.com/gotomicro/ego/core/eapp"
"github.com/gotomicro/ego/core/elog"
"github.com/gotomicro/ego/core/emetric"
Expand Down Expand Up @@ -140,7 +141,7 @@ func logInterceptor(name string, config *Config, logger *elog.Component, builder
}

func metricInterceptor(name string, config *Config, logger *elog.Component, builder resolver.Resolver) (resty.RequestMiddleware, resty.ResponseMiddleware, resty.ErrorHook) {
if !config.EnableMetricsInterceptor {
if !config.EnableMetricInterceptor {
return nil, nil, nil
}
addr := strings.TrimRight(config.Addr, "/")
Expand Down
6 changes: 3 additions & 3 deletions client/ehttp/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ func WithEnableTraceInterceptor(enableTraceInterceptor bool) Option {
}
}

// WithEnableMetricsInterceptor 设置开启 Metrics 拦截器
func WithEnableMetricsInterceptor(enableMetricsInterceptor bool) Option {
// WithEnableMetricInterceptor 设置开启 Metrics 拦截器
func WithEnableMetricInterceptor(enableMetricsInterceptor bool) Option {
return func(c *Container) {
c.config.EnableMetricsInterceptor = enableMetricsInterceptor
c.config.EnableMetricInterceptor = enableMetricsInterceptor
}
}

Expand Down
Loading