elixir_agent icon indicating copy to clipboard operation
elixir_agent copied to clipboard

Newrelic Agent does not send transaction data when run as release eval

Open nathanjohnson320 opened this issue 2 years ago • 0 comments

Describe the bug When running a function in a release eval the events do not get sent to newrelic without a long running process. This is not the case when running a release with start_iex

Some solutions I have tried

  • Regular function transaction that starts newrelic and the app
  • Calling NewRelic.manual_shutdown() after the stop transaction
  • Using NewRelic.other_transaction instead of start/stop transaction
  • Copying the macro code from instrumented mix tasks
    • This one results in an exception when stopping new_relic_agent # (stdlib 3.15.1) :ets.lookup(NewRelic.Transaction.Sidecar.ContextStore, {:context, nil}
  • Adding a long Process.sleep at the end of the function
    • This works but isn't really feasible

This repo has all these in a minimal app if that helps diagnose the behavior https://github.com/nathanjohnson320/nr_test/blob/master/lib/nr_test.ex#L7

The general way to reproduce is to do a release

  • MIX_ENV=prod mix release

and then eval the run function

  • _build/prod/rel/nr_test/bin/nr_test eval 'NrTest.run()'

If you check newrelic for the events they do not display however if you use the start_iex command instead of eval new_relic will record the transactions. I am not sure what other steps to take to debug/diagnose what the underlying problem is here.

Environment

  • Elixir & Erlang version (elixir -v): Elixir 1.12.2 (compiled with Erlang/OTP 24)
  • Agent version (mix deps | grep new_relic_agent): new_relic_agent 1.27.7 (Hex package) (mix)

nathanjohnson320 avatar Mar 18 '22 15:03 nathanjohnson320