When instantiating SpannerClient on google/cloud-spanner-php v2.10.0, there is a 1.5s delay when running against the emulator.
It seems like the constructor is calling $this->configureMetrics() -> $this->getLocation() -> GCECredentials::onGce(), and this method probes http://169.254.169.254 up to 3 times with a 0.5s timeout each.
In an emulator, this endpoint doesn't exist and will cause the code to timeout, hence the 1.5s delay.
Can the following code be moved up to the top of the method so that the code doesn't have to call getLocation when enableBuiltInMetrics is set to false (the default option)?
|
if (!$this->pluck('enableBuiltInMetrics', $options, false)) { |
|
return; |
|
} |
If this is fixed, I think we can expect a boost in performance for non-emulator environment as well.
When instantiating SpannerClient on
google/cloud-spanner-phpv2.10.0, there is a 1.5s delay when running against the emulator.It seems like the constructor is calling
$this->configureMetrics()->$this->getLocation()->GCECredentials::onGce(), and this method probeshttp://169.254.169.254up to 3 times with a 0.5s timeout each.In an emulator, this endpoint doesn't exist and will cause the code to timeout, hence the 1.5s delay.
Can the following code be moved up to the top of the method so that the code doesn't have to call
getLocationwhenenableBuiltInMetricsis set to false (the default option)?google-cloud-php/Spanner/src/SpannerClient.php
Lines 1062 to 1064 in 284f348
If this is fixed, I think we can expect a boost in performance for non-emulator environment as well.