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

T2viz UI metrics #312

Merged
merged 6 commits into from
Sep 27, 2024
Merged

T2viz UI metrics #312

merged 6 commits into from
Sep 27, 2024

Conversation

ruanyl
Copy link
Member

@ruanyl ruanyl commented Sep 14, 2024

Description

[Describe what this change achieves]

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test.
  • New functionality has user manual doc added.
  • Commits are signed per the DCO using --signoff.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Sep 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.65%. Comparing base (4e68047) to head (ce386b6).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #312      +/-   ##
==========================================
+ Coverage   88.59%   88.65%   +0.06%     
==========================================
  Files          60       61       +1     
  Lines        1710     1728      +18     
  Branches      419      426       +7     
==========================================
+ Hits         1515     1532      +17     
- Misses        193      194       +1     
  Partials        2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -111,14 +127,23 @@ export const Text2Viz = () => {
});
} else {
setEditorInput(JSON.stringify(result, undefined, 4));

// Report metric when visualization generated successfully
if (usageCollection) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use METRIC_TYPE.COUNT to either record a 1 for success or 0 for failure. We could calculate average to get success rate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, it doesn't record the failures. If we do need to record the failures, I'd rather use another event type, like:

  usageCollection.reportUiStats(
    VIS_NLQ_APP_ID,
    usageCollection.METRIC_TYPE.LOADED,
    `generate_failed-${uuidv4()}`
  );

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean we could use the same metric, and emit 0 when fails, 1 when succeeds. Like

try {
 const response = await fetch();
emitMetric("fetch_success", COUNT, 1);
} catch( err: any) {
emitMetric("fetch_success", COUNT, 0);
}

We always ensure that we emit one time for a fetch, it's either 1 or 0.

@@ -410,6 +444,13 @@ export const Text2Viz = () => {
paddingSize="none"
scrollable={false}
>
{usageCollection ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC, usageCollection is always available, the feature flag only controls whether it can send metrics to server.

Copy link
Member Author

Choose a reason for hiding this comment

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

usageCollection is declared as an optional plugin of dashboards-assistant plugin. Theoretically, it can be undefined.

}

export const FeedbackThumbs = ({ usageCollection, appName, className }: Props) => {
const [feedback, setFeedback] = useState<'thumbs_up' | 'thumbs_down' | undefined>();
Copy link
Contributor

Choose a reason for hiding this comment

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

If visualization is regenerated, will feedback be reset?

Copy link
Member Author

@ruanyl ruanyl Sep 14, 2024

Choose a reason for hiding this comment

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

Yes, it will reset because the FeedbackThumbs component will be re-rendered.

Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Signed-off-by: Yulong Ruan <[email protected]>
Comment on lines +22 to +23
right: 16px;
top: 4px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: $euiSize is 16px

Comment on lines +273 to +278
if (usageCollection) {
usageCollection.reportUiStats(
VIS_NLQ_APP_ID,
usageCollection.METRIC_TYPE.LOADED,
`saved-${uuidv4()}`
);
Copy link
Collaborator

@Hailong-am Hailong-am Sep 27, 2024

Choose a reason for hiding this comment

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

out of curiosity, how we are going to use those metrics? For example, how to get the statics of how many user save the visualization? the event name is with a uuid, sounds like not suitable for aggregation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we don't need it any more? @chishui any idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we don't need it any more?

You mean uuid or metric itself? We need both

Comment on lines +41 to +42
tap(() => this.status$.next('RUNNING')),
debounceTime(200)
Copy link
Collaborator

Choose a reason for hiding this comment

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

any reason for changing the order?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes, it causes UI flashing.

@ruanyl ruanyl merged commit 519bb92 into opensearch-project:main Sep 27, 2024
9 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 27, 2024
* Add metrics for text2viz

Signed-off-by: Yulong Ruan <[email protected]>

* remove new line at the end of file

Signed-off-by: Yulong Ruan <[email protected]>

* fix imported types

Signed-off-by: Yulong Ruan <[email protected]>

* update changelogs

Signed-off-by: Yulong Ruan <[email protected]>

* fix UI flashing

Signed-off-by: Yulong Ruan <[email protected]>

* cleanup duplicate imports

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
(cherry picked from commit 519bb92)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
ruanyl pushed a commit that referenced this pull request Sep 27, 2024
* Add metrics for text2viz

Signed-off-by: Yulong Ruan <[email protected]>

* remove new line at the end of file

Signed-off-by: Yulong Ruan <[email protected]>

* fix imported types

Signed-off-by: Yulong Ruan <[email protected]>

* update changelogs

Signed-off-by: Yulong Ruan <[email protected]>

* fix UI flashing

Signed-off-by: Yulong Ruan <[email protected]>

* cleanup duplicate imports

Signed-off-by: Yulong Ruan <[email protected]>

---------

Signed-off-by: Yulong Ruan <[email protected]>
(cherry picked from commit 519bb92)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Trigger the backport flow to 2.x t2viz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants