From e84fb71a39da6afd33732cb364d17626fad2ea67 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Fri, 9 Feb 2024 13:08:42 +0000 Subject: [PATCH] Expose `EventSinkClientInfo` in metrics (#5344) --- backend/canisters/event_relay/CHANGELOG.md | 1 + backend/canisters/user_index/CHANGELOG.md | 1 + backend/canisters/user_index/impl/src/lib.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/canisters/event_relay/CHANGELOG.md b/backend/canisters/event_relay/CHANGELOG.md index 2ac563f6a9..c92b608f63 100644 --- a/backend/canisters/event_relay/CHANGELOG.md +++ b/backend/canisters/event_relay/CHANGELOG.md @@ -8,3 +8,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Forward anonymised events on to the `event_sink` canister ([#5337](https://github.com/open-chat-labs/open-chat/pull/5337)) +- Initial commit ([#5334](https://github.com/open-chat-labs/open-chat/pull/5334)) diff --git a/backend/canisters/user_index/CHANGELOG.md b/backend/canisters/user_index/CHANGELOG.md index eaa67cc88e..5c94ade999 100644 --- a/backend/canisters/user_index/CHANGELOG.md +++ b/backend/canisters/user_index/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Track `user_registered` and `diamond_membership_payment` events ([#5342](https://github.com/open-chat-labs/open-chat/pull/5342)) +- Expose `EventSinkClientInfo` in metrics ([#5344](https://github.com/open-chat-labs/open-chat/pull/5344)) ## [[2.0.1047](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1047-user_index)] - 2024-02-05 diff --git a/backend/canisters/user_index/impl/src/lib.rs b/backend/canisters/user_index/impl/src/lib.rs index d0ddd040e9..e8dc645a9b 100644 --- a/backend/canisters/user_index/impl/src/lib.rs +++ b/backend/canisters/user_index/impl/src/lib.rs @@ -7,7 +7,7 @@ use crate::timer_job_types::TimerJob; use candid::Principal; use canister_state_macros::canister_state; use canister_timer_jobs::TimerJobs; -use event_sink_client::{EventSinkClient, EventSinkClientBuilder}; +use event_sink_client::{EventSinkClient, EventSinkClientBuilder, EventSinkClientInfo}; use event_sink_client_cdk_runtime::CdkRuntime; use fire_and_forget_handler::FireAndForgetHandler; use icrc_ledger_types::icrc1::account::{Account, Subaccount}; @@ -176,6 +176,9 @@ impl RuntimeState { pub fn metrics(&self) -> Metrics { let now = self.env.now(); let canister_upgrades_metrics = self.data.canisters_requiring_upgrade.metrics(); + let event_sink_client_info = self.data.event_sink_client.info(); + let event_relay_canister_id = event_sink_client_info.event_sink_canister_id; + Metrics { memory_used: utils::memory::used(), now: self.env.now(), @@ -202,6 +205,7 @@ impl RuntimeState { local_user_indexes: self.data.local_index_map.iter().map(|(c, i)| (*c, i.clone())).collect(), platform_moderators_group: self.data.platform_moderators_group, nns_8_year_neuron: self.data.nns_8_year_neuron.clone(), + event_sink_client_info, canister_ids: CanisterIds { group_index: self.data.group_index_canister_id, notifications_index: self.data.notifications_index_canister_id, @@ -211,6 +215,7 @@ impl RuntimeState { storage_index: self.data.storage_index_canister_id, escrow: self.data.escrow_canister_id, translations: self.data.translations_canister_id, + event_relay: event_relay_canister_id, internet_identity: self.data.internet_identity_canister_id, }, pending_modclub_submissions: self.data.pending_modclub_submissions_queue.len(), @@ -448,6 +453,7 @@ pub struct Metrics { pub local_user_indexes: Vec<(CanisterId, LocalUserIndex)>, pub platform_moderators_group: Option, pub nns_8_year_neuron: Option, + pub event_sink_client_info: EventSinkClientInfo, pub canister_ids: CanisterIds, pub pending_modclub_submissions: usize, pub reporting_metrics: ReportingMetrics, @@ -495,6 +501,7 @@ pub struct CanisterIds { pub cycles_dispenser: CanisterId, pub storage_index: CanisterId, pub escrow: CanisterId, - pub internet_identity: CanisterId, pub translations: CanisterId, + pub event_relay: CanisterId, + pub internet_identity: CanisterId, }