istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/collateral/metrics/otel_test.go (about)

     1  // Copyright 2019 Istio Authors
     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 metrics_test
    16  
    17  import (
    18  	"testing"
    19  
    20  	"istio.io/istio/pkg/collateral/metrics"
    21  	"istio.io/istio/pkg/monitoring"
    22  	"istio.io/istio/pkg/test/util/assert"
    23  )
    24  
    25  func TestExportedMetrics(t *testing.T) {
    26  	assert.Equal(t, metrics.ExportedMetrics(), want)
    27  }
    28  
    29  var (
    30  	// AttributesTotal is a measure of the number of known attributes.
    31  	AttributesTotal = monitoring.NewGauge(
    32  		"mixer/config/attributes_total",
    33  		"The number of known attributes in the current config.",
    34  	)
    35  
    36  	// HandlersTotal is a measure of the number of known handlers.
    37  	HandlersTotal = monitoring.NewSum(
    38  		"mixer/config/handler_configs_total",
    39  		"The number of known handlers in the current config.",
    40  	)
    41  
    42  	// InstancesTotal is a measure of the number of known instances.
    43  	InstancesTotal = monitoring.NewDistribution(
    44  		"mixer/config/instance_configs_total",
    45  		"The number of known instances in the current config.",
    46  		[]float64{0, 1, 2},
    47  	)
    48  
    49  	// InstanceErrs is a measure of the number of errors for processing instance config.
    50  	InstanceErrs = monitoring.NewGauge(
    51  		"mixer/config/instance_config_errors_total",
    52  		"The number of errors encountered during processing of the instance configuration.",
    53  	)
    54  
    55  	// RulesTotal is a measure of the number of known rules.
    56  	RulesTotal = monitoring.NewGauge(
    57  		"mixer/config/rule_configs_total",
    58  		"The number of known rules in the current config.",
    59  	)
    60  
    61  	// RuleErrs is a measure of the number of errors for processing rules config.
    62  	RuleErrs = monitoring.NewGauge(
    63  		"mixer/config/rule_config_errors_total",
    64  		"The number of errors encountered during processing of the rule configuration.",
    65  	)
    66  
    67  	// AdapterInfosTotal is a measure of the number of known adapters.
    68  	AdapterInfosTotal = monitoring.NewGauge(
    69  		"mixer/config/adapter_info_configs_total",
    70  		"The number of known adapters in the current config.",
    71  	)
    72  
    73  	want = []monitoring.MetricDefinition{
    74  		{
    75  			Name:        "mixer_config_adapter_info_configs_total",
    76  			Type:        "LastValue",
    77  			Description: "The number of known adapters in the current config.",
    78  		},
    79  		{
    80  			Name:        "mixer_config_attributes_total",
    81  			Type:        "LastValue",
    82  			Description: "The number of known attributes in the current config.",
    83  		},
    84  		{
    85  			Name:        "mixer_config_handler_configs_total",
    86  			Type:        "Sum",
    87  			Description: "The number of known handlers in the current config.",
    88  		},
    89  		{
    90  			Name:        "mixer_config_instance_config_errors_total",
    91  			Type:        "LastValue",
    92  			Description: "The number of errors encountered during processing of the instance configuration.",
    93  		},
    94  		{
    95  			Name:        "mixer_config_instance_configs_total",
    96  			Type:        "Distribution",
    97  			Description: "The number of known instances in the current config.",
    98  			Bounds:      []float64{0, 1, 2},
    99  		},
   100  		{
   101  			Name:        "mixer_config_rule_config_errors_total",
   102  			Type:        "LastValue",
   103  			Description: "The number of errors encountered during processing of the rule configuration.",
   104  		},
   105  		{
   106  			Name:        "mixer_config_rule_configs_total",
   107  			Type:        "LastValue",
   108  			Description: "The number of known rules in the current config.",
   109  		},
   110  	}
   111  )