How can you send `revision` to Appsignal from a Phoenix app?

With Appsignal, you can use deploy markers to flag when a bug happened in the git timeline.

In my appsignal.exs file I have:

use Mix.Config

config :appsignal, :config,
  otp_app: :my_app,
  name: "my_app",
  push_api_key: "my_key",
  env: Mix.env(),
  revision: System.get_env("RENDER_GIT_COMMIT")

However I don’t think it’s pulling the right value during compilation using mix release.

Does anyone have experience with this?

I’m using that setting on a project of mine and it works fine – though not using render for that one.

Interesting, do you mind pasting your appsignal.exs file here to compare? I also tried changing to import Config at the top of the file and it doesn’t seem to grab the revision flag.

It looks the same as the code you posted besides a different system env variable name.

Very weird… I wonder if the ENV var is just not there.

This worked fine:

import Config

config :appsignal, :config,
  otp_app: :my_app,
  name: "my_app",
  push_api_key: "my_key",
  env: Mix.env(),
  revision: "jan-10-2023-test"

I wonder why the ENV value isn’t being loaded in properly…

I got it to work.

For posterity, I delete the appsignal.exs file that Appsignal recommends.

Instead I put the appsignal configuration in runtime.exs where I know System.get_env works fine.

if config_env() == :prod do
  config :appsignal, :config,
    otp_app: :my_app,
    name: "my_app",
    push_api_key: "my_key",
    env: :prod,
    revision: System.get_env("RENDER_GIT_COMMIT")

And now I can see the deploy marker.

image

1 Like