-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collect cloud metadata #826
Conversation
Leaving a thought here: A lot of the JSON response value collecting is fragile to any change in the metadata API response structure. If any field on the JSON response were to change then all fields wouldn't be detected for that provider. Obviously unlikely to happen but something I thought of. |
@sethmlarson Yes, that's definitely a concern. Unfortunately we don't have an easy way to do cross-cloud integration tests to test against the actual endpoints, though we may add that in the future. Luckily, these APIs tend to be very stable because they're heavily relied on. |
@beniwohli This has now been tested against apm-server 7.8.0 and the latest nightly. Working in both places (and I do see the metadata in the nightly). Ready for final review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one suggestion regarding the changes in sleep duration, otherwise LGTM
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
* Fetch cloud metadata Based on the Python reference implementation: elastic/apm-agent-python#826 By default we attempt to sniff metadata for all cloud providers. This can be overridden by setting the environment variable ELASTIC_APM_CLOUD_PROVIDER to one of "none", "aws", "azure", or "gcp". We set a short (100ms) socket connect timeout, and a slightly longer overall timeout (1s) for fetching the cloud metadata. In tests we disable cloud metadata fetching by default. There are currently no functional tests, as that would rely on us running in a known cloud environment.
* Add cloud metadata skeleton * Add config value * Add aws metadata collection * Use resp instead of r * Add GCP metadata * Add Azure metadata * Refactor headers * Use older metadata service version to guarantee availability * Add configuration docs * Use a single GCP metadata call with recursive=true * Use urllib3 properly * Fix some copy pasta * Normalize variable names * Pop zone if empty in azure * Remove provider guessing * Token step doesn't appear necessary for AWS * Just kidding, token needed for IMDSv2 * Actually import cloud * Add a socket call to avoid urllib3 logs * Add tests * Add changelog * Don't bother with tcp handshake for google metadata * Add logs for missing metadata when provider is defined * Move metadata generation to post-thread-start * Update tests to allow metadata to be generated in transport * For GCP IDs to string * Consolidate ret * We don't need warning counts, just check for the warning we care about * Fix header encodings test timing * Turn off cloud metadata for tests * Typo * We do need a short sleep here * Remove unused import
* Add cloud metadata skeleton * Add config value * Add aws metadata collection * Use resp instead of r * Add GCP metadata * Add Azure metadata * Refactor headers * Use older metadata service version to guarantee availability * Add configuration docs * Use a single GCP metadata call with recursive=true * Use urllib3 properly * Fix some copy pasta * Normalize variable names * Pop zone if empty in azure * Remove provider guessing * Token step doesn't appear necessary for AWS * Just kidding, token needed for IMDSv2 * Actually import cloud * Add a socket call to avoid urllib3 logs * Add tests * Add changelog * Don't bother with tcp handshake for google metadata * Add logs for missing metadata when provider is defined * Move metadata generation to post-thread-start * Update tests to allow metadata to be generated in transport * For GCP IDs to string * Consolidate ret * We don't need warning counts, just check for the warning we care about * Fix header encodings test timing * Turn off cloud metadata for tests * Typo * We do need a short sleep here * Remove unused import
* Add cloud metadata skeleton * Add config value * Add aws metadata collection * Use resp instead of r * Add GCP metadata * Add Azure metadata * Refactor headers * Use older metadata service version to guarantee availability * Add configuration docs * Use a single GCP metadata call with recursive=true * Use urllib3 properly * Fix some copy pasta * Normalize variable names * Pop zone if empty in azure * Remove provider guessing * Token step doesn't appear necessary for AWS * Just kidding, token needed for IMDSv2 * Actually import cloud * Add a socket call to avoid urllib3 logs * Add tests * Add changelog * Don't bother with tcp handshake for google metadata * Add logs for missing metadata when provider is defined * Move metadata generation to post-thread-start * Update tests to allow metadata to be generated in transport * For GCP IDs to string * Consolidate ret * We don't need warning counts, just check for the warning we care about * Fix header encodings test timing * Turn off cloud metadata for tests * Typo * We do need a short sleep here * Remove unused import
What does this pull request do?
Collects cloud metadata
Remaining work
Add provider guessingRelated issues
Closes #822