From 3bb91f0a563f9473eef2be8bb179981753bbe5ea Mon Sep 17 00:00:00 2001 From: Shivam Srivastava Date: Thu, 27 Jun 2024 12:24:23 +0530 Subject: [PATCH 1/2] fix cpature service name to accomadate alternate service detail --- runtime/tchannel_client.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/runtime/tchannel_client.go b/runtime/tchannel_client.go index 7b904c083..a9564c083 100644 --- a/runtime/tchannel_client.go +++ b/runtime/tchannel_client.go @@ -27,7 +27,6 @@ import ( "github.com/pkg/errors" "github.com/uber-go/tally" - "github.com/uber/tchannel-go" "github.com/uber/zanzibar/v2/runtime/ruleengine" netContext "golang.org/x/net/context" ) @@ -234,6 +233,7 @@ func (c *TChannelClient) call( if sk != "" { ctxBuilder.SetShardKey(sk) } + serviceName := "" ctx, cancel := ctxBuilder.Build() defer cancel() @@ -242,7 +242,8 @@ func (c *TChannelClient) call( call.resHeaders = map[string]string{} call.success = false - sc, ctx := c.getDynamicChannelWithFallback(reqHeaders, c.sc, ctx) + sc, ctx, altService := c.getDynamicChannelWithFallback(reqHeaders, c.sc, ctx, c.serviceName) + serviceName = altService call.call, cerr = sc.BeginCall(ctx, call.serviceMethod, &tchannel.CallOptions{ Format: tchannel.Thrift, ShardKey: GetShardKeyFromCtx(ctx), @@ -294,7 +295,7 @@ func (c *TChannelClient) call( if GetToCapture(ctx) { event := &ThriftOutgoingEvent{ MethodName: call.serviceMethod, - ServiceName: c.serviceName, + ServiceName: serviceName, ReqHeaders: call.reqHeaders, Req: req, RspHeaders: call.resHeaders, @@ -312,10 +313,10 @@ func (c *TChannelClient) call( // first rule match, would be the chosen channel. if nothing matches fallback to default channel func (c *TChannelClient) getDynamicChannelWithFallback(reqHeaders map[string]string, - sc *tchannel.SubChannel, ctx netContext.Context) (*tchannel.SubChannel, netContext.Context) { + sc *tchannel.SubChannel, ctx netContext.Context, serviceName string) (*tchannel.SubChannel, netContext.Context, string) { ch := sc if c.ruleEngine == nil { - return ch, ctx + return ch, ctx, serviceName } for _, headerPattern := range c.headerPatterns { // this header is not present, so can't match a rule @@ -334,8 +335,8 @@ func (c *TChannelClient) getDynamicChannelWithFallback(reqHeaders map[string]str if len(serviceDetails) > 1 { ctx = WithRoutingDelegate(ctx, serviceDetails[1]) } - return ch, ctx + return ch, ctx, serviceDetails[0] } // if nothing matches return the default channel/**/ - return ch, ctx + return ch, ctx, serviceName } From e41ce73e4e0533318d45e1f3585404b118a7e341 Mon Sep 17 00:00:00 2001 From: Shivam Srivastava Date: Thu, 27 Jun 2024 13:01:31 +0530 Subject: [PATCH 2/2] add dependency --- runtime/tchannel_client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/tchannel_client.go b/runtime/tchannel_client.go index a9564c083..ef4712f13 100644 --- a/runtime/tchannel_client.go +++ b/runtime/tchannel_client.go @@ -27,6 +27,7 @@ import ( "github.com/pkg/errors" "github.com/uber-go/tally" + "github.com/uber/tchannel-go" "github.com/uber/zanzibar/v2/runtime/ruleengine" netContext "golang.org/x/net/context" )