googleapis / java-spanner

Apache License 2.0
55 stars 110 forks source link

chore: client metrics #3125

Open surbhigarg92 opened 3 months ago

surbhigarg92 commented 3 months ago

This PR adds built-in metrics to the Java client library. This will introduce below metrics for the consumers of this library .

This feature is not currently available for customers to use. Once GA'ed consumers of this library will start getting these metrics in the MetricsExplorer



Attempt Latency
The latency of an RPC attempt. Useful for monitoring the general health of the applicationWith attributes like “Token Expiry”, “Status” etc, this metric can help us troubleshoot a wide range of issues.
Attempt Count The count of RPC attempts Useful for monitoring trafficUseful for deriving “Error Rate” with status attributes
Operation Latency The total end-to-end latency across all request attempts, including retries. Useful for monitoring the general health of the applicationThe combination of this metric and Attempt Latency can help us troubleshoot connectivity issues.
Operation Count The count of operations Useful for monitoring trafficUseful for deriving “Error Rate” with status labelThe combination of this metric and Attempt Count can be used for deriving Retry Count

conventional-commit-lint-gcf[bot] commented 2 months ago

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

surbhigarg92 commented 3 weeks ago

nit: please check behaviour of this with emulator env set, ideally it should be noop with emulator

Added a check for skipping enabling metrics for emulator

olavloite commented 2 weeks ago

Can we add a more descriptive pull request title than client metrics, and also add a description to the pull request? That will improve the release notes that are generated from this change.

If it is something that is not yet GA, but still needs to be merged now, then we should rename the pull request title to chore:....

surbhigarg92 commented 2 weeks ago

If it is only for testing, can we then use the following trick to make this package-private: Make this package-private Add a public static method to SpannerOptionsTestHelper that takes a SpannerOptions.Builder instance as an argument, and that calls this setEnableBuiltInMetrics(...) method. Call the SpannerOptionsTestHelper method from the tests that need to set this value.

I have actually removed public from setEnableBuiltInMetrics . It was only required for ITBuiltinMetricsTest which we are not enabling right now anyway. Lets not give an option to customers to enable it till the time we actually GA our feature.