-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update logcollector telemetry with common properties #3242
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
from heapq import heappush, heappop | ||
|
||
from azurelinuxagent.common.conf import get_lib_dir, get_ext_log_dir, get_agent_log_file | ||
from azurelinuxagent.common.event import initialize_event_logger_vminfo_common_parameters | ||
from azurelinuxagent.common.event import initialize_event_logger_vminfo_common_parameters, add_event, WALAEventOperation | ||
from azurelinuxagent.common.future import ustr | ||
from azurelinuxagent.ga.logcollector_manifests import MANIFEST_NORMAL, MANIFEST_FULL | ||
|
||
|
@@ -76,7 +76,6 @@ def __init__(self, is_full_mode=False): | |
self._must_collect_files = self._expand_must_collect_files() | ||
self._create_base_dirs() | ||
self._set_logger() | ||
self._initialize_telemetry() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now done in the azurelinuxagent.agent.Agent.collect_logs |
||
|
||
@staticmethod | ||
def _mkdir(dirname): | ||
|
@@ -104,7 +103,7 @@ def _set_logger(): | |
_LOGGER.setLevel(logging.INFO) | ||
|
||
@staticmethod | ||
def _initialize_telemetry(): | ||
def initialize_telemetry(): | ||
protocol = get_protocol_util().get_protocol(init_goal_state=False) | ||
protocol.client.reset_goal_state(goal_state_properties=GoalStateProperties.RoleConfig | GoalStateProperties.HostingEnv) | ||
# Initialize the common parameters for telemetry events | ||
|
@@ -326,7 +325,9 @@ def _get_final_list_for_archive(self, priority_file_queue): | |
if e.errno == 2: # [Errno 2] No such file or directory | ||
_LOGGER.warning("File %s does not exist, skipping collection for this file", file_path) | ||
|
||
_LOGGER.info("Uncompressed archive size is %s b", total_uncompressed_size) | ||
msg = "Uncompressed archive size is {0} b".format(total_uncompressed_size) | ||
_LOGGER.info(msg) | ||
add_event(op=WALAEventOperation.LogCollection, message=msg) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding this event before the process enters the main loop in an effort to collect this info for runs that fail due to mem limit exceeded |
||
|
||
return final_files_to_collect, total_uncompressed_size | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,9 +211,8 @@ def test_log_collector_parses_commands_in_manifest(self): | |
diskinfo,""".format(folder_to_list, file_to_collect) | ||
|
||
with patch("azurelinuxagent.ga.logcollector.MANIFEST_NORMAL", manifest): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These unit tests mocked _initialize_telemetry because it was in LogCollector init. Now that it has been removed from init, the mock is not necessary |
||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
with open(self.output_results_file_path, "r") as fh: | ||
results = fh.readlines() | ||
|
@@ -241,9 +240,8 @@ def test_log_collector_uses_full_manifest_when_full_mode_enabled(self): | |
""".format(file_to_collect) | ||
|
||
with patch("azurelinuxagent.ga.logcollector.MANIFEST_FULL", manifest): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector(is_full_mode=True) | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector(is_full_mode=True) | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
self._assert_archive_created(archive) | ||
self._assert_files_are_in_archive(expected_files=[file_to_collect]) | ||
|
@@ -256,9 +254,8 @@ def test_log_collector_should_collect_all_files(self): | |
# All files in the manifest should be collected, since none of them are over the individual file size limit, | ||
# and combined they do not cross the archive size threshold. | ||
|
||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
self._assert_archive_created(archive) | ||
|
||
|
@@ -282,9 +279,8 @@ def test_log_collector_should_collect_all_files(self): | |
def test_log_collector_should_truncate_large_text_files_and_ignore_large_binary_files(self): | ||
# Set the size limit so that some files are too large to collect in full. | ||
with patch("azurelinuxagent.ga.logcollector._FILE_SIZE_LIMIT", SMALL_FILE_SIZE): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
self._assert_archive_created(archive) | ||
|
||
|
@@ -323,9 +319,8 @@ def test_log_collector_should_prioritize_important_files_if_archive_too_big(self | |
|
||
with patch("azurelinuxagent.ga.logcollector._UNCOMPRESSED_ARCHIVE_SIZE_LIMIT", 10 * 1024 * 1024): | ||
with patch("azurelinuxagent.ga.logcollector._MUST_COLLECT_FILES", must_collect_files): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
self._assert_archive_created(archive) | ||
|
||
|
@@ -382,9 +377,8 @@ def test_log_collector_should_prioritize_important_files_if_archive_too_big(self | |
def test_log_collector_should_update_archive_when_files_are_new_or_modified_or_deleted(self): | ||
# Ensure the archive reflects the state of files on the disk at collection time. If a file was updated, it | ||
# needs to be updated in the archive, deleted if removed from disk, and added if not previously seen. | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
first_archive, first_uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
first_archive, first_uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
self._assert_archive_created(first_archive) | ||
|
||
# Everything should be in the archive | ||
|
@@ -461,9 +455,8 @@ def test_log_collector_should_clean_up_uncollected_truncated_files(self): | |
with patch("azurelinuxagent.ga.logcollector._UNCOMPRESSED_ARCHIVE_SIZE_LIMIT", 2 * SMALL_FILE_SIZE): | ||
with patch("azurelinuxagent.ga.logcollector._MUST_COLLECT_FILES", must_collect_files): | ||
with patch("azurelinuxagent.ga.logcollector._FILE_SIZE_LIMIT", SMALL_FILE_SIZE): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
archive, uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
self._assert_archive_created(archive) | ||
|
||
|
@@ -490,9 +483,8 @@ def test_log_collector_should_clean_up_uncollected_truncated_files(self): | |
with patch("azurelinuxagent.ga.logcollector._UNCOMPRESSED_ARCHIVE_SIZE_LIMIT", 2 * SMALL_FILE_SIZE): | ||
with patch("azurelinuxagent.ga.logcollector._MUST_COLLECT_FILES", must_collect_files): | ||
with patch("azurelinuxagent.ga.logcollector._FILE_SIZE_LIMIT", SMALL_FILE_SIZE): | ||
with patch('azurelinuxagent.ga.logcollector.LogCollector._initialize_telemetry'): | ||
log_collector = LogCollector() | ||
second_archive, second_uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
log_collector = LogCollector() | ||
second_archive, second_uncompressed_file_size = log_collector.collect_logs_and_get_archive() | ||
|
||
expected_files = [ | ||
os.path.join(self.root_collect_dir, "waagent.log"), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously this was happening in LogCollector init.
We don't initialize the LogCollector until after cgroup checks, which resulted in all cgroup check events having initialized common properties (see PR description)