Skip to content

feat: add metrics for pkg/runtime#1053

Open
NicholasBlaskey wants to merge 1 commit intokubernetes-sigs:mainfrom
NicholasBlaskey:runtime_metrics
Open

feat: add metrics for pkg/runtime#1053
NicholasBlaskey wants to merge 1 commit intokubernetes-sigs:mainfrom
NicholasBlaskey:runtime_metrics

Conversation

@NicholasBlaskey
Copy link
Contributor

@NicholasBlaskey NicholasBlaskey commented Feb 16, 2026

Add metrics to track runtime operations during reconciliation:

  • runtime_creation_total
  • runtime_creation_duration_seconds
  • runtime_node_eval_total
  • runtime_node_eval_duration_seconds
  • runtime_node_eval_errors_total
  • runtime_node_ignored_check_total
  • runtime_node_ignored_total
  • runtime_node_ready_check_total
  • runtime_node_not_ready_total
  • runtime_collection_size
  • cel_expr_eval_total
  • cel_expr_eval_duration_seconds

Examples

# HELP cel_expr_eval_duration_seconds Duration of CEL expression evaluations in seconds
# TYPE cel_expr_eval_duration_seconds histogram
cel_expr_eval_duration_seconds_bucket{le="0.005"} 42
cel_expr_eval_duration_seconds_bucket{le="0.01"} 42
cel_expr_eval_duration_seconds_bucket{le="0.025"} 42
cel_expr_eval_duration_seconds_bucket{le="0.05"} 42
cel_expr_eval_duration_seconds_bucket{le="0.1"} 42
cel_expr_eval_duration_seconds_bucket{le="0.25"} 42
cel_expr_eval_duration_seconds_bucket{le="0.5"} 42
cel_expr_eval_duration_seconds_bucket{le="1"} 42
cel_expr_eval_duration_seconds_bucket{le="2.5"} 42
cel_expr_eval_duration_seconds_bucket{le="5"} 42
cel_expr_eval_duration_seconds_bucket{le="10"} 42
cel_expr_eval_duration_seconds_bucket{le="+Inf"} 42
cel_expr_eval_duration_seconds_sum 0.000303914
cel_expr_eval_duration_seconds_count 42
# HELP cel_expr_eval_total Total number of CEL expression evaluations
# TYPE cel_expr_eval_total counter
cel_expr_eval_total 42
# HELP runtime_collection_size Number of items generated by forEach collection expansion
# TYPE runtime_collection_size histogram
runtime_collection_size_bucket{le="1"} 0
runtime_collection_size_bucket{le="2"} 0
runtime_collection_size_bucket{le="4"} 6
runtime_collection_size_bucket{le="8"} 6
runtime_collection_size_bucket{le="16"} 6
runtime_collection_size_bucket{le="32"} 6
runtime_collection_size_bucket{le="64"} 6
runtime_collection_size_bucket{le="128"} 6
runtime_collection_size_bucket{le="256"} 6
runtime_collection_size_bucket{le="512"} 6
runtime_collection_size_bucket{le="+Inf"} 6
runtime_collection_size_sum 24
runtime_collection_size_count 6
# HELP runtime_creation_duration_seconds Duration of runtime creation setup phase in seconds
# TYPE runtime_creation_duration_seconds histogram
runtime_creation_duration_seconds_bucket{le="0.005"} 6
runtime_creation_duration_seconds_bucket{le="0.01"} 6
runtime_creation_duration_seconds_bucket{le="0.025"} 6
runtime_creation_duration_seconds_bucket{le="0.05"} 6
runtime_creation_duration_seconds_bucket{le="0.1"} 6
runtime_creation_duration_seconds_bucket{le="0.25"} 6
runtime_creation_duration_seconds_bucket{le="0.5"} 6
runtime_creation_duration_seconds_bucket{le="1"} 6
runtime_creation_duration_seconds_bucket{le="2.5"} 6
runtime_creation_duration_seconds_bucket{le="5"} 6
runtime_creation_duration_seconds_bucket{le="10"} 6
runtime_creation_duration_seconds_bucket{le="+Inf"} 6
runtime_creation_duration_seconds_sum 0.000289517
runtime_creation_duration_seconds_count 6
# HELP runtime_creation_total Total number of runtimes created
# TYPE runtime_creation_total counter
runtime_creation_total 6
# HELP runtime_node_eval_duration_seconds Duration of node evaluations during reconciliation in seconds
# TYPE runtime_node_eval_duration_seconds histogram
runtime_node_eval_duration_seconds_bucket{le="0.005"} 30
runtime_node_eval_duration_seconds_bucket{le="0.01"} 30
runtime_node_eval_duration_seconds_bucket{le="0.025"} 30
runtime_node_eval_duration_seconds_bucket{le="0.05"} 30
runtime_node_eval_duration_seconds_bucket{le="0.1"} 30
runtime_node_eval_duration_seconds_bucket{le="0.25"} 30
runtime_node_eval_duration_seconds_bucket{le="0.5"} 30
runtime_node_eval_duration_seconds_bucket{le="1"} 30
runtime_node_eval_duration_seconds_bucket{le="2.5"} 30
runtime_node_eval_duration_seconds_bucket{le="5"} 30
runtime_node_eval_duration_seconds_bucket{le="10"} 30
runtime_node_eval_duration_seconds_bucket{le="+Inf"} 30
runtime_node_eval_duration_seconds_sum 0.000641967
runtime_node_eval_duration_seconds_count 30
# HELP runtime_node_eval_errors_total Total number of node evaluation errors
# TYPE runtime_node_eval_errors_total counter
runtime_node_eval_errors_total 12
# HELP runtime_node_eval_total Total number of node evaluations during reconciliation
# TYPE runtime_node_eval_total counter
runtime_node_eval_total 30
# HELP runtime_node_ignored_check_total Total number of node includeWhen checks
# TYPE runtime_node_ignored_check_total counter
runtime_node_ignored_check_total 24
# HELP runtime_node_ignored_total Total number of nodes skipped due to includeWhen conditions
# TYPE runtime_node_ignored_total counter
runtime_node_ignored_total 0
# HELP runtime_node_ready_check_total Total number of node readyWhen checks
# TYPE runtime_node_ready_check_total counter
runtime_node_ready_check_total 0

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 16, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: NicholasBlaskey
Once this PR has been reviewed and has the lgtm label, please assign bridgetkromhout for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 16, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @NicholasBlaskey. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 16, 2026
@NicholasBlaskey NicholasBlaskey force-pushed the runtime_metrics branch 3 times, most recently from 4c4f5a1 to 9c5693a Compare February 16, 2026 22:13
@NicholasBlaskey NicholasBlaskey marked this pull request as ready for review February 16, 2026 22:14
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 16, 2026

// evalExpression wraps expression evaluation with metrics tracking.
func evalExpression(expr *krocel.Expression, ctx map[string]any) (any, error) {
startTime := time.Now()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you instead track this in krocel.Expression? Whats the reason for a separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate function to make it easier to add metrics

However, moved this tracking to krocel.Expression

Add metrics to track runtime operations during reconciliation:

- runtime_creation_total
- runtime_creation_duration_seconds
- runtime_node_eval_total
- runtime_node_eval_duration_seconds
- runtime_node_eval_errors_total
- runtime_node_ignored_check_total
- runtime_node_ignored_total
- runtime_node_ready_check_total
- runtime_node_not_ready_total
- runtime_collection_size
- cel_expr_eval_total
- cel_expr_eval_duration_seconds
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 24, 2026
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@a-hilaly
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants