Skip to content

Commit

Permalink
Add statsd_port config option
Browse files Browse the repository at this point in the history
Allow configuration of the agent's statsd server port through the
statsd_port option.

Requires an agent update from
appsignal/appsignal-agent#995
  • Loading branch information
tombruijn committed May 31, 2023
1 parent 6f0a3c8 commit 37810e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changesets/statsd-port-config-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "add"
---

Allow configuration of the agent's StatsD server port through the `statsd_port` option.
4 changes: 3 additions & 1 deletion lib/appsignal/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ defmodule Appsignal.Config do
"APPSIGNAL_SEND_PARAMS" => :send_params,
"APPSIGNAL_SEND_SESSION_DATA" => :send_session_data,
"APPSIGNAL_SKIP_SESSION_DATA" => :skip_session_data,
"APPSIGNAL_STATSD_PORT" => :statsd_port,
"APPSIGNAL_TRANSACTION_DEBUG_MODE" => :transaction_debug_mode,
"APPSIGNAL_WORKING_DIRECTORY_PATH" => :working_directory_path,
"APPSIGNAL_WORKING_DIR_PATH" => :working_dir_path,
Expand All @@ -331,7 +332,7 @@ defmodule Appsignal.Config do
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_LEVEL APPSIGNAL_LOG_PATH
APPSIGNAL_LOGGING_ENDPOINT APPSIGNAL_WORKING_DIR_PATH APPSIGNAL_WORKING_DIRECTORY_PATH APPSIGNAL_CA_FILE_PATH
APPSIGNAL_DIAGNOSE_ENDPOINT APP_REVISION APPSIGNAL_REPORT_OBAN_ERRORS
APPSIGNAL_DIAGNOSE_ENDPOINT APP_REVISION APPSIGNAL_REPORT_OBAN_ERRORS APPSIGNAL_STATSD_PORT
)
@bool_keys ~w(
APPSIGNAL_ACTIVE APPSIGNAL_DEBUG APPSIGNAL_INSTRUMENT_NET_HTTP APPSIGNAL_ENABLE_FRONTEND_ERROR_CATCHING
Expand Down Expand Up @@ -463,6 +464,7 @@ defmodule Appsignal.Config do

Nif.env_put("_APPSIGNAL_SEND_PARAMS", to_string(config[:send_params]))
Nif.env_put("_APPSIGNAL_SEND_SESSION_DATA", to_string(config[:send_session_data]))
Nif.env_put("_APPSIGNAL_STATSD_PORT", to_string(config[:statsd_port]))
Nif.env_put("_APPSIGNAL_RUNNING_IN_CONTAINER", to_string(config[:running_in_container]))
Nif.env_put("_APPSIGNAL_TRANSACTION_DEBUG_MODE", to_string(config[:transaction_debug_mode]))
Nif.env_put("_APPSIGNAL_WORKING_DIRECTORY_PATH", to_string(config[:working_directory_path]))
Expand Down
16 changes: 15 additions & 1 deletion test/appsignal/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ defmodule Appsignal.ConfigTest do
assert output =~ "Deprecation warning: The `skip_session_data` config option is deprecated."
end

test "statsd_port" do
assert %{statsd_port: "3000"} = with_config(%{statsd_port: "3000"}, &init_config/0)
end

test "transaction_debug_mode" do
assert %{transaction_debug_mode: true} =
with_config(%{transaction_debug_mode: true}, &init_config/0)
Expand Down Expand Up @@ -926,6 +930,13 @@ defmodule Appsignal.ConfigTest do
assert output =~ "Deprecation warning: The `skip_session_data` config option is deprecated."
end

test "statsd_port" do
assert with_env(
%{"APPSIGNAL_STATSD_PORT" => "3000"},
&init_config/0
) == default_configuration() |> Map.put(:statsd_port, "3000")
end

test "transaction_debug_mode" do
assert with_env(
%{"APPSIGNAL_TRANSACTION_DEBUG_MODE" => "true"},
Expand Down Expand Up @@ -1148,6 +1159,7 @@ defmodule Appsignal.ConfigTest do
assert Nif.env_get("_APPSIGNAL_WORKING_DIR_PATH") == ~c""
assert Nif.env_get("_APPSIGNAL_WORKING_DIRECTORY_PATH") == ~c""
assert Nif.env_get("_APPSIGNAL_RUNNING_IN_CONTAINER") == ~c""
assert Nif.env_get("_APPSIGNAL_STATSD_PORT") == ~c""
assert Nif.env_get("_APP_REVISION") == ~c""
end

Expand Down Expand Up @@ -1198,7 +1210,8 @@ defmodule Appsignal.ConfigTest do
revision: "03bd9e",
transaction_debug_mode: true,
filter_parameters: ["password", "confirm_password"],
filter_session_data: ["key1", "key2"]
filter_session_data: ["key1", "key2"],
statsd_port: "3000"
},
fn ->
without_logger(&write_to_environment/0)
Expand Down Expand Up @@ -1240,6 +1253,7 @@ defmodule Appsignal.ConfigTest do
assert Nif.env_get("_APPSIGNAL_FILTER_PARAMETERS") == ~c"password,confirm_password"
assert Nif.env_get("_APPSIGNAL_FILTER_SESSION_DATA") == ~c"key1,key2"
assert Nif.env_get("_APPSIGNAL_SEND_ENVIRONMENT_METADATA") == ~c"true"
assert Nif.env_get("_APPSIGNAL_STATSD_PORT") == ~c"3000"
assert Nif.env_get("_APP_REVISION") == ~c"03bd9e"
end
)
Expand Down

0 comments on commit 37810e1

Please sign in to comment.