Skip to content

Commit

Permalink
Log fields cleanup (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
amolmejari2 committed Jul 13, 2023
1 parent 0dc5fb6 commit c226da8
Show file tree
Hide file tree
Showing 68 changed files with 190 additions and 380 deletions.
18 changes: 6 additions & 12 deletions codegen/template_bundle/template_files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions codegen/templates/endpoint.tmpl
Expand Up @@ -111,8 +111,7 @@ func (h *{{$handlerName}}) HandleRequest(
ctx,
"Endpoint failure: endpoint panic",
zap.Error(e),
zap.String("stacktrace", stacktrace),
zap.String("endpoint", h.endpoint.EndpointName))
zap.String("stacktrace", stacktrace))

h.Dependencies.Default.ContextMetrics.IncCounter(ctx, zanzibar.MetricEndpointPanics, 1)
res.SendError(502, "Unexpected workflow panic, recovered at endpoint.", nil)
Expand Down Expand Up @@ -150,9 +149,7 @@ func (h *{{$handlerName}}) HandleRequest(

// log endpoint request to downstream services
if ce := h.Dependencies.Default.ContextLogger.Check(zapcore.DebugLevel, "stub"); ce != nil {
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
var zfields []zapcore.Field
{{- if ne .RequestType ""}}
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", req.GetRawBody())))
{{- end}}
Expand Down Expand Up @@ -180,9 +177,7 @@ func (h *{{$handlerName}}) HandleRequest(

// log downstream response to endpoint
if ce := h.Dependencies.Default.ContextLogger.Check(zapcore.DebugLevel, "stub"); ce != nil {
zfields := []zapcore.Field{
zap.String("endpoint", h.endpoint.EndpointName),
}
var zfields []zapcore.Field
{{- if ne .ResponseType ""}}
if body, err := json.Marshal(response); err == nil {
zfields = append(zfields, zap.String("body", fmt.Sprintf("%s", body)))
Expand Down
3 changes: 1 addition & 2 deletions codegen/templates/tchannel_endpoint.tmpl
Expand Up @@ -91,8 +91,7 @@ func (h *{{$handlerName}}) Handle(
ctx,
"Endpoint failure: endpoint panic",
zap.Error(e),
zap.String("stacktrace", stacktrace),
zap.String("endpoint", h.endpoint.EndpointID))
zap.String("stacktrace", stacktrace))

h.Deps.Default.ContextMetrics.IncCounter(ctx, zanzibar.MetricEndpointPanics, 1)
isSuccessful = false
Expand Down
20 changes: 20 additions & 0 deletions config/production.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c226da8

Please sign in to comment.