Skip to content

Commit 582461d

Browse files
Update README.md
1 parent 237c6cf commit 582461d

File tree

1 file changed

+11
-64
lines changed

1 file changed

+11
-64
lines changed

rust/query_stats/README.md

Lines changed: 11 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# Query statistics
22

3-
This example shows to work with the query stats feature.
4-
5-
## Architecture
6-
7-
The example consists of a single canister called `query_stats`.
8-
It exports the following candid interface:
3+
This example shows to work with the query stats feature. It consists of a single canister called `query_stats`. It exports the following candid interface:
94

105
```candid
116
service : {
@@ -15,70 +10,22 @@ service : {
1510
1611
```
1712

18-
The `load` function just returns a timestamp.
19-
It just exists such that there is a query endpoint to call.
20-
The `get_query_stats` is the function that queries the status endpoint and returns the collected query statistics.
21-
22-
## Prerequisites
23-
24-
This example requires an installation of:
25-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/getting-started/install).
26-
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
27-
28-
29-
## Step 1: Setup project environment
30-
31-
Navigate into the folder containing the project's files and start a local instance of the replica with the command:
32-
33-
```sh
34-
cd examples/rust/query_stats
35-
dfx start --clean
36-
```
37-
38-
## Step 2: Compile and deploy `query_stats` canister
39-
40-
```sh
41-
dfx deploy
42-
```
43-
44-
## Step 3: Call the canister's load function a few times to generate query traffic
45-
46-
```
47-
dfx canister call query_stats load
48-
```
49-
50-
## Step 4: Observe the following result
51-
52-
```
53-
dfx canister call query_stats get_query_stats
54-
```
55-
56-
## Step 5: After a while, the values should become populated
57-
58-
```
59-
"Number of calls: 19 - Number of instructions 414_083 - Request payload bytes: 114 - Response payload bytes: 270"
60-
```
61-
62-
Alternatively, you can use the candid interface to make those calls.
63-
64-
### Troubleshooting
13+
The `load` function just returns a timestamp. It just exists such that there is a query endpoint to call. The method `get_query_stats` queries the status endpoint and returns the collected query statistics.
6514

66-
On the local `dfx` replica, the aggregation epoch is set to 60 seconds.
67-
So calling the load function a couple of times should result in values showing up a couple minutes later.
15+
## Deploying from ICP Ninja
6816

69-
On mainnet, the aggregation epoch is 10 minutes, thus it will up to half an hour before the values appear on mainnet.
17+
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/editor?g=https://github.com/dfinity/examples/tree/master/rust/query_stats)
7018

71-
### Possible next steps
19+
## Build and deploy from the command-line
7220

73-
Query statistics are simple counters that increase.
74-
Their raw values are not that useful, you may want to implement some sort of metering system.
21+
### 1. [Download and install the IC SDK.](https://internetcomputer.org/docs/building-apps/getting-started/install)
7522

76-
One way to go from here is to get the query stats in a regular interval using a timer and compare to the last values, calculating rates.
23+
### 2. Download your project from ICP Ninja using the 'Download files' button on the upper left corner, or [clone the GitHub examples repository.](https://github.com/dfinity/examples/)
7724

78-
## Resources
25+
### 3. Navigate into the project's directory.
7926

80-
- [ic-cdk](https://docs.rs/ic-cdk/latest/ic_cdk/).
27+
### 4. Run `dfx start --background --clean && dfx deploy` to deploy the project to your local environment.
8128

82-
## Security considerations and security best practices
29+
## Security considerations and best practices
8330

84-
If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices.
31+
If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/building-apps/security/overview) for developing on ICP. This example may not implement all the best practices.

0 commit comments

Comments
 (0)