From 94ba4f2b74a566aed1865343fda6b09c50fb6059 Mon Sep 17 00:00:00 2001 From: jeremydvoss Date: Mon, 22 Jan 2024 13:16:15 -0800 Subject: [PATCH 1/3] Change timeout to 4 seconds --- CHANGELOG.md | 2 ++ .../src/opentelemetry/resource/detector/azure/version.py | 2 +- .../src/opentelemetry/resource/detector/azure/vm.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed9a4c205..add05f28d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ([#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) + ([#XXXX](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/XXXX)) ## Version 1.22.0/0.43b0 (2023-12-14) diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/version.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/version.py index 7b936f07f0..97109f529b 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/version.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.1.1" +__version__ = "0.1.2" diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py index e90fec5a8d..20fee96284 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py @@ -68,7 +68,7 @@ def get_azure_vm_metadata(self): # pylint: disable=no-self-use request = Request(_AZURE_VM_METADATA_ENDPOINT) request.add_header("Metadata", "True") try: - with urlopen(request, timeout=10) as response: + with urlopen(request, timeout=4) as response: return loads(response.read()) except URLError: # Not on Azure VM From 6056a3f03d207cf6225e9f9fdfabb67960606ee2 Mon Sep 17 00:00:00 2001 From: jeremydvoss Date: Mon, 22 Jan 2024 13:19:32 -0800 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index add05f28d7..024c8473d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ 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 ([#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) - ([#XXXX](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/XXXX)) + ([#2136](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2136)) ## Version 1.22.0/0.43b0 (2023-12-14) From 546f186dfc7c1c61d5788d5ecb184b3526694308 Mon Sep 17 00:00:00 2001 From: jeremydvoss Date: Tue, 23 Jan 2024 14:03:40 -0800 Subject: [PATCH 3/3] Feedback --- .../src/opentelemetry/resource/detector/azure/vm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py index 20fee96284..b0e0f4d45b 100644 --- a/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py +++ b/resource/opentelemetry-resource-detector-azure/src/opentelemetry/resource/detector/azure/vm.py @@ -68,6 +68,9 @@ def get_azure_vm_metadata(self): # pylint: disable=no-self-use request = Request(_AZURE_VM_METADATA_ENDPOINT) request.add_header("Metadata", "True") try: + # 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()) except URLError: