Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Config

config :phoenix, :json_library, Jason

import_config "#{config_env()}.exs"
1 change: 1 addition & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Config
1 change: 1 addition & 0 deletions config/prod.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import Config
3 changes: 3 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Config

config :logger, level: :warning
20 changes: 15 additions & 5 deletions test/flame_on/capture/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ defmodule FlameOn.Capture.ServerTest do

setup do
on_exit(fn ->
if Process.whereis(Server) do
Process.exit(Process.whereis(Server), :kill)
Process.sleep(100)
if pid = Process.whereis(Server) do
GenServer.stop(pid, :normal)
end

case ETS.Set.wrap_existing(Server) do
Expand Down Expand Up @@ -149,6 +148,7 @@ defmodule FlameOn.Capture.ServerTest do
end

test "handles :out trace message for sleep" do
Logger.configure(level: :debug)
config = build_config()
{:ok, pid} = Server.start(config)

Expand All @@ -158,6 +158,8 @@ defmodule FlameOn.Capture.ServerTest do
Process.sleep(10)
end)

Logger.configure(level: :warning)

state = :sys.get_state(pid)

assert length(state.stack) == 2
Expand All @@ -167,18 +169,23 @@ defmodule FlameOn.Capture.ServerTest do
end

test "handles :in trace message for sleep" do
Logger.configure(level: :debug)
config = build_config()
{:ok, pid} = Server.start(config)

send(pid, {:trace_ts, self(), :out, {:example, :foo, 0}, {0, 1000, 0}})
Process.sleep(10)
capture_log(fn ->
send(pid, {:trace_ts, self(), :out, {:example, :foo, 0}, {0, 1000, 0}})
Process.sleep(10)
end)

log =
capture_log(fn ->
send(pid, {:trace_ts, self(), :in, {:example, :foo, 0}, {0, 2000, 0}})
Process.sleep(10)
end)

Logger.configure(level: :warning)

state = :sys.get_state(pid)

assert [starter] = state.stack
Expand All @@ -188,6 +195,7 @@ defmodule FlameOn.Capture.ServerTest do
end

test "logs trace messages at debug level" do
Logger.configure(level: :debug)
config = build_config()
{:ok, pid} = Server.start(config)

Expand All @@ -197,6 +205,8 @@ defmodule FlameOn.Capture.ServerTest do
Process.sleep(10)
end)

Logger.configure(level: :warning)

assert log =~ "flame_on trace: call"
assert log =~ "{:example, :foo, 0}"
end
Expand Down