Skip to content

Commit 292588c

Browse files
authored
added include_process_args config option (#1867)
closes #1860
1 parent e5aaf3d commit 292588c

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

docs/configuration.asciidoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,17 @@ views.
12581258
If set to `True`, the agent will intercept the default `sys.excepthook`, which
12591259
allows the agent to collect all uncaught exceptions.
12601260

1261+
[float]
1262+
[[config-include-process-args]]
1263+
==== `include_process_args`
1264+
1265+
[options="header"]
1266+
|============
1267+
| Environment | Django/Flask | Default
1268+
| `ELASTIC_APM_INCLUDE_PROCESS_ARGS` | `INCLUDE_PROCESS_ARGS` | `False`
1269+
|============
1270+
1271+
Whether each transaction should have the process arguments attached. Disabled by default to save disk space.
12611272

12621273
[float]
12631274
[[config-django-specific]]

elasticapm/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,14 @@ def get_service_info(self):
370370
return result
371371

372372
def get_process_info(self):
373-
return {
373+
result = {
374374
"pid": os.getpid(),
375375
"ppid": os.getppid() if hasattr(os, "getppid") else None,
376-
"argv": sys.argv,
377376
"title": None, # Note: if we implement this, the value needs to be wrapped with keyword_field
378377
}
378+
if self.config.include_process_args:
379+
result["argv"] = sys.argv
380+
return result
379381

380382
def get_system_info(self):
381383
system_data = {

elasticapm/conf/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ class Config(_ConfigBase):
691691
],
692692
default=TRACE_CONTINUATION_STRATEGY.CONTINUE,
693693
)
694+
include_process_args = _BoolConfigValue("INCLUDE_PROCESS_ARGS", default=False)
694695

695696
@property
696697
def is_recording(self):

tests/client/client_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,17 @@ def test_service_info_node_name(elasticapm_client):
7575

7676

7777
def test_process_info(elasticapm_client):
78-
with mock.patch.object(sys, "argv", ["a", "b", "c"]):
79-
process_info = elasticapm_client.get_process_info()
78+
process_info = elasticapm_client.get_process_info()
8079
assert process_info["pid"] == os.getpid()
8180
if hasattr(os, "getppid"):
8281
assert process_info["ppid"] == os.getppid()
8382
else:
8483
# Windows + Python 2.7
8584
assert process_info["ppid"] is None
85+
assert "argv" not in process_info
86+
elasticapm_client.config.update("1", include_process_args=True)
87+
with mock.patch.object(sys, "argv", ["a", "b", "c"]):
88+
process_info = elasticapm_client.get_process_info()
8689
assert process_info["argv"] == ["a", "b", "c"]
8790

8891

0 commit comments

Comments
 (0)