github.com/braveheart12/just@v0.8.7/ledger/heavyserver/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 heavyserver 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 statSyncedCount = stats.Int64("heavyserver/synced/count", "StoreKeyValues successful calls", stats.UnitDimensionless) 33 statSyncedRecords = stats.Int64("heavyserver/synced/records", "The number synced records", stats.UnitDimensionless) 34 statSyncedPulse = stats.Int64("heavyserver/synced/pulse", "Last synced pulse", stats.UnitDimensionless) 35 statSyncedBytes = stats.Int64("heavyserver/synced/bytes", "Amount of synced records in bytes", stats.UnitBytes) 36 ) 37 38 func init() { 39 commontags := []tag.Key{tagJet} 40 err := view.Register( 41 &view.View{ 42 Name: statSyncedCount.Name(), 43 Description: statSyncedCount.Description(), 44 Measure: statSyncedCount, 45 Aggregation: view.Count(), 46 TagKeys: commontags, 47 }, 48 &view.View{ 49 Name: statSyncedRecords.Name(), 50 Description: statSyncedRecords.Description(), 51 Measure: statSyncedRecords, 52 Aggregation: view.Sum(), 53 TagKeys: commontags, 54 }, 55 &view.View{ 56 Name: statSyncedPulse.Name(), 57 Description: statSyncedPulse.Description(), 58 Measure: statSyncedPulse, 59 Aggregation: view.LastValue(), 60 TagKeys: commontags, 61 }, 62 &view.View{ 63 Name: statSyncedBytes.Name(), 64 Description: statSyncedBytes.Description(), 65 Measure: statSyncedBytes, 66 Aggregation: view.Sum(), 67 TagKeys: commontags, 68 }, 69 ) 70 if err != nil { 71 panic(err) 72 } 73 }