Skip to content

Conversation

@ChinYing-Li
Copy link
Contributor

@ChinYing-Li ChinYing-Li commented Aug 7, 2021

Pull Request checklist

  • Quality: Make sure this PR builds and runs cleanly.
    • Inside the glean/ folder, run:
      • npm run test Runs all tests
      • npm run lint Runs all linters
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry to CHANGELOG.md or an explanation of why it does not need one
  • Documentation: This PR includes documentation changes, an explanation of why it does not need that or a follow-up bug has been filed to do that work

Currently one unit test case and schema test fails. Opening a draft and is not ready for review.
EDIT: PR now ready for review; For StringMetricType, I have to declare add as async.

@brizental
Copy link
Contributor

Hey @ChinYing-Li , just FYI I am on PTO this week and will come back to review this PR on Monday! Thank you for seding this in and sorry for the delayed response 👋

Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

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

Great work here @ChinYing-Li ! This is definitely on the right path, nothing major is wrong and the apporach is correct. Left a few comments, let me know if you have any questions.

@brizental
Copy link
Contributor

Currently one unit test case and schema test fails. Opening a draft and is not ready for review.

Heh, just saw this comment. Left a review anyways, hope it is helpful.

Regarding the schema test, it's possible it is failing because of the stringlist -> string_list change I requested in the review. The Glean schema is expecting the payload to contain string_list with the underline and anything different should cause a schema error.

@ChinYing-Li ChinYing-Li changed the title Draft: Bug 1716956: Initial attempt to implement metric type "StringList" Bug 1716956: Initial attempt to implement metric type "StringList" Aug 21, 2021
@ChinYing-Li
Copy link
Contributor Author

ChinYing-Li commented Aug 21, 2021

Without async means I have to write something like

truncatedValule = "";
 const truncatedValuePromise = truncateStringAtBoundaryWithError(this, value, MAX_STRING_LENGTH);
truncatedValuePromise.then((v) => {
  truncatedValue = v;
});

However the code above led to failure of unit test case attempt to add string to string list of maximum length records an error: the empty string "" was inserted instead.
Any suggestion is appreciated!

@ChinYing-Li ChinYing-Li marked this pull request as ready for review August 21, 2021 21:48
@brizental
Copy link
Contributor

Without async means I have to write something like

truncatedValule = "";
 const truncatedValuePromise = truncateStringAtBoundaryWithError(this, value, MAX_STRING_LENGTH);
truncatedValuePromise.then((v) => {
  truncatedValue = v;
});

By wrapping the whole function body in a dispatcher.launch call, it will be inside an async function block so you can use await normally. You can see that pattern in action on the URL metric type set function (https://github.com/mozilla/glean.js/blob/main/glean/src/core/metrics/types/url.ts#L94-L113) or any other metric type.

The dispatcher orchestrates Glean's async tasks, so that they are run in the order the user called them. But that all happens in the background, without the user having to await on anything. That is a bit confusing, let me know if it's still unclear I am happy to try and clarify more :)

However the code above led to failure of unit test cas

They failure is probably happening because the code is not using the dispatcher, so at the time the assertion is called the action that should precede has not completed yet.

dependabot bot and others added 5 commits August 23, 2021 06:34
Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.2.0 to 10.2.1.
- [Release notes](https://github.com/TypeStrong/ts-node/releases)
- [Commits](TypeStrong/ts-node@v10.2.0...v10.2.1)

---
updated-dependencies:
- dependency-name: ts-node
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [geckodriver](https://github.com/vladikoff/node-geckodriver) from 2.0.2 to 2.0.3.
- [Release notes](https://github.com/vladikoff/node-geckodriver/releases)
- [Commits](webdriverio-community/node-geckodriver@v2.0.2...v2.0.3)

---
updated-dependencies:
- dependency-name: geckodriver
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 16.6.1 to 16.6.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
@ChinYing-Li
Copy link
Contributor Author

@brizental I've addressed all the issues, and would be great if you can take a look. Thank you so much for the guidance!

Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

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

This is looking great, I left a few nits, but nothing major. Once these are adressed this should be good to go.

Thanks for the work here @ChinYing-Li !

@brizental
Copy link
Contributor

brizental commented Sep 1, 2021

Hey @ChinYing-Li I see you addressed the review comments, but there are three still missing :) Would you mind addressing those and rebasing this PR so I can merge? Thank you so much :)

Also, the package-lock.json changes can be dropped. That has already ben fixed in a different PR.

@ChinYing-Li
Copy link
Contributor Author

Hi @brizental , sorry for the delay! Please review and let me know if anything else needs to be fixed. Thank you.

Copy link
Contributor

@brizental brizental left a comment

Choose a reason for hiding this comment

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

This is looking perfect. Thanks so much for the great work here @ChinYing-Li .

Would you like to also take on the documentation updates over on the Glean book, for the string list metric type? That means adding the JavaScript examples to this page. If not, that is no problem, just let me know so I can file a follow up bug for that work.

Also, let me know if you want help to find a next bug, I am always happy to assist. Note that I will be on vacation next week. During that time, you can reach out to @Dexterp37 .

@brizental brizental merged commit cc00636 into mozilla:main Sep 2, 2021
@ChinYing-Li
Copy link
Contributor Author

Hi @brizental , Sure, I can update the Glean book!

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.

2 participants