Skip to content

Commit

Permalink
Update CLOUD_PROVIDER for new valid options (elastic#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
basepi authored and romulorosa committed Oct 15, 2020
1 parent c9ebb4c commit 6e9f3ec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
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 @@ -371,9 +371,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 @@ -390,7 +390,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 @@ -401,6 +401,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

0 comments on commit 6e9f3ec

Please sign in to comment.