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

Introduce new metrics to track API call duration and Update status.Status to capture underlying cause #842

Merged
merged 2 commits into from
Sep 5, 2023

Conversation

unmarshall
Copy link
Contributor

@unmarshall unmarshall commented Aug 24, 2023

What this PR does / why we need it:

Two new metrics have been introduced

  • Duration of all successful provider API calls
  • Total duration taken to execute Driver methods.

In addition to the metrics, status.Status has been enhanced to capture the underline cause error. A convenience function WrapError has also been added which captures the underline cause. This will help consumers(mcm provider implementations) to introspect the error to extract underline error code, especially during writing unit tests

Which issue(s) this PR fixes:
Fixes #841

Special notes for your reviewer:

Release note:

New metrics introduced: 
- api_request_duration_seconds -> tracks time taken for successful invocation of provider APIs. This metric can be filtered by provider and service.
- driver_request_duration_seconds -> tracks total time taken to successfully complete driver method invocation. This metric can be filtered by provider and operation.
- driver_requests_failed_total -> records total number of failed driver API requests. This metric can be filtered by provider, operations and error_code.
status.Status now captures underline cause, allowing consumers to introspect the error returned by the provider. WrapError() function could be used to wrap the provider error

@unmarshall unmarshall requested a review from a team as a code owner August 24, 2023 09:04
@gardener-robot gardener-robot added needs/review Needs review size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Aug 24, 2023
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 24, 2023
@gardener-robot
Copy link

@himanshu-kun, @rishabh-11 You have pull request review open invite, please check

@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 28, 2023
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2023
Copy link
Contributor

@himanshu-kun himanshu-kun left a comment

Choose a reason for hiding this comment

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

thanks for the changes!
minor nits requested.

pkg/util/provider/metrics/metrics.go Show resolved Hide resolved
pkg/util/provider/metrics/metrics.go Outdated Show resolved Hide resolved
pkg/util/provider/metrics/metrics.go Outdated Show resolved Hide resolved
pkg/util/provider/machinecodes/status/status.go Outdated Show resolved Hide resolved
pkg/util/provider/metrics/metrics.go Outdated Show resolved Hide resolved
pkg/util/provider/metrics/metrics.go Outdated Show resolved Hide resolved
@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Aug 29, 2023
@himanshu-kun
Copy link
Contributor

/assign @unmarshall to address the review

@unmarshall unmarshall changed the title Introduce new metrics to track API call duration Introduce new metrics to track API call duration and Update status.Status to capture underlying cause Aug 29, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 29, 2023
changed the name of the API request duration metric

added metric to capture overall duration for driver api calls

reverted back to using service label for provider api metric

added cause to status.Status

added WrapError function

corrected docstrings

corrected leftover docstring

Update pkg/util/provider/metrics/metrics.go

Co-authored-by: Himanshu Sharma <[email protected]>

Apply suggestions from code review

Co-authored-by: Himanshu Sharma <[email protected]>

addressed review comment - removed populating cause when in FromError when err is already status.Status
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 29, 2023
@gardener-robot
Copy link

@rishabh-11 You have pull request review open invite, please check

@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Sep 4, 2023
Copy link
Contributor

@himanshu-kun himanshu-kun left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-robot gardener-robot added reviewed/lgtm Has approval for merging and removed needs/changes Needs (more) changes needs/review Needs review labels Sep 4, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 4, 2023
@himanshu-kun himanshu-kun merged commit 61d9417 into gardener:master Sep 5, 2023
8 checks passed
@gardener-robot gardener-robot added the status/closed Issue is closed (either delivered or triaged) label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) size/s Size of pull request is small (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
7 participants