Should com.oracle.bmc.monitoring.MonitoringClient be closed every time after querying for metrics?

153 views Asked by At

In the examples provided on using the Monitoring Client: https://github.com/oracle/oci-java-sdk/blob/master/bmc-examples/src/main/java/MonitoringMetricListExample.java https://github.com/oracle/oci-java-sdk/blob/master/bmc-examples/src/main/java/MonitoringMetricSummarizeExample.java, for the monitoringClient.summarizeMetricsData(request) a new Monitoring Client is created and closed after a request. Is it necessary? Or can this client be reused for the new request, so for example there will be one client for the whole runtime of the application?

1

There are 1 answers

0
Mathias Ricken On BEST ANSWER

closing the client after every request is not necessary. You can re-use the same client for multiple requests, e.g. for the whole lifetime of the application.