k8s.io/perf-tests/clusterloader2@v0.0.0-20240304094227-64bdb12da87e/pkg/measurement/util/perftype.go (about)

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     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 util
    18  
    19  // TODO(random-liu): Replace this with prometheus' data model.
    20  
    21  // The following performance data structures are generalized and well-formatted.
    22  // They can be pretty printed in json format and be analyzed by other performance
    23  // analyzing tools, such as Perfdash (k8s.io/contrib/perfdash).
    24  
    25  // DataItem is the data point.
    26  type DataItem struct {
    27  	// Data is a map from bucket to real data point (e.g. "Perc90" -> 23.5). Notice
    28  	// that all data items with the same label combination should have the same buckets.
    29  	Data map[string]float64 `json:"data"`
    30  	// Unit is the data unit. Notice that all data items with the same label combination
    31  	// should have the same unit.
    32  	Unit string `json:"unit"`
    33  	// Labels is the labels of the data item.
    34  	Labels map[string]string `json:"labels,omitempty"`
    35  }
    36  
    37  // PerfData contains all data items generated in current test.
    38  type PerfData struct {
    39  	// Version is the version of the metrics. The metrics consumer could use the version
    40  	// to detect metrics version change and decide what version to support.
    41  	Version   string     `json:"version"`
    42  	DataItems []DataItem `json:"dataItems"`
    43  	// Labels is the labels of the dataset.
    44  	Labels map[string]string `json:"labels,omitempty"`
    45  }
    46  
    47  // PerfResultTag is the prefix of generated perfdata. Analyzing tools can find the perf result
    48  // with this tag.
    49  const PerfResultTag = "[Result:Performance]"
    50  
    51  // PerfResultEnd is the end of generated perfdata. Analyzing tools can find the end of the perf
    52  // result with this tag.
    53  const PerfResultEnd = "[Finish:Performance]"