github.com/braveheart12/insolar-09-08-19@v0.8.7/ledger/storage/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 storage 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 recordType = insmetrics.MustTagKey("rectype") 29 ) 30 31 var ( 32 statCleanScanned = stats.Int64("lightcleanup/scanned", "How many records have been scanned on LM cleanup", stats.UnitDimensionless) 33 statCleanRemoved = stats.Int64("lightcleanup/removed", "How many records have been removed on LM cleanup", stats.UnitDimensionless) 34 statCleanFailed = stats.Int64("lightcleanup/rmfailed", "How many records have not been removed because of error", stats.UnitDimensionless) 35 36 statPulseDeleted = stats.Int64("lightcleanup/pulses/removed/total", "How many pulses deleted from pulseTracker on LM cleanup", stats.UnitDimensionless) 37 statPulseAdded = stats.Int64("lightcleanup/pulses/added/total", "How many pulses added to pulseTracker", stats.UnitDimensionless) 38 ) 39 40 func init() { 41 err := view.Register( 42 &view.View{ 43 Name: statCleanScanned.Name(), 44 Description: statCleanScanned.Description(), 45 Measure: statCleanScanned, 46 Aggregation: view.Sum(), 47 TagKeys: []tag.Key{recordType}, 48 }, 49 &view.View{ 50 Name: statCleanRemoved.Name(), 51 Description: statCleanRemoved.Description(), 52 Measure: statCleanRemoved, 53 Aggregation: view.Sum(), 54 TagKeys: []tag.Key{recordType}, 55 }, 56 &view.View{ 57 Name: statCleanFailed.Name(), 58 Description: statCleanFailed.Description(), 59 Measure: statCleanFailed, 60 Aggregation: view.Sum(), 61 TagKeys: []tag.Key{recordType}, 62 }, 63 &view.View{ 64 Name: statPulseDeleted.Name(), 65 Description: statPulseDeleted.Description(), 66 Measure: statPulseDeleted, 67 Aggregation: view.Count(), 68 }, 69 &view.View{ 70 Name: statPulseAdded.Name(), 71 Description: statPulseAdded.Description(), 72 Measure: statPulseAdded, 73 Aggregation: view.Count(), 74 }, 75 ) 76 if err != nil { 77 panic(err) 78 } 79 }