Closed saimedhi closed 6 months ago
Sample usage
host = 'localhost'
port = 9200
auth = ('admin', 'admin') # For testing only. Don't store credentials in code.
client = OpenSearch(
hosts = [{'host': host, 'port': port}],
http_auth = auth,
use_ssl = True,
verify_certs = False,
connection_class = RequestsHttpConnection,
calculate_service_time = True,
)
client.info()
{'name': 'c3b344c0372b', 'cluster_name': 'docker-cluster', 'cluster_uuid': 'f6p2z4YRQvGW8nknOPgPeg', 'version': {'distribution': 'opensearch', 'number': '2.11.1', 'build_type': 'tar', 'build_hash': '6b1986e964d440be9137eba1413015c31c5a7752', 'build_date': '2023-11-29T21:45:35.524809067Z', 'build_snapshot': False, 'lucene_version': '9.7.0', 'minimum_wire_compatibility_version': '7.10.0', 'minimum_index_compatibility_version': '7.0.0'}, 'tagline': 'The OpenSearch Project: https://opensearch.org/', '__client': {'Service_Time': '0.43622279167175293'}}
Attention: 3 lines
in your changes are missing coverage. Please review.
Comparison is base (
4b69c09
) 72.14% compared to head (921cd55
) 72.13%.
Files | Patch % | Lines |
---|---|---|
opensearchpy/connection/http_requests.py | 62.50% | 3 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This is a good start and shows what we're trying to achieve.
What do you think about an idea where we first expose "events", then add "metrics"? Googling I found https://stackoverflow.com/questions/443885/python-callbacks-delegates-what-is-common and https://pypi.org/project/Events/ that could be a start. The client could expose events such as "request started", "finished", "errored", etc., and then another class called Metrics
or Measurements
could collect time information using this event system.
Description
Service time is calculated within the perform_request function of the Connection class ( This draft uses RequestsHttpConnection) at the point where the server call is made.
The calculated service time is added to the response or data in the connection.
I understand that this method is not ideal for returning service time and am exploring alternative options for improvement.
Issues Resolved
Related to #678
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.