diff --git a/service/pool/Logs.mo b/service/pool/Logs.mo index 3a1e9940..284c3f7a 100644 --- a/service/pool/Logs.mo +++ b/service/pool/Logs.mo @@ -3,6 +3,7 @@ import {compare} "mo:base/Text"; import {toArray} "mo:base/Iter"; import {now = timeNow} "mo:base/Time"; import {toText} "mo:base/Int"; +import {get} "mo:base/Option"; module { public type Origin = { origin: Text; tags: [Text] }; @@ -52,7 +53,7 @@ module { let now = timeNow() / 1_000_000; for ((origin, count) in canisters.entries()) { let name = "canisters_" # origin; - let desc = "Number of canisters deployed from " # origin; + let desc = "Number of canisters requested from " # origin; result := result # encode_single_value("counter", name, count, desc, now); }; for ((origin, count) in installs.entries()) { @@ -60,6 +61,17 @@ module { let desc = "Number of Wasm installed from " # origin; result := result # encode_single_value("counter", name, count, desc, now); }; + let profiling = get(tags.get("profiling"), 0); + let asset = get(tags.get("asset"), 0); + let install = get(tags.get("install"), 0); + let reinstall = get(tags.get("reinstall"), 0); + let upgrade = get(tags.get("upgrade"), 0); + result := result + # encode_single_value("counter", "profiling", profiling, "Number of Wasm profiled", now) + # encode_single_value("counter", "asset", asset, "Number of asset Wasm canister installed", now) + # encode_single_value("counter", "install", install, "Number of Wasm with install mode", now) + # encode_single_value("counter", "reinstall", reinstall, "Number of Wasm with reinstall mode", now) + # encode_single_value("counter", "upgrade", upgrade, "Number of Wasm with upgrad mode", now); result; }; }; diff --git a/service/pool/Main.mo b/service/pool/Main.mo index ffc84575..f3cf0a56 100644 --- a/service/pool/Main.mo +++ b/service/pool/Main.mo @@ -6,6 +6,7 @@ import Option "mo:base/Option"; import Nat "mo:base/Nat"; import Text "mo:base/Text"; import Array "mo:base/Array"; +import Buffer "mo:base/Buffer"; import List "mo:base/List"; import Deque "mo:base/Deque"; import Result "mo:base/Result"; @@ -169,7 +170,22 @@ shared (creator) actor class Self(opt_params : ?Types.InitParams) = this { }; await IC.install_code newArgs; stats := Logs.updateStats(stats, #install); - statsByOrigin.addInstall(install_config.origin); + + // Build tags from install arguments + let tags = Buffer.fromArray(install_config.origin.tags); + if (install_config.profiling) { + tags.add("profiling"); + }; + if (install_config.is_whitelisted) { + tags.add("asset"); + }; + switch (args.mode) { + case (#install) { tags.add("install") }; + case (#upgrade) { tags.add("upgrade") }; + case (#reinstall) { tags.add("reinstall") }; + }; + let origin = { origin = install_config.origin.origin; tags = Buffer.toArray(tags) }; + statsByOrigin.addInstall(origin); switch (pool.refresh(info, install_config.profiling)) { case (?newInfo) { updateTimer(newInfo);