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

Update use context logger #748

Merged
merged 21 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from 20 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
28 changes: 14 additions & 14 deletions codegen/template_bundle/template_files.go

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

2 changes: 1 addition & 1 deletion codegen/templates/grpc_client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func {{$exportName}}(deps *module.Dependencies) Client {
{{camel $s.Name}}Client: gen.New{{pascal $s.Name}}YARPCClient(oc),
{{ end -}}
opts: zanzibar.NewGRPCClientOpts(
deps.Default.Logger,
deps.Default.ContextLogger,
amit-lamba marked this conversation as resolved.
Show resolved Hide resolved
deps.Default.ContextMetrics,
deps.Default.ContextExtractor,
methodNames,
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/http_client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func {{$exportName}}(deps *module.Dependencies) Client {
altRoutingMap: initializeAltRoutingMap(altServiceDetail),
{{end -}}
httpClient: zanzibar.NewHTTPClientContext(
deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper,
deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper,
"{{$clientID}}",
map[string]string{
{{range $serviceMethod, $methodName := $exposedMethods -}}
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/service_mock.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func MustCreateTestService(t *testing.T, testConfigPaths ...string) MockService

tchannelClient := zanzibar.NewRawTChannelClient(
server.Channel,
server.Logger,
server.ContextLogger,
server.RootScope,
&zanzibar.TChannelClientOption{
ServiceName: server.ServiceName,
Expand Down
10 changes: 5 additions & 5 deletions codegen/templates/tchannel_client.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func {{$exportName}}(deps *module.Dependencies) Client {

client := zanzibar.NewTChannelClientContext(
deps.Default.Channel,
deps.Default.Logger,
deps.Default.ContextLogger,
deps.Default.ContextMetrics,
deps.Default.ContextExtractor,
&zanzibar.TChannelClientOption{
Expand Down Expand Up @@ -250,7 +250,7 @@ type {{$clientName}} struct {
{{if .ResponseType -}}
var resp {{.ResponseType}}
{{end}}
logger := c.client.Loggers["{{$serviceMethod}}"]
logger := c.client.ContextLogger

{{if eq .RequestType "" -}}
args := &{{.GenCodePkgName}}.{{title $svc.Name}}_{{title .Name}}_Args{}
Expand Down Expand Up @@ -290,15 +290,15 @@ type {{$clientName}} struct {
{{end -}}
{{if ne .ResponseType "" -}}
case result.Success != nil:
logger.Error("Internal error. Success flag is not set for {{title .Name}}. Overriding")
logger.Error(ctx, "Internal error. Success flag is not set for {{title .Name}}. Overriding", zap.Error(err))
success = true
{{end -}}
default:
err = errors.New("{{$clientName}} received no result or unknown exception for {{title .Name}}")
}
}
if err != nil {
logger.Warn("Client failure: TChannel client call returned error", zap.Error(err))
logger.Warn(ctx, "Client failure: TChannel client call returned error", zap.Error(err))
{{if eq .ResponseType "" -}}
return respHeaders, err
{{else -}}
Expand All @@ -311,7 +311,7 @@ type {{$clientName}} struct {
{{else -}}
resp, err = {{.GenCodePkgName}}.{{title $svc.Name}}_{{title .Name}}_Helper.UnwrapResponse(&result)
if err != nil {
logger.Warn("Client failure: unable to unwrap client response", zap.Error(err))
logger.Warn(ctx, "Client failure: unable to unwrap client response", zap.Error(err))
}
return resp, respHeaders, err
{{end -}}
Expand Down
2 changes: 1 addition & 1 deletion codegen/templates/tchannel_endpoint.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (h *{{$handlerName}}) redirectToDeputy(
deputyChannel.Peers().Add(hostPort)
client := zanzibar.NewTChannelClientContext(
deputyChannel,
h.Deps.Default.Logger,
h.Deps.Default.ContextLogger,
h.Deps.Default.ContextMetrics,
h.Deps.Default.ContextExtractor,
&zanzibar.TChannelClientOption{
Expand Down

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

2 changes: 1 addition & 1 deletion examples/example-gateway/build/clients/bar/bar.go

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

Loading