Skip to content

Commit

Permalink
🚀 Restore :revision config (#315)
Browse files Browse the repository at this point in the history
* Restore :revision config

Closes #215.

* Always set APP_REVISION in Config.write_to_environment/0

* Bump agent to 4d113e7

- Unset revision config option when the APP_REVISION environment
  variable only contains an empty string.

* :revision doesn't override APP_REVISION

* Set :revision from APP_REVISION

* Use underscored _APP_REVISION environment variable

* Bump agent to ca32965

Underscore `_APP_REVISION` environment variable.
  • Loading branch information
jeffkreeftmeijer authored Mar 20, 2018
1 parent 6149b79 commit d991f28
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 24 deletions.
42 changes: 21 additions & 21 deletions agent.exs
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
defmodule Appsignal.Agent do
def version, do: "ee63235"
def version, do: "ca32965"

def triples do
%{
"x86_64-darwin" => %{
checksum: "44566908e93a31fbbc5f4ba35f41de99947c3c748287283600868fbbe5c18338",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-darwin-all-static.tar.gz"
checksum: "4536f611bf2e31137520fcbbf2175dd19e86d4ae8c1d2910b82cb63d67634a8e",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-darwin-all-static.tar.gz"
},
"universal-darwin" => %{
checksum: "44566908e93a31fbbc5f4ba35f41de99947c3c748287283600868fbbe5c18338",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-darwin-all-static.tar.gz"
checksum: "4536f611bf2e31137520fcbbf2175dd19e86d4ae8c1d2910b82cb63d67634a8e",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-darwin-all-static.tar.gz"
},
"i686-linux" => %{
checksum: "85d4ac72aaed0b08226fc5a12fe210f2789d97bc162e15d8d36273c3936a5e19",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-i686-linux-all-static.tar.gz"
checksum: "c5e0cfcc1a26bab694dda5297c9f34fd76d020709475062a2a5d7b1e11a02231",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-i686-linux-all-static.tar.gz"
},
"x86-linux" => %{
checksum: "85d4ac72aaed0b08226fc5a12fe210f2789d97bc162e15d8d36273c3936a5e19",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-i686-linux-all-static.tar.gz"
checksum: "c5e0cfcc1a26bab694dda5297c9f34fd76d020709475062a2a5d7b1e11a02231",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-i686-linux-all-static.tar.gz"
},
"i686-linux-musl" => %{
checksum: "59beb7c8b7b6e3ade4f654e300aa53cb0a7d9bbbd547257b52d2e19c49ddb6d5",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-i686-linux-musl-all-static.tar.gz"
checksum: "a6e45a2c4a9054cbfb71dcacd23c012dc01b4b0af40b356c67153ce728f57e16",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-i686-linux-musl-all-static.tar.gz"
},
"x86-linux-musl" => %{
checksum: "59beb7c8b7b6e3ade4f654e300aa53cb0a7d9bbbd547257b52d2e19c49ddb6d5",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-i686-linux-musl-all-static.tar.gz"
checksum: "a6e45a2c4a9054cbfb71dcacd23c012dc01b4b0af40b356c67153ce728f57e16",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-i686-linux-musl-all-static.tar.gz"
},
"x86_64-linux" => %{
checksum: "a05243504688705d93caf105da29ecbca6b190eb2cd9b0f09673aacd4824d435",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-linux-all-static.tar.gz"
checksum: "ec400854cc123e73655bb09ebc4554726a2658980cfe5347f36076f74dac0524",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-linux-all-static.tar.gz"
},
"x86_64-linux-musl" => %{
checksum: "9ddbc05f47776d712e58be84f0d31fe1cb23eeab90afe79a2724db13b1471ba4",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-linux-musl-all-static.tar.gz"
checksum: "84250cf6d97893c584f779c7ad600e4e7d1b280eae36a76815173a83df85bd3a",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-linux-musl-all-static.tar.gz"
},
"x86_64-freebsd" => %{
checksum: "b7200bf705cdbafad2d62f24554f90a7f317ad9fc4121e9a8a33f36bf1060215",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-freebsd-all-static.tar.gz"
checksum: "ce28eed8dd12e6886657517bc0e1da442fbad135e449fb3a430c35087ed13973",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-freebsd-all-static.tar.gz"
},
"amd64-freebsd" => %{
checksum: "b7200bf705cdbafad2d62f24554f90a7f317ad9fc4121e9a8a33f36bf1060215",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ee63235/appsignal-x86_64-freebsd-all-static.tar.gz"
checksum: "ce28eed8dd12e6886657517bc0e1da442fbad135e449fb3a430c35087ed13973",
download_url: "https://appsignal-agent-releases.global.ssl.fastly.net/ca32965/appsignal-x86_64-freebsd-all-static.tar.gz"
},
}
end
Expand Down
6 changes: 4 additions & 2 deletions lib/appsignal/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ defmodule Appsignal.Config do
"APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
"APPSIGNAL_ENABLE_HOST_METRICS" => :enable_host_metrics,
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
"APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible
"APPSIGNAL_FILES_WORLD_ACCESSIBLE" => :files_world_accessible,
"APP_REVISION" => :revision
}

@string_keys ~w(APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_KEY APPSIGNAL_PUSH_API_ENDPOINT APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HOSTNAME APPSIGNAL_HTTP_PROXY APPSIGNAL_LOG APPSIGNAL_LOG_PATH APPSIGNAL_WORKING_DIR_PATH APPSIGNAL_CA_FILE_PATH)
@string_keys ~w(APPSIGNAL_APP_NAME APPSIGNAL_PUSH_API_KEY APPSIGNAL_PUSH_API_ENDPOINT APPSIGNAL_FRONTEND_ERROR_CATCHING_PATH APPSIGNAL_HOSTNAME APPSIGNAL_HTTP_PROXY APPSIGNAL_LOG APPSIGNAL_LOG_PATH APPSIGNAL_WORKING_DIR_PATH APPSIGNAL_CA_FILE_PATH APP_REVISION)
@bool_keys ~w(APPSIGNAL_ACTIVE APPSIGNAL_DEBUG APPSIGNAL_INSTRUMENT_NET_HTTP APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING APPSIGNAL_ENABLE_ALLOCATION_TRACKING APPSIGNAL_ENABLE_GC_INSTRUMENTATION APPSIGNAL_RUNNING_IN_CONTAINER APPSIGNAL_ENABLE_HOST_METRICS APPSIGNAL_SKIP_SESSION_DATA APPSIGNAL_FILES_WORLD_ACCESSIBLE)
@atom_keys ~w(APPSIGNAL_APP_ENV)
@string_list_keys ~w(APPSIGNAL_FILTER_PARAMETERS APPSIGNAL_IGNORE_ACTIONS APPSIGNAL_IGNORE_ERRORS APPSIGNAL_IGNORE_NAMESPACES APPSIGNAL_DNS_SERVERS)
Expand Down Expand Up @@ -199,6 +200,7 @@ defmodule Appsignal.Config do
System.put_env("_APPSIGNAL_SEND_PARAMS", to_string(config[:send_params]))
System.put_env("_APPSIGNAL_WORKING_DIR_PATH", to_string(config[:working_dir_path]))
System.put_env("_APPSIGNAL_FILES_WORLD_ACCESSIBLE", to_string(config[:files_world_accessible]))
System.put_env("_APP_REVISION", to_string(config[:revision]))
end

@doc """
Expand Down
17 changes: 16 additions & 1 deletion test/appsignal/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ defmodule Appsignal.ConfigTest do
assert with_config(%{working_dir_path: "/tmp/appsignal"}, &init_config/0)
== default_configuration() |> Map.put(:working_dir_path, "/tmp/appsignal")
end

test "revision" do
assert with_config(%{revision: "03bd9e"}, &init_config/0)
== default_configuration() |> Map.put(:revision, "03bd9e")
end
end

describe "using the system environment" do
Expand Down Expand Up @@ -351,6 +356,13 @@ defmodule Appsignal.ConfigTest do
&init_config/0
) == default_configuration() |> Map.put(:working_dir_path, "/tmp/appsignal")
end

test "revision" do
assert with_env(
%{"APP_REVISION" => "03bd9e"},
&init_config/0
) == default_configuration() |> Map.put(:revision, "03bd9e")
end
end

test "system environment overwrites application environment configuration" do
Expand Down Expand Up @@ -424,6 +436,7 @@ defmodule Appsignal.ConfigTest do
assert System.get_env("_APPSIGNAL_LOG_FILE_PATH") == ""
assert System.get_env("_APPSIGNAL_WORKING_DIR_PATH") == ""
assert System.get_env("_APPSIGNAL_RUNNING_IN_CONTAINER") == ""
assert System.get_env("_APP_REVISION") == ""
end

test "deletes existing configuration in environment" do
Expand Down Expand Up @@ -464,7 +477,8 @@ defmodule Appsignal.ConfigTest do
name: "AppSignal test suite app",
running_in_container: false,
working_dir_path: "/tmp/appsignal",
files_world_accessible: false
files_world_accessible: false,
revision: "03bd9e"
}, fn() ->
write_to_environment()

Expand All @@ -491,6 +505,7 @@ defmodule Appsignal.ConfigTest do
assert System.get_env("_APPSIGNAL_SEND_PARAMS") == "true"
assert System.get_env("_APPSIGNAL_WORKING_DIR_PATH") == "/tmp/appsignal"
assert System.get_env("_APPSIGNAL_FILES_WORLD_ACCESSIBLE") == "false"
assert System.get_env("_APP_REVISION") == "03bd9e"
end)
end

Expand Down

0 comments on commit d991f28

Please sign in to comment.