예제 #1
0
func NewRoundTripStats(m *memmetrics.RTMetrics) (*RoundTripStats, error) {
	codes := m.StatusCodesCounts()

	sc := make([]StatusCode, 0, len(codes))
	for k, v := range codes {
		if v != 0 {
			sc = append(sc, StatusCode{Code: k, Count: v})
		}
	}

	h, err := m.LatencyHistogram()
	if err != nil {
		return nil, err
	}

	return &RoundTripStats{
		Counters: Counters{
			NetErrors:   m.NetworkErrorCount(),
			Total:       m.TotalCount(),
			Period:      m.CounterWindowSize(),
			StatusCodes: sc,
		},
		LatencyBrackets: NewBrackets(h),
	}, nil
}
예제 #2
0
func (rt *RTWatcher) collectServerMetrics(m *memmetrics.RTMetrics, u *url.URL) error {
	rt.mtx.Lock()
	defer rt.mtx.Unlock()

	sm, ok := rt.srvs[surl{scheme: u.Scheme, host: u.Host}]
	if ok {
		m.Append(sm)
	}
	return nil
}
예제 #3
0
func (rt *RTWatcher) collectMetrics(m *memmetrics.RTMetrics) error {
	rt.mtx.Lock()
	defer rt.mtx.Unlock()

	return m.Append(rt.m)
}