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

Emit metrics for new headers handling behaviour. Hide actual changes under feature flag. #2267

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

biosvs
Copy link
Collaborator

@biosvs biosvs commented Apr 22, 2024

Currently underlying implementation of headers handling wary significantly from one transport to another (docs/docs/headers-handling.md in this PR). Eventually, in one of the following releases, we want to make behaviour consistent and protective: filter inbound 'rpc-' headers, return error for attempting of 'rpc-' header setting.

Proposed changes are backward incompatible, so to identify the edges that are affected by the future changes, at first stage let's emit metrics.

Metrics: reserved_headers_stripped and reserved_headers_error metrics with "component": "yarpc-header-migration" constant tag and with source and dest variable tags

Part of #2265

Copy link

codecov bot commented Apr 22, 2024

Codecov Report

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

Project coverage is 85.17%. Comparing base (407d76c) to head (010d653).

Files Patch % Lines
transport/tchannel/response_writer.go 85.91% 5 Missing and 5 partials ⚠️
transport/http/outbound.go 42.85% 4 Missing and 4 partials ⚠️
transport/grpc/outbound.go 33.33% 3 Missing and 3 partials ⚠️
transport/http/handler.go 60.00% 3 Missing and 3 partials ⚠️
transport/tchannel/outbound.go 40.00% 4 Missing and 2 partials ⚠️
transport/grpc/handler.go 20.00% 2 Missing and 2 partials ⚠️
transport/grpc/headers.go 90.00% 2 Missing and 2 partials ⚠️
transport/tchannel/channel_outbound.go 0.00% 1 Missing and 1 partial ⚠️
transport/tchannel/handler.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2267      +/-   ##
==========================================
- Coverage   85.20%   85.17%   -0.03%     
==========================================
  Files         270      272       +2     
  Lines       15555    15687     +132     
==========================================
+ Hits        13253    13361     +108     
- Misses       1877     1890      +13     
- Partials      425      436      +11     

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

@AllenLuUber AllenLuUber self-requested a review April 23, 2024 00:20
"go.uber.org/net/metrics"
)

var (
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like the idea of using global variables here. Let's just create a simple struct type ReserveHeaderMetrics struct and plumb it into dispatcher so all 3 transports get the same copy. This also will get rid of sync.Once usage.


func incHeaderMetric(vector *metrics.CounterVector, source, dest string) {
if vector != nil {
if counter, err := vector.Get("source", source, "dest", dest); counter != nil && err == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

under what case the error is not nil, and counter could be empty?

@@ -153,10 +168,17 @@ func metadataToTransportRequest(md metadata.MD) (*transport.Request, error) {
request.Encoding = transport.Encoding(getContentSubtype(value))
}
default:
if isReserved(header) || isReservedWithDollarSign(header) {
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 add a comment on why do we need check both condition?. Same for the if enforceHeaderRules condition

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