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

feat: Sample app for query stats feature #710

Closed
wants to merge 13 commits into from

Conversation

Dfinity-skaestle
Copy link
Contributor

Overview
With query stats, developers gain insights into the use of query calls in their canister.
This has previously been difficult, since no state can be persisted when executing query calls.

This example shows how to use the canister status to gain access to query statistics.
It also shows how to use a timer to periodically query them and calculate rates for query metrics.

@Dfinity-skaestle Dfinity-skaestle requested a review from a team as a code owner February 16, 2024 12:49
Copy link
Contributor

@sesi200 sesi200 left a comment

Choose a reason for hiding this comment

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

Can you also add some basic tests that at a minimum show that the example still compiles? You can draw inspiration from the other examples

rust/query-stats/Cargo.toml Outdated Show resolved Hide resolved
rust/query-stats/dfx.json Outdated Show resolved Hide resolved
rust/query-stats/README.md Outdated Show resolved Hide resolved
rust/query-stats/README.md Outdated Show resolved Hide resolved
Comment on lines 11 to 12
This is currently only for use from within DFINITY, as the replica shipped with `dfx` as well as nodes on
mainnet do not enable the query stats feature at the moment.
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is true this should not be in this repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is currently true, but the canary rollout should start soon.


## Issuing load

We now want to generate queries at a certain rate. One way to achieve this is by using `ic-workload-generator`, which is part of the [IC repo](https://github.com/dfinity/ic/tree/master/rs/workload_generator).
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there binaries available for downloading somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No.
The workload generator is not strictly needed for this, but it's probably the easiest tool to get started.

What would you recommend instead? Should I recommend to run dfx calls in a bash loop instead?

Comment on lines +45 to +46
There is a delay until query stats show up in the canister status. Depending on the configuration, this
can reach from multiple minutes to an hour.
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this behave on local? Is it easily testable there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not currently, but as discussed offline, we should probably enable it in the dfx replica. I will talk to people to come up with a suggestion on how to do that.

rust/query-stats/README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,75 @@
# Query stats
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
# Query stats
# Query stats
This example is about...

rust/query-stats/src/lib.rs Outdated Show resolved Hide resolved
@sa-github-api
Copy link
Collaborator

Dear @Dfinity-skaestle,

In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA.

If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged.

— The DFINITY Foundation

@ghost
Copy link

ghost commented Mar 20, 2024

cloned by #769

@ghost ghost closed this Mar 20, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants