-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log probe status and errors to the integration log
Get more insights into the operation of the minutely probes by logging what it's doing (which probes it's running) and if it encounters an error. These logs follow the same format as the Ruby gem. Resolves #754 because it now logs when it times out a probe.
- Loading branch information
Showing
5 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
bump: patch | ||
type: change | ||
--- | ||
|
||
Add debug and error logs to probes to better track what it's doing. This is helpful when debugging issues with the minutely probes system. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
defmodule Appsignal.FakeIntegrationLogger do | ||
use TestAgent, %{ | ||
logs: [] | ||
} | ||
|
||
def trace(message) do | ||
add(:logs, [:trace, message]) | ||
end | ||
|
||
def debug(message) do | ||
add(:logs, [:debug, message]) | ||
end | ||
|
||
def info(message) do | ||
add(:logs, [:info, message]) | ||
end | ||
|
||
def warn(message) do | ||
add(:logs, [:warn, message]) | ||
end | ||
|
||
def error(message) do | ||
add(:logs, [:error, message]) | ||
end | ||
|
||
def logged?(pid_or_module, type, message) do | ||
Enum.any?(get(pid_or_module, :logs), fn element -> | ||
match?([^type, ^message], element) | ||
end) | ||
end | ||
|
||
def get_logs(pid_or_module, type) do | ||
Enum.filter(get(pid_or_module, :logs), fn element -> | ||
match?([^type, _], element) | ||
end) | ||
end | ||
|
||
def clear do | ||
if alive?() do | ||
Agent.update(__MODULE__, fn state -> | ||
Map.update!(state, :logs, fn _ -> [] end) | ||
end) | ||
end | ||
end | ||
|
||
defp add(key, event) do | ||
if alive?() do | ||
Agent.update(__MODULE__, fn state -> | ||
Map.update!(state, key, fn current -> [event | current] end) | ||
end) | ||
end | ||
end | ||
end |