Skip to content

Update CLOUD_PROVIDER for new valid options #878

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

Merged
merged 3 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ endif::[]
//===== Bug fixes
//

=== Unreleased

// Unreleased changes go here
// When the next release happens, nest these changes under the "Python Agent version 5.x" heading
[float]
===== Features


[float]
===== Bug fixes

* Updated CLOUD_PROVIDER config to allow for new options defined in https://github.com/elastic/apm/issues/289[#289] {pull}878[#878]


[[release-notes-5.x]]
=== Python Agent version 5.x

Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ You must use the query bar to filter for a specific environment in versions prio
[options="header"]
|============
| Environment | Django/Flask | Default | Example
| `ELASTIC_APM_CLOUD_PROVIDER` | `CLOUD_PROVIDER` | `True` | `"aws"`
| `ELASTIC_APM_CLOUD_PROVIDER` | `CLOUD_PROVIDER` | `"auto"` | `"aws"`
|============

This config value allows you to specify which cloud provider should be assumed
for metadata collection. By default, the agent will attempt to detect the cloud
provider or, if that fails, will use trial and error to collect the metadata.

Valid options are `"aws"`, `"gcp"`, and `"azure"`. If this config value is set
to `False`, then no cloud metadata will be collected.
to `"none"`, then no cloud metadata will be collected.

[float]
[[config-secret-token]]
Expand Down
9 changes: 6 additions & 3 deletions elasticapm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ def get_cloud_info(self):
Detects if the app is running in a cloud provider and fetches relevant
metadata from the cloud provider's metadata endpoint.
"""
provider = self.config.cloud_provider
provider = str(self.config.cloud_provider).lower()

if not provider:
if not provider or provider == "none" or provider == "false":
return {}
if provider == "aws":
data = cloud.aws_metadata()
Expand All @@ -384,7 +384,7 @@ def get_cloud_info(self):
if not data:
self.logger.warning("Cloud provider {0} defined, but no metadata was found.".format(provider))
return data
else:
elif provider == "auto" or provider == "true":
# Trial and error
data = {}
data = cloud.aws_metadata()
Expand All @@ -395,6 +395,9 @@ def get_cloud_info(self):
return data
data = cloud.azure_metadata()
return data
else:
self.logger.warning("Unknown value for CLOUD_PROVIDER, skipping cloud metadata: {}".format(provider))
return {}

def build_metadata(self):
data = {
Expand Down