Skip to content

Commit

Permalink
FIX: resilient environment settings (#825)
Browse files Browse the repository at this point in the history
if the application uses generalimport to manage optional depedencies,
it's possible that generalimport.MissingOptionalDependency is raised.
In this case, we should not report the module as it is not actually loaded and
is not a runtime dependency of the application.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Hannah Stepanek <[email protected]>
  • Loading branch information
3 people authored Jun 27, 2023
1 parent db07523 commit c2fd5e3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion newrelic/core/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,15 @@ def environment_settings():

# If the module isn't actually loaded (such as failed relative imports
# in Python 2.7), the module will be None and should not be reported.
if not module:
try:
if not module:
continue
except Exception:
# if the application uses generalimport to manage optional depedencies,
# it's possible that generalimport.MissingOptionalDependency is raised.
# In this case, we should not report the module as it is not actually loaded and
# is not a runtime dependency of the application.
#
continue

# Exclude standard library/built-in modules.
Expand Down

0 comments on commit c2fd5e3

Please sign in to comment.