Skip to content
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
89203b0
Change loaded modules to go one at a time
lrafeei Feb 25, 2026
11aaece
Merge branch 'main' into loaded-modules-fix
lrafeei Feb 25, 2026
2454063
Send individual plugin inside list
lrafeei Feb 26, 2026
b93898c
Reset plugin generator for reconnect
lrafeei Mar 3, 2026
c99e785
[MegaLinter] Apply linters fixes
lrafeei Mar 3, 2026
dd0cca6
Clarify comment
lrafeei Mar 3, 2026
bcbfad4
Merge branch 'main' into loaded-modules-fix
lrafeei Mar 6, 2026
2a32b43
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 7, 2026
8cfbb0d
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 9, 2026
28993c2
Revert to original logic (with bug fixes)
lrafeei Mar 10, 2026
c2031f1
[MegaLinter] Apply linters fixes
lrafeei Mar 10, 2026
515b5b7
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 10, 2026
c6be361
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 10, 2026
8c476a0
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 12, 2026
8d38018
Tweak logic for package reporting
lrafeei Mar 12, 2026
d4d0262
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 12, 2026
ed8ad69
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 12, 2026
53af784
Remove time constraint completely for first iteration
lrafeei Mar 16, 2026
89594b4
[MegaLinter] Apply linters fixes
lrafeei Mar 16, 2026
7265f2f
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 18, 2026
4968e64
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 23, 2026
3808b05
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 24, 2026
8cc9f6c
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 25, 2026
d06ae42
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 26, 2026
c4f906c
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 26, 2026
133c954
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 27, 2026
7628eb2
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 30, 2026
ad8bccc
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 30, 2026
78f0512
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 30, 2026
63f579c
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 30, 2026
2c2a62e
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 30, 2026
8961d8c
Merge branch 'main' into loaded-modules-fix
mergify[bot] Mar 31, 2026
467cc52
Merge branch 'main' into loaded-modules-fix
mergify[bot] Apr 8, 2026
e6f1559
Merge branch 'main' into loaded-modules-fix
mergify[bot] Apr 13, 2026
d6aecbe
Merge branch 'main' into loaded-modules-fix
mergify[bot] Apr 14, 2026
7b7cf99
Merge branch 'main' into loaded-modules-fix
mergify[bot] Apr 15, 2026
935f0c5
Merge branch 'main' into loaded-modules-fix
mergify[bot] Apr 15, 2026
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
56 changes: 19 additions & 37 deletions newrelic/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

_logger = logging.getLogger(__name__)

MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 2.0
MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 3.0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 3.0
MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST = 2.0



class Application:
Expand Down Expand Up @@ -105,8 +105,6 @@ def __init__(self, app_name, linked_applications=None):
self._data_samplers_lock = threading.Lock()
self._data_samplers_started = False

self._remaining_plugins = True

self._agent_control_health_thread = threading.Thread(
name="Agent-Control-Health-Session-Thread", target=agent_control_healthcheck_loop
)
Expand Down Expand Up @@ -1284,27 +1282,13 @@ def harvest(self, shutdown=False, flexible=False):
data_sampler.name,
)

# Send environment plugin list

stopwatch_start = time.time()
while (
configuration
and configuration.package_reporting.enabled
and self._remaining_plugins
and ((time.time() - stopwatch_start) < MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST)
):
try:
module_info = next(self.plugins)
self.modules.append(module_info)
except StopIteration:
self._remaining_plugins = False

# Send the accumulated environment plugin list if not empty
if self.modules:
self._active_session.send_loaded_modules(self.modules)

# Reset the modules list every harvest cycle
self.modules = []
# Send environment plugin.
if self.configuration and self.configuration.package_reporting.enabled:
start = time.time()
while package := next(self.plugins, False):
self._active_session.send_loaded_modules([package])
if (time.time() - start) < MAX_PACKAGE_CAPTURE_TIME_PER_SLOW_HARVEST:
break

# Add a metric we can use to track how many harvest
# periods have occurred.
Expand Down Expand Up @@ -1741,19 +1725,14 @@ def internal_agent_shutdown(self, restart=False):

self.stop_data_samplers()

# Finishes collecting environment plugin information
# if this has not been completed during harvest
# lifetime of the application

while self.configuration and self.configuration.package_reporting.enabled and self._remaining_plugins:
try:
module_info = next(self.plugins)
self.modules.append(module_info)
except StopIteration:
self._remaining_plugins = False
if self.modules:
self._active_session.send_loaded_modules(self.modules)
self.modules = []
# Finishes collecting environment plugin information if this has
# not been completed during harvest lifetime of the application.
if self.configuration and self.configuration.package_reporting.enabled:
# Anything that was left in the plugins
# generator will be resolved here.
plugins_list = list(self.plugins)
if plugins_list:
self._active_session.send_loaded_modules(plugins_list)

# Now shutdown the actual agent session.

Expand All @@ -1776,6 +1755,9 @@ def internal_agent_shutdown(self, restart=False):
# as shutdown.

if restart:
# Reset package/module generator
self.plugins = plugins()

self._agent_restart += 1
self.activate_session()

Expand Down
Loading