diff --git a/lib/new_relic/aggregate/aggregate.ex b/lib/new_relic/aggregate/aggregate.ex index 3361a949..ac2e4e0e 100644 --- a/lib/new_relic/aggregate/aggregate.ex +++ b/lib/new_relic/aggregate/aggregate.ex @@ -20,9 +20,7 @@ defmodule NewRelic.Aggregate do defp averages(%{call_count: call_count} = values) do values |> Stream.reject(fn {key, _value} -> key == :call_count end) - |> Enum.reduce(%{}, fn {key, value}, acc -> - Map.put(acc, :"avg_#{key}", value / call_count) - end) + |> Map.new(fn {key, value} -> {:"avg_#{key}", value / call_count} end) end defp averages(_values), do: %{} diff --git a/lib/new_relic/distributed_trace.ex b/lib/new_relic/distributed_trace.ex index 18acf387..67eb656f 100644 --- a/lib/new_relic/distributed_trace.ex +++ b/lib/new_relic/distributed_trace.ex @@ -207,7 +207,7 @@ defmodule NewRelic.DistributedTrace do end def set_span(:generic, attrs) do - add_span_attributes(Enum.into(attrs, %{})) + add_span_attributes(Map.new(attrs)) end def set_span(:http, url: url, method: method, component: component) do @@ -237,10 +237,7 @@ defmodule NewRelic.DistributedTrace do def add_span_attributes(attrs) do Process.put( :nr_current_span_attrs, - Map.merge( - get_span_attrs(), - Enum.into(attrs, %{}) - ) + Map.merge(get_span_attrs(), Map.new(attrs)) ) :ok diff --git a/lib/new_relic/error/trace.ex b/lib/new_relic/error/trace.ex index 1890a9cb..46a4340d 100644 --- a/lib/new_relic/error/trace.ex +++ b/lib/new_relic/error/trace.ex @@ -49,7 +49,7 @@ defmodule NewRelic.Error.Trace do defp format_user_attributes(user_attributes) do user_attributes |> Map.drop(@intrinsics) - |> Enum.into(%{}, fn {k, v} -> + |> Map.new(fn {k, v} -> (String.Chars.impl_for(v) && {k, v}) || {k, inspect(v)} end) end diff --git a/lib/new_relic/init.ex b/lib/new_relic/init.ex index a2007aba..d01c43b3 100644 --- a/lib/new_relic/init.ex +++ b/lib/new_relic/init.ex @@ -162,7 +162,7 @@ defmodule NewRelic.Init do def determine_automatic_attributes() do Application.get_env(:new_relic_agent, :automatic_attributes, []) - |> Enum.into(%{}, fn + |> Map.new(fn {name, {:system, env_var}} -> {name, System.get_env(env_var)} {name, {m, f, a}} -> {name, apply(m, f, a)} {name, value} -> {name, value} diff --git a/lib/new_relic/sampler/process.ex b/lib/new_relic/sampler/process.ex index 2e8f60d7..10a054a3 100644 --- a/lib/new_relic/sampler/process.ex +++ b/lib/new_relic/sampler/process.ex @@ -47,10 +47,10 @@ defmodule NewRelic.Sampler.Process do end defp record_samples(state) do - Enum.reduce(state.pids, %{}, fn {pid, true}, acc -> + Map.new(state.pids, fn {pid, true} -> {current_sample, stats} = collect(pid, state.previous[pid]) NewRelic.report_sample(:ProcessSample, stats) - Map.put(acc, pid, current_sample) + {pid, current_sample} end) end diff --git a/lib/new_relic/transaction/complete.ex b/lib/new_relic/transaction/complete.ex index 8bf057ff..22afc23d 100644 --- a/lib/new_relic/transaction/complete.ex +++ b/lib/new_relic/transaction/complete.ex @@ -113,7 +113,7 @@ defmodule NewRelic.Transaction.Complete do |> Enum.map(&transform_trace_name_attrs/1) |> Enum.map(&struct(Transaction.Trace.Segment, &1)) |> Enum.group_by(& &1.pid) - |> Enum.into(%{}, &generate_segment_tree(&1)) + |> Map.new(&generate_segment_tree(&1)) root_process_segment = tx_attrs diff --git a/lib/new_relic/util.ex b/lib/new_relic/util.ex index f1ff5a1f..91869132 100644 --- a/lib/new_relic/util.ex +++ b/lib/new_relic/util.ex @@ -119,7 +119,7 @@ defmodule NewRelic.Util do def metadata() do System.get_env() |> Enum.filter(fn {key, _} -> String.starts_with?(key, @nr_metadata_prefix) end) - |> Enum.into(%{}) + |> Map.new() end def utilization() do diff --git a/test/transaction_trace_test.exs b/test/transaction_trace_test.exs index daf424eb..ba5df2cf 100644 --- a/test/transaction_trace_test.exs +++ b/test/transaction_trace_test.exs @@ -84,7 +84,7 @@ defmodule TransactionTraceTest do end get "/huge_args" do - Enum.into(1..10000, %{}, &{&1, &1}) + Map.new(1..10000, &{&1, &1}) |> HelperModule.do_work() HelperModule.work_hard(%{on: :something}) diff --git a/test/util_test.exs b/test/util_test.exs index d39b2e4d..44868751 100644 --- a/test/util_test.exs +++ b/test/util_test.exs @@ -32,7 +32,7 @@ defmodule UtilTest do nested: %{foo: %{bar: %{baz: "qux"}}}, nested_list: [%{one: %{two: "three"}}, %{four: "five"}, %{}, "string", ["nested string"]], super_long_list: Enum.map(0..99, & &1), - big_map: String.graphemes("abcdefghijklmnopqrstuvwxyz") |> Enum.into(%{}, &{&1, &1}) + big_map: String.graphemes("abcdefghijklmnopqrstuvwxyz") |> Map.new(&{&1, &1}) ) assert {"nested.foo.bar.baz", "qux"} in flattened