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

add method or to the context a way to retrieve the endpoint #16

Closed
nbari opened this issue Dec 10, 2017 · 1 comment
Closed

add method or to the context a way to retrieve the endpoint #16

nbari opened this issue Dec 10, 2017 · 1 comment

Comments

@nbari
Copy link
Owner

nbari commented Dec 10, 2017

When instrumenting endpoints with a wildcard *, instead of logging all the possible requests would be better to just use the name of the "endpoint", this would avoid having to do something like this:

 endpoint := "*"
 for _, v := range []string{"/foo/", "/foo"} {
       if r.URL.Path == v {
            endpoint = "/foo"
            break
       }
 }
@nbari nbari changed the title add method or in context to get the path add method or to the context a way to retrieve the endpoint Dec 10, 2017
@nbari nbari added the fixed label Jan 2, 2018
@nbari
Copy link
Owner Author

nbari commented Jan 2, 2018

implemented in version 5.0.0

The idea is to create / add names to routes like this:

 router.HandleFunc("/path", handler).Name("route-name")

To retrieve the name of the route in the requests:

 endpoint := violetear.GetRouteName(r)
 c.WithLabelValues(endpoint).Observe(time.Since(start).Seconds())

@nbari nbari closed this as completed Jan 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant