github.com/braveheart12/just@v0.8.7/ledger/artifactmanager/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 artifactmanager
    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  	tagMethod = insmetrics.MustTagKey("method")
    29  	tagResult = insmetrics.MustTagKey("result")
    30  )
    31  
    32  var (
    33  	statCalls   = stats.Int64("artifactmanager/calls", "The number of AM method calls", stats.UnitDimensionless)
    34  	statLatency = stats.Int64("artifactmanager/latency", "The latency in milliseconds per AM call", stats.UnitMilliseconds)
    35  
    36  	statRedirects = stats.Int64("artifactmanager/redirects", "The number redirects happens on AM", stats.UnitDimensionless)
    37  )
    38  
    39  func init() {
    40  	commontags := []tag.Key{tagMethod, tagResult}
    41  	err := view.Register(
    42  		&view.View{
    43  			Name:        statCalls.Name(),
    44  			Description: statCalls.Description(),
    45  			Measure:     statCalls,
    46  			Aggregation: view.Count(),
    47  			TagKeys:     commontags,
    48  		},
    49  		&view.View{
    50  			Name:        "artifactmanager_latency",
    51  			Description: statLatency.Description(),
    52  			Measure:     statLatency,
    53  			Aggregation: view.Distribution(25, 50, 75, 100, 200, 400, 600, 800, 1000, 2000, 4000, 6000),
    54  			TagKeys:     commontags,
    55  		},
    56  
    57  		&view.View{
    58  			Name:        statRedirects.Name(),
    59  			Description: statRedirects.Description(),
    60  			Measure:     statRedirects,
    61  			Aggregation: view.Count(),
    62  		},
    63  	)
    64  	if err != nil {
    65  		panic(err)
    66  	}
    67  }