Skip to content

Commit 534dfce

Browse files
authored
Update CLOUD_PROVIDER for new valid options (#878)
Ref elastic/apm#289
1 parent 091f49b commit 534dfce

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

CHANGELOG.asciidoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ endif::[]
3030
//===== Bug fixes
3131
//
3232
33+
=== Unreleased
34+
35+
// Unreleased changes go here
36+
// When the next release happens, nest these changes under the "Python Agent version 5.x" heading
37+
[float]
38+
===== Features
39+
40+
41+
[float]
42+
===== Bug fixes
43+
44+
* Updated CLOUD_PROVIDER config to allow for new options defined in https://github.com/elastic/apm/issues/289[#289] {pull}878[#878]
45+
46+
3347
[[release-notes-5.x]]
3448
=== Python Agent version 5.x
3549

docs/configuration.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,15 @@ You must use the query bar to filter for a specific environment in versions prio
206206
[options="header"]
207207
|============
208208
| Environment | Django/Flask | Default | Example
209-
| `ELASTIC_APM_CLOUD_PROVIDER` | `CLOUD_PROVIDER` | `True` | `"aws"`
209+
| `ELASTIC_APM_CLOUD_PROVIDER` | `CLOUD_PROVIDER` | `"auto"` | `"aws"`
210210
|============
211211

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

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

219219
[float]
220220
[[config-secret-token]]

elasticapm/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,9 @@ def get_cloud_info(self):
365365
Detects if the app is running in a cloud provider and fetches relevant
366366
metadata from the cloud provider's metadata endpoint.
367367
"""
368-
provider = self.config.cloud_provider
368+
provider = str(self.config.cloud_provider).lower()
369369

370-
if not provider:
370+
if not provider or provider == "none" or provider == "false":
371371
return {}
372372
if provider == "aws":
373373
data = cloud.aws_metadata()
@@ -384,7 +384,7 @@ def get_cloud_info(self):
384384
if not data:
385385
self.logger.warning("Cloud provider {0} defined, but no metadata was found.".format(provider))
386386
return data
387-
else:
387+
elif provider == "auto" or provider == "true":
388388
# Trial and error
389389
data = {}
390390
data = cloud.aws_metadata()
@@ -395,6 +395,9 @@ def get_cloud_info(self):
395395
return data
396396
data = cloud.azure_metadata()
397397
return data
398+
else:
399+
self.logger.warning("Unknown value for CLOUD_PROVIDER, skipping cloud metadata: {}".format(provider))
400+
return {}
398401

399402
def build_metadata(self):
400403
data = {

0 commit comments

Comments
 (0)