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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Success markers telemetry #10065

Merged
merged 20 commits into from
Nov 5, 2021
Merged

Success markers telemetry #10065

merged 20 commits into from
Nov 5, 2021

Conversation

alwx
Copy link
Contributor

@alwx alwx commented Nov 2, 2021

Proposed changes:

Status (please check what you already did):

  • added some tests for the functionality
  • updated the documentation
  • updated the changelog (please check changelog for instructions)
  • reformat files using black (please check Readme for instructions)

@alwx alwx requested review from usc-m and aeshky November 2, 2021 17:36
@alwx alwx requested a review from a team as a code owner November 2, 2021 17:36
@alwx
Copy link
Contributor Author

alwx commented Nov 2, 2021

This PR adds events specified in this comment: #9830 (comment)

Copy link
Contributor

@usc-m usc-m left a comment

Choose a reason for hiding this comment

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

Not 100% sure if we should be referring to as "Markers Evaluation" - maybe "Evaluation - Success Markers" (@aeshky @ka-bu any opinions?). Otherwise looks good though!

]
},
"Markers Stats Computed": {
"description": "Triggered when marker stats has been computed.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Triggered when marker stats has been computed.",
"description": "Triggered when marker stats have been computed.",

docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
rasa/cli/evaluate.py Outdated Show resolved Hide resolved
Copy link
Contributor

@aeshky aeshky left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @alwx.
Are we not tracking the number of markers defined? (I can see that it's not in the final list here). If not, why did we decide to drop it? It's informative because it tells us whether users have 1-2 KPIs or are abusing the feature by defining dozens of things to track.

docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
Comment on lines 450 to 455
"required": [
"count"
]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is saying that count is required, however, it's only required when strategy is first_n or sample. Or am I misunderstanding how this is used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's a mistake, fixed it in the latest commit.

docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
changelog/10065.misc.md Outdated Show resolved Hide resolved
docs/docs/telemetry/events.json Outdated Show resolved Hide resolved
@@ -123,6 +124,10 @@ def _run_markers(
stats_file: (Optional) Path to write out statistics about the extracted
markers.
"""
telemetry.track_markers_evaluation_initiated(
Copy link
Contributor

Choose a reason for hiding this comment

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

different name suggestion: track_evaluate_markers_initiated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the event is now called "Markers Extraction Initiated" (based on one of your suggestions) so I renamed this function to have a similar name

@aeshky
Copy link
Contributor

aeshky commented Nov 2, 2021

@usc-m sorry I didn't read your comment until after I finished my review:

Not 100% sure if we should be referring to as "Markers Evaluation" - maybe "Evaluation - Success Markers"

I made a similar observation but suggested a different name. I like your suggestion: "Evaluation - Success Markers"

@alwx alwx requested review from usc-m and aeshky November 3, 2021 09:26
@alwx
Copy link
Contributor Author

alwx commented Nov 3, 2021

Re-requesting your review because I changed all the names and fixed the issue with required in events.json.

Are we not tracking the number of markers defined?

I think we can do this if it makes sense. When does this event need to be tracked?

@aeshky
Copy link
Contributor

aeshky commented Nov 3, 2021

Are we not tracking the number of markers defined?

I think we can do this if it makes sense. When does this event need to be tracked?

What I mean is the number of markers in the config file. So as soon as the config file is processed we would know the number of markers. I can dig into the code to see where this happens.

@usc-m anything else you want to track? You suggested a measure of marker complexity. It's a good idea, but maybe not as trivial to implement so maybe we can add it later. What do you think?

@usc-m
Copy link
Contributor

usc-m commented Nov 3, 2021

What I mean is the number of markers in the config file. So as soon as the config file is processed we would know the number of markers. I can dig into the code to see where this happens.

Number of markers in the config file should be a matter of counting the number of sub-markers of the marker returned from Marker.from_config in the CLI code I believe. (so len(markers.sub_markers) in _run_markers in rasa\cli\evaluate.py)

@usc-m anything else you want to track? You suggested a measure of marker complexity. It's a good idea, but maybe not as trivial to implement so maybe we can add it later. What do you think?

Not strictly necessary but something like maximum depth of nested markers, or how wide they get (maximum number of sub-markers under a marker that isn't top-level). Don't think these would be hard to add but also aren't as necessary - I think we'd get some useful info out about how the feature is used but it's something we could add later perhaps?

@aeshky
Copy link
Contributor

aeshky commented Nov 3, 2021

Not strictly necessary but something like maximum depth of nested markers, or how wide they get (maximum number of sub-markers under a marker that isn't top-level). Don't think these would be hard to add but also aren't as necessary

It tells us how complex the conditions get, and thus how people are using (or potentially abusing?) Markers.

I think we'd get some useful info out about how the feature is used but it's something we could add later perhaps?

Definitely useful but not urgent. Let's just count how many Markers are defined for now 👍

Comment on lines +450 to +454
"required": [
"strategy",
"only_extract",
"seed",
"count"
Copy link
Contributor

Choose a reason for hiding this comment

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

@usc-m are all of these required? 🤔 or just the top two?

Copy link
Contributor

Choose a reason for hiding this comment

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

From the perspective of telemetry I think it makes sense - we'd want to know if it's being used or not. The types of those are string or null so if it's not present we'd see an explicit null. Would be good to check with someone who understands the telemetry schema here better (though I think this is only used in the docs to explain what data we send back to users and isn't used to actually validate anything internally)

]
},
"Markers Stats Computed": {
"description": "Triggered when marker stats has been computed.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"description": "Triggered when marker stats has been computed.",
"description": "Triggered when marker statistics have been computed.",

Copy link
Contributor

@aeshky aeshky Nov 3, 2021

Choose a reason for hiding this comment

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

Let's use the full word in text, and reserve "stats" for code :)

@usc-m
Copy link
Contributor

usc-m commented Nov 3, 2021

OK, I think I've added the extra telemetry. Is there any other changes we need to make? Anything more to collect, names all fine etc.?

{
"strategy": strategy,
"only_extract": only_extract,
"seed": seed,
Copy link
Contributor

Choose a reason for hiding this comment

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

This will report the actual seed used by the user - do we want the actual seed or do we want to just know if they used a seed? Is this something that's worth changing or are we considering the actual seed value not important enough to be careful about not collecting?

Copy link
Contributor

Choose a reason for hiding this comment

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

We only want to know if the user set a seed. I don't think it counts as private info so maybe it doesn't matter if we collect it. But if we can do true/false that might be better.

@@ -139,6 +147,10 @@ def _run_markers(
"Please see errors listed above and fix before running again."
)

# Subtract one to remove the virtual OR over all markers
num_markers = len(markers) - 1
Copy link
Contributor

@ka-bu ka-bu Nov 3, 2021

Choose a reason for hiding this comment

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

this is the total number of all conditions and operators used in all marker configurations that were evaluated -- to get the number of user-defined markers we should

  1. get rid of the special case here and always add an "ANY_MARKER
  2. len(markers.sub_markers) instead of len(markers) ... My bad, iter gives us all conditions and operators but len is just the sub-markers all good 👍 - but because of 1. there might not be sub-markers if there is a single user defined marker

Copy link
Contributor

Choose a reason for hiding this comment

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

@usc-m , I could help and add that while you work on other comments if you like?

Copy link
Contributor

Choose a reason for hiding this comment

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

we could also track something like max( len(sub_marker) for sub_marker in markers), i.e. the maximum number of conditions and operators used in a single user defined marker, to get a glimpse of how complex the queries are

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I suggested that too, also the branching factor (maximum number of children under any marker)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, that's also a nice idea -- will definitely tell us if people miss begin able to re-use a marker definition

@@ -608,6 +609,9 @@ def evaluate_trackers(
if tracker:
tracker_result = self.evaluate_events(tracker.events)
processed_trackers[tracker.sender_id] = tracker_result

processed_trackers_count = len(processed_trackers)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want the number of processed trackers or processed sessions (or both)?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think in this case processed trackers is actually useful because we get it before, as a command line argument (the users intent) and after (what they actually got). Might help to highlight issues in our models of how tracker stores work. Right now we don't collect session info anywhere so I'm not sure what info we could get from it, but we could also just collect it as well if you think it would be useful

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no clue how people use sender_ids and trackers usually, so no idea if that is better - but I guess it won't hurt if we don't add this now (and maybe later)

@usc-m usc-m requested review from ka-bu and aeshky November 3, 2021 16:37
telemetry.track_markers_parsed_count(num_markers)
max_depth = markers.depth() - 1
# Find maximum branching of marker
branching_factor = max(len(marker) - 1 for marker in markers)
Copy link
Contributor

Choose a reason for hiding this comment

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

branching_factor = max(len(sub_marker) - 1 for marker in markers.sub_markers for for sub_marker in marker) to exclude the artificial Or marker?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yep, otherwise we can end up with cases where the number of markers (which we already get) is returned twice - good spot

Copy link
Contributor

@ka-bu ka-bu left a comment

Choose a reason for hiding this comment

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

LGTM

@usc-m usc-m enabled auto-merge (squash) November 3, 2021 16:53
Copy link
Contributor

@aeshky aeshky left a comment

Choose a reason for hiding this comment

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

Looks good. There are still a couple of unresolved typos. Did you miss them? (one spotted by you even 😄)

@usc-m usc-m merged commit 8e922dd into main Nov 5, 2021
@usc-m usc-m deleted the markers-telemetry branch November 5, 2021 12:50
srinivasupadhya pushed a commit to srinivasupadhya/rasa that referenced this pull request Nov 8, 2021
* Markers telemetry

* Everything without tests

* Specified events.json

* Test added

* Changelog entry

* Naming fixes

* Fix lint, fix CLI bug

No way to actually change config path, now fixed with nargs

* Add markers parsed telemetry

* Document telemetry functions

* always add ANY_MARKER; add test

* Add complexity telemetry

* Skip root marker to avoid double reporting total marker count

Co-authored-by: Matthew Summers <m.summers@rasa.com>
Co-authored-by: ka-bu <kathrin.bujna@gmail.com>
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.

Success makers: telemetry
4 participants