Skip to content

Commit 5c3dbf3

Browse files
authored
Merge pull request #1419 from appsignal/nginx-port
Add `nginx_port` configuration option
2 parents 876db59 + b894f01 commit 5c3dbf3

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
bump: patch
33
type: add
4-
integrations: all
54
---
65

76
Add `nginx_port` configuration option. This configuration option can be used to customize the port on which the AppSignal integration exposes [the NGINX metrics server](https://docs.appsignal.com/metrics/nginx.html).

lib/appsignal/config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def dsl_config_file?
166166
:push_api_key => "APPSIGNAL_PUSH_API_KEY",
167167
:sidekiq_report_errors => "APPSIGNAL_SIDEKIQ_REPORT_ERRORS",
168168
:statsd_port => "APPSIGNAL_STATSD_PORT",
169+
:nginx_port => "APPSIGNAL_NGINX_PORT",
169170
:working_directory_path => "APPSIGNAL_WORKING_DIRECTORY_PATH",
170171
:revision => "APP_REVISION"
171172
}.freeze
@@ -436,6 +437,7 @@ def write_to_environment # rubocop:disable Metrics/AbcSize
436437
ENV["_APPSIGNAL_RUNNING_IN_CONTAINER"] = config_hash[:running_in_container].to_s
437438
ENV["_APPSIGNAL_SEND_ENVIRONMENT_METADATA"] = config_hash[:send_environment_metadata].to_s
438439
ENV["_APPSIGNAL_STATSD_PORT"] = config_hash[:statsd_port].to_s
440+
ENV["_APPSIGNAL_NGINX_PORT"] = config_hash[:nginx_port].to_s
439441
if config_hash[:working_directory_path]
440442
ENV["_APPSIGNAL_WORKING_DIRECTORY_PATH"] = config_hash[:working_directory_path]
441443
end

spec/lib/appsignal/config_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ def on_load
616616
:send_session_data => false,
617617
:sidekiq_report_errors => "all",
618618
:statsd_port => "7890",
619-
:working_directory_path => working_directory_path
619+
:working_directory_path => working_directory_path,
620+
:nginx_port => "4321"
620621
}
621622
end
622623
let(:env_vars) do
@@ -638,6 +639,7 @@ def on_load
638639
"APPSIGNAL_PUSH_API_KEY" => "aaa-bbb-ccc",
639640
"APPSIGNAL_SIDEKIQ_REPORT_ERRORS" => "all",
640641
"APPSIGNAL_STATSD_PORT" => "7890",
642+
"APPSIGNAL_NGINX_PORT" => "4321",
641643
"APPSIGNAL_WORKING_DIRECTORY_PATH" => working_directory_path,
642644
"APP_REVISION" => "v2.5.1",
643645

@@ -1002,6 +1004,7 @@ def on_load
10021004
expect(ENV.fetch("_APPSIGNAL_FILES_WORLD_ACCESSIBLE", nil)).to eq "true"
10031005
expect(ENV.fetch("_APPSIGNAL_SEND_ENVIRONMENT_METADATA", nil)).to eq "false"
10041006
expect(ENV.fetch("_APPSIGNAL_STATSD_PORT", nil)).to eq ""
1007+
expect(ENV.fetch("_APPSIGNAL_NGINX_PORT", nil)).to eq ""
10051008
expect(ENV.fetch("_APPSIGNAL_FILTER_PARAMETERS", nil)).to eq "password,confirm_password"
10061009
expect(ENV.fetch("_APPSIGNAL_FILTER_SESSION_DATA", nil)).to eq "key1,key2"
10071010
expect(ENV.fetch("_APP_REVISION", nil)).to eq "v2.5.1"
@@ -1043,6 +1046,15 @@ def on_load
10431046
expect(ENV.fetch("_APPSIGNAL_STATSD_PORT", nil)).to eq "1000"
10441047
end
10451048
end
1049+
1050+
context "with :nginx_port" do
1051+
let(:options) { { :nginx_port => "4321" } }
1052+
before { config.write_to_environment }
1053+
1054+
it "sets the nginx_port env var" do
1055+
expect(ENV.fetch("_APPSIGNAL_NGINX_PORT", nil)).to eq "4321"
1056+
end
1057+
end
10461058
end
10471059

10481060
describe "#log_file_path" do

0 commit comments

Comments
 (0)