github.com/observiq/bindplane-agent@v1.51.0/internal/throughputwrapper/metrics.go (about)

     1  // Copyright  observIQ, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package throughputwrapper
    16  
    17  import (
    18  	"go.opencensus.io/stats"
    19  	"go.opencensus.io/stats/view"
    20  	"go.opencensus.io/tag"
    21  )
    22  
    23  const tagComponentKey = "component"
    24  
    25  var (
    26  	componentTagKey      = tag.MustNewKey(tagComponentKey)
    27  	logThroughputSize    = stats.Int64("log_throughput_size", "Size of the log package emitted from the component", stats.UnitBytes)
    28  	metricThroughputSize = stats.Int64("metric_throughput_size", "Size of the metric package emitted from the component", stats.UnitBytes)
    29  	traceThroughputSize  = stats.Int64("trace_throughput_size", "Size of the trace package emitted from the component", stats.UnitBytes)
    30  )
    31  
    32  func metricViews() []*view.View {
    33  	componentTagKeys := []tag.Key{componentTagKey}
    34  
    35  	return []*view.View{
    36  		{
    37  			Name:        tagComponentKey + "/" + logThroughputSize.Name(),
    38  			Description: logThroughputSize.Description(),
    39  			Measure:     logThroughputSize,
    40  			TagKeys:     componentTagKeys,
    41  			Aggregation: view.Sum(),
    42  		},
    43  		{
    44  			Name:        tagComponentKey + "/" + metricThroughputSize.Name(),
    45  			Description: metricThroughputSize.Description(),
    46  			Measure:     metricThroughputSize,
    47  			TagKeys:     componentTagKeys,
    48  			Aggregation: view.Sum(),
    49  		},
    50  		{
    51  			Name:        tagComponentKey + "/" + traceThroughputSize.Name(),
    52  			Description: traceThroughputSize.Description(),
    53  			Measure:     traceThroughputSize,
    54  			TagKeys:     componentTagKeys,
    55  			Aggregation: view.Sum(),
    56  		},
    57  	}
    58  }