Skip to content

Commit

Permalink
feat: travelaudience#7 - Create instrumented client with more than on…
Browse files Browse the repository at this point in the history
…e const label

Signed-off-by: grzesuav <[email protected]>
  • Loading branch information
grzesuav committed Jul 26, 2021
1 parent 249c7bf commit 2a74a26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ func (c *Client) ForRecipient(recipient string) (*http.Client, error) {
})
}

// ForConstLabels allocates new client based on base one with incomingInstrumentation.
// Given constLabels is used as a constant label.
func (c *Client) ForConstLabels(constLabels map[string]string) (*http.Client, error) {
return instrumentClientWithConstLabels(c.Namespace, c.Client, c.Registerer, constLabels)
}

func instrumentClientWithConstLabels(namespace string, c *http.Client, reg prometheus.Registerer, constLabels map[string]string) (*http.Client, error) {
i := &outgoingInstrumentation{
requests: prometheus.NewCounterVec(
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/travelaudience/go-promhttp

go 1.16

require (
github.com/golang/protobuf v1.3.2 // indirect
github.com/prometheus/client_golang v1.0.0
Expand Down

0 comments on commit 2a74a26

Please sign in to comment.