Hello Folks,

There are some closed issues for exposing a request path (#491 
<https://github.com/prometheus/client_golang/issues/491> and #520 
<https://github.com/prometheus/client_golang/issues/520>). The previous 
attempts to expose the label were rejected as we were concerned that it's 
easy to create cardinality explosions.

If we can expose the path label it will be beneficial in some use cases. 
Suppose we want to track a combination of method, path, and status code. 
At  the moment, we must use a separate "http.Client" for each path with the 
curried metric vector with the path label. But by using the context, we can 
use a simpler approach. As shown in the following pull request 
<https://github.com/prometheus/client_golang/pull/1139>, we can do it 
simply. See the following example:

```
   ctx := WithRequestPath(context.Background(), "/v1/get-tickets")
   req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
   if err != nil {
       log.Printf("error: %v", err)
   }
   resp, err := client.Do(req)
```

I provide a proof of concept in the following pull request. please don't 
hesitate to take a look.

https://github.com/prometheus/client_golang/pull/1139/files

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-developers/5b03122a-6e0f-4589-866f-95054c5a29bdn%40googlegroups.com.

Reply via email to