func newHTTPMetrics()

in transport/http/metrics.go [68:116]


func newHTTPMetrics(meter metrics.Meter) (*httpMetrics, error) {
	hm := &httpMetrics{}

	var err error
	hm.DNSLookupDuration, err = meter.Float64Histogram("client.http.connections.dns_lookup_duration", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "s"
		o.Description = "The time it takes a request to perform DNS lookup."
	})
	if err != nil {
		return nil, err
	}
	hm.ConnectDuration, err = meter.Float64Histogram("client.http.connections.acquire_duration", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "s"
		o.Description = "The time it takes a request to acquire a connection."
	})
	if err != nil {
		return nil, err
	}
	hm.TLSHandshakeDuration, err = meter.Float64Histogram("client.http.connections.tls_handshake_duration", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "s"
		o.Description = "The time it takes an HTTP request to perform the TLS handshake."
	})
	if err != nil {
		return nil, err
	}
	hm.ConnectionUsage, err = meter.Int64UpDownCounter("client.http.connections.usage", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "{connection}"
		o.Description = "Current state of connections pool."
	})
	if err != nil {
		return nil, err
	}
	hm.DoRequestDuration, err = meter.Float64Histogram("client.http.do_request_duration", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "s"
		o.Description = "Time spent performing an entire HTTP transaction."
	})
	if err != nil {
		return nil, err
	}
	hm.TimeToFirstByte, err = meter.Float64Histogram("client.http.time_to_first_byte", func(o *metrics.InstrumentOptions) {
		o.UnitLabel = "s"
		o.Description = "Time from start of transaction to when the first response byte is available."
	})
	if err != nil {
		return nil, err
	}

	return hm, nil
}