Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spans): Add role level spans, item spans, rework test #22

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

louisquentinjoucla
Copy link
Contributor

@louisquentinjoucla louisquentinjoucla commented Jun 26, 2022

馃憢 !

Close #18
Close #1
Close #23

Rework tests to take in account there can be multiple duration events with the same uuid
As we are lacking of callback this is mostly hack atm

Here some examples:
image
image

And here an use case:

image

Sorry for the noise, with all tests will fix it asap,
Waiting for your review !

refactor(plugin): apply pep8 recommendations

fix(test): correct module name

fix(test): c: dont use community modules
@louisquentinjoucla louisquentinjoucla marked this pull request as draft June 26, 2022 07:04
@louisquentinjoucla louisquentinjoucla marked this pull request as ready for review June 26, 2022 07:21

return (hosts, duration_events, duration_stacks)
return (hosts, duration_events)


def add_duration_event(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

only this sub really changed

@@ -243,7 +244,7 @@ def _start_role_span(self, host, role):
"id": abs(hash(role._uuid)),
"args": {
"role": name,
"path": role.get_path(),
"path": role._role_path,
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not much of a python programmer: how legit/good/frowned-upon is it to use underscore variables? They're nominally-private, right? I suppose this could break in future versions? But it's the only way to get this data on old Ansible?

I wonder if we could check if get_path function exists and use it, falling back to this otherwise? WDYT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these are private fields. Function get_path for role does not exists under 2.12 core. So yea this could break in futur version.

I will try to remove usage of private var when possible.

@@ -12,7 +12,7 @@
@pytest.mark.ansible_strategy('free')
def test_basic_multiple_free(ansible_play):
trace_hosts: Dict[int, HostEvent]
trace_events: Dict[int, Any]
trace_events: Dict[int, List[List[Any]]]
Copy link
Owner

Choose a reason for hiding this comment

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

I think this is getting complex enough (and repeated enough) that it might be worth declaring a named type for these, WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I agree

# Write end event
self._write_event({
"name": self._current_play.get_name().strip(),
"cat": "play",
"id": self._play_id,
"id": abs(hash(self._current_play._uuid)),
Copy link
Owner

Choose a reason for hiding this comment

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

Why hash + abs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll admit I copy/pasted this one to stay coherent. But I guess it was for shorter iand more distinct id

self._end_play_span()
self._f.write("\n]")
self._f.close()


@dataclass
@ dataclass
Copy link
Owner

Choose a reason for hiding this comment

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

is a space here normal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's autopep8 lint. I do not know pep8 by heart, so I will double check

if task._role is not None:

# Still in current role, nothing to do
if(self._hosts[host._uuid].role_stack and
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not a python style expert, but isn't it normal to have a space after the if ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be the autopep8 or just me when wrapping, if its not lint, I can change that.

@@ -12,14 +12,15 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
Copy link
Owner

Choose a reason for hiding this comment

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

General comment: There's a lot of changes in this commit; would it be possible to split out the reformatting from the actual new changes? If not, no worries, it'll just take me a bit longer to review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I know it was too much when I read the changes, I'll split it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong time compute Add role level Add trace spans for items
2 participants