Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Add FormatStatsPath to ochttp Transport to reduce stats path cardinality #1229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

otternq
Copy link

@otternq otternq commented Oct 1, 2020

Updates ochttp.Transport to accept an optional FormatStatsPath which is supplied to ochttp.statsTransport. FormatStatsPath can override a request URL's path parameter to reduce cardinality for stats similar to FormatSpanName.

This should be useful when a resource id is part of a request path such as /posts/1 or /posts/2. Currently each resource is treated as a unique path but it would be nice to optionally treat these requests as a single path.

Without FormatStatsPath specified

2020/10/01 09:02:59 	Row: 0: &view.Row{
    Tags:[]tag.Tag{
        tag.Tag{Key:tag.Key{name:"http_client_host"}, Value:"jsonplaceholder.typicode.com"}, 
        tag.Tag{Key:tag.Key{name:"http_client_method"}, Value:"GET"}, 
        tag.Tag{Key:tag.Key{name:"http_client_path"}, Value:"/posts/2"}, 
        tag.Tag{Key:tag.Key{name:"http_client_status"}, Value:"200"}
    }, 
    Data:(*view.CountData)(0xc00035c080)
}
2020/10/01 09:02:59 	Row: 1: &view.Row{
    Tags:[]tag.Tag{
        tag.Tag{Key:tag.Key{name:"http_client_host"}, Value:"jsonplaceholder.typicode.com"}, 
        tag.Tag{Key:tag.Key{name:"http_client_method"}, Value:"GET"}, 
        tag.Tag{Key:tag.Key{name:"http_client_path"}, Value:"/posts/1"}, 
        tag.Tag{Key:tag.Key{name:"http_client_status"}, Value:"200"}
    }, 
    Data:(*view.CountData)(0xc00035c100)
}

With FormatStatsPath specified

2020/10/01 09:06:48 	Row: 0: &view.Row{
    Tags:[]tag.Tag{
        tag.Tag{Key:tag.Key{name:"http_client_host"}, Value:"jsonplaceholder.typicode.com"}, 
        tag.Tag{Key:tag.Key{name:"http_client_method"}, Value:"GET"}, 
        tag.Tag{Key:tag.Key{name:"http_client_path"}, Value:"/posts/:id"}, 
        tag.Tag{Key:tag.Key{name:"http_client_status"}, Value:"200"}
    }, 
    Data:(*view.DistributionData)(0xc0001181b0)
}

Updates ochttp.Transport to accept an optional FormatStatsPath which is supplied
to ochttp.statsTransport. FormatStatsPath can override a request URL's path parameter
to reduce cardinality for stats similar to FormatSpanName.
@otternq otternq requested review from rakyll, rghetia and a team as code owners October 1, 2020 16:23
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@otternq
Copy link
Author

otternq commented Oct 1, 2020

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Oct 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants