diff --git a/CHANGELOG.md b/CHANGELOG.md index 17ff73e78..90af59051 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.6.7 - 2021-02-05 +### Changed +- **BREAKING** runtime/client_http_request.go, runtime/grpc_client.go, runtime/http_client.go, runtime/router.go, +runtime/server_http_request.go, runtime/server_http_response.go, runtime/tchannel_client.go, +runtime/tchannel_client_raw.go, runtime/tchannel_outbound_call.go, runtime_inbound_call.go, runtime/tchannel_server.go +now uses contextLogger instead of nornal logger ([#748](https://github.com/uber/zanzibar/pull/748)) + ## 0.6.5 - 2020-08-10 ### Added - Added support for fetching multiple header values. https://github.com/uber/zanzibar/pull/733. diff --git a/codegen/template_bundle/template_files.go b/codegen/template_bundle/template_files.go index 0705977ab..a9c36e767 100644 --- a/codegen/template_bundle/template_files.go +++ b/codegen/template_bundle/template_files.go @@ -1274,7 +1274,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, deps.Default.ContextMetrics, deps.Default.ContextExtractor, methodNames, @@ -1387,7 +1387,7 @@ func grpc_clientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "grpc_client.tmpl", size: 6603, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "grpc_client.tmpl", size: 6610, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -1511,7 +1511,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 -}} @@ -1892,7 +1892,7 @@ func http_clientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "http_client.tmpl", size: 16405, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "http_client.tmpl", size: 16412, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -2627,7 +2627,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, @@ -2730,7 +2730,7 @@ func service_mockTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "service_mock.tmpl", size: 5403, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "service_mock.tmpl", size: 5410, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -2905,7 +2905,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{ @@ -3023,7 +3023,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{} @@ -3063,7 +3063,7 @@ 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: @@ -3071,7 +3071,7 @@ type {{$clientName}} struct { } } 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 -}} @@ -3084,7 +3084,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 -}} @@ -3104,7 +3104,7 @@ func tchannel_clientTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "tchannel_client.tmpl", size: 11400, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "tchannel_client.tmpl", size: 11422, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } @@ -3482,7 +3482,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{ @@ -3513,7 +3513,7 @@ func tchannel_endpointTmpl() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "tchannel_endpoint.tmpl", size: 8784, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + info := bindataFileInfo{name: "tchannel_endpoint.tmpl", size: 8791, mode: os.FileMode(420), modTime: time.Unix(1, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/codegen/templates/grpc_client.tmpl b/codegen/templates/grpc_client.tmpl index 7c2cd38cc..82fe1e417 100644 --- a/codegen/templates/grpc_client.tmpl +++ b/codegen/templates/grpc_client.tmpl @@ -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, deps.Default.ContextMetrics, deps.Default.ContextExtractor, methodNames, diff --git a/codegen/templates/http_client.tmpl b/codegen/templates/http_client.tmpl index e323f0b0a..f1ef0625f 100644 --- a/codegen/templates/http_client.tmpl +++ b/codegen/templates/http_client.tmpl @@ -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 -}} diff --git a/codegen/templates/service_mock.tmpl b/codegen/templates/service_mock.tmpl index 48a3999a6..356c63603 100644 --- a/codegen/templates/service_mock.tmpl +++ b/codegen/templates/service_mock.tmpl @@ -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, diff --git a/codegen/templates/tchannel_client.tmpl b/codegen/templates/tchannel_client.tmpl index 9cad4d495..b62ba43c4 100644 --- a/codegen/templates/tchannel_client.tmpl +++ b/codegen/templates/tchannel_client.tmpl @@ -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{ @@ -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{} @@ -290,7 +290,7 @@ 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: @@ -298,7 +298,7 @@ type {{$clientName}} struct { } } 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 -}} @@ -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 -}} diff --git a/codegen/templates/tchannel_endpoint.tmpl b/codegen/templates/tchannel_endpoint.tmpl index 84fb68273..45c61cf85 100644 --- a/codegen/templates/tchannel_endpoint.tmpl +++ b/codegen/templates/tchannel_endpoint.tmpl @@ -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{ diff --git a/examples/example-gateway/build/app/demo/services/xyz/mock-service/mock_service.go b/examples/example-gateway/build/app/demo/services/xyz/mock-service/mock_service.go index c20f953de..3eb9c484d 100644 --- a/examples/example-gateway/build/app/demo/services/xyz/mock-service/mock_service.go +++ b/examples/example-gateway/build/app/demo/services/xyz/mock-service/mock_service.go @@ -122,7 +122,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, diff --git a/examples/example-gateway/build/clients/bar/bar.go b/examples/example-gateway/build/clients/bar/bar.go index cd21e8b02..71c16d36a 100644 --- a/examples/example-gateway/build/clients/bar/bar.go +++ b/examples/example-gateway/build/clients/bar/bar.go @@ -258,7 +258,7 @@ func NewClient(deps *module.Dependencies) Client { return &barClient{ clientID: "bar", httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "bar", map[string]string{ "ArgNotStruct": "Bar::argNotStruct", diff --git a/examples/example-gateway/build/clients/baz/baz.go b/examples/example-gateway/build/clients/baz/baz.go index f6e5808d8..4cee9d062 100644 --- a/examples/example-gateway/build/clients/baz/baz.go +++ b/examples/example-gateway/build/clients/baz/baz.go @@ -272,7 +272,7 @@ func NewClient(deps *module.Dependencies) Client { client := zanzibar.NewTChannelClientContext( deps.Default.Channel, - deps.Default.Logger, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.ContextExtractor, &zanzibar.TChannelClientOption{ @@ -382,7 +382,7 @@ func (c *bazClient) EchoBinary( var result clientsIDlClientsBazBaz.SecondService_EchoBinary_Result var resp []byte - logger := c.client.Loggers["SecondService::echoBinary"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -413,20 +413,20 @@ func (c *bazClient) EchoBinary( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoBinary. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoBinary. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoBinary") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoBinary_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 } @@ -440,7 +440,7 @@ func (c *bazClient) EchoBool( var result clientsIDlClientsBazBaz.SecondService_EchoBool_Result var resp bool - logger := c.client.Loggers["SecondService::echoBool"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -471,20 +471,20 @@ func (c *bazClient) EchoBool( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoBool. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoBool. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoBool") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoBool_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 } @@ -498,7 +498,7 @@ func (c *bazClient) EchoDouble( var result clientsIDlClientsBazBaz.SecondService_EchoDouble_Result var resp float64 - logger := c.client.Loggers["SecondService::echoDouble"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -529,20 +529,20 @@ func (c *bazClient) EchoDouble( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoDouble. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoDouble. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoDouble") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoDouble_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 } @@ -556,7 +556,7 @@ func (c *bazClient) EchoEnum( var result clientsIDlClientsBazBaz.SecondService_EchoEnum_Result var resp clientsIDlClientsBazBaz.Fruit - logger := c.client.Loggers["SecondService::echoEnum"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -587,20 +587,20 @@ func (c *bazClient) EchoEnum( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoEnum. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoEnum. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoEnum") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoEnum_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 } @@ -614,7 +614,7 @@ func (c *bazClient) EchoI16( var result clientsIDlClientsBazBaz.SecondService_EchoI16_Result var resp int16 - logger := c.client.Loggers["SecondService::echoI16"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -645,20 +645,20 @@ func (c *bazClient) EchoI16( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoI16. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoI16. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoI16") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoI16_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 } @@ -672,7 +672,7 @@ func (c *bazClient) EchoI32( var result clientsIDlClientsBazBaz.SecondService_EchoI32_Result var resp int32 - logger := c.client.Loggers["SecondService::echoI32"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -703,20 +703,20 @@ func (c *bazClient) EchoI32( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoI32. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoI32. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoI32") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoI32_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 } @@ -730,7 +730,7 @@ func (c *bazClient) EchoI64( var result clientsIDlClientsBazBaz.SecondService_EchoI64_Result var resp int64 - logger := c.client.Loggers["SecondService::echoI64"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -761,20 +761,20 @@ func (c *bazClient) EchoI64( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoI64. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoI64. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoI64") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoI64_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 } @@ -788,7 +788,7 @@ func (c *bazClient) EchoI8( var result clientsIDlClientsBazBaz.SecondService_EchoI8_Result var resp int8 - logger := c.client.Loggers["SecondService::echoI8"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -819,20 +819,20 @@ func (c *bazClient) EchoI8( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoI8. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoI8. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoI8") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoI8_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 } @@ -846,7 +846,7 @@ func (c *bazClient) EchoString( var result clientsIDlClientsBazBaz.SecondService_EchoString_Result var resp string - logger := c.client.Loggers["SecondService::echoString"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -877,20 +877,20 @@ func (c *bazClient) EchoString( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoString. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoString. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoString") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoString_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 } @@ -904,7 +904,7 @@ func (c *bazClient) EchoStringList( var result clientsIDlClientsBazBaz.SecondService_EchoStringList_Result var resp []string - logger := c.client.Loggers["SecondService::echoStringList"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -935,20 +935,20 @@ func (c *bazClient) EchoStringList( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoStringList. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoStringList. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoStringList") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoStringList_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 } @@ -962,7 +962,7 @@ func (c *bazClient) EchoStringMap( var result clientsIDlClientsBazBaz.SecondService_EchoStringMap_Result var resp map[string]*clientsIDlClientsBazBase.BazResponse - logger := c.client.Loggers["SecondService::echoStringMap"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -993,20 +993,20 @@ func (c *bazClient) EchoStringMap( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoStringMap. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoStringMap. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoStringMap") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoStringMap_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 } @@ -1020,7 +1020,7 @@ func (c *bazClient) EchoStringSet( var result clientsIDlClientsBazBaz.SecondService_EchoStringSet_Result var resp map[string]struct{} - logger := c.client.Loggers["SecondService::echoStringSet"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1051,20 +1051,20 @@ func (c *bazClient) EchoStringSet( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoStringSet. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoStringSet. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoStringSet") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoStringSet_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 } @@ -1078,7 +1078,7 @@ func (c *bazClient) EchoStructList( var result clientsIDlClientsBazBaz.SecondService_EchoStructList_Result var resp []*clientsIDlClientsBazBase.BazResponse - logger := c.client.Loggers["SecondService::echoStructList"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1109,20 +1109,20 @@ func (c *bazClient) EchoStructList( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoStructList. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoStructList. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoStructList") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoStructList_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 } @@ -1136,7 +1136,7 @@ func (c *bazClient) EchoStructSet( var result clientsIDlClientsBazBaz.SecondService_EchoStructSet_Result var resp []*clientsIDlClientsBazBase.BazResponse - logger := c.client.Loggers["SecondService::echoStructSet"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1167,20 +1167,20 @@ func (c *bazClient) EchoStructSet( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoStructSet. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoStructSet. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoStructSet") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoStructSet_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 } @@ -1194,7 +1194,7 @@ func (c *bazClient) EchoTypedef( var result clientsIDlClientsBazBaz.SecondService_EchoTypedef_Result var resp clientsIDlClientsBazBase.UUID - logger := c.client.Loggers["SecondService::echoTypedef"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1225,20 +1225,20 @@ func (c *bazClient) EchoTypedef( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoTypedef. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoTypedef. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for EchoTypedef") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SecondService_EchoTypedef_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 } @@ -1251,7 +1251,7 @@ func (c *bazClient) Call( ) (map[string]string, error) { var result clientsIDlClientsBazBaz.SimpleService_Call_Result - logger := c.client.Loggers["SimpleService::call"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1288,7 +1288,7 @@ func (c *bazClient) Call( } } 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)) return respHeaders, err } @@ -1304,7 +1304,7 @@ func (c *bazClient) Compare( var result clientsIDlClientsBazBaz.SimpleService_Compare_Result var resp *clientsIDlClientsBazBase.BazResponse - logger := c.client.Loggers["SimpleService::compare"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1339,20 +1339,20 @@ func (c *bazClient) Compare( case result.OtherAuthErr != nil: err = result.OtherAuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for Compare. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for Compare. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for Compare") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_Compare_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 } @@ -1366,7 +1366,7 @@ func (c *bazClient) GetProfile( var result clientsIDlClientsBazBaz.SimpleService_GetProfile_Result var resp *clientsIDlClientsBazBaz.GetProfileResponse - logger := c.client.Loggers["SimpleService::getProfile"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1399,20 +1399,20 @@ func (c *bazClient) GetProfile( case result.AuthErr != nil: err = result.AuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for GetProfile. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for GetProfile. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for GetProfile") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_GetProfile_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 } @@ -1426,7 +1426,7 @@ func (c *bazClient) HeaderSchema( var result clientsIDlClientsBazBaz.SimpleService_HeaderSchema_Result var resp *clientsIDlClientsBazBaz.HeaderSchema - logger := c.client.Loggers["SimpleService::headerSchema"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1461,20 +1461,20 @@ func (c *bazClient) HeaderSchema( case result.OtherAuthErr != nil: err = result.OtherAuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for HeaderSchema. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for HeaderSchema. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for HeaderSchema") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_HeaderSchema_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 } @@ -1487,7 +1487,7 @@ func (c *bazClient) Ping( var result clientsIDlClientsBazBaz.SimpleService_Ping_Result var resp *clientsIDlClientsBazBase.BazResponse - logger := c.client.Loggers["SimpleService::ping"] + logger := c.client.ContextLogger args := &clientsIDlClientsBazBaz.SimpleService_Ping_Args{} var success bool @@ -1519,20 +1519,20 @@ func (c *bazClient) Ping( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for Ping. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for Ping. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for Ping") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_Ping_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 } @@ -1544,7 +1544,7 @@ func (c *bazClient) DeliberateDiffNoop( ) (map[string]string, error) { var result clientsIDlClientsBazBaz.SimpleService_SillyNoop_Result - logger := c.client.Loggers["SimpleService::sillyNoop"] + logger := c.client.ContextLogger args := &clientsIDlClientsBazBaz.SimpleService_SillyNoop_Args{} var success bool @@ -1584,7 +1584,7 @@ func (c *bazClient) DeliberateDiffNoop( } } 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)) return respHeaders, err } @@ -1598,7 +1598,7 @@ func (c *bazClient) TestUUID( ) (map[string]string, error) { var result clientsIDlClientsBazBaz.SimpleService_TestUuid_Result - logger := c.client.Loggers["SimpleService::testUuid"] + logger := c.client.ContextLogger args := &clientsIDlClientsBazBaz.SimpleService_TestUuid_Args{} var success bool @@ -1634,7 +1634,7 @@ func (c *bazClient) TestUUID( } } 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)) return respHeaders, err } @@ -1650,7 +1650,7 @@ func (c *bazClient) Trans( var result clientsIDlClientsBazBaz.SimpleService_Trans_Result var resp *clientsIDlClientsBazBase.TransStruct - logger := c.client.Loggers["SimpleService::trans"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1685,20 +1685,20 @@ func (c *bazClient) Trans( case result.OtherAuthErr != nil: err = result.OtherAuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for Trans. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for Trans. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for Trans") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_Trans_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 } @@ -1712,7 +1712,7 @@ func (c *bazClient) TransHeaders( var result clientsIDlClientsBazBaz.SimpleService_TransHeaders_Result var resp *clientsIDlClientsBazBase.TransHeaders - logger := c.client.Loggers["SimpleService::transHeaders"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1747,20 +1747,20 @@ func (c *bazClient) TransHeaders( case result.OtherAuthErr != nil: err = result.OtherAuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for TransHeaders. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for TransHeaders. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for TransHeaders") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_TransHeaders_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 } @@ -1774,7 +1774,7 @@ func (c *bazClient) TransHeadersNoReq( var result clientsIDlClientsBazBaz.SimpleService_TransHeadersNoReq_Result var resp *clientsIDlClientsBazBase.TransHeaders - logger := c.client.Loggers["SimpleService::transHeadersNoReq"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1807,20 +1807,20 @@ func (c *bazClient) TransHeadersNoReq( case result.AuthErr != nil: err = result.AuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for TransHeadersNoReq. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for TransHeadersNoReq. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for TransHeadersNoReq") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_TransHeadersNoReq_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 } @@ -1834,7 +1834,7 @@ func (c *bazClient) TransHeadersType( var result clientsIDlClientsBazBaz.SimpleService_TransHeadersType_Result var resp *clientsIDlClientsBazBaz.TransHeaderType - logger := c.client.Loggers["SimpleService::transHeadersType"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -1869,20 +1869,20 @@ func (c *bazClient) TransHeadersType( case result.OtherAuthErr != nil: err = result.OtherAuthErr case result.Success != nil: - logger.Error("Internal error. Success flag is not set for TransHeadersType. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for TransHeadersType. Overriding", zap.Error(err)) success = true default: err = errors.New("bazClient received no result or unknown exception for TransHeadersType") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsBazBaz.SimpleService_TransHeadersType_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 } @@ -1894,7 +1894,7 @@ func (c *bazClient) URLTest( ) (map[string]string, error) { var result clientsIDlClientsBazBaz.SimpleService_UrlTest_Result - logger := c.client.Loggers["SimpleService::urlTest"] + logger := c.client.ContextLogger args := &clientsIDlClientsBazBaz.SimpleService_UrlTest_Args{} var success bool @@ -1930,7 +1930,7 @@ func (c *bazClient) URLTest( } } 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)) return respHeaders, err } diff --git a/examples/example-gateway/build/clients/contacts/contacts.go b/examples/example-gateway/build/clients/contacts/contacts.go index 9b7cc29e2..80266a1f8 100644 --- a/examples/example-gateway/build/clients/contacts/contacts.go +++ b/examples/example-gateway/build/clients/contacts/contacts.go @@ -90,7 +90,7 @@ func NewClient(deps *module.Dependencies) Client { return &contactsClient{ clientID: "contacts", httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "contacts", map[string]string{ "SaveContacts": "Contacts::saveContacts", diff --git a/examples/example-gateway/build/clients/corge-http/corge-http.go b/examples/example-gateway/build/clients/corge-http/corge-http.go index e557959b3..40ddb02c6 100644 --- a/examples/example-gateway/build/clients/corge-http/corge-http.go +++ b/examples/example-gateway/build/clients/corge-http/corge-http.go @@ -126,7 +126,7 @@ func NewClient(deps *module.Dependencies) Client { calleeName: calleeName, altRoutingMap: initializeAltRoutingMap(altServiceDetail), httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "corge-http", map[string]string{ "EchoString": "Corge::echoString", diff --git a/examples/example-gateway/build/clients/corge/corge.go b/examples/example-gateway/build/clients/corge/corge.go index 60d2cf2b9..c097a5383 100644 --- a/examples/example-gateway/build/clients/corge/corge.go +++ b/examples/example-gateway/build/clients/corge/corge.go @@ -117,7 +117,7 @@ func NewClient(deps *module.Dependencies) Client { client := zanzibar.NewTChannelClientContext( deps.Default.Channel, - deps.Default.Logger, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.ContextExtractor, &zanzibar.TChannelClientOption{ @@ -227,7 +227,7 @@ func (c *corgeClient) EchoString( var result clientsIDlClientsCorgeCorge.Corge_EchoString_Result var resp string - logger := c.client.Loggers["Corge::echoString"] + logger := c.client.ContextLogger var success bool respHeaders := make(map[string]string) @@ -258,20 +258,20 @@ func (c *corgeClient) EchoString( if err == nil && !success { switch { case result.Success != nil: - logger.Error("Internal error. Success flag is not set for EchoString. Overriding") + logger.Error(ctx, "Internal error. Success flag is not set for EchoString. Overriding", zap.Error(err)) success = true default: err = errors.New("corgeClient received no result or unknown exception for EchoString") } } 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)) return resp, respHeaders, err } resp, err = clientsIDlClientsCorgeCorge.Corge_EchoString_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 } diff --git a/examples/example-gateway/build/clients/echo/echo.go b/examples/example-gateway/build/clients/echo/echo.go index 3f6b3e9d9..3414e9c0a 100644 --- a/examples/example-gateway/build/clients/echo/echo.go +++ b/examples/example-gateway/build/clients/echo/echo.go @@ -68,7 +68,7 @@ func NewClient(deps *module.Dependencies) Client { return &echoClient{ echoClient: gen.NewEchoYARPCClient(oc), opts: zanzibar.NewGRPCClientOpts( - deps.Default.Logger, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.ContextExtractor, methodNames, diff --git a/examples/example-gateway/build/clients/google-now/google-now.go b/examples/example-gateway/build/clients/google-now/google-now.go index 2634caa14..f4b6e0bb4 100644 --- a/examples/example-gateway/build/clients/google-now/google-now.go +++ b/examples/example-gateway/build/clients/google-now/google-now.go @@ -90,7 +90,7 @@ func NewClient(deps *module.Dependencies) Client { return &googleNowClient{ clientID: "google-now", httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "google-now", map[string]string{ "AddCredentials": "GoogleNowService::addCredentials", diff --git a/examples/example-gateway/build/clients/multi/multi.go b/examples/example-gateway/build/clients/multi/multi.go index e026a52cd..db45f7e5d 100644 --- a/examples/example-gateway/build/clients/multi/multi.go +++ b/examples/example-gateway/build/clients/multi/multi.go @@ -88,7 +88,7 @@ func NewClient(deps *module.Dependencies) Client { return &multiClient{ clientID: "multi", httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "multi", map[string]string{ "HelloA": "ServiceABack::hello", diff --git a/examples/example-gateway/build/clients/withexceptions/withexceptions.go b/examples/example-gateway/build/clients/withexceptions/withexceptions.go index ee53981b3..0f3f07510 100644 --- a/examples/example-gateway/build/clients/withexceptions/withexceptions.go +++ b/examples/example-gateway/build/clients/withexceptions/withexceptions.go @@ -85,7 +85,7 @@ func NewClient(deps *module.Dependencies) Client { return &withexceptionsClient{ clientID: "withexceptions", httpClient: zanzibar.NewHTTPClientContext( - deps.Default.Logger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.JSONWrapper, "withexceptions", map[string]string{ "Func1": "WithExceptions::Func1", diff --git a/examples/example-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go b/examples/example-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go index 85f577e90..f195963e4 100644 --- a/examples/example-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go +++ b/examples/example-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go @@ -166,7 +166,7 @@ func (h *BounceBounceHandler) 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{ diff --git a/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_call_tchannel.go b/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_call_tchannel.go index 00d0c7a80..66acb8fa5 100644 --- a/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_call_tchannel.go +++ b/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_call_tchannel.go @@ -222,7 +222,7 @@ func (h *SimpleServiceCallHandler) 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{ diff --git a/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_echo_tchannel.go b/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_echo_tchannel.go index 51572b319..44468398b 100644 --- a/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_echo_tchannel.go +++ b/examples/example-gateway/build/endpoints/tchannel/baz/baz_simpleservice_method_echo_tchannel.go @@ -166,7 +166,7 @@ func (h *SimpleServiceEchoHandler) 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{ diff --git a/examples/example-gateway/build/endpoints/tchannel/echo/echo_echo_method_echo_tchannel.go b/examples/example-gateway/build/endpoints/tchannel/echo/echo_echo_method_echo_tchannel.go index 180ee52b8..4aae5d58e 100644 --- a/examples/example-gateway/build/endpoints/tchannel/echo/echo_echo_method_echo_tchannel.go +++ b/examples/example-gateway/build/endpoints/tchannel/echo/echo_echo_method_echo_tchannel.go @@ -166,7 +166,7 @@ func (h *EchoEchoHandler) 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{ diff --git a/examples/example-gateway/build/endpoints/tchannel/panic/panic_simpleservice_method_anothercall_tchannel.go b/examples/example-gateway/build/endpoints/tchannel/panic/panic_simpleservice_method_anothercall_tchannel.go index f5e27a32b..e20f35d6a 100644 --- a/examples/example-gateway/build/endpoints/tchannel/panic/panic_simpleservice_method_anothercall_tchannel.go +++ b/examples/example-gateway/build/endpoints/tchannel/panic/panic_simpleservice_method_anothercall_tchannel.go @@ -216,7 +216,7 @@ func (h *SimpleServiceAnotherCallHandler) 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{ diff --git a/examples/example-gateway/build/endpoints/tchannel/quux/quux_simpleservice_method_echostring_tchannel.go b/examples/example-gateway/build/endpoints/tchannel/quux/quux_simpleservice_method_echostring_tchannel.go index dd4902102..1342dcd55 100644 --- a/examples/example-gateway/build/endpoints/tchannel/quux/quux_simpleservice_method_echostring_tchannel.go +++ b/examples/example-gateway/build/endpoints/tchannel/quux/quux_simpleservice_method_echostring_tchannel.go @@ -166,7 +166,7 @@ func (h *SimpleServiceEchoStringHandler) 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{ diff --git a/examples/example-gateway/build/services/echo-gateway/mock-service/mock_service.go b/examples/example-gateway/build/services/echo-gateway/mock-service/mock_service.go index 9001ab57c..51d7a071c 100644 --- a/examples/example-gateway/build/services/echo-gateway/mock-service/mock_service.go +++ b/examples/example-gateway/build/services/echo-gateway/mock-service/mock_service.go @@ -122,7 +122,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, diff --git a/examples/example-gateway/build/services/example-gateway/mock-service/mock_service.go b/examples/example-gateway/build/services/example-gateway/mock-service/mock_service.go index 7c6964aa5..18d7e07ac 100644 --- a/examples/example-gateway/build/services/example-gateway/mock-service/mock_service.go +++ b/examples/example-gateway/build/services/example-gateway/mock-service/mock_service.go @@ -122,7 +122,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, diff --git a/examples/selective-gateway/build/clients/echo/echo.go b/examples/selective-gateway/build/clients/echo/echo.go index 9d7852f82..f180fa37b 100644 --- a/examples/selective-gateway/build/clients/echo/echo.go +++ b/examples/selective-gateway/build/clients/echo/echo.go @@ -68,7 +68,7 @@ func NewClient(deps *module.Dependencies) Client { return &echoClient{ echoClient: gen.NewEchoYARPCClient(oc), opts: zanzibar.NewGRPCClientOpts( - deps.Default.Logger, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.ContextExtractor, methodNames, diff --git a/examples/selective-gateway/build/clients/mirror/mirror.go b/examples/selective-gateway/build/clients/mirror/mirror.go index e74888567..c9c78a6a4 100644 --- a/examples/selective-gateway/build/clients/mirror/mirror.go +++ b/examples/selective-gateway/build/clients/mirror/mirror.go @@ -77,7 +77,7 @@ func NewClient(deps *module.Dependencies) Client { mirrorClient: gen.NewMirrorYARPCClient(oc), mirrorInternalClient: gen.NewMirrorInternalYARPCClient(oc), opts: zanzibar.NewGRPCClientOpts( - deps.Default.Logger, + deps.Default.ContextLogger, deps.Default.ContextMetrics, deps.Default.ContextExtractor, methodNames, diff --git a/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go b/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go index 5662fc305..bfc13a7ca 100644 --- a/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go +++ b/examples/selective-gateway/build/endpoints/bounce/bounce_bounce_method_bounce_tchannel.go @@ -160,7 +160,7 @@ func (h *BounceBounceHandler) 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{ diff --git a/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go index cd25ce747..da85b56f5 100644 --- a/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go +++ b/examples/selective-gateway/build/services/selective-gateway/mock-service/mock_service.go @@ -122,7 +122,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, diff --git a/runtime/client_http_request.go b/runtime/client_http_request.go index 94d27d135..38d284d34 100644 --- a/runtime/client_http_request.go +++ b/runtime/client_http_request.go @@ -77,8 +77,7 @@ func NewClientHTTPRequest( ClientTargetEndpoint: clientTargetEndpoint, Metrics: client.contextMetrics, client: client, - Logger: client.loggers[clientMethod], - ContextLogger: NewContextLogger(client.loggers[clientMethod]), + ContextLogger: client.ContextLogger, defaultHeaders: client.DefaultHeaders, ctx: ctx, jsonWrapper: client.JSONWrapper, diff --git a/runtime/client_http_request_test.go b/runtime/client_http_request_test.go index b9b94e73b..60fe90749 100644 --- a/runtime/client_http_request_test.go +++ b/runtime/client_http_request_test.go @@ -65,7 +65,7 @@ func TestMakingClientWriteJSONWithBadJSON(t *testing.T) { bgateway := gateway.(*benchGateway.BenchGateway) client := zanzibar.NewHTTPClientContext( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.ContextMetrics, jsonwrapper.NewDefaultJSONWrapper(), "clientID", @@ -104,7 +104,7 @@ func TestMakingClientWriteJSONWithBadHTTPMethod(t *testing.T) { bgateway := gateway.(*benchGateway.BenchGateway) client := zanzibar.NewHTTPClient( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.RootScope, jsonwrapper.NewDefaultJSONWrapper(), "clientID", @@ -212,8 +212,8 @@ func TestBarClientWithoutHeaders(t *testing.T) { assert.Equal(t, 1, len(lines)) logLine := lines[0] - assert.Equal(t, "bar", logLine["clientID"]) - assert.Equal(t, "EchoI8", logLine["clientMethod"]) + //assert.Equal(t, "bar", logLine["clientID"]) + //assert.Equal(t, "EchoI8", logLine["clientMethod"]) assert.Equal(t, "x-uuid", logLine["headerName"]) } @@ -284,9 +284,6 @@ func TestMakingClientCallWithRespHeaders(t *testing.T) { "zone": "unknown", "service": "example-gateway", "statusCode": float64(200), - "clientMethod": "Normal", - "clientID": "bar", - "clientThriftMethod": "Bar::normal", "clientHTTPMethod": "POST", "Client-Req-Header-X-Client-Id": "bar", "Client-Req-Header-Content-Type": "application/json", diff --git a/runtime/client_http_request_write_json_test.go b/runtime/client_http_request_write_json_test.go index 73acbedc9..f771907da 100644 --- a/runtime/client_http_request_write_json_test.go +++ b/runtime/client_http_request_write_json_test.go @@ -42,7 +42,7 @@ type writeJSONSuit struct { func (wjs *writeJSONSuit) SetupSuite() { client := NewHTTPClient( - zap.NewNop(), + NewContextLogger(zap.NewNop()), tally.NewTestScope("", nil), jsonwrapper.NewDefaultJSONWrapper(), "foo", diff --git a/runtime/client_http_response_test.go b/runtime/client_http_response_test.go index 00a52c1ef..956204332 100644 --- a/runtime/client_http_response_test.go +++ b/runtime/client_http_response_test.go @@ -68,7 +68,7 @@ func TestReadAndUnmarshalNonStructBody(t *testing.T) { baseURL := "http://" + addr client := zanzibar.NewHTTPClientContext( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.ContextMetrics, jsonwrapper.NewDefaultJSONWrapper(), "bar", @@ -130,7 +130,7 @@ func TestReadAndUnmarshalNonStructBodyUnmarshalError(t *testing.T) { baseURL := "http://" + addr client := zanzibar.NewHTTPClientContext( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.ContextMetrics, jsonwrapper.NewDefaultJSONWrapper(), "bar", @@ -200,7 +200,7 @@ func TestUnknownStatusCode(t *testing.T) { bgateway.HTTPBackends()["bar"].HandleFunc("GET", "/bar-path", fakeNormal) client := zanzibar.NewHTTPClientContext( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.ContextMetrics, jsonwrapper.NewDefaultJSONWrapper(), "bar", @@ -275,7 +275,7 @@ func TestNotFollowRedirect(t *testing.T) { bgateway.HTTPBackends()["bar"].HandleFunc("POST", "/bar/echo", fakeEcho) client := zanzibar.NewHTTPClientContext( - bgateway.ActualGateway.Logger, + bgateway.ActualGateway.ContextLogger, bgateway.ActualGateway.ContextMetrics, jsonwrapper.NewDefaultJSONWrapper(), "bar", diff --git a/runtime/grpc_client.go b/runtime/grpc_client.go index f228a92b8..a6e434728 100644 --- a/runtime/grpc_client.go +++ b/runtime/grpc_client.go @@ -32,7 +32,7 @@ import ( // GRPCClientOpts used to configure various client options. type GRPCClientOpts struct { - Loggers map[string]*zap.Logger + ContextLogger ContextLogger Metrics ContextMetrics ContextExtractor ContextExtractor RoutingKey string @@ -44,7 +44,7 @@ type GRPCClientOpts struct { // NewGRPCClientOpts creates a new instance of GRPCClientOpts. func NewGRPCClientOpts( - logger *zap.Logger, + contextLogger ContextLogger, metrics ContextMetrics, contextExtractor ContextExtractor, methodNames map[string]string, @@ -52,16 +52,7 @@ func NewGRPCClientOpts( circuitBreakerDisabled bool, timeoutInMS int, ) *GRPCClientOpts { - numMethods := len(methodNames) - loggers := make(map[string]*zap.Logger, numMethods) scopeTags := make(map[string]map[string]string) - for serviceMethod, methodName := range methodNames { - loggers[serviceMethod] = logger.With( - zap.String(logFieldClientID, clientID), - zap.String(logFieldClientMethod, methodName), - zap.String(logFieldClientThriftMethod, serviceMethod), - ) - } for serviceMethod, methodName := range methodNames { scopeTags[serviceMethod] = map[string]string{ scopeTagClient: clientID, @@ -70,7 +61,7 @@ func NewGRPCClientOpts( } } return &GRPCClientOpts{ - Loggers: loggers, + ContextLogger: contextLogger, Metrics: metrics, ContextExtractor: contextExtractor, RoutingKey: routingKey, @@ -90,11 +81,11 @@ type GRPCClientCallHelper interface { } type callHelper struct { - startTime time.Time - finishTime time.Time - logger *zap.Logger - metrics ContextMetrics - extractor ContextExtractor + startTime time.Time + finishTime time.Time + contextLogger ContextLogger + metrics ContextMetrics + extractor ContextExtractor } // NewGRPCClientCallHelper used to initialize a helper that will @@ -102,9 +93,9 @@ type callHelper struct { func NewGRPCClientCallHelper(ctx context.Context, serviceMethod string, opts *GRPCClientOpts) (context.Context, GRPCClientCallHelper) { ctx = WithScopeTags(ctx, opts.ScopeTags[serviceMethod]) return ctx, &callHelper{ - logger: opts.Loggers[serviceMethod], - metrics: opts.Metrics, - extractor: opts.ContextExtractor, + contextLogger: opts.ContextLogger, + metrics: opts.Metrics, + extractor: opts.ContextExtractor, } } @@ -145,10 +136,10 @@ func (c *callHelper) Finish(ctx context.Context, err error) context.Context { fields = append(fields, zap.Error(err)) } c.metrics.IncCounter(ctx, "client.errors", 1) - c.logger.Warn("Failed to send outgoing client gRPC request", fields...) + c.contextLogger.Warn(ctx, "Failed to send outgoing client gRPC request", fields...) return ctx } - c.logger.Debug("Finished an outgoing client gRPC request", fields...) + c.contextLogger.Debug(ctx, "Finished an outgoing client gRPC request", fields...) c.metrics.IncCounter(ctx, "client.success", 1) return ctx } diff --git a/runtime/grpc_client_test.go b/runtime/grpc_client_test.go index 934cc1d4c..3d3a75341 100644 --- a/runtime/grpc_client_test.go +++ b/runtime/grpc_client_test.go @@ -60,19 +60,16 @@ var ( } return fields } - logger = zap.NewNop() - metrics = NewContextMetrics(tally.NoopScope) - extractors = &ContextExtractors{ + contextLoggerImpl = NewContextLogger(zap.NewNop()) + metrics = NewContextMetrics(tally.NoopScope) + extractors = &ContextExtractors{ ScopeTagsExtractors: []ContextScopeTagsExtractor{scopeExtractor}, LogFieldsExtractors: []ContextLogFieldsExtractor{logFieldsExtractors}, } methodNames = map[string]string{ serviceMethod: methodName, } - expectedTimeout = time.Duration(timeoutInMS) * time.Millisecond - expectedLoggers = map[string]*zap.Logger{ - serviceMethod: logger, - } + expectedTimeout = time.Duration(timeoutInMS) * time.Millisecond expectedScopeTags = map[string]map[string]string{ serviceMethod: { scopeTagClient: clientID, @@ -84,7 +81,7 @@ var ( func TestNewGRPCClientOpts(t *testing.T) { actual := NewGRPCClientOpts( - logger, + contextLoggerImpl, metrics, extractors, methodNames, @@ -95,7 +92,7 @@ func TestNewGRPCClientOpts(t *testing.T) { timeoutInMS, ) expected := &GRPCClientOpts{ - expectedLoggers, + contextLoggerImpl, metrics, extractors, routingKey, @@ -110,7 +107,7 @@ func TestNewGRPCClientOpts(t *testing.T) { func TestGRPCCallHelper(t *testing.T) { ctx := context.Background() opts := NewGRPCClientOpts( - logger, + contextLoggerImpl, metrics, extractors, methodNames, @@ -122,18 +119,18 @@ func TestGRPCCallHelper(t *testing.T) { ) _, actual := NewGRPCClientCallHelper(ctx, serviceMethod, opts) expected := &callHelper{ - logger: expectedLoggers[serviceMethod], - metrics: metrics, - extractor: extractors, + contextLogger: contextLoggerImpl, + metrics: metrics, + extractor: extractors, } assert.Equal(t, expected, actual) } func testCallHelper(t *testing.T, err error) { helper := &callHelper{ - logger: logger, - metrics: metrics, - extractor: extractors, + contextLogger: contextLoggerImpl, + metrics: metrics, + extractor: extractors, } assert.Zero(t, helper.startTime, "startTime not initialized to zero") diff --git a/runtime/http_client.go b/runtime/http_client.go index 85d8fb8ec..70a60b073 100644 --- a/runtime/http_client.go +++ b/runtime/http_client.go @@ -27,8 +27,6 @@ import ( "github.com/uber-go/tally" "github.com/uber/zanzibar/runtime/jsonwrapper" - - "go.uber.org/zap" ) // HTTPClient defines a http client. @@ -37,7 +35,7 @@ type HTTPClient struct { BaseURL string DefaultHeaders map[string]string JSONWrapper jsonwrapper.JSONWrapper - loggers map[string]*zap.Logger + ContextLogger ContextLogger contextMetrics ContextMetrics } @@ -54,7 +52,7 @@ func (rawErr *UnexpectedHTTPError) Error() string { // NewHTTPClient is deprecated, use NewHTTPClientContext instead func NewHTTPClient( - logger *zap.Logger, + contextLogger ContextLogger, scope tally.Scope, jsonWrapper jsonwrapper.JSONWrapper, clientID string, @@ -64,7 +62,7 @@ func NewHTTPClient( timeout time.Duration, ) *HTTPClient { return NewHTTPClientContext( - logger, + contextLogger, NewContextMetrics(scope), jsonWrapper, clientID, @@ -78,7 +76,7 @@ func NewHTTPClient( // NewHTTPClientContext will allocate a http client. func NewHTTPClientContext( - logger *zap.Logger, + contextLogger ContextLogger, ContextMetrics ContextMetrics, jsonWrapper jsonwrapper.JSONWrapper, clientID string, @@ -88,15 +86,6 @@ func NewHTTPClientContext( timeout time.Duration, followRedirect bool, ) *HTTPClient { - loggers := make(map[string]*zap.Logger, len(methodToTargetEndpoint)) - - for methodName, targetEndpointName := range methodToTargetEndpoint { - loggers[methodName] = logger.With( - zap.String(logFieldClientID, clientID), - zap.String(logFieldClientMethod, methodName), - zap.String(logFieldClientThriftMethod, targetEndpointName), - ) - } var checkRedirect func(req *http.Request, via []*http.Request) error if !followRedirect { @@ -117,7 +106,7 @@ func NewHTTPClientContext( }, BaseURL: baseURL, DefaultHeaders: defaultHeaders, - loggers: loggers, + ContextLogger: contextLogger, contextMetrics: ContextMetrics, JSONWrapper: jsonWrapper, } diff --git a/runtime/router.go b/runtime/router.go index e959007cf..f79bea336 100644 --- a/runtime/router.go +++ b/runtime/router.go @@ -86,7 +86,7 @@ type RouterEndpoint struct { JSONWrapper jsonwrapper.JSONWrapper contextExtractor ContextExtractor - logger *zap.Logger + contextLogger ContextLogger scope tally.Scope tracer opentracing.Tracer } @@ -104,7 +104,7 @@ func NewRouterEndpoint( HandlerName: handlerID, HandlerFn: handler, contextExtractor: extractor, - logger: deps.Logger, + contextLogger: deps.ContextLogger, scope: deps.Scope, tracer: deps.Tracer, JSONWrapper: deps.JSONWrapper, diff --git a/runtime/router_test.go b/runtime/router_test.go index 210daf31e..c5ae14f75 100644 --- a/runtime/router_test.go +++ b/runtime/router_test.go @@ -45,6 +45,7 @@ func (s *routerSuite) SetupTest() { logger, _ := zap.NewDevelopment() s.gw = new(Gateway) s.gw.Logger = logger + s.gw.ContextLogger = NewContextLogger(zap.NewNop()) s.scope = tally.NewTestScope("", nil) s.gw.RootScope = s.scope s.gw.Config = NewStaticConfigOrDie( diff --git a/runtime/server_http_request.go b/runtime/server_http_request.go index 2bd02cd0a..d3977e5aa 100644 --- a/runtime/server_http_request.go +++ b/runtime/server_http_request.go @@ -58,7 +58,7 @@ type ServerHTTPRequest struct { Header Header // logger logs entries with default fields that contains request meta info - logger Logger + contextLogger ContextLogger // scope emit metrics with default tags that contains request meta info scope tally.Scope jsonWrapper jsonwrapper.JSONWrapper @@ -105,21 +105,21 @@ func NewServerHTTPRequest( httpRequest := r.WithContext(ctx) scope := endpoint.scope.Tagged(scopeTags) - logger := endpoint.logger.With(logFields...) + logger := endpoint.contextLogger req := &ServerHTTPRequest{ - httpRequest: httpRequest, - queryValues: nil, - tracer: endpoint.tracer, - EndpointName: endpoint.EndpointName, - HandlerName: endpoint.HandlerName, - URL: httpRequest.URL, - Method: httpRequest.Method, - Params: params, - Header: NewServerHTTPHeader(r.Header), - logger: logger, - scope: scope, - jsonWrapper: endpoint.JSONWrapper, + httpRequest: httpRequest, + queryValues: nil, + tracer: endpoint.tracer, + EndpointName: endpoint.EndpointName, + HandlerName: endpoint.HandlerName, + URL: httpRequest.URL, + Method: httpRequest.Method, + Params: params, + Header: NewServerHTTPHeader(r.Header), + contextLogger: logger, + scope: scope, + jsonWrapper: endpoint.JSONWrapper, } req.res = NewServerHTTPResponse(w, req) @@ -141,7 +141,7 @@ func (req *ServerHTTPRequest) StartTime() time.Time { func (req *ServerHTTPRequest) start() { if req.started { /* coverage ignore next line */ - req.logger.Error( + req.contextLogger.Error(req.Context(), "Cannot start ServerHTTPRequest twice", zap.String("path", req.URL.Path), ) @@ -164,7 +164,7 @@ func (req *ServerHTTPRequest) start() { if err != nil { if err != opentracing.ErrSpanContextNotFound { /* coverage ignore next line */ - req.logger.Warn("Error Extracting Trace Headers", zap.Error(err)) + req.contextLogger.Warn(req.Context(), "Error Extracting Trace Headers", zap.Error(err)) } span = req.tracer.StartSpan(opName, urlTag, MethodTag) } else { @@ -179,7 +179,7 @@ func (req *ServerHTTPRequest) CheckHeaders(headers []string) bool { for _, headerName := range headers { _, ok := req.Header.Get(headerName) if !ok { - req.logger.Warn("Got request without mandatory header", + req.contextLogger.Warn(req.Context(), "Got request without mandatory header", zap.String("headerName", headerName), ) @@ -225,7 +225,7 @@ func (req *ServerHTTPRequest) parseQueryValues() bool { values, err := url.ParseQuery(req.httpRequest.URL.RawQuery) if err != nil { - req.logger.Warn("Got request with invalid query string", zap.Error(err)) + req.contextLogger.Warn(req.Context(), "Got request with invalid query string", zap.Error(err)) if !req.parseFailed { req.res.SendErrorString( @@ -700,7 +700,7 @@ func (req *ServerHTTPRequest) CheckQueryValue(key string) bool { values := req.queryValues[key] if len(values) == 0 { - req.logger.Warn("Got request with missing query string value", + req.contextLogger.Warn(req.Context(), "Got request with missing query string value", zap.String("expectedKey", key), ) if !req.parseFailed { @@ -753,7 +753,7 @@ func (req *ServerHTTPRequest) ReadAll() ([]byte, bool) { } rawBody, err := ioutil.ReadAll(req.httpRequest.Body) if err != nil { - req.logger.Error("Could not read request body", zap.Error(err)) + req.contextLogger.Error(req.Context(), "Could not read request body", zap.Error(err)) if !req.parseFailed { req.res.SendError(500, "Could not read request body", err) req.parseFailed = true @@ -770,7 +770,7 @@ func (req *ServerHTTPRequest) UnmarshalBody( ) bool { err := req.jsonWrapper.Unmarshal(rawBody, body) if err != nil { - req.logger.Warn("Could not parse json", zap.Error(err)) + req.contextLogger.Warn(req.Context(), "Could not parse json", zap.Error(err)) if !req.parseFailed { req.res.SendError(400, "Could not parse json: "+err.Error(), err) req.parseFailed = true @@ -799,7 +799,7 @@ func (req *ServerHTTPRequest) GetSpan() opentracing.Span { // LogAndSendQueryError handles parse failure of query params by logging the issue and returning a 400 to the requestor func (req *ServerHTTPRequest) LogAndSendQueryError(err error, expected, key, value string) { - req.logger.Warn("Got request with invalid query string types", + req.contextLogger.Warn(req.Context(), "Got request with invalid query string types", zap.String("expected", expected), zap.String("actual", value), zap.String("key", key), diff --git a/runtime/server_http_response.go b/runtime/server_http_response.go index a55e5ef2e..bdf42e04e 100644 --- a/runtime/server_http_response.go +++ b/runtime/server_http_response.go @@ -47,10 +47,10 @@ type ServerHTTPResponse struct { pendingBodyBytes []byte pendingBodyObj interface{} pendingStatusCode int - logger Logger + contextLogger ContextLogger scope tally.Scope jsonWrapper jsonwrapper.JSONWrapper - err error + Err error } // NewServerHTTPResponse is helper function to alloc ServerHTTPResponse @@ -62,7 +62,7 @@ func NewServerHTTPResponse( Request: req, StatusCode: 200, responseWriter: w, - logger: req.logger, + contextLogger: req.contextLogger, scope: req.scope, jsonWrapper: req.jsonWrapper, } @@ -73,7 +73,7 @@ func (res *ServerHTTPResponse) finish(ctx context.Context) { logFields := GetLogFieldsFromCtx(ctx) if !res.Request.started { /* coverage ignore next line */ - res.logger.Error( + res.contextLogger.Error(ctx, "Forgot to start server response", append(logFields, zap.String("path", res.Request.URL.Path))..., ) @@ -82,7 +82,7 @@ func (res *ServerHTTPResponse) finish(ctx context.Context) { } if res.finished { /* coverage ignore next line */ - res.logger.Error( + res.contextLogger.Error(ctx, "Finished a server response multiple times", append(logFields, zap.String("path", res.Request.URL.Path))..., ) @@ -100,7 +100,7 @@ func (res *ServerHTTPResponse) finish(ctx context.Context) { tagged.Timer(endpointLatency).Record(delta) tagged.Histogram(endpointLatencyHist, tally.DefaultBuckets).RecordDuration(delta) if !known { - res.logger.Error( + res.contextLogger.Error(ctx, "Unknown status code", append(logFields, zap.Int("UnknownStatusCode", res.StatusCode))..., ) @@ -108,10 +108,10 @@ func (res *ServerHTTPResponse) finish(ctx context.Context) { tagged.Counter(endpointStatus).Inc(1) } - logFn := res.logger.Debug + logFn := res.contextLogger.Debug if !known || res.StatusCode >= 400 && res.StatusCode < 600 { tagged.Counter(endpointAppErrors).Inc(1) - logFn = res.logger.Warn + logFn = res.contextLogger.Warn } span := res.Request.GetSpan() @@ -119,7 +119,7 @@ func (res *ServerHTTPResponse) finish(ctx context.Context) { span.Finish() } - logFn( + logFn(ctx, fmt.Sprintf("Finished an incoming server HTTP request with %d status code", res.StatusCode), append(logFields, serverHTTPLogFields(res.Request, res)...)..., ) @@ -145,11 +145,11 @@ func serverHTTPLogFields(req *ServerHTTPRequest, res *ServerHTTPResponse) []zapc } } - if res.err != nil { - fields = append(fields, zap.Error(res.err)) + if res.Err != nil { + fields = append(fields, zap.Error(res.Err)) - cause := errors.Cause(res.err) - if cause != nil && cause != res.err { + cause := errors.Cause(res.Err) + if cause != nil && cause != res.Err { fields = append(fields, zap.NamedError("errorCause", cause)) } } @@ -170,7 +170,7 @@ func (res *ServerHTTPResponse) SendErrorString( func (res *ServerHTTPResponse) SendError( statusCode int, errMsg string, errCause error, ) { - res.err = errCause + res.Err = errCause res.WriteJSONBytes(statusCode, nil, []byte(`{"error":"`+errMsg+`"}`), ) @@ -207,15 +207,16 @@ func (res *ServerHTTPResponse) WriteJSONBytes( // MarshalResponseJSON serializes a json serializable into bytes func (res *ServerHTTPResponse) MarshalResponseJSON(body interface{}) []byte { + ctx := res.Request.Context() if body == nil { res.SendError(500, "Could not serialize json response", errors.New("No Body JSON")) - res.logger.Error("Could not serialize nil pointer body") + res.contextLogger.Error(ctx, "Could not serialize nil pointer body") return nil } bytes, err := res.jsonWrapper.Marshal(body) if err != nil { res.SendError(500, "Could not serialize json response", err) - res.logger.Error("Could not serialize json response", zap.Error(err)) + res.contextLogger.Error(ctx, "Could not serialize json response", zap.Error(err)) return nil } return bytes @@ -280,7 +281,7 @@ func (res *ServerHTTPResponse) PeekBody( func (res *ServerHTTPResponse) flush(ctx context.Context) { if res.flushed { /* coverage ignore next line */ - res.logger.Error( + res.contextLogger.Error(ctx, "Flushed a server response multiple times", zap.String("path", res.Request.URL.Path), ) @@ -304,7 +305,7 @@ func (res *ServerHTTPResponse) writeBytes(bytes []byte) { _, err := res.responseWriter.Write(bytes) if err != nil { /* coverage ignore next line */ - res.logger.Error( + res.contextLogger.Error(res.Request.Context(), "Could not write string to resp body", zap.Error(err), ) diff --git a/runtime/tchannel_client.go b/runtime/tchannel_client.go index eef0e75ae..1fb54cec2 100644 --- a/runtime/tchannel_client.go +++ b/runtime/tchannel_client.go @@ -28,7 +28,6 @@ import ( "github.com/pkg/errors" "github.com/uber-go/tally" "github.com/uber/tchannel-go" - "go.uber.org/zap" netContext "golang.org/x/net/context" "github.com/uber/zanzibar/runtime/ruleengine" @@ -77,8 +76,8 @@ type TChannelClientOption struct { // TChannelClient implements TChannelCaller and makes outgoing Thrift calls. type TChannelClient struct { - ClientID string - Loggers map[string]*zap.Logger + ClientID string + ContextLogger ContextLogger ch *tchannel.Channel sc *tchannel.SubChannel @@ -101,14 +100,14 @@ type TChannelClient struct { // NewTChannelClient is deprecated, use NewTChannelClientContext instead func NewTChannelClient( ch *tchannel.Channel, - logger *zap.Logger, + contextLogger ContextLogger, scope tally.Scope, contextExtractor ContextExtractor, opt *TChannelClientOption, ) *TChannelClient { return NewTChannelClientContext( ch, - logger, + contextLogger, NewContextMetrics(scope), contextExtractor, opt, @@ -118,22 +117,11 @@ func NewTChannelClient( // NewTChannelClientContext returns a TChannelClient that makes calls over the given tchannel to the given thrift service. func NewTChannelClientContext( ch *tchannel.Channel, - logger *zap.Logger, + contextLogger ContextLogger, metrics ContextMetrics, contextExtractor ContextExtractor, opt *TChannelClientOption, ) *TChannelClient { - numMethods := len(opt.MethodNames) - loggers := make(map[string]*zap.Logger, numMethods) - - for serviceMethod, methodName := range opt.MethodNames { - loggers[serviceMethod] = logger.With( - zap.String(logFieldClientID, opt.ClientID), - zap.String(logFieldClientService, opt.ServiceName), - zap.String(logFieldClientMethod, methodName), - zap.String(logFieldClientThriftMethod, serviceMethod), - ) - } client := &TChannelClient{ ch: ch, @@ -144,7 +132,7 @@ func NewTChannelClientContext( timeout: opt.Timeout, timeoutPerAttempt: opt.TimeoutPerAttempt, routingKey: opt.RoutingKey, - Loggers: loggers, + ContextLogger: contextLogger, metrics: metrics, contextExtractor: contextExtractor, requestUUIDHeaderKey: opt.RequestUUIDHeaderKey, @@ -175,7 +163,7 @@ func (c *TChannelClient) Call( methodName: c.methodNames[serviceMethod], serviceMethod: serviceMethod, reqHeaders: reqHeaders, - logger: c.Loggers[serviceMethod], + contextLogger: c.ContextLogger, metrics: c.metrics, } diff --git a/runtime/tchannel_client_raw.go b/runtime/tchannel_client_raw.go index 5a1acdd33..39564cb12 100644 --- a/runtime/tchannel_client_raw.go +++ b/runtime/tchannel_client_raw.go @@ -25,7 +25,6 @@ import ( "github.com/uber-go/tally" "github.com/uber/tchannel-go" - "go.uber.org/zap" ) const rawClient = "raw" @@ -39,9 +38,9 @@ const rawClient = "raw" // method information (because there isn't a method anyway), but the Thrift service // and method information is still there. type RawTChannelClient struct { - tc *TChannelClient - logger *zap.Logger - metrics ContextMetrics + tc *TChannelClient + contextLogger ContextLogger + metrics ContextMetrics } // NewRawTChannelClient returns a RawTChannelClient that makes calls over the given @@ -50,25 +49,16 @@ type RawTChannelClient struct { // It is intended to be used internally for testing. func NewRawTChannelClient( ch *tchannel.Channel, - logger *zap.Logger, + contextLogger ContextLogger, scope tally.Scope, opt *TChannelClientOption, ) *RawTChannelClient { - clientID := rawClient - if opt.ClientID != "" { - clientID = opt.ClientID - } - - l := logger.With( - zap.String("clientID", clientID), - zap.String("serviceName", opt.ServiceName), - ) metrics := NewContextMetrics(scope) return &RawTChannelClient{ - tc: NewTChannelClientContext(ch, logger, metrics, nil, opt), - logger: l, - metrics: metrics, + tc: NewTChannelClientContext(ch, contextLogger, metrics, nil, opt), + contextLogger: contextLogger, + metrics: metrics, } } @@ -86,13 +76,13 @@ func (r *RawTChannelClient) Call( methodName: serviceMethod, serviceMethod: serviceMethod, reqHeaders: reqHeaders, - logger: r.logger, + contextLogger: r.tc.ContextLogger, metrics: r.metrics, } if m, ok := r.tc.methodNames[serviceMethod]; ok { call.methodName = m - call.logger = r.tc.Loggers[serviceMethod] + call.contextLogger = r.tc.ContextLogger call.metrics = r.metrics } diff --git a/runtime/tchannel_inbound_call.go b/runtime/tchannel_inbound_call.go index 48d0454f6..f5b5ca30c 100644 --- a/runtime/tchannel_inbound_call.go +++ b/runtime/tchannel_inbound_call.go @@ -45,7 +45,7 @@ type tchannelInboundCall struct { resHeaders map[string]string // Logger logs entries with default fields that contains request meta info - logger Logger + contextLogger ContextLogger // Scope emit metrics with default tags that contains request meta info scope tally.Scope } @@ -73,10 +73,10 @@ func (c *tchannelInboundCall) finish(ctx context.Context, err error) { fields := c.logFields(ctx) if err == nil { - c.logger.Debug("Finished an incoming server TChannel request", fields...) + c.contextLogger.Debug(ctx, "Finished an incoming server TChannel request", fields...) } else { fields = append(fields, zap.Error(err)) - c.logger.Warn("Failed to serve incoming TChannel request", fields...) + c.contextLogger.Warn(ctx, "Failed to serve incoming TChannel request", fields...) } } @@ -159,7 +159,7 @@ func (c *tchannelInboundCall) readReqBody(ctx context.Context) (wireValue wire.V } wireValue, err = protocol.Binary.Decode(bytes.NewReader(buf.Bytes()), wire.TStruct) if err != nil { - c.logger.Warn("Could not decode arg3 for inbound request", zap.Error(err)) + c.contextLogger.Warn(ctx, "Could not decode arg3 for inbound request", zap.Error(err)) err = errors.Wrapf(err, "Could not decode arg3 for inbound %s.%s (%s) request", c.endpoint.EndpointID, c.endpoint.HandlerID, c.endpoint.Method, ) @@ -195,15 +195,15 @@ func (c *tchannelInboundCall) handle(ctx context.Context, wireValue *wire.Value) defer c.endpoint.callback(ctx, c.endpoint.Method, resp) } if err != nil { - c.logger.Warn("Unexpected tchannel system error", zap.Error(err)) + c.contextLogger.Warn(ctx, "Unexpected tchannel system error", zap.Error(err)) if er := c.call.Response().SendSystemError(errors.New("Server Error")); er != nil { - c.logger.Warn("Error sending server error response", zap.Error(er)) + c.contextLogger.Warn(ctx, "Error sending server error response", zap.Error(er)) } return } if !c.success { if err = c.call.Response().SetApplicationError(); err != nil { - c.logger.Warn("Could not set application error for inbound response", zap.Error(err)) + c.contextLogger.Warn(ctx, "Could not set application error for inbound response", zap.Error(err)) return } } @@ -247,7 +247,7 @@ func (c *tchannelInboundCall) writeResBody(ctx context.Context, resp RWTStruct) structWireValue, err := resp.ToWire() if err != nil { if er := c.call.Response().SendSystemError(errors.New("Server Error")); er != nil { - c.logger.Warn("Error sending server error response", zap.Error(er)) + c.contextLogger.Warn(ctx, "Error sending server error response", zap.Error(er)) } return errors.Wrapf(err, "Could not serialize arg3 for inbound %s.%s (%s) response", c.endpoint.EndpointID, c.endpoint.HandlerID, c.endpoint.Method, diff --git a/runtime/tchannel_outbound_call.go b/runtime/tchannel_outbound_call.go index 8498aafcc..c78e1714a 100644 --- a/runtime/tchannel_outbound_call.go +++ b/runtime/tchannel_outbound_call.go @@ -42,7 +42,7 @@ type tchannelOutboundCall struct { finishTime time.Time reqHeaders map[string]string resHeaders map[string]string - logger *zap.Logger + contextLogger ContextLogger metrics ContextMetrics } @@ -71,10 +71,10 @@ func (c *tchannelOutboundCall) finish(ctx context.Context, err error) { // write logs fields := c.logFields(ctx) if err == nil { - c.logger.Debug("Finished an outgoing client TChannel request", fields...) + c.contextLogger.Debug(ctx, "Finished an outgoing client TChannel request", fields...) } else { fields = append(fields, zap.Error(err)) - c.logger.Warn("Failed to send outgoing client TChannel request", fields...) + c.contextLogger.Warn(ctx, "Failed to send outgoing client TChannel request", fields...) } } diff --git a/runtime/tchannel_server.go b/runtime/tchannel_server.go index 062266682..2f34780bf 100644 --- a/runtime/tchannel_server.go +++ b/runtime/tchannel_server.go @@ -54,11 +54,11 @@ type TChannelEndpoint struct { // TChannelRouter handles incoming TChannel calls and routes them to the matching TChannelHandler. type TChannelRouter struct { sync.RWMutex - registrar tchannel.Registrar - endpoints map[string]*TChannelEndpoint - logger *zap.Logger - scope tally.Scope - extractor ContextExtractor + registrar tchannel.Registrar + endpoints map[string]*TChannelEndpoint + contextLogger ContextLogger + scope tally.Scope + extractor ContextExtractor requestUUIDHeaderKey string } @@ -103,11 +103,11 @@ func NewTChannelEndpointWithPostResponseCB( // NewTChannelRouter returns a TChannel router that can serve thrift services over TChannel. func NewTChannelRouter(registrar tchannel.Registrar, g *Gateway) *TChannelRouter { return &TChannelRouter{ - registrar: registrar, - endpoints: map[string]*TChannelEndpoint{}, - logger: g.Logger, - scope: g.RootScope, - extractor: g.ContextExtractor, + registrar: registrar, + endpoints: map[string]*TChannelEndpoint{}, + contextLogger: g.ContextLogger, + scope: g.RootScope, + extractor: g.ContextExtractor, requestUUIDHeaderKey: g.requestUUIDHeaderKey, } @@ -134,7 +134,7 @@ func (s *TChannelRouter) Register(e *TChannelEndpoint) error { func (s *TChannelRouter) Handle(ctx context.Context, call *tchannel.InboundCall) { method := call.MethodString() if sep := strings.Index(method, "::"); sep == -1 { - s.logger.Error("Handle got call for which does not match the expected call format", zap.String(logFieldRequestMethod, method)) + s.contextLogger.Error(ctx, "Handle got call for which does not match the expected call format", zap.String(logFieldRequestMethod, method)) return } @@ -142,7 +142,7 @@ func (s *TChannelRouter) Handle(ctx context.Context, call *tchannel.InboundCall) e, ok := s.endpoints[method] s.RUnlock() if !ok { - s.logger.Error("Handle got call for method which is not registered", + s.contextLogger.Error(ctx, "Handle got call for method which is not registered", zap.String(logFieldRequestMethod, method), ) return @@ -167,10 +167,10 @@ func (s *TChannelRouter) Handle(ctx context.Context, call *tchannel.InboundCall) var err error c := &tchannelInboundCall{ - call: call, - endpoint: e, - logger: s.logger, - scope: s.scope.Tagged(scopeTags), + call: call, + endpoint: e, + contextLogger: s.contextLogger, + scope: s.scope.Tagged(scopeTags), } c.start() diff --git a/test/clients/echo/echo_test.go b/test/clients/echo/echo_test.go index 8921a8cdf..75370efca 100644 --- a/test/clients/echo/echo_test.go +++ b/test/clients/echo/echo_test.go @@ -83,6 +83,7 @@ func TestEcho(t *testing.T) { GRPCClientDispatcher: dispatcher, Config: sc, Logger: zap.NewNop(), + ContextLogger: zanzibar.NewContextLogger(zap.NewNop()), ContextMetrics: zanzibar.NewContextMetrics(tally.NewTestScope("", nil)), }, }) diff --git a/test/endpoints/bar/bar_metrics_test.go b/test/endpoints/bar/bar_metrics_test.go index f5a7d278d..fd96e7d77 100644 --- a/test/endpoints/bar/bar_metrics_test.go +++ b/test/endpoints/bar/bar_metrics_test.go @@ -210,13 +210,13 @@ func TestCallMetrics(t *testing.T) { delete(logMsg, dynamicValue) } expectedValues := map[string]interface{}{ - "env": "test", - "level": "debug", - "msg": "Finished an outgoing client HTTP request", - "statusCode": float64(200), - "clientID": "bar", - "clientMethod": "Normal", - "clientThriftMethod": "Bar::normal", + "env": "test", + "level": "debug", + "msg": "Finished an outgoing client HTTP request", + "statusCode": float64(200), + //"clientID": "bar", + //"clientMethod": "Normal", + //"clientThriftMethod": "Bar::normal", "clientHTTPMethod": "POST", "Client-Req-Header-X-Client-Id": "bar", "Client-Req-Header-Content-Type": "application/json", diff --git a/test/endpoints/tchannel/baz/baz_simpleservice_method_call_test.go b/test/endpoints/tchannel/baz/baz_simpleservice_method_call_test.go index df7ea2450..cbf54e7cb 100644 --- a/test/endpoints/tchannel/baz/baz_simpleservice_method_call_test.go +++ b/test/endpoints/tchannel/baz/baz_simpleservice_method_call_test.go @@ -184,10 +184,10 @@ func TestCallTChannelSuccessfulRequestOKResponse(t *testing.T) { "Regionname": "sf", // client specific logs - "clientID": "baz", - "clientService": "bazService", - "clientThriftMethod": "SimpleService::call", - "clientMethod": "Call", + //"clientID": "baz", + //"clientService": "bazService", + //"clientThriftMethod": "SimpleService::call", + //"clientMethod": "Call", "Client-Req-Header-Device": "ios", "Client-Req-Header-x-uuid": "uuid", "Client-Req-Header-Regionname": "sf", diff --git a/test/lib/bench_gateway/bench_gateway.go b/test/lib/bench_gateway/bench_gateway.go index 1616581e2..12581287a 100644 --- a/test/lib/bench_gateway/bench_gateway.go +++ b/test/lib/bench_gateway/bench_gateway.go @@ -164,7 +164,7 @@ func CreateGateway( benchGateway.tchannelClient = zanzibar.NewTChannelClient( gateway.Channel, - gateway.Logger, + gateway.ContextLogger, gateway.RootScope, gateway.ContextExtractor, &zanzibar.TChannelClientOption{ diff --git a/test/lib/test_backend/test_tchannel_backend.go b/test/lib/test_backend/test_tchannel_backend.go index f9f499362..bd249dd0e 100644 --- a/test/lib/test_backend/test_tchannel_backend.go +++ b/test/lib/test_backend/test_tchannel_backend.go @@ -161,6 +161,8 @@ func CreateTChannelBackend(port int32, serviceName string) (*TestTChannelBackend zap.String("test-backend", serviceName), ) + contextLogger := zanzibar.NewContextLogger(testLogger) + tchannelOpts := &tchannel.ChannelOptions{ Logger: zanzibar.NewTChannelLogger(testLogger), } @@ -188,6 +190,7 @@ func CreateTChannelBackend(port int32, serviceName string) (*TestTChannelBackend RootScope: tally.NoopScope, ContextExtractor: contextExtractors, ContextMetrics: zanzibar.NewContextMetrics(tally.NoopScope), + ContextLogger: contextLogger, } backend.Channel = channel diff --git a/test/lib/test_gateway/test_gateway.go b/test/lib/test_gateway/test_gateway.go index bcad34964..22264c87b 100644 --- a/test/lib/test_gateway/test_gateway.go +++ b/test/lib/test_gateway/test_gateway.go @@ -111,6 +111,7 @@ type ChildProcessGateway struct { RealTChannelPort int ContextExtractor zanzibar.ContextExtractor ContextMetrics zanzibar.ContextMetrics + ContextLogger zanzibar.ContextLogger staticConfig *zanzibar.StaticConfig } @@ -236,7 +237,7 @@ func CreateGateway( tchannelClient := zanzibar.NewTChannelClientContext( channel, - zap.NewNop(), + zanzibar.NewContextLogger(zap.NewNop()), zanzibar.NewContextMetrics(tally.NoopScope), extractors, &zanzibar.TChannelClientOption{