-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors on Application.stop in simple Mix Task #212
Comments
Hello thanks for the report! I took a look locally and I think your task completes too fast for the Agent to have completed it's boot process. The Agent needs to make a request to NewRelic upon boot which is not done synchronously in the supervision tree (that'd block your app). A quick fix for this would be to make a call to a GenServer that will only respond after it's fully connected: Application.ensure_all_started(:new_relic_agent)
GenServer.call(NewRelic.Harvest.Collector.AgentRun, :ping) I can add simpler function that can be called instead of this one and also protect against the failure you are seeing |
Hey @binaryseed thanks for the explanation and quick fix tip, I appreciate it! What you said makes sense and that simple test task was probably a snowflake, but I appreciate you making an API update to proactively prevent it in the future. Thanks again! |
I had one final quick question in this timing regard, @binaryseed. Is there a way to flush the metrics to NewRelic before |
It does flush everything upon shutdown, what data are you expecting? There won't be an automatic Transaction created for the task, that's something you'd currently need to instrument yourself. Perhaps I can wrap up all of this & auto-create a Transaction in the function I was talking about... |
Hey @binaryseed thanks for clarifying. Indeed, I was hoping an automatic Transaction would be created for the Mix Task. That would be great if you could autowrap all of that into a single function call! 👍 Also, can you please point me to any docs/snippets that show what I would need to manually do for a Transaction in the meantime? Thank you! |
Perfect thanks sorry I missed that! |
I have a PR that adds nice & easy |
That is great, thanks @binaryseed ! |
GenServer error in simple Mix Task
Hi there, I'm trying to instrument the following simple Mix Task:
but I keep getting this error:
Environment
elixir -v
):mix deps | grep new_relic_agent
):Any ideas on what may be the problem? Thank you!
The text was updated successfully, but these errors were encountered: