-
Notifications
You must be signed in to change notification settings - Fork 196
feat(spec/parser): new spec and parser for AnsibleTelemetry #4589
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
base: master
Are you sure you want to change the base?
Conversation
- New spec to collect command "/usr/share/ansible/telemetry/telemetry.py" - New AnsibleTelemetry to parse the command - Jira: RHINENG-20964 Signed-off-by: Xiangce Liu <xiangceliu@redhat.com>
Reviewer's GuideThis PR implements full support for collecting and parsing Ansible telemetry data by registering a new spec, wiring it into the default specs, providing a JSON‐based parser, accompanying unit tests, and a documentation placeholder, along with small formatting refinements in existing spec definitions. ER diagram for parsed Ansible telemetry data structureerDiagram
COLLECTIONS {
string ansible_builtin
string version
JSON resources
}
RESOURCES {
JSON action
JSON connection
}
ACTION {
int add_host
int uri
int set_fact
int debug
int find
int file
int template
int command
}
CONNECTION {
int local
int ssh
}
ANSIBLE_CORE {
string version
}
HOSTS {
int count
}
COLLECTIONS ||--|{ RESOURCES : contains
RESOURCES ||--|{ ACTION : contains
RESOURCES ||--|{ CONNECTION : contains
COLLECTIONS ||--|{ ANSIBLE_CORE : has
COLLECTIONS ||--|{ HOSTS : has
Class diagram for the new AnsibleTelemetry parserclassDiagram
class AnsibleTelemetry {
<<CommandParser>>
<<JSONParser>>
+__init__()
+parse()
+data: dict
}
AnsibleTelemetry --|> CommandParser
AnsibleTelemetry --|> JSONParser
CommandParser <|-- JSONParser
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes - here's some feedback:
- The new docs/shared_parsers_catalog/ansible.rst is empty; please populate it with usage and examples for the AnsibleTelemetry parser.
- Consider adding convenience properties or helper methods to AnsibleTelemetry to simplify common lookups (e.g. retrieving collection versions or host counts) rather than relying solely on raw dict access.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new docs/shared_parsers_catalog/ansible.rst is empty; please populate it with usage and examples for the AnsibleTelemetry parser.
- Consider adding convenience properties or helper methods to AnsibleTelemetry to simplify common lookups (e.g. retrieving collection versions or host counts) rather than relying solely on raw dict access.
## Individual Comments
### Comment 1
<location> `insights/tests/parsers/test_ansible.py:45-50` </location>
<code_context>
+""".strip()
+
+
+def test_ansible_telemetry():
+ ret = ansible.AnsibleTelemetry(context_wrap(AT_INPUT))
+ assert ret['hosts']['count'] == 44
+
+ with pytest.raises(ContentException):
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding tests for additional edge cases and malformed JSON input.
Tests currently focus on valid input and a specific error. Please add cases for empty input, malformed JSON, and unexpected structures to verify robust error handling.
```suggestion
def test_ansible_telemetry():
ret = ansible.AnsibleTelemetry(context_wrap(AT_INPUT))
assert ret['hosts']['count'] == 44
with pytest.raises(ContentException):
ansible.AnsibleTelemetry(context_wrap(AT_INPUT_NG))
def test_ansible_telemetry_empty_input():
with pytest.raises(ContentException):
ansible.AnsibleTelemetry(context_wrap(""))
def test_ansible_telemetry_malformed_json():
malformed_json = "{'hosts': 44" # missing closing brace, single quotes
with pytest.raises(ContentException):
ansible.AnsibleTelemetry(context_wrap(malformed_json))
def test_ansible_telemetry_unexpected_structure():
unexpected_json = '{"unexpected_key": {"foo": "bar"}}'
with pytest.raises(ContentException):
ansible.AnsibleTelemetry(context_wrap(unexpected_json))
```
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4589 +/- ##
==========================================
- Coverage 89.03% 89.03% -0.01%
==========================================
Files 722 723 +1
Lines 33310 33317 +7
Branches 4940 4940
==========================================
+ Hits 29659 29664 +5
- Misses 2922 2923 +1
- Partials 729 730 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
All Pull Requests:
Check all that apply:
3.0_egg
? Yes, refer to RPM/Egg Delivery to open a new PR.master
? Yes, this is a backport of #PR-IDComplete Description of Additions/Changes:
Add your description here
Summary by Sourcery
Introduce a new AnsibleTelemetry spec and parser to collect and process Ansible telemetry data, along with associated tests and documentation.
New Features:
Enhancements: