Skip to content

Commit

Permalink
chore: update calculate -> calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Sep 19, 2024
1 parent 6f88bc9 commit bfcaa07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions documentation/topics/advanced/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Note the mention of `:start` and `:stop` suffixes. The event below `[:ash, (doma
- `[:ash, :query]` - A query being processed for an action, with `Ash.Query.for_read`. Use `resource_short_name` metadata to break down measurements.
- `[:ash, :validation]` - A validation being run on a changeset. Use `resource_short_name` and `validation` metadata to break down measurements.
- `[:ash, :change]` - A change being run on a changeset. Use `resource_short_name` and `change` metadata to break down measurements.
- `[:ash, :calculate]` - A calculation being computed in the app. Use `resource_short_name` and `calculation` metadata to break down measurements.
- `[:ash, :calculation]` - A calculation being computed in the app. Use `resource_short_name` and `calculation` metadata to break down measurements.
- `[:ash, :before_action]` - A before_action being run on a changeset. Use `resource_short_name` to break down measurements.
- `[:ash, :after_action]` - An after_action being run on a changeset. Use `resource_short_name` to break down measurements.
- `[:ash, :preparation]` - A preparation being run on a changeset. Use `resource_short_name` and `preparation` metadata to break down measurements.
Expand Down Expand Up @@ -68,7 +68,7 @@ These are the list of trace types.
- :changeset
- :validation
- :change
- :calculate
- :calculation
- :before_transaction
- :before_action
- :after_transaction
Expand Down
6 changes: 3 additions & 3 deletions lib/ash/actions/read/calculations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ defmodule Ash.Actions.Read.Calculations do
short_name = Ash.Resource.Info.short_name(resource)
tracer = opts[:tracer]

Ash.Tracer.span :calculate,
Ash.Tracer.span :calculation,
fn ->
calculation_name =
if is_atom(calculation_name) do
Expand All @@ -493,7 +493,7 @@ defmodule Ash.Actions.Read.Calculations do
String.replace(to_string(calculation_name), ~r/[^a-zA-Z0-9_\-?]/, "")
end

"#{short_name}:calculate:#{calculation_name}"
"#{short_name}:calculation:#{calculation_name}"
end,
tracer do
metadata = fn ->
Expand All @@ -514,7 +514,7 @@ defmodule Ash.Actions.Read.Calculations do
}
end

Ash.Tracer.telemetry_span [:ash, :calculate],
Ash.Tracer.telemetry_span [:ash, :calculation],
metadata,
skip?: !!opts[:initial_data] do
Ash.Tracer.set_metadata(tracer, :action, metadata)
Expand Down
10 changes: 5 additions & 5 deletions test/tracer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ defmodule Ash.Test.TracerTest.AsyncLoadTest do
[:ash, :domain, :create],
[:ash, :domain, :destroy],
[:ash, :domain, :update],
[:ash, :calculate],
[:ash, :calculation],
[:ash, :flow]
]
|> Enum.flat_map(fn list ->
Expand Down Expand Up @@ -278,8 +278,8 @@ defmodule Ash.Test.TracerTest.AsyncLoadTest do
},
spans: [
%Ash.Tracer.Simple.Span{
name: "author:calculate:name_length",
type: :calculate,
name: "author:calculation:name_length",
type: :calculation,
metadata: %{
resource: Ash.Test.TracerTest.AsyncLoadTest.Author,
resource_short_name: :author,
Expand All @@ -302,11 +302,11 @@ defmodule Ash.Test.TracerTest.AsyncLoadTest do
%{resource_short_name: :author}, []}}

assert_receive {:telemetry,
{[:ash, :calculate, :start], %{system_time: _},
{[:ash, :calculation, :start], %{system_time: _},
%{resource_short_name: :author, calculation: "name_length"}, []}}

assert_receive {:telemetry,
{[:ash, :calculate, :stop], %{duration: _, system_time: _},
{[:ash, :calculation, :stop], %{duration: _, system_time: _},
%{resource_short_name: :author, calculation: "name_length"}, []}}

refute_receive {:telemetry, _}
Expand Down

0 comments on commit bfcaa07

Please sign in to comment.