Update azure resource detector timeout to 4 seconds (#2136)

This commit is contained in:
Jeremy Voss 2024-01-24 10:10:51 -08:00 committed by GitHub
parent f2c536ed82
commit 743c2fe2d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector - `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119)) ([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))
- `opentelemetry-resource-detector-azure` Changed timeout to 4 seconds due to [timeout bug](https://github.com/open-telemetry/opentelemetry-python/issues/3644)
([#2136](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2136))
## Version 1.22.0/0.43b0 (2023-12-14) ## Version 1.22.0/0.43b0 (2023-12-14)

View File

@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
__version__ = "0.1.1" __version__ = "0.1.2"

View File

@ -68,7 +68,10 @@ class _AzureVMMetadataServiceRequestor:
request = Request(_AZURE_VM_METADATA_ENDPOINT) request = Request(_AZURE_VM_METADATA_ENDPOINT)
request.add_header("Metadata", "True") request.add_header("Metadata", "True")
try: try:
with urlopen(request, timeout=10) as response: # TODO: Changed to 4s to fit into OTel SDK's 5 second timeout.
# Lengthen or allow user input if issue is resolved.
# See https://github.com/open-telemetry/opentelemetry-python/issues/3644
with urlopen(request, timeout=4) as response:
return loads(response.read()) return loads(response.read())
except URLError: except URLError:
# Not on Azure VM # Not on Azure VM