-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Enable request log flag support #8958
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
Changes from all commits
349c864
cbc6aee
a5b1ab8
654235e
5ad5d27
632b7fa
46c1bde
dc6bc38
3cd302c
8c4693a
a25e53f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,7 @@ import ( | |||||||
|
|
||||||||
| "go.uber.org/zap" | ||||||||
| corev1 "k8s.io/api/core/v1" | ||||||||
| "knative.dev/pkg/metrics" | ||||||||
| "knative.dev/serving/pkg/activator" | ||||||||
| "knative.dev/serving/pkg/apis/serving" | ||||||||
| servinglisters "knative.dev/serving/pkg/client/listers/serving/v1" | ||||||||
|
|
@@ -29,7 +30,16 @@ import ( | |||||||
|
|
||||||||
| func updateRequestLogFromConfigMap(logger *zap.SugaredLogger, h *pkghttp.RequestLogHandler) func(configMap *corev1.ConfigMap) { | ||||||||
| return func(configMap *corev1.ConfigMap) { | ||||||||
| newTemplate := configMap.Data["logging.request-log-template"] | ||||||||
| obsconfig, err := metrics.NewObservabilityConfigFromConfigMap(configMap) | ||||||||
| if err != nil { | ||||||||
| logger.Errorw("Failed to get observability configmap.", zap.Error(err), "configmap", configMap) | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably better to do this as a guard clause at the top with a return, then the rest of the method can be out-dented
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. refactored |
||||||||
| return | ||||||||
| } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. total nit, but nicer to have a newline after a guard clause I think
Suggested change
|
||||||||
|
|
||||||||
| var newTemplate string | ||||||||
| if obsconfig.EnableRequestLog { | ||||||||
| newTemplate = obsconfig.RequestLogTemplate | ||||||||
| } | ||||||||
| if err := h.SetTemplate(newTemplate); err != nil { | ||||||||
| logger.Errorw("Failed to update the request log template.", zap.Error(err), "template", newTemplate) | ||||||||
| } else { | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,7 @@ type config struct { | |
| ServingLoggingConfig string `split_words:"true" required:"true"` | ||
| ServingLoggingLevel string `split_words:"true" required:"true"` | ||
| ServingRequestLogTemplate string `split_words:"true"` // optional | ||
| ServingEnableRequestLog bool `split_words:"true"` // optional | ||
| ServingEnableProbeRequestLog bool `split_words:"true"` // optional | ||
|
|
||
| // Metrics configuration | ||
|
|
@@ -432,7 +433,7 @@ func buildMetricsServer(promStatReporter *queue.PrometheusStatsReporter, protobu | |
| } | ||
|
|
||
| func pushRequestLogHandler(currentHandler http.Handler, env config) http.Handler { | ||
| if env.ServingRequestLogTemplate == "" { | ||
| if !env.ServingEnableRequestLog { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we want to handle the case where ServiceEnableRequestLog is true but ServingRequestLogTemplate is ""? (e.g. maybe this would happen with default settings in 0.17 and we'd still want to avoid bothering with the request log handler, even though it'll eventually be a no-op?)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @julz in Afaik what you describe cannot happen. We only set it to true internally in 0.17 if the template is not empty.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok cool, sounds good to me then |
||
| return currentHandler | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,6 +311,9 @@ func makeQueueContainer(rev *v1.Revision, loggingConfig *logging.Config, tracing | |
| }, { | ||
| Name: "SERVING_REQUEST_LOG_TEMPLATE", | ||
| Value: observabilityConfig.RequestLogTemplate, | ||
| }, { | ||
| Name: "SERVING_ENABLE_REQUEST_LOG", | ||
| Value: strconv.FormatBool(observabilityConfig.EnableRequestLog), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems worth adding a quick test for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
| }, { | ||
| Name: "SERVING_REQUEST_METRICS_BACKEND", | ||
| Value: observabilityConfig.RequestMetricsBackend, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like it'll need updates to
request_log_test.goThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it was
queue_test.go, for 0.17 we want things to work as previously so unit tests shouldnt break.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queue_test.gofailed because of the changes toqueue.go. This requires changes torequest_log_test.gobecause it changes the behaviour so should probably at least result in a new row in the table test or something :-).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I was referring to the failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right, gotcha. I was just meaning "we probably need to add a test for the new logic here"