Add EnableProbeReqLogKey constant (#1806)

For consistency with existing EnableReqLogKey.
This commit is contained in:
Julian Friedman 2020-10-14 18:28:30 +01:00 committed by GitHub
parent 5a5f68637e
commit 7c6171acf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -42,6 +42,9 @@ const (
// EnableReqLogKey is the CM key to enable request log.
EnableReqLogKey = "logging.enable-request-log"
// EnableProbeReqLogKey is the CM key to enable request logs for probe requests.
EnableProbeReqLogKey = "logging.enable-probe-request-log"
)
// ObservabilityConfig contains the configuration defined in the observability ConfigMap.
@ -94,7 +97,7 @@ func NewObservabilityConfigFromConfigMap(configMap *corev1.ConfigMap) (*Observab
cm.AsString("logging.revision-url-template", &oc.LoggingURLTemplate),
cm.AsString(ReqLogTemplateKey, &oc.RequestLogTemplate),
cm.AsBool(EnableReqLogKey, &oc.EnableRequestLog),
cm.AsBool("logging.enable-probe-request-log", &oc.EnableProbeRequestLog),
cm.AsBool(EnableProbeReqLogKey, &oc.EnableProbeRequestLog),
cm.AsString("metrics.request-metrics-backend-destination", &oc.RequestMetricsBackend),
cm.AsBool("profiling.enable", &oc.EnableProfiling),
cm.AsString("metrics.opencensus-address", &oc.MetricsCollectorAddress),

View File

@ -44,7 +44,7 @@ func TestObservabilityConfiguration(t *testing.T) {
RequestMetricsBackend: "stackdriver",
},
data: map[string]string{
"logging.enable-probe-request-log": "true",
EnableProbeReqLogKey: "true",
"logging.enable-var-log-collection": "true",
ReqLogTemplateKey: `{"requestMethod": "{{.Request.Method}}"}`,
"logging.revision-url-template": "https://logging.io",
@ -64,7 +64,7 @@ func TestObservabilityConfiguration(t *testing.T) {
}, {
name: "observability configuration with request log set and template default",
data: map[string]string{
"logging.enable-probe-request-log": "true",
EnableProbeReqLogKey: "true",
EnableReqLogKey: "true",
"logging.enable-var-log-collection": "true",
"logging.revision-url-template": "https://logging.io",
@ -90,7 +90,7 @@ func TestObservabilityConfiguration(t *testing.T) {
RequestMetricsBackend: "stackdriver",
},
data: map[string]string{
"logging.enable-probe-request-log": "true",
EnableProbeReqLogKey: "true",
EnableReqLogKey: "false",
"logging.enable-var-log-collection": "true",
ReqLogTemplateKey: "",
@ -102,7 +102,7 @@ func TestObservabilityConfiguration(t *testing.T) {
name: "observability configuration with request log set and template not set",
wantErr: true,
data: map[string]string{
"logging.enable-probe-request-log": "true",
EnableProbeReqLogKey: "true",
EnableReqLogKey: "true",
"logging.enable-var-log-collection": "true",
ReqLogTemplateKey: "",
@ -121,7 +121,7 @@ func TestObservabilityConfiguration(t *testing.T) {
RequestMetricsBackend: "stackdriver",
},
data: map[string]string{
"logging.enable-probe-request-log": "true",
EnableProbeReqLogKey: "true",
"logging.enable-var-log-collection": "true",
ReqLogTemplateKey: `{"requestMethod": "{{.Request.Method}}"}`,
"logging.revision-url-template": "https://logging.io",