in esrally/metrics.py [0:0]
def __init__(self, cfg: types.Config):
self._config = cfg
host = self._config.opts("reporting", "datastore.host")
port = self._config.opts("reporting", "datastore.port")
hosts = [{"host": host, "port": port}]
secure = convert.to_bool(self._config.opts("reporting", "datastore.secure"))
user = self._config.opts("reporting", "datastore.user")
distribution_version = None
distribution_flavor = None
try:
password = os.environ["RALLY_REPORTING_DATASTORE_PASSWORD"]
except KeyError:
try:
password = self._config.opts("reporting", "datastore.password")
except exceptions.ConfigError:
raise exceptions.ConfigError(
"No password configured through [reporting] configuration or RALLY_REPORTING_DATASTORE_PASSWORD environment variable."
) from None
verify = self._config.opts("reporting", "datastore.ssl.verification_mode", default_value="full", mandatory=False) != "none"
ca_path = self._config.opts("reporting", "datastore.ssl.certificate_authorities", default_value=None, mandatory=False)
self.probe_version = self._config.opts("reporting", "datastore.probe.cluster_version", default_value=True, mandatory=False)
# Instead of duplicating code, we're just adapting the metrics store specific properties to match the regular client options.
client_options = {
"use_ssl": secure,
"verify_certs": verify,
"timeout": 120,
}
if ca_path:
client_options["ca_certs"] = ca_path
if user and password:
client_options["basic_auth_user"] = user
client_options["basic_auth_password"] = password
# TODO #1335: Use version-specific support for metrics stores after 7.8.0.
if self.probe_version:
distribution_flavor, distribution_version, _, _ = client.cluster_distribution_version(
hosts=hosts, client_options=client_options
)
self._cluster_version = distribution_version
factory = client.EsClientFactory(
hosts=hosts,
client_options=client_options,
distribution_version=distribution_version,
distribution_flavor=distribution_flavor,
)
self._client = factory.create()