Skip to content

Conversation

@stuartnelson3
Copy link
Contributor

@stuartnelson3 stuartnelson3 commented Mar 31, 2017

@beorn7 adding this here for to start discussion, it has been heavily informed by the middleware approach in #285

Current API:

client := *http.DefaultClient
client.Timeout = 500 * time.Millisecond

inFlightGauge := prometheus.NewGauge(prometheus.GaugeOpts{
	Name: "in_flight",
	Help: "An in-flight gauge",
})

counter := prometheus.NewCounterVec(
	prometheus.CounterOpts{
		Name: "test_counter",
		Help: "A test counter.",
	},
	[]string{"code", "method"},
)

histVec := prometheus.NewHistogramVec(
	prometheus.HistogramOpts{
		Name:    "latency",
		Help:    "A histogram of latency.",
		Buckets: prometheus.DefBuckets,
	},
	[]string{"event"},
)

prometheus.MustRegister(counter, histVec, inFlightGauge)

promclient := promhttp.InFlightC(inFlightGauge,
	promhttp.CounterC(counter,
		promhttp.ClientTrace(histVec, &client),
	),
)

resp, err := promclient.Get("example.com")
// And so forth ...

@stuartnelson3 stuartnelson3 requested a review from beorn7 March 31, 2017 12:33
Same result, but uses stdlib code and doesn't mess
with people's clients.
InstrumentTrace allows for greater flexibility in
instrumenting the trace function, allowing users
to pass in uniquely partitioned and bucketed
histograms, e.g., or have additional counters for
certain trace hooks.
@stuartnelson3
Copy link
Contributor Author

Closed in favor of #295

@stuartnelson3 stuartnelson3 deleted the http-client branch April 25, 2017 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants