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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ erl_crash.dump
tmp
config/secret.exs
.DS_Store
.tool-versions
6 changes: 5 additions & 1 deletion lib/new_relic/harvest/harvest_cycle.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,12 @@ defmodule NewRelic.Harvest.HarvestCycle do
catch
:exit, _exit ->
NewRelic.log(:error, "Failed to send harvest from #{inspect(supervisor)}")
after
end

try do
DynamicSupervisor.terminate_child(supervisor, harvester)
catch
:exit, _exit -> :ok
end
end,
shutdown: @harvest_timeout
Expand Down
24 changes: 12 additions & 12 deletions test/telemetry/finch_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ defmodule NewRelic.Telemetry.FinchTest do
end

test "finch external metrics" do
request("https://httpstat.us/200")
request("https://httpbin.org/200")

metrics = TestHelper.gather_harvest(Collector.Metric.Harvester)

assert TestHelper.find_metric(metrics, "External/httpstat.us/Finch/GET", 1)
assert TestHelper.find_metric(metrics, "External/httpstat.us/all", 1)
assert TestHelper.find_metric(metrics, "External/httpbin.org/Finch/GET", 1)
assert TestHelper.find_metric(metrics, "External/httpbin.org/all", 1)
assert TestHelper.find_metric(metrics, "External/all", 1)
end

test "[:finch, :request, :stop] - 200" do
Task.async(fn ->
NewRelic.start_transaction("FinchTest", "200")
request("https://httpstat.us/200")
request("https://httpbin.org/status/200")
end)
|> Task.await()

span_events = TestHelper.gather_harvest(Collector.SpanEvent.Harvester)

external_span = TestHelper.find_event(span_events, "External/httpstat.us/Finch/GET")
external_span = TestHelper.find_event(span_events, "External/httpbin.org/Finch/GET")

assert external_span[:"http.url"] == "https://httpstat.us/200"
assert external_span[:"http.url"] == "https://httpbin.org/status/200"
assert external_span[:"http.method"] == "GET"
assert external_span[:component] == "Finch"
assert external_span[:"response.status"] == 200
Expand All @@ -40,15 +40,15 @@ defmodule NewRelic.Telemetry.FinchTest do
test "[:finch, :request, :stop] - 500" do
Task.async(fn ->
NewRelic.start_transaction("FinchTest", "500")
request("https://httpstat.us/500")
request("https://httpbin.org/status/500")
end)
|> Task.await()

span_events = TestHelper.gather_harvest(Collector.SpanEvent.Harvester)

external_span = TestHelper.find_event(span_events, "External/httpstat.us/Finch/GET")
external_span = TestHelper.find_event(span_events, "External/httpbin.org/Finch/GET")

assert external_span[:"http.url"] == "https://httpstat.us/500"
assert external_span[:"http.url"] == "https://httpbin.org/status/500"
assert external_span[:"response.status"] == 500
end

Expand All @@ -73,17 +73,17 @@ defmodule NewRelic.Telemetry.FinchTest do
{:ok, pid} =
Task.start(fn ->
NewRelic.start_transaction("FinchTest", "Exception")
request("https://httpstat.us/200", :exception)
request("https://httpbin.org/status/200", :exception)
end)

Process.monitor(pid)
assert_receive {:DOWN, _ref, :process, ^pid, _reason}, 1_000

span_events = TestHelper.gather_harvest(Collector.SpanEvent.Harvester)

external_span = TestHelper.find_event(span_events, "External/httpstat.us/Finch/GET")
external_span = TestHelper.find_event(span_events, "External/httpbin.org/Finch/GET")

assert external_span[:"http.url"] == "https://httpstat.us/200"
assert external_span[:"http.url"] == "https://httpbin.org/status/200"
assert external_span[:error] == true
assert external_span[:"error.message"] =~ "Oops"
end
Expand Down
Loading