Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2/3 header changes][tchannel] Emit metrics for new headers handling behaviour. Hide actual changes under feature flag. #2272

Open
wants to merge 1 commit into
base: tchannel-refactoring-2
Choose a base branch
from

Conversation

biosvs
Copy link
Collaborator

@biosvs biosvs commented May 3, 2024

Part of #2265

Copy link

codecov bot commented May 3, 2024

Codecov Report

Attention: Patch coverage is 96.72131% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 85.34%. Comparing base (08690c2) to head (38ecd35).

Files Patch % Lines
transport/tchannel/outbound.go 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                    Coverage Diff                     @@
##           tchannel-refactoring-2    #2272      +/-   ##
==========================================================
+ Coverage                   85.31%   85.34%   +0.03%     
==========================================================
  Files                         272      272              
  Lines                       15630    15669      +39     
==========================================================
+ Hits                        13334    13373      +39     
  Misses                       1874     1874              
  Partials                      422      422              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@biosvs biosvs changed the title [3/4 tchannel] Emit metrics for new headers handling behaviour. Hide actual changes under feature flag. [2/3 header changes][tchannel] Emit metrics for new headers handling behaviour. Hide actual changes under feature flag. May 7, 2024
@biosvs biosvs force-pushed the emit-metrics-for-new-behavior-step-2 branch from 1037c9f to 5f291fa Compare May 7, 2024 11:35
@biosvs biosvs changed the base branch from emit-metrics-for-new-behavior-step-1-2 to tchannel-refactoring-2 May 7, 2024 11:36
@biosvs biosvs force-pushed the emit-metrics-for-new-behavior-step-2 branch from 5f291fa to 09b3d5f Compare May 10, 2024 11:54
@@ -195,7 +195,9 @@ func (o *ChannelOutbound) Call(ctx context.Context, req *transport.Request) (*tr
}

err = getResponseError(headers)
deleteReservedHeaders(headers)
// no check: err will be returned as is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this comment intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for some reason I was asking myself "where's error handling?" every time I look at this line, so I decided to left a comment


func deleteReservedPrefixHeaders(headers transport.Headers, edgeMetrics observability.ReservedHeaderEdgeMetrics) {
for key := range headers.Items() {
if isReservedHeaderPrefix(key) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's reduce some nesting here:

if !isReservedHeaderPrefix(key) {
   continue
}
edgeMetrics.IncStripped()
if enforceHeaderRules {
	headers.Del(key)
}

another question, I don't see reuse here. Can we just combine those 2 and make a single deleteReservedHeaders func?

Copy link
Collaborator Author

@biosvs biosvs May 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isReservedHeaderKey(k) {
w.failedWith = appendError(w.failedWith, fmt.Errorf("cannot use reserved header key: %s", k))
return
}

// Header with reserved prefix is used, but it's not a reserved key (existing rule),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove existing rule? after this change is merged, we don't know what it means?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, fixed

@biosvs biosvs force-pushed the emit-metrics-for-new-behavior-step-2 branch from 09b3d5f to 38ecd35 Compare May 23, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants