Add stats for doc migrations and metadata cache lookups
diff --git a/priv/stat_descriptions.cfg b/priv/stat_descriptions.cfg
new file mode 100644
index 0000000..a007f7a
--- /dev/null
+++ b/priv/stat_descriptions.cfg
@@ -0,0 +1,17 @@
+{[cassim, metadata_cache, hit], [
+ {type, counter},
+ {desc, <<"number of cassim metadata cache lookup hits">>}
+]}.
+{[cassim, metadata_cache, miss], [
+ {type, counter},
+ {desc, <<"number of cassim metadata cache lookup misses">>}
+]}.
+{[cassim, security_migration, success], [
+ {type, counter},
+ {desc, <<"number of successful cassim security doc migrations">>}
+]}.
+{[cassim, security_migration, conflict], [
+ {type, counter},
+ {desc, <<"number of conflicted cassim security doc migrations">>}
+]}.
+
diff --git a/src/cassim_metadata_cache.erl b/src/cassim_metadata_cache.erl
index 35b5dad..920f748 100644
--- a/src/cassim_metadata_cache.erl
+++ b/src/cassim_metadata_cache.erl
@@ -240,11 +240,14 @@
fetch_cached_meta(MetaId) ->
try ets:lookup(?META_TABLE, MetaId) of
[{MetaId, Props}] ->
+ couch_stats:increment_counter([cassim, metadata_cache, hit]),
Props;
[] ->
+ couch_stats:increment_counter([cassim, metadata_cache, miss]),
couch_log:notice("cache miss on metadata ~s", [MetaId]),
undefined
catch error:badarg ->
+ couch_stats:increment_counter([cassim, metadata_cache, miss]),
couch_log:notice("cache miss on metadata ~s", [MetaId]),
undefined
end.
diff --git a/src/cassim_security.erl b/src/cassim_security.erl
index b9e5e0f..6afada2 100644
--- a/src/cassim_security.erl
+++ b/src/cassim_security.erl
@@ -71,8 +71,12 @@
SecProps = fabric:get_security(DbName),
try migrate_security_props(DbName, SecProps) of
{ok, SecDoc} ->
+ couch_stats:increment_counter(
+ [cassim, security_migration, success]),
SecDoc
catch conflict ->
+ couch_stats:increment_counter(
+ [cassim, security_migration, conflict]),
get_security_doc(DbName0, RetryCnt-1)
end;
{error, Error} ->