Start to add request time profiling.
[bluesky.git] / bluesky / store.c
index 5d9dc43..1ee3916 100644 (file)
@@ -112,6 +112,7 @@ BlueSkyStoreAsync *bluesky_store_async_new(BlueSkyStore *store)
     async->notifier_count = 0;
     async->barrier = NULL;
     async->store_private = NULL;
+    async->profile = bluesky_profile_get();
 
     return async;
 }
@@ -255,6 +256,18 @@ void bluesky_store_async_mark_complete(BlueSkyStoreAsync *async)
         g_thread_pool_push(notifier_thread_pool, nl, NULL);
     }
 
+    if (async->profile) {
+        bluesky_profile_add_event(
+            async->profile,
+            g_strdup_printf("%s for %s complete",
+                            async->op == STORE_OP_GET ? "GET"
+                            : async->op == STORE_OP_PUT ? "PUT"
+                            : async->op == STORE_OP_DELETE ? "DELETE"
+                            : async->op == STORE_OP_BARRIER ? "BARRIER" : "???",
+                            async->key)
+        );
+    }
+
     if (bluesky_verbose) {
         g_log("bluesky/store", G_LOG_LEVEL_DEBUG,
               "[%p] complete: elapsed = %"PRIi64" ns, latency = %"PRIi64" ns",
@@ -280,6 +293,18 @@ void bluesky_store_async_submit(BlueSkyStoreAsync *async)
     // processing was started, if there could be a delay from submission time.
     async->exec_time = bluesky_now_hires();
 
+    if (async->profile) {
+        bluesky_profile_add_event(
+            async->profile,
+            g_strdup_printf("Start %s for %s",
+                            async->op == STORE_OP_GET ? "GET"
+                            : async->op == STORE_OP_PUT ? "PUT"
+                            : async->op == STORE_OP_DELETE ? "DELETE"
+                            : async->op == STORE_OP_BARRIER ? "BARRIER" : "???",
+                            async->key)
+        );
+    }
+
     if (bluesky_verbose) {
         g_log("bluesky/store", G_LOG_LEVEL_DEBUG, "[%p] submit: %s %s",
               async,