1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 type statsTicker struct {
17 ErrorCodes map[string]uint64 `json:",omitempty"`
21 // Tick increments each of the given counters by 1 using
23 func (s *statsTicker) Tick(counters ...*uint64) {
24 for _, counter := range counters {
25 atomic.AddUint64(counter, 1)
29 // TickErr increments the overall error counter, as well as the
30 // ErrorCodes entry for the given errType. If err is nil, TickErr is a
32 func (s *statsTicker) TickErr(err error, errType string) {
39 if s.ErrorCodes == nil {
40 s.ErrorCodes = make(map[string]uint64)
42 s.ErrorCodes[errType]++
46 // TickInBytes increments the incoming byte counter by n.
47 func (s *statsTicker) TickInBytes(n uint64) {
48 atomic.AddUint64(&s.InBytes, n)
51 // TickOutBytes increments the outgoing byte counter by n.
52 func (s *statsTicker) TickOutBytes(n uint64) {
53 atomic.AddUint64(&s.OutBytes, n)