fix: metrics (#331)
This commit is contained in:
parent
1b00f4ba86
commit
8e36792dd9
|
|
@ -122,6 +122,7 @@ pub async fn run(
|
|||
.service(ws_scope())
|
||||
.service(file_storage_scope())
|
||||
.service(metrics_scope())
|
||||
.app_data(Data::new(state.metrics.registry.clone()))
|
||||
.app_data(Data::new(state.metrics.request_metrics.clone()))
|
||||
.app_data(Data::new(state.metrics.realtime_metrics.clone()))
|
||||
.app_data(Data::new(state.metrics.access_control_metrics.clone()))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ where
|
|||
}
|
||||
|
||||
#[instrument(level = "debug", skip_all, err)]
|
||||
#[allow(clippy::blocks_in_if_conditions)]
|
||||
async fn check_collab_permission(
|
||||
&self,
|
||||
oid: &str,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ where
|
|||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all, err)]
|
||||
#[allow(clippy::blocks_in_if_conditions)]
|
||||
async fn check_workspace_permission(
|
||||
&self,
|
||||
workspace_id: &Uuid,
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ impl UserCache {
|
|||
#[derive(Clone)]
|
||||
pub struct AppMetrics {
|
||||
#[allow(dead_code)]
|
||||
registry: Arc<prometheus_client::registry::Registry>,
|
||||
pub registry: Arc<prometheus_client::registry::Registry>,
|
||||
pub request_metrics: Arc<RequestMetrics>,
|
||||
pub realtime_metrics: Arc<RealtimeMetrics>,
|
||||
pub access_control_metrics: Arc<AccessControlMetrics>,
|
||||
|
|
|
|||
|
|
@ -526,3 +526,49 @@ async fn collab_flush_test() {
|
|||
}
|
||||
// TODO(nathan): assert the collab content in disk
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn simulate_50_offline_user_connect_and_then_sync_document_test() {
|
||||
let text = generate_random_string(1024 * 1024 * 3);
|
||||
let mut tasks = Vec::new();
|
||||
for i in 0..50 {
|
||||
let cloned_text = text.clone();
|
||||
let task = tokio::spawn(async move {
|
||||
let mut new_user = TestClient::new_user_without_ws_conn().await;
|
||||
// sleep to make sure it do not trigger register user too fast in gotrue
|
||||
sleep(Duration::from_secs(i % 5)).await;
|
||||
|
||||
let object_id = Uuid::new_v4().to_string();
|
||||
let workspace_id = new_user.workspace_id().await;
|
||||
let doc_state = make_big_collab_doc_state(&object_id, "text", cloned_text);
|
||||
new_user
|
||||
.open_collab_with_doc_state(&workspace_id, &object_id, CollabType::Document, doc_state)
|
||||
.await;
|
||||
(new_user, object_id)
|
||||
});
|
||||
tasks.push(task);
|
||||
}
|
||||
|
||||
let results = futures::future::join_all(tasks).await;
|
||||
let mut tasks = Vec::new();
|
||||
for result in results.into_iter() {
|
||||
let task = tokio::spawn(async move {
|
||||
let (mut client, object_id) = result.unwrap();
|
||||
client.reconnect().await;
|
||||
client.wait_object_sync_complete(&object_id).await;
|
||||
|
||||
for i in 0..100 {
|
||||
client
|
||||
.collab_by_object_id
|
||||
.get_mut(&object_id)
|
||||
.unwrap()
|
||||
.collab
|
||||
.lock()
|
||||
.insert(&i.to_string(), i.to_string());
|
||||
sleep(Duration::from_millis(30)).await;
|
||||
}
|
||||
});
|
||||
tasks.push(task);
|
||||
}
|
||||
let _results = futures::future::join_all(tasks).await;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue