Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Add New Relic (#186)
Browse files Browse the repository at this point in the history
This PR adds New Relic agent as Elixir dependency:
* Reports metrics and errors
* Forwards logs
  • Loading branch information
klaus993 authored Sep 21, 2023
1 parent e79724a commit 5ae9aef
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/deploy-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ jobs:
SSH_HOST: ${{ vars.SSH_HOST }}
GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
CONTINUATION_TOKEN_FORMAT: "large"
NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }}
NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }}
run: |
ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml
2 changes: 2 additions & 0 deletions .github/workflows/deploy-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ jobs:
ENABLE_LISTENER: "true"
ENABLE_GATEWAY_DATA: "true"
CONTINUATION_TOKEN_FORMAT: "large"
NEWRELIC_KEY: ${{ secrets.NEWRELIC_KEY }}
NEWRELIC_APP_NAME: ${{ vars.NEWRELIC_APP_NAME }}
run: |
ansible-playbook -i ansible/inventory.yaml ansible/playbooks/deployment.yaml
2 changes: 2 additions & 0 deletions ansible/playbooks/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
prover_storage: "{{ lookup('ansible.builtin.env', 'PROVER_STORAGE') }}"
enable_listener: "{{ lookup('ansible.builtin.env', 'ENABLE_LISTENER') }}"
enable_gateway_data: "{{ lookup('ansible.builtin.env', 'ENABLE_GATEWAY_DATA') }}"
newrelic_key: "{{ lookup('ansible.builtin.env', 'NEWRELIC_KEY') }}"
newrelic_app_name: "{{ lookup('ansible.builtin.env', 'NEWRELIC_APP_NAME') }}"

- name: Create user systemd directory
ansible.builtin.file:
Expand Down
2 changes: 2 additions & 0 deletions ansible/playbooks/templates/.env.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ AWS_REGION={{ aws_region }}
PROVER_STORAGE={{ prover_storage }}
ENABLE_LISTENER={{ enable_listener }}
ENABLE_GATEWAY_DATA={{ enable_gateway_data }}
NEWRELIC_KEY={{ newrelic_key }}
NEWRELIC_APP_NAME={{ newrelic_app_name }}
15 changes: 15 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ if config_env() == :prod do
],
secret_key_base: secret_key_base

# Newrelic agent
newrelic_license_key =
System.get_env("NEWRELIC_KEY") ||
raise "environment variable NEWRELIC_KEY is missing."

newrelic_app_name =
System.get_env("NEWRELIC_APP_NAME") ||
raise "environment variable NEWRELIC_APP_NAME is missing."

config :new_relic_agent,
app_name: newrelic_app_name,
license_key: newrelic_license_key,
# Logs are forwarded directly from Elixir to New Relic
logs_in_context: :direct

# ## SSL Support
#
# To get SSL working, you will need to add the `https` key
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ defmodule StarknetExplorer.MixProject do
{:sweet_xml, "~> 0.7.0"},
{:ecto_sqlite3, ">= 0.0.0"},
{:esbuild, "~> 0.4", runtime: Mix.env() == :dev},
{:scrivener_ecto, "~> 2.7"}
{:scrivener_ecto, "~> 2.7"},
{:new_relic_agent, "~> 1.0", only: :prod}
]
end

Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"},
"new_relic_agent": {:hex, :new_relic_agent, "1.27.8", "a2835b686bc46fc7e53222651cce56a253ae1cedef6dd4042a2f12d41ff95624", [:mix], [{:castore, ">= 0.1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:ecto, ">= 3.4.1", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, ">= 3.4.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.5.5", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, ">= 1.10.4", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 2.4.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:redix, ">= 0.11.0", [hex: :redix, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fd52f329db7d731a767d5f527f4424dd72d26c5c89f04504b769d4fa7f1ee77c"},
"nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},
"nimble_pool": {:hex, :nimble_pool, "1.0.0", "5eb82705d138f4dd4423f69ceb19ac667b3b492ae570c9f5c900bb3d2f50a847", [:mix], [], "hexpm", "80be3b882d2d351882256087078e1b1952a28bf98d0a287be87e4a24a710b67a"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
Expand Down

0 comments on commit 5ae9aef

Please sign in to comment.