github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/transport/stats.go (about)

     1  // Package transport provides long-lived http/tcp connections for
     2  // intra-cluster communications (see README for details and usage example).
     3  /*
     4   * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
     5   */
     6  package transport
     7  
     8  import (
     9  	"github.com/NVIDIA/aistore/cmn/atomic"
    10  )
    11  
    12  // cumulative transport counters (this target)
    13  const (
    14  	OutObjCount = "stream.out.n"
    15  	OutObjSize  = "stream.out.size"
    16  	InObjCount  = "stream.in.n"
    17  	InObjSize   = "stream.in.size"
    18  )
    19  
    20  // stream (session) stats
    21  type Stats struct {
    22  	Num            atomic.Int64 // number of transferred objects including zero size (header-only) objects
    23  	Size           atomic.Int64 // transferred object size (does not include transport headers)
    24  	Offset         atomic.Int64 // stream offset, in bytes
    25  	CompressedSize atomic.Int64 // compressed size (converges to the actual compressed size over time)
    26  }
    27  
    28  type nopRxStats struct{}
    29  
    30  // interface guard
    31  var (
    32  	_ rxStats = (*Stats)(nil)
    33  	_ rxStats = (*nopRxStats)(nil)
    34  )
    35  
    36  func (s *Stats) addOff(o int64) { s.Offset.Add(o) }
    37  func (s *Stats) incNum()        { s.Num.Inc() }
    38  
    39  func (nopRxStats) addOff(int64) {}
    40  func (nopRxStats) incNum()      {}