Documentation ¶
Index ¶
- Constants
- Variables
- func RecordKustomizeExecutionTime(ctx context.Context, executionTime float64)
- func RecordKustomizeFieldCountData(ctx context.Context, fieldCountData *KustomizeFieldMetrics)
- func RecordKustomizeResourceCount(ctx context.Context, resourceCount int)
- func RegisterKustomizeMetricsViews() error
- func RegisterOCAgentExporter() (*ocagent.Exporter, error)
- func RunKustomizeBuild(ctx context.Context, sendMetrics bool, inputDir string, flags ...string) (string, error)
- type KustomizeFieldMetrics
Constants ¶
const RenderHelmChart = "render-helm-chart"
RenderHelmChart is the name of the KRM function that inflates a helm chart
Variables ¶
var ( // KustomizeFieldCount is the number of times a particular field is used KustomizeFieldCount = stats.Int64( "kustomize_field_count", "The number of times a particular field is used in the kustomization files", stats.UnitDimensionless) // KustomizeDeprecatingFields is the usage of fields that may become deprecated KustomizeDeprecatingFields = stats.Int64( "kustomize_deprecating_field_count", "The usage of fields that may become deprecated", stats.UnitDimensionless) // KustomizeSimplification is the usage of simplification transformers KustomizeSimplification = stats.Int64( "kustomize_simplification_adoption_count", "The usage of simplification transformers images, replicas, and replacements", stats.UnitDimensionless) // KustomizeK8sMetadata is the usage of builtin transformers KustomizeK8sMetadata = stats.Int64( "kustomize_builtin_transformers", "The usage of builtin transformers related to kubernetes object metadata", stats.UnitDimensionless) // KustomizeHelmMetrics is the usage of helm KustomizeHelmMetrics = stats.Int64( "kustomize_helm_inflator_count", "The usage of helm in kustomize, whether by the builtin fields or the custom function", stats.UnitDimensionless) // KustomizeBaseCount is the number of remote and local bases KustomizeBaseCount = stats.Int64( "kustomize_base_count", "The number of remote and local bases", stats.UnitDimensionless) // KustomizePatchCount is the number of patches KustomizePatchCount = stats.Int64( "kustomize_patch_count", "The number of patches in the fields `patches`, `patchesStrategicMerge`, and `patchesJson6902`", stats.UnitDimensionless) // KustomizeTopTierMetrics is the usage of high level metrics KustomizeTopTierMetrics = stats.Int64( "kustomize_ordered_top_tier_metrics", "Usage of Resources, Generators, SecretGenerator, ConfigMapGenerator, Transformers, and Validators", stats.UnitDimensionless) // KustomizeResourceCount is the number of resources outputted by `kustomize build` KustomizeResourceCount = stats.Int64( "kustomize_resource_count", "The number of resources outputted by `kustomize build`", stats.UnitDimensionless) // KustomizeExecutionTime is the execution time of `kustomize build` KustomizeExecutionTime = stats.Float64( "kustomize_build_latency", "Kustomize build latency", stats.UnitMilliseconds) )
var ( // KustomizeFieldCountView is the number of times a field is used KustomizeFieldCountView = &view.View{ Name: KustomizeFieldCount.Name(), Measure: KustomizeFieldCount, Description: "The number of times a particular field is used in the kustomization files", TagKeys: []tag.Key{keyFieldName}, Aggregation: view.LastValue(), } // KustomizeDeprecatingFieldsView is the usage of fields that may become deprecated KustomizeDeprecatingFieldsView = &view.View{ Name: KustomizeDeprecatingFields.Name(), Measure: KustomizeDeprecatingFields, Description: "The usage of fields that may become deprecated", TagKeys: []tag.Key{keyDeprecatingField}, Aggregation: view.LastValue(), } // KustomizeSimplificationView is the usage of simplification transformers KustomizeSimplificationView = &view.View{ Name: KustomizeSimplification.Name(), Measure: KustomizeSimplification, Description: "The usage of simplification transformers images, replicas, and replacements", TagKeys: []tag.Key{keySimplificationAdoption}, Aggregation: view.LastValue(), } // KustomizeK8sMetadataView is the usage of builtin transformers KustomizeK8sMetadataView = &view.View{ Name: KustomizeK8sMetadata.Name(), Measure: KustomizeK8sMetadata, Description: "The usage of builtin transformers related to kubernetes object metadata", TagKeys: []tag.Key{keyK8sMetadata}, Aggregation: view.LastValue(), } // KustomizeHelmMetricsView is the usage of helm in kustomize KustomizeHelmMetricsView = &view.View{ Name: KustomizeHelmMetrics.Name(), Measure: KustomizeHelmMetrics, Description: "The usage of helm in kustomize, whether by the builtin fields or the custom function", TagKeys: []tag.Key{keyHelmMetrics}, Aggregation: view.LastValue(), } // KustomizeBaseCountView is the number of remote and local bases KustomizeBaseCountView = &view.View{ Name: KustomizeBaseCount.Name(), Measure: KustomizeBaseCount, Description: "The number of remote and local bases", TagKeys: []tag.Key{keyBaseCount}, Aggregation: view.LastValue(), } // KustomizePatchCountView is the number of patches KustomizePatchCountView = &view.View{ Name: KustomizePatchCount.Name(), Measure: KustomizePatchCount, Description: "The number of patches in the fields `patches`, `patchesStrategicMerge`, and `patchesJson6902`", TagKeys: []tag.Key{keyPatchCount}, Aggregation: view.LastValue(), } // KustomizeTopTierMetricsView is the usage of high level metrics KustomizeTopTierMetricsView = &view.View{ Name: KustomizeTopTierMetrics.Name(), Measure: KustomizeTopTierMetrics, Description: "Usage of Resources, Generators, SecretGenerator, ConfigMapGenerator, Transformers, and Validators", TagKeys: []tag.Key{keyTopTierCount}, Aggregation: view.LastValue(), } // KustomizeResourceCountView is the number of resources outputted by `kustomize build` KustomizeResourceCountView = &view.View{ Name: KustomizeResourceCount.Name(), Measure: KustomizeResourceCount, Description: "The number of resources outputted by `kustomize build`", Aggregation: view.LastValue(), } // KustomizeExecutionTimeView is the execution time of `kustomize build` KustomizeExecutionTimeView = &view.View{ Name: KustomizeExecutionTime.Name(), Measure: KustomizeExecutionTime, Description: "Execution time of `kustomize build`", Aggregation: view.Distribution(0, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240), } )
Functions ¶
func RecordKustomizeExecutionTime ¶
RecordKustomizeExecutionTime produces measurement for KustomizeExecutionTime view
func RecordKustomizeFieldCountData ¶
func RecordKustomizeFieldCountData(ctx context.Context, fieldCountData *KustomizeFieldMetrics)
RecordKustomizeFieldCountData records all data relevant to the kustomization's field counts
func RecordKustomizeResourceCount ¶
RecordKustomizeResourceCount produces measurement for KustomizeResourceCount view
func RegisterKustomizeMetricsViews ¶
func RegisterKustomizeMetricsViews() error
RegisterKustomizeMetricsViews registers the views so that recorded metrics can be exported. .
func RegisterOCAgentExporter ¶
RegisterOCAgentExporter creates the OC Agent metrics exporter.
func RunKustomizeBuild ¶
func RunKustomizeBuild(ctx context.Context, sendMetrics bool, inputDir string, flags ...string) (string, error)
RunKustomizeBuild runs `kustomize build` with the provided arguments. inputDir is the directory upon which to invoke `kustomize build`, and flags is what flags to run on it.
For example: RunKustomizeBuild(".", []string{"--enable-helm"}) will run `kustomize build . --enable-helm`.
The argument sendMetrics determines whether to send metrics about kustomize to Google Cloud.
Prior to running `kustomize build`, the wrapper will check the `buildMetadata` field of the kustomization file. By default, we would like to enable the `buildMetadata.originAnnotations`. If the kustomization file does not include it already, we add it and remove it afterwards.
Types ¶
type KustomizeFieldMetrics ¶
type KustomizeFieldMetrics struct { // fieldCount is how many times a given field is used in an instance // of kustomize build (including in bases and overlays) FieldCount map[string]int // TopTierCount looks at the fields Resources, Generators, SecretGenerator, // ConfigMapGenerator, Transformers, and Validators, and counts how many // of each are being used in a kustomization, e.g. for resources, how // many total resource paths there are. TopTierCount map[string]int // PatchCount looks at the patches, patchesStrategicMerge, and patchesJson6902 // and counts how many patches are in each field PatchCount map[string]int // BaseCount counts the number of remote and local bases BaseCount map[string]int // HelmMetrics counts the usage of helm in kustomize, if the new helm generator // function is used and how many charts are being inflated with the builtin // helm fields HelmMetrics map[string]int // K8sMetadata looks at the usage of builtin transformers related to kubernetes // object metadata K8sMetadata map[string]int // SimplMetrics looks at the usage of simplification transformers images, replicas, // and replacements SimplMetrics map[string]int // DeprecationMetrics looks at the usage of fields that may become deprecated DeprecationMetrics map[string]int }
KustomizeFieldMetrics stores kustomize metrics