Allow to disable NGINX metrics

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-12-04 16:59:54 -03:00
parent c4ba23832a
commit 06d33c16b5
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
9 changed files with 42 additions and 9 deletions

View file

@ -715,6 +715,7 @@ type TemplateConfig struct {
ListenPorts *ListenPorts
PublishService *apiv1.Service
DynamicCertificatesEnabled bool
EnableMetrics bool
}
// ListenPorts describe the ports required to run the

View file

@ -87,6 +87,8 @@ type Configuration struct {
EnableProfiling bool
EnableMetrics bool
EnableSSLChainCompletion bool
FakeCertificatePath string

View file

@ -602,6 +602,7 @@ func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
ListenPorts: n.cfg.ListenPorts,
PublishService: n.GetPublishService(),
DynamicCertificatesEnabled: n.cfg.DynamicCertificatesEnabled,
EnableMetrics: n.cfg.EnableMetrics,
}
tc.Cfg.Checksum = ingressCfg.ConfigurationChecksum

View file

@ -914,13 +914,15 @@ func proxySetHeader(loc interface{}) string {
// buildCustomErrorDeps is a utility function returning a struct wrapper with
// the data required to build the 'CUSTOM_ERRORS' template
func buildCustomErrorDeps(proxySetHeaders map[string]string, errorCodes []int) interface{} {
func buildCustomErrorDeps(proxySetHeaders map[string]string, errorCodes []int, enableMetrics bool) interface{} {
return struct {
ProxySetHeaders map[string]string
ErrorCodes []int
EnableMetrics bool
}{
ProxySetHeaders: proxySetHeaders,
ErrorCodes: errorCodes,
EnableMetrics: enableMetrics,
}
}

View file

@ -826,7 +826,7 @@ func TestEscapeLiteralDollar(t *testing.T) {
}
}
func Test_opentracingPropagateContext(t *testing.T) {
func TestOpentracingPropagateContext(t *testing.T) {
tests := map[interface{}]string{
&ingress.Location{BackendProtocol: "HTTP"}: "opentracing_propagate_context",
&ingress.Location{BackendProtocol: "HTTPS"}: "opentracing_propagate_context",

View file

@ -16,7 +16,15 @@ limitations under the License.
package metric
import "k8s.io/ingress-nginx/internal/ingress"
import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/ingress-nginx/internal/ingress"
)
// NewDummyCollector returns a dummy metric collector
func NewDummyCollector() Collector {
return &DummyCollector{}
}
// DummyCollector dummy implementation for mocks in tests
type DummyCollector struct{}
@ -41,3 +49,6 @@ func (dc DummyCollector) Stop() {}
// SetSSLExpireTime ...
func (dc DummyCollector) SetSSLExpireTime([]*ingress.Server) {}
// SetHosts ...
func (dc DummyCollector) SetHosts(hosts sets.String) {}