Skip to content

Commit e531134

Browse files
committed
Add nginx_port configuration option
Implement an `nginx_port` configuration option that is passed on to the agent, like the existing `statsd_port` and `opentelemetry_port` configuration options.
1 parent 8a53e98 commit e531134

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
bump: patch
3+
type: add
4+
---
5+
6+
Add `nginxPort` 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).

src/appsignal/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Options(TypedDict, total=False):
3838
log_level: str | None
3939
log_path: str | None
4040
logging_endpoint: str | None
41+
nginx_port: str | int | None
4142
opentelemetry_port: str | int | None
4243
name: str | None
4344
push_api_key: str | None
@@ -184,6 +185,7 @@ def load_from_environment() -> Options:
184185
log_level=os.environ.get("APPSIGNAL_LOG_LEVEL"),
185186
log_path=os.environ.get("APPSIGNAL_LOG_PATH"),
186187
logging_endpoint=os.environ.get("APPSIGNAL_LOGGING_ENDPOINT"),
188+
nginx_port=os.environ.get("APPSIGNAL_NGINX_PORT"),
187189
opentelemetry_port=os.environ.get("APPSIGNAL_OPENTELEMETRY_PORT"),
188190
name=os.environ.get("APPSIGNAL_APP_NAME"),
189191
push_api_key=os.environ.get("APPSIGNAL_PUSH_API_KEY"),
@@ -252,6 +254,7 @@ def set_private_environ(self) -> None:
252254
"_APPSIGNAL_LOG_LEVEL": options.get("log_level"),
253255
"_APPSIGNAL_LOG_FILE_PATH": self.log_file_path(),
254256
"_APPSIGNAL_LOGGING_ENDPOINT": options.get("logging_endpoint"),
257+
"_APPSIGNAL_NGINX_PORT": options.get("nginx_port"),
255258
"_APPSIGNAL_OPENTELEMETRY_PORT": options.get("opentelemetry_port"),
256259
"_APPSIGNAL_PUSH_API_KEY": options.get("push_api_key"),
257260
"_APPSIGNAL_PUSH_API_ENDPOINT": options.get("endpoint"),

tests/test_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def test_environ_source():
6464
os.environ["APPSIGNAL_IGNORE_NAMESPACES"] = "namespace1,namespace2"
6565
os.environ["APPSIGNAL_LOG_LEVEL"] = "trace"
6666
os.environ["APPSIGNAL_LOG_PATH"] = "/path/to/log_dir"
67+
os.environ["APPSIGNAL_NGINX_PORT"] = "8080"
6768
os.environ["APPSIGNAL_OPENTELEMETRY_PORT"] = "9002"
6869
os.environ["APPSIGNAL_PUSH_API_KEY"] = "some-api-key"
6970
os.environ["APPSIGNAL_PUSH_API_ENDPOINT"] = "https://push.appsignal.com"
@@ -100,6 +101,7 @@ def test_environ_source():
100101
ignore_namespaces=["namespace1", "namespace2"],
101102
log_level="trace",
102103
log_path="/path/to/log_dir",
104+
nginx_port="8080",
103105
opentelemetry_port="9002",
104106
name="MyApp",
105107
push_api_key="some-api-key",
@@ -198,6 +200,7 @@ def test_set_private_environ():
198200
ignore_namespaces=["namespace1", "namespace2"],
199201
log_level="trace",
200202
log_path=cwdir,
203+
nginx_port=8080,
201204
opentelemetry_port=9002,
202205
name="MyApp",
203206
push_api_key="some-api-key",
@@ -235,6 +238,7 @@ def test_set_private_environ():
235238
assert os.environ["_APPSIGNAL_IGNORE_NAMESPACES"] == "namespace1,namespace2"
236239
assert os.environ["_APPSIGNAL_LOG_LEVEL"] == "trace"
237240
assert os.environ["_APPSIGNAL_LOG_FILE_PATH"] == f"{cwdir}/appsignal.log"
241+
assert os.environ["_APPSIGNAL_NGINX_PORT"] == "8080"
238242
assert os.environ["_APPSIGNAL_OPENTELEMETRY_PORT"] == "9002"
239243
assert os.environ["_APPSIGNAL_PUSH_API_KEY"] == "some-api-key"
240244
assert os.environ["_APPSIGNAL_PUSH_API_ENDPOINT"] == "https://push.appsignal.com"

0 commit comments

Comments
 (0)