@@ -2,6 +2,8 @@ defmodule NebulexTelemetryExample.Telemetry do
22 use Supervisor
33 import Telemetry.Metrics
44
5+ @ telemetry_prefix "nebulex_telemetry_example.cache"
6+
57 def start_link ( arg ) do
68 Supervisor . start_link ( __MODULE__ , arg , name: __MODULE__ )
79 end
@@ -21,22 +23,29 @@ defmodule NebulexTelemetryExample.Telemetry do
2123
2224 defp metrics do
2325 [
24- # Nebulex Stats Metrics
25- last_value ( "nebulex.cache.stats.hits" , tags: [ :cache ] ) ,
26- last_value ( "nebulex.cache.stats.misses" , tags: [ :cache ] ) ,
27- last_value ( "nebulex.cache.stats.writes" , tags: [ :cache ] ) ,
28- last_value ( "nebulex.cache.stats.updates" , tags: [ :cache , :node ] ) ,
29- last_value ( "nebulex.cache.stats.evictions" , tags: [ :cache ] ) ,
30- last_value ( "nebulex.cache.stats.expirations" , tags: [ :cache ] ) ,
31-
32- # Nebulex custom Metrics
33- last_value ( "nebulex.cache.size.value" , tags: [ :cache ] ) ,
34-
35- # VM Metrics
36- summary ( "vm.memory.total" , unit: { :byte , :kilobyte } ) ,
37- summary ( "vm.total_run_queue_lengths.total" ) ,
38- summary ( "vm.total_run_queue_lengths.cpu" ) ,
39- summary ( "vm.total_run_queue_lengths.io" )
26+ # Cache command events
27+ summary (
28+ @ telemetry_prefix <> ".command.stop.duration" ,
29+ unit: { :native , :millisecond } ,
30+ tags: [ :cache , :function_name ] ,
31+ tag_values: & Map . put ( & 1 , :cache , & 1 . adapter_meta . cache )
32+ ) ,
33+ summary (
34+ @ telemetry_prefix <> ".command.exception.duration" ,
35+ unit: { :native , :millisecond } ,
36+ tags: [ :function_name , :kind ]
37+ ) ,
38+
39+ # Cache stats
40+ last_value ( @ telemetry_prefix <> ".stats.hits" , tags: [ :cache ] ) ,
41+ last_value ( @ telemetry_prefix <> ".stats.misses" , tags: [ :cache ] ) ,
42+ last_value ( @ telemetry_prefix <> ".stats.writes" , tags: [ :cache ] ) ,
43+ last_value ( @ telemetry_prefix <> ".stats.updates" , tags: [ :cache , :node ] ) ,
44+ last_value ( @ telemetry_prefix <> ".stats.evictions" , tags: [ :cache ] ) ,
45+ last_value ( @ telemetry_prefix <> ".stats.expirations" , tags: [ :cache ] ) ,
46+
47+ # Custom metrics
48+ last_value ( @ telemetry_prefix <> ".size.value" , tags: [ :cache ] )
4049 ]
4150 end
4251
0 commit comments