Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Add metrics to Runtime SDK hook client #6675

Conversation

chrischdi
Copy link
Member

@chrischdi chrischdi commented Jun 20, 2022

What this PR does / why we need it:

Adds request related metrics to the Runtime SDK hook client which will be helpful to analyse request durations to Runtime SDK extensions.

Adds the following metrics:

  1. capi_runtime_sdk_request_latency_seconds, example:

# HELP capi_runtime_sdk_request_duration_seconds Request duration in seconds, broken down by hook and host.
# TYPE capi_runtime_sdk_request_duration_seconds histogram
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.001"} 0
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.002"} 0
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.004"} 0
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.008"} 2
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.016"} 2
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.032"} 3
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.064"} 3
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.128"} 3
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.256"} 3
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="0.512"} 3
capi_runtime_sdk_request_duration_seconds_bucket{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1",le="+Inf"} 3
capi_runtime_sdk_request_duration_seconds_sum{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1"} 0.028844958
capi_runtime_sdk_request_duration_seconds_count{group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1"} 3
  1. capi_runtime_sdk_requests_total example:
# HELP capi_runtime_sdk_requests_total Number of HTTP requests, partitioned by status code, host and hook.
# TYPE capi_runtime_sdk_requests_total counter
capi_runtime_sdk_requests_total{code="200",group="hooks.runtime.cluster.x-k8s.io",hook="Discovery",host="webhook-service.test-extension.svc:443",version="v1alpha1"} 3

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #6330

Additional info

Some prior art from client-go:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 20, 2022
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 20, 2022
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from f754d0a to ec924f4 Compare June 20, 2022 13:37
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 20, 2022
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from ec924f4 to f90ed03 Compare June 20, 2022 13:47
@chrischdi chrischdi changed the title 🌱 [wip] Add metrics to runtime SDK hook client 🌱 Add metrics to runtime SDK hook client Jun 21, 2022
Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

This is great - using it now to get a feel for how the e2e tests run!

Just a couple of nits around comments.

internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from f90ed03 to c3425b3 Compare June 21, 2022 11:38
@chrischdi chrischdi changed the title 🌱 Add metrics to runtime SDK hook client 🌱 Add metrics to Runtime SDK hook client Jun 21, 2022
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from c3425b3 to adfbe00 Compare June 21, 2022 11:43
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

General approach looks fine. Mostly questions/nits as I don't really remember the metric best practices.

internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/metrics/metrics.go Outdated Show resolved Hide resolved
internal/runtime/client/client.go Outdated Show resolved Hide resolved
internal/runtime/client/client.go Outdated Show resolved Hide resolved
@sbueringer sbueringer mentioned this pull request Jun 21, 2022
30 tasks
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from adfbe00 to 5911bf0 Compare June 22, 2022 15:00
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 22, 2022
@chrischdi chrischdi changed the title 🌱 Add metrics to Runtime SDK hook client 🌱 [wip] Add metrics to Runtime SDK hook client Jun 22, 2022
@sbueringer
Copy link
Member

I would take another look once CI is green or ping me otherwise if you want another review :)

@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from 5911bf0 to 1f79f18 Compare June 24, 2022 07:30
@chrischdi
Copy link
Member Author

/retitle 🌱 Add metrics to Runtime SDK hook client

@k8s-ci-robot k8s-ci-robot changed the title 🌱 [wip] Add metrics to Runtime SDK hook client 🌱 Add metrics to Runtime SDK hook client Jun 24, 2022
@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from 1f79f18 to ae78c78 Compare June 24, 2022 09:36
@sbueringer
Copy link
Member

/lgtm

/assign @fabriziopandini

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 24, 2022
@sbueringer
Copy link
Member

@ykakarap @killianmuldoon If you have some time, would be good if you can review this PR

Copy link
Contributor

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

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

/lgtm

@ykakarap
Copy link
Contributor

@ykakarap @killianmuldoon If you have some time, would be good if you can review this PR

Will take a look at this today :)

Copy link
Contributor

@ykakarap ykakarap left a comment

Choose a reason for hiding this comment

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

/lgtm

I am not very familiar with metric and practices to follow. But the overall approach here looks good.

@sbueringer
Copy link
Member

/lgtm
/approve
/cherry-pick release-1.2

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.2 in a new PR and assign it to you.

In response to this:

/lgtm
/approve
/cherry-pick release-1.2

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 28, 2022
@sbueringer
Copy link
Member

@chrischdi please rebase when you've got some time :)

@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from ae78c78 to 6ffd863 Compare June 28, 2022 07:41
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 28, 2022
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jun 28, 2022

@chrischdi: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-e2e-informing-main 6ffd863 link false /test pull-cluster-api-e2e-informing-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@chrischdi chrischdi force-pushed the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch from 6ffd863 to e36b78f Compare June 28, 2022 07:44
@sbueringer
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 28, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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

The pull request process is described here

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-infra-cherrypick-robot

@sbueringer: new pull request created: #6755

In response to this:

/lgtm
/approve
/cherry-pick release-1.2

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/test-infra repository.

@sbueringer sbueringer deleted the pr-runtime-sdk-experiments-poc-runtime-client-metrics branch June 28, 2022 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants