Skip to content

Commit 21bd267

Browse files
committed
Update to Nebulex v2.1.0
1 parent 89f84ca commit 21bd267

File tree

11 files changed

+66
-36
lines changed

11 files changed

+66
-36
lines changed

erlang_cache/elixir_libs/nbx_cache/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule NbxCache.MixProject do
1818

1919
defp deps do
2020
[
21-
{:nebulex, "~> 2.0"},
21+
{:nebulex, "~> 2.1"},
2222
{:shards, "~> 1.0"}
2323
]
2424
end

erlang_cache/rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
]}.
66

77
{deps, [
8-
{nebulex, {elixir, "nebulex", "2.0.0"}},
8+
{nebulex, {elixir, "nebulex", "2.1.0"}},
99
{shards, "1.0.1"}
1010
]}.
1111

near_cache/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ defmodule NearCache.MixProject do
2121

2222
defp deps do
2323
[
24-
{:nebulex, "~> 2.0"},
24+
{:nebulex, "~> 2.1"},
2525
{:shards, "~> 1.0"},
26-
{:decorator, "~> 1.3"},
26+
{:decorator, "~> 1.4"},
2727
{:jchash, "~> 0.1", app: false}
2828
]
2929
end

nebulex_bench/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule NebulexBench.MixProject do
2121

2222
defp deps do
2323
[
24-
{:nebulex, "~> 2.0"},
24+
{:nebulex, "~> 2.1"},
2525
{:shards, "~> 1.0"},
2626
{:basho_bench, github: "mrallen1/basho_bench", ref: "mra-rebar3"}
2727
]

nebulex_ecto_example/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ defmodule NebulexEctoExample.MixProject do
2121

2222
defp deps do
2323
[
24-
{:nebulex, "~> 2.0"},
24+
{:nebulex, "~> 2.1"},
2525
{:shards, "~> 1.0"},
26-
{:decorator, "~> 1.3"},
26+
{:decorator, "~> 1.4"},
2727
{:ecto_sql, "~> 3.4"},
2828
{:postgrex, ">= 0.0.0"}
2929
]

nebulex_telemetry_example/README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
This example illustrates how to instrument our Nebulex caches using Telemetry.
44

5-
See also [Nebulex.Cache.Stats](http://hexdocs.pm/nebulex/Nebulex.Cache.Stats.html)
6-
and [Telemetry Guide](http://hexdocs.pm/nebulex/telemetry.html).
5+
For more information about Telemetry events and stats, see:
6+
7+
* [Telemetry Events](https://hexdocs.pm/nebulex/Nebulex.Cache.html#module-telemetry-events)
8+
* [Cache Stats](http://hexdocs.pm/nebulex/Nebulex.Cache.Stats.html)
9+
* [Telemetry Guide](http://hexdocs.pm/nebulex/telemetry.html)
710

811
## Getting started
912

@@ -32,13 +35,27 @@ iex(7)> NebulexTelemetryExample.Cache.get 1
3235
nil
3336
```
3437

35-
You should see the metrics popping out:
38+
For the event `nebulex_telemetry_example.cache.command.stop.duration` you should
39+
see something like:
3640

3741
```
3842
[Telemetry.Metrics.ConsoleReporter] Got new event!
39-
Event name: nebulex.cache.stats
43+
Event name: nebulex_telemetry_example.cache.command.stop
44+
All measurements: %{duration: 13000}
45+
All metadata: %{adapter_meta: %{backend: :ets, cache: NebulexTelemetryExample.Cache, meta_tab: #Reference<0.1959874111.2908094469.85946>, pid: #PID<0.216.0>, started_at: ~U[2021-05-15 15:14:52.603317Z], stats_counter: {:write_concurrency, #Reference<0.1959874111.2908094469.85953>}, telemetry: true, telemetry_prefix: [:nebulex_telemetry_example, :cache]}, args: [1, 1, 10, :put, [ttl: 10]], function_name: :put, result: true, telemetry_span_context: #Reference<0.1959874111.2907963407.84960>}
46+
47+
Metric measurement: #Function<4.70336728/1 in Telemetry.Metrics.maybe_convert_measurement/2> (summary)
48+
With value: 0.013 millisecond
49+
Tag values: %{cache: NebulexTelemetryExample.Cache, function_name: :put}
50+
```
51+
52+
For the stats:
53+
54+
```
55+
[Telemetry.Metrics.ConsoleReporter] Got new event!
56+
Event name: nebulex_telemetry_example.cache.stats
4057
All measurements: %{evictions: 2, expirations: 1, hits: 1, misses: 2, writes: 2}
41-
All metadata: %{cache: NebulexTelemetryExample.Cache}
58+
All metadata: %{cache: NebulexTelemetryExample.Cache, started_at: ~U[2021-05-15 15:14:52.603317Z]}
4259
4360
Metric measurement: :hits (last_value)
4461
With value: 1
@@ -63,9 +80,13 @@ Tag values: %{cache: NebulexTelemetryExample.Cache}
6380
Metric measurement: :expirations (last_value)
6481
With value: 1
6582
Tag values: %{cache: NebulexTelemetryExample.Cache}
83+
```
6684

85+
And for the custome event:
86+
87+
```
6788
[Telemetry.Metrics.ConsoleReporter] Got new event!
68-
Event name: nebulex.cache.size
89+
Event name: nebulex_telemetry_example.cache.size
6990
All measurements: %{value: 0}
7091
All metadata: %{cache: NebulexTelemetryExample.Cache}
7192

nebulex_telemetry_example/lib/nebulex_telemetry_example/cache.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule NebulexTelemetryExample.Cache do
55

66
def dispatch_cache_size do
77
:telemetry.execute(
8-
[:nebulex, :cache, :size],
8+
[:nebulex_telemetry_example, :cache, :size],
99
%{value: size()},
1010
%{cache: __MODULE__}
1111
)

nebulex_telemetry_example/lib/nebulex_telemetry_example/telemetry.ex

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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

nebulex_telemetry_example/mix.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ defmodule NebulexTelemetryExample.MixProject do
2222
# Run "mix help deps" to learn about dependencies.
2323
defp deps do
2424
[
25-
{:nebulex, "~> 2.0"},
26-
{:decorator, "~> 1.3"},
27-
{:telemetry_metrics, "~> 0.5"},
25+
{:nebulex, "~> 2.1"},
26+
{:decorator, "~> 1.4"},
27+
{:telemetry_metrics, "~> 0.6"},
2828
{:telemetry_poller, "~> 0.5"},
2929
{:telemetry_metrics_statsd, "~> 0.5.0"}
3030
]

partitioned_cache/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ defmodule PartitionedCache.MixProject do
2121

2222
defp deps do
2323
[
24-
{:nebulex, "~> 2.0"},
24+
{:nebulex, "~> 2.1"},
2525
{:shards, "~> 1.0"},
26-
{:decorator, "~> 1.3"},
26+
{:decorator, "~> 1.4"},
2727
{:jchash, "~> 0.1", app: false},
2828
{:telemetry, "~> 0.4"},
2929
{:telemetry_metrics, "~> 0.6"},

0 commit comments

Comments
 (0)