Skip to content

Commit 084a3b2

Browse files
authored
Use a shorter timeout for AWS EC2 metadata requests
Fix #1088 According to the docs, the value for `timeout` is in seconds: https://docs.python.org/3/library/urllib.request.html#urllib.request.urlopen. 1000 seconds seems slow and in some cases can block the startup of the program being instrumented (see #1088 as an example), because the request will hang indefinitely in non-AWS environments. Using a much shorter 1 second timeout seems like a reasonable workaround for this.
1 parent 80969a0 commit 084a3b2

File tree

1 file changed

+1
-1
lines changed
  • sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource

1 file changed

+1
-1
lines changed

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/ec2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _aws_http_request(method, path, headers):
3434
Request(
3535
"http://169.254.169.254" + path, headers=headers, method=method
3636
),
37-
timeout=1000,
37+
timeout=1,
3838
) as response:
3939
return response.read().decode("utf-8")
4040

0 commit comments

Comments
 (0)