...

Source file src/github.com/GoogleCloudPlatform/k8s-config-connector/pkg/metrics/views.go

Documentation: github.com/GoogleCloudPlatform/k8s-config-connector/pkg/metrics

     1  // Copyright 2022 Google LLC
     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
    16  
    17  import (
    18  	"go.opencensus.io/stats/view"
    19  	"go.opencensus.io/tag"
    20  )
    21  
    22  var (
    23  	processStartTime = &view.View{
    24  		Name:        "process_start_time_seconds",
    25  		Measure:     MProcessStartTime,
    26  		Description: MProcessStartTime.Description(),
    27  		Aggregation: view.LastValue(),
    28  	}
    29  	sharedControllerViews = []*view.View{
    30  		{
    31  			Name:        "reconcile_occupied_workers_total",
    32  			Measure:     MReconcileOccupiedWorkers,
    33  			Description: MReconcileOccupiedWorkers.Description(),
    34  			TagKeys:     []tag.Key{KindTag},
    35  			Aggregation: view.LastValue(),
    36  		},
    37  		{
    38  			Name:        "reconcile_workers_total",
    39  			Measure:     MReconcileTotalWorkers,
    40  			Description: MReconcileTotalWorkers.Description(),
    41  			TagKeys:     []tag.Key{KindTag},
    42  			Aggregation: view.LastValue(),
    43  		},
    44  		{
    45  			Name:        "internal_errors_total",
    46  			Measure:     MInternalErrors,
    47  			Description: MInternalErrors.Description(),
    48  			TagKeys:     []tag.Key{KindTag, NamespaceTag},
    49  			Aggregation: view.Count(),
    50  		},
    51  		processStartTime,
    52  	}
    53  	controllerViewsWithResourceNameLabel = []*view.View{
    54  		{
    55  			Name:        "reconcile_requests_total",
    56  			Measure:     MReconcileRequests,
    57  			Description: MReconcileRequests.Description(),
    58  			TagKeys:     []tag.Key{KindTag, NamespaceTag, StatusTag, ResourceNameTag},
    59  			Aggregation: view.Count(),
    60  		},
    61  		{
    62  			Name:        "reconcile_request_duration_seconds",
    63  			Measure:     MReconcileDuration,
    64  			Description: MReconcileDuration.Description(),
    65  			TagKeys:     []tag.Key{KindTag, NamespaceTag, StatusTag, ResourceNameTag},
    66  			// Latency in buckets:
    67  			// [>=0s, >=5s, >=10s, >=25s, >=1min, >=5min, >=10min, >=15min, >=30min, >=45min, >1h]
    68  			Aggregation: view.Distribution(0, 5, 10, 25, 60, 5*60, 10*60, 15*60, 30*60, 45*60, 60*60),
    69  		},
    70  	}
    71  	controllerViews = []*view.View{
    72  		{
    73  			Name:        "reconcile_requests_total",
    74  			Measure:     MReconcileRequests,
    75  			Description: MReconcileRequests.Description(),
    76  			TagKeys:     []tag.Key{KindTag, NamespaceTag, StatusTag},
    77  			Aggregation: view.Count(),
    78  		},
    79  		{
    80  			Name:        "reconcile_request_duration_seconds",
    81  			Measure:     MReconcileDuration,
    82  			Description: MReconcileDuration.Description(),
    83  			TagKeys:     []tag.Key{KindTag, NamespaceTag, StatusTag},
    84  			// Latency in buckets:
    85  			// [>=0s, >=5s, >=10s, >=25s, >=1min, >=5min, >=10min, >=15min, >=30min, >=45min, >1h]
    86  			Aggregation: view.Distribution(0, 5, 10, 25, 60, 5*60, 10*60, 15*60, 30*60, 45*60, 60*60),
    87  		},
    88  	}
    89  )
    90  
    91  func GetControllerViews() []*view.View {
    92  	views := make([]*view.View, 0)
    93  	views = append(views, sharedControllerViews...)
    94  	views = append(views, controllerViews...)
    95  	return views
    96  }
    97  
    98  func GetControllerViewsWithResourceNameLabel() []*view.View {
    99  	views := make([]*view.View, 0)
   100  	views = append(views, sharedControllerViews...)
   101  	views = append(views, controllerViewsWithResourceNameLabel...)
   102  	return views
   103  }
   104  

View as plain text