Skip to content

Commit

Permalink
Log cloud metadata provider failures at trace level (#1338)
Browse files Browse the repository at this point in the history
This commit logs the cloud metadata provider failures
at the trace level and adds more detail to the log message.

Closes #1283
  • Loading branch information
russcam authored Jun 18, 2021
1 parent 708ece0 commit 2368354
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/Elastic.Apm/Cloud/AwsCloudMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ internal AwsCloudMetadataProvider(IApmLogger logger, HttpMessageHandler handler)
}
catch (Exception e)
{
_logger.Info()?.LogException(e, "Unable to get {Provider} cloud metadata", Provider);
_logger.Trace()?.LogException(
e,
"Unable to get {Provider} cloud metadata. The application is likely not running in {Provider}", Provider);
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Apm/Cloud/AzureAppServiceMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool NullOrEmptyVariable(string key, string value)
if (!string.IsNullOrEmpty(value)) return false;

_logger.Trace()?.Log(
"Unable to get {Provider} cloud metadata as no {EnvironmentVariable} environment variable",
"Unable to get {Provider} cloud metadata as no {EnvironmentVariable} environment variable. The application is likely not running in {Provider}",
Provider,
key);

Expand Down
4 changes: 3 additions & 1 deletion src/Elastic.Apm/Cloud/AzureCloudMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ internal AzureCloudMetadataProvider(IApmLogger logger, HttpMessageHandler handle
}
catch (Exception e)
{
_logger.Info()?.LogException(e, "Unable to get {Provider} cloud metadata", Provider);
_logger.Trace()?.LogException(
e,
"Unable to get {Provider} cloud metadata. The application is likely not running in {Provider}", Provider);
return null;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Elastic.Apm/Cloud/GcpCloudMetadataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ internal GcpCloudMetadataProvider(IApmLogger logger, HttpMessageHandler handler)
}
catch (Exception e)
{
_logger.Info()?.LogException(e, "Unable to get {Provider} cloud metadata", Provider);
_logger.Trace()?.LogException(
e,
"Unable to get {Provider} cloud metadata. The application is likely not running in {Provider}", Provider);
return null;
}
}
Expand Down

0 comments on commit 2368354

Please sign in to comment.