-
Notifications
You must be signed in to change notification settings - Fork 207
Added Basic Client side Metrics #1574
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
base: main
Are you sure you want to change the base?
Added Basic Client side Metrics #1574
Conversation
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
…ide-metrics # Conflicts: # CHANGELOG.md
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
i haven't reviewed the code, but: i think this is great, thanks! would it be possible to add documentation for it to the README? otherwise people will not notice that these metrics now exist. |
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
…ide-metrics # Conflicts: # CHANGELOG.md
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
Signed-off-by: Pushpendra Singh - WM <mertiya.pushpendra@gmail.com>
…ide-metrics # Conflicts: # CHANGELOG.md
…into micrometer-client-side-metrics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for adding the documentation, this looks great!
i won't review the java code (no time for this right now and anyway one of the maintainers - which i'm not - needs to review this), but i did look through the documentation and added some remarks there.
guides/metrics.md
Outdated
|
||
## How to enable metrics | ||
|
||
We should create a MetricOptions instance and set it in the ApacheHttpClient5TransportBuilder when creating the client. Take a look at below code snippet for an example of how to create a client with metrics enabled: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
We should create a MetricOptions instance and set it in the ApacheHttpClient5TransportBuilder when creating the client. Take a look at below code snippet for an example of how to create a client with metrics enabled: | |
We should create a `MetricOptions` instance and set it in the `ApacheHttpClient5TransportBuilder` when creating the client. Take a look at below code snippet for an example of how to create a client with metrics enabled: |
guides/metrics.md
Outdated
var port = Integer.parseInt(env.getOrDefault("PORT", "9200")); | ||
var user = env.getOrDefault("USERNAME", "admin"); | ||
var pass = env.getOrDefault("PASSWORD", "admin"); | ||
var metricEnabled = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
var metricEnabled = true; | |
var metricsEnabled = true; |
(also for the usage(s) below)
|
||
final var hosts = new HttpHost[]{new HttpHost(https ? "https" : "http", hostname, port)}; | ||
|
||
final var sslContext = SSLContextBuilder.create().loadTrustMaterial(null, (chains, authType) -> true).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use org.apache.hc.client5.http.ssl.TrustAllStrategy
here.
final var sslContext = SSLContextBuilder.create().loadTrustMaterial(null, (chains, authType) -> true).build(); | |
final var sslContext = SSLContextBuilder.create().loadTrustMaterial(null, new TrustAllStrategy()).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rursprung the TrustAllStrategy should not be used in production code, we should probably have a placehoder here or use the default one SSLContexts.createDefault()
guides/metrics.md
Outdated
|
||
| Metric | Description | Important Dimensions(tags) | | ||
|---------------------------------------|-----------------------------------------------------------------|--------------------------------| | ||
| os.client.request.seconds | End-to-end request execution latency | StatusCodeOrException, Request | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit (also for the other rows): i'd mark the metric name & tags as code for better readability):
| os.client.request.seconds | End-to-end request execution latency | StatusCodeOrException, Request | | |
| `os.client.request.seconds` | End-to-end request execution latency | `StatusCodeOrException`, `Request` | |
guides/metrics.md
Outdated
var metricEnabled = true; | ||
double PERCENTILE_99 = 0.99; | ||
double PERCENTILE_95 = 0.95; | ||
var meterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use SimpleMeterRegistry
for the example since it's not specific to prometheus? it's the simplest example which they also use in their intro docs.
# SDK Metrics | ||
|
||
We've integrated a robust metrics solution into the OpenSearch Java client to provide comprehensive insights into its API usage and performance. This includes the collection of vital operational metrics, such as overall throughput, request latency, and error rate. Furthermore, we're capturing more granular details like request and response payload sizes, distinct success and failure rates for operations, and real-time OpenSearch node status to provide a holistic view of client behavior and cluster health. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add an explicit mention here that this uses micrometer (with a link to micrometer.io
) and that it offers various integrations with monitoring systems (with a link to their overview)?
CHANGELOG.md
Outdated
@@ -3,10 +3,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) | |||
|
|||
## [Unreleased 3.x] | |||
### Added | |||
|
|||
- Metrics support includes micrometer integration and Prometheus support with a custom client-side metrics. [Metrics](./guides/metrics.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think that prometheus warrants explicit mention here since the integration is with micrometer and not prometheus. it's just that micrometer offers an integration with prometheus - amongst many others
Signed-off-by: psingh3 <pushpendra.singh@walmart.com>
@reta Could you please review this PR ? |
Thank for the pull request @001mertiya , I will try to find time this week |
@001mertiya the Micrometer has support of Apache HttpClient 5 metrics out of the box, it could be plugged in the
Could you please clarify why the provided out of the box instrumentation is not sufficient? Thank you. [1] https://docs.micrometer.io/micrometer/reference/reference/httpcomponents.html |
oh, that's actually very interesting! is this something which could be enabled by default if micrometer is present? (maybe just in |
In general - yes, it could be part of auto configuration |
in |
Hi @reta , The out of the box instrumentation provides only high-level metrics and lacks detailed insights. Additionally, we are not capturing all possible metrics. However, if we implement custom metric integration, we can improve this significantly.
By integrating metrics within the opensearch-java client, we gain more granular control over requests and can collect detailed tags such as request type, StatusCodeOrException, and if a status code is unavailable extract the exception class name.
The this PR, we collects a variety of metrics to provide insights into its operations. Below is a summary of key metrics, including descriptions and important dimensions (tags) for filtering and analysis:
Metrics on dashboard: ![]() What are your thoughts on having all the above metrics and tags? Thank you! |
Thanks @001mertiya
We get these metrics for free, this is huge benefit. Now, to your point of adding more / custom metrics or/and labels. There is nothing that prevents as to add additional metrics (if needed to) by composing multiple ExecChainHandler, however it has to be done following Micrometer conventions that are there. Regarding additional tags / labels, we have all control there by providing own The maintenance cost of duplicating similar efforts and maintaining custom one off dashboards (for the standard components) is extremely high. I think we should be leveraging what has been built already at maximum. |
Description
This PR introduces client-side metrics to track request rate, latency, and error rate. These metrics will help improve user experience by providing insights into how the request is used and identifying performance bottlenecks or unexpected behaviors.
Issues Resolved
The metrics PR includes integration with Micrometer and support for Prometheus, along with custom client-side metrics capabilities.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.