github.com/rohankumardubey/proxyfs@v0.0.0-20210108201508-653efa9ab00e/stats/api.go (about) 1 // Package stats provides a simple statsd client API. 2 package stats 3 4 type MultipleStat int 5 6 const ( 7 DirRead MultipleStat = iota // uses operations, entries and bytes stats 8 FileRead // uses operations, op bucketed bytes, and bytes stats 9 FileReadplan // uses operations, op bucketed bytes, bytes, and bucketed steps stats 10 FileWrite // uses operations, op bucketed bytes, bytes, appended and overwritten stats 11 FileWrote // uses operations, op bucketed bytes, and bytes stats 12 JrpcfsIoWrite // uses operations, op bucketed bytes, and bytes stats 13 JrpcfsIoRead // uses operations, op bucketed bytes, and bytes stats 14 SwiftObjGet // uses operations, op bucketed bytes, and bytes stats 15 SwiftObjLoad // uses operations, op bucketed bytes, and bytes stats 16 SwiftObjRead // uses operations, op bucketed bytes, and bytes stats 17 SwiftObjTail // uses operations and bytes stats 18 SwiftObjPutCtxRead // uses operations, op bucketed bytes, and bytes stats 19 SwiftObjPutCtxSendChunk // uses operations, op bucketed bytes, and bytes stats 20 ) 21 22 // Dump returns a map of all accumulated stats since process start. 23 // 24 // Key is a string containing the name of the stat 25 // Value is the accumulation of all increments for the stat since process start 26 func Dump() (statMap map[string]uint64) { 27 statMap = dump() 28 return 29 } 30 31 // IncrementOperations sends an increment of .operations to statsd. 32 func IncrementOperations(statName *string) { 33 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 34 go incrementOperations(statName) 35 } 36 37 // IncrementOperationsBy sends an increment by <incBy> of .operations to statsd. 38 func IncrementOperationsBy(statName *string, incBy uint64) { 39 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 40 go incrementOperationsBy(statName, incBy) 41 } 42 43 // IncrementOperationsAndBytes sends an increment of .operations and .bytes to statsd. 44 func IncrementOperationsAndBytes(stat MultipleStat, bytes uint64) { 45 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 46 go incrementOperationsAndBytes(stat, bytes) 47 } 48 49 // IncrementOperationsEntriesAndBytes sends an increment of .operations, .entries, and .bytes to statsd. 50 func IncrementOperationsEntriesAndBytes(stat MultipleStat, entries uint64, bytes uint64) { 51 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 52 go incrementOperationsEntriesAndBytes(stat, entries, bytes) 53 } 54 55 // IncrementOperationsAndBucketedBytes sends an increment of .operations, .bytes, and the appropriate .operations.size-* to statsd. 56 func IncrementOperationsAndBucketedBytes(stat MultipleStat, bytes uint64) { 57 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 58 go incrementOperationsAndBucketedBytes(stat, bytes) 59 } 60 61 // IncrementOperationsBuckedtedBytesAndBucketedSteps sends an increment of .operations, .bytes, and the appropriate .operations.size-* to statsd. 62 func IncrementOperationsBucketedEntriesAndBucketedBytes(stat MultipleStat, entries uint64, bytes uint64) { 63 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 64 go incrementOperationsBucketedEntriesAndBucketedBytes(stat, entries, bytes) 65 } 66 67 // IncrementOperationsBucketedBytesAndAppendedOverwritten sends an increment of .operations, .bytes, .appended, .overwritten, and the appropriate .operations.size-* to statsd. 68 func IncrementOperationsBucketedBytesAndAppendedOverwritten(stat MultipleStat, bytes uint64, appended uint64, overwritten uint64) { 69 // Do this in a goroutine since channel operations are suprisingly expensive due to locking underneath 70 go incrementOperationsBucketedBytesAndAppendedOverwritten(stat, bytes, appended, overwritten) 71 }