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

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

Open
wants to merge 1 commit into
base: emit-metrics-for-new-behavior-step-1
Choose a base branch
from

Conversation

biosvs
Copy link
Collaborator

@biosvs biosvs commented May 8, 2024

Part of #2265

Copy link

codecov bot commented May 8, 2024

Codecov Report

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

Project coverage is 85.29%. Comparing base (f7b3c8e) to head (0c05bc3).

Files Patch % Lines
transport/http/handler.go 84.61% 1 Missing and 1 partial ⚠️
transport/http/outbound.go 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                           Coverage Diff                            @@
##           emit-metrics-for-new-behavior-step-1    #2275      +/-   ##
========================================================================
- Coverage                                 85.33%   85.29%   -0.05%     
========================================================================
  Files                                       271      271              
  Lines                                     15624    15648      +24     
========================================================================
+ Hits                                      13333    13347      +14     
- Misses                                     1872     1877       +5     
- Partials                                    419      424       +5     

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

)

// headerConverter converts HTTP headers to and from transport headers.
type headerMapper struct{ Prefix string }

var (
applicationHeaders = headerMapper{ApplicationHeaderPrefix}

// enforceHeaderRules is a feature flag for a more strict error handling rules.
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you be more specific here? from the impl, it looks it means we will not attach headers if this value is set to true && isReservedHeaderPrefix returns true? If that is the case, please call it out in the comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated this comment

@@ -95,7 +95,7 @@ func TestCreateRequest(t *testing.T) {

for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
o := &Outbound{urlTemplate: defaultURLTemplate}
o := &Outbound{urlTemplate: defaultURLTemplate, transport: &Transport{}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why this change?

Copy link
Collaborator Author

@biosvs biosvs May 10, 2024

Choose a reason for hiding this comment

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

I added new field reservedHeaderMetric to transport and use it, so this test fails if transport is nil.

@@ -330,3 +340,9 @@ func getContentType(encoding transport.Encoding) string {
return ""
}
}

func popHeader(h http.Header, n string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

move it back to the original place

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved back

@@ -267,7 +277,7 @@ func (rw *responseWriter) Write(s []byte) (int, error) {
}

func (rw *responseWriter) AddHeaders(h transport.Headers) {
applicationHeaders.ToHTTPHeaders(h, rw.w.Header())
_, rw.err = applicationHeaders.ToHTTPHeaders(h, rw.w.Header(), rw.edgeMetrics)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should you use https://pkg.go.dev/go.uber.org/multierr to combine the errors here instead of override every time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AddHeaders is called only once, so that's why we can just set err

@biosvs biosvs force-pushed the emit-metrics-for-new-behavior-step-3 branch from 4087147 to cb2af3f Compare May 10, 2024 11:52
@biosvs biosvs force-pushed the emit-metrics-for-new-behavior-step-3 branch from cb2af3f to 0c05bc3 Compare May 10, 2024 11:52
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.

2 participants