github.com/braveheart12/just@v0.8.7/messagebus/metrics.go (about) 1 /* 2 * Copyright 2019 Insolar Technologies 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package messagebus 18 19 import ( 20 "go.opencensus.io/stats" 21 "go.opencensus.io/stats/view" 22 "go.opencensus.io/tag" 23 24 "github.com/insolar/insolar/instrumentation/insmetrics" 25 ) 26 27 var ( 28 tagMessageType = insmetrics.MustTagKey("messageType") 29 ) 30 31 var ( 32 statParcelsSentTotal = stats.Int64( 33 "messagebus/parcels/sent/count", 34 "number of parcels sent", 35 stats.UnitDimensionless, 36 ) 37 statLocallyDeliveredParcelsTotal = stats.Int64( 38 "messagebus/parcels/locally/delivered/count", 39 "total number of parcels delivered to the same machine", 40 stats.UnitDimensionless, 41 ) 42 statParcelsTime = stats.Float64( 43 "messagebus/parcels/time", 44 "time spent on sending parcels", 45 stats.UnitMilliseconds, 46 ) 47 ) 48 49 func init() { 50 err := view.Register( 51 &view.View{ 52 Measure: statParcelsSentTotal, 53 Aggregation: view.Sum(), 54 TagKeys: []tag.Key{tagMessageType}, 55 }, 56 &view.View{ 57 Measure: statLocallyDeliveredParcelsTotal, 58 Aggregation: view.Count(), 59 TagKeys: []tag.Key{tagMessageType}, 60 }, 61 &view.View{ 62 Measure: statParcelsTime, 63 Aggregation: view.Distribution(0.001, 0.01, 0.1, 1, 10, 100, 1000, 5000, 10000, 20000), 64 TagKeys: []tag.Key{tagMessageType}, 65 }, 66 ) 67 if err != nil { 68 panic(err) 69 } 70 }