github.com/braveheart12/insolar-09-08-19@v0.8.7/ledger/heavyclient/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 heavyclient 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 tagJet = insmetrics.MustTagKey("jet") 29 ) 30 31 var ( 32 statUnsyncedPulsesCount = stats.Int64("heavyclient/unsynced/count", "How many pulses unsynced", stats.UnitDimensionless) 33 statFirstUnsyncedPulse = stats.Int64("heavyclient/unsynced/firstpulse", "First unsynced pulse number", stats.UnitDimensionless) 34 35 statSyncedPulsesCount = stats.Int64("heavyclient/synced/count", "How many pulses unsynced", stats.UnitDimensionless) 36 37 statCleanLatencyDB = stats.Int64("lightcleanup/latency/db", "Light storage db cleanup time in milliseconds", stats.UnitMilliseconds) 38 ) 39 40 func init() { 41 err := view.Register( 42 &view.View{ 43 Name: statUnsyncedPulsesCount.Name(), 44 Description: statUnsyncedPulsesCount.Description(), 45 Measure: statUnsyncedPulsesCount, 46 Aggregation: view.LastValue(), 47 TagKeys: []tag.Key{tagJet}, 48 }, 49 &view.View{ 50 Name: statFirstUnsyncedPulse.Name(), 51 Description: statFirstUnsyncedPulse.Description(), 52 Measure: statFirstUnsyncedPulse, 53 Aggregation: view.LastValue(), 54 TagKeys: []tag.Key{tagJet}, 55 }, 56 &view.View{ 57 Name: statSyncedPulsesCount.Name(), 58 Description: statSyncedPulsesCount.Description(), 59 Measure: statSyncedPulsesCount, 60 Aggregation: view.Count(), 61 TagKeys: []tag.Key{tagJet}, 62 }, 63 64 &view.View{ 65 Name: statCleanLatencyDB.Name(), 66 Description: statCleanLatencyDB.Description(), 67 Measure: statCleanLatencyDB, 68 Aggregation: view.Distribution(100, 500, 1000, 5000, 10000), 69 }, 70 ) 71 if err != nil { 72 panic(err) 73 } 74 }