nebulex
nebulex copied to clipboard
Confusing documentation for telemetry
With the latest nebulex version the telemetry setup/integration changed quite a lot and broke a few of our dashboards (this is fine, that one's on us for updating), I have finally gotten around to updating our code to match the new telemetry layout! This task took longer than I thought it would because the initial examples in the documentation didn't work in our use case.
The documentation implies that the prefix, no matter what adapter being used, is the same:
defp metrics do
[
# Nebulex Stats Metrics
last_value("my_app.cache.stats.hits", tags: [:cache]),
last_value("my_app.cache.stats.misses", tags: [:cache]),
last_value("my_app.cache.stats.writes", tags: [:cache]),
last_value("my_app.cache.stats.updates", tags: [:cache]),
last_value("my_app.cache.stats.evictions", tags: [:cache]),
last_value("my_app.cache.stats.expirations", tags: [:cache])
]
end
When using the replicated cache this prefix appears to be incorrect, eventually after digging through the internals I found out how to extract the default prefix for that particular adapter:
name = YYY.ReplicatedCache.get_dynamic_cache()
Nebulex.Adapter.with_meta(name, fn _adapter, meta -> meta end)
%{
cache: YYY.ReplicatedCache,
name: YYY.ReplicatedCache,
pid: #PID<0.913.0>,
primary_name: nil,
stats: true,
task_sup: nil,
telemetry: true,
telemetry_prefix: [:yyy, :replicated_cache] # <- HERE
}
Changing the format then to "my_app.replicated_cache.stats.expirations" as an example yielded the expected results. I feel it should be made more obvious in the documentation that the "cache" prefix is not static by default and changes by adapter.
Ok, let me check the docs and improve it. But overall, by default, the telemetry prefix by default is the defined cache module converted into a list of atoms (lowercased and underscored). But yeah, I agree the docs should be more clear. Thanks!