Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

enable apm-server self profiling by default #686

Merged
merged 1 commit into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/modules/elastic_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ def __init__(self, **options):
("monitoring.elasticsearch" if self.at_least_version("7.2") else "xpack.monitoring.elasticsearch", "true"),
("monitoring.enabled" if self.at_least_version("7.2") else "xpack.monitoring.enabled", "true")
])
if options.get("apm_server_self_instrument"):
if options.get("apm_server_self_instrument", True):
self.apm_server_command_args.append(("apm-server.instrumentation.enabled", "true"))
if self.at_least_version("7.6") and options.get("apm_server_profile", True):
self.apm_server_command_args.extend([
("apm-server.instrumentation.profiling.cpu.enabled", "true"),
("apm-server.instrumentation.profiling.heap.enabled", "true"),
])
self.depends_on = {"elasticsearch": {"condition": "service_healthy"}} if options.get(
"enable_elasticsearch", True) else {}
self.build = self.options.get("apm_server_build")
Expand Down Expand Up @@ -237,6 +242,11 @@ def add_arguments(cls, parser):
dest="apm_server_self_instrument",
help='disable apm-server self instrumentation.'
)
parser.add_argument(
"--no-apm-server-profile",
action="store_false",
help='disable apm-server self instrumentation profiling.'
)
parser.add_argument(
'--apm-server-count',
type=int,
Expand Down
23 changes: 23 additions & 0 deletions scripts/tests/service_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,29 @@ def test_queue_mem(self):
"no queue settings with memory queue (for now)"
)

def test_self_instrument(self):
# self instrumentation comes with profiling by default
apm_server = ApmServer(version="8.0.0").render()["apm-server"]
self.assertIn("apm-server.instrumentation.enabled=true", apm_server["command"])
self.assertIn("apm-server.instrumentation.profiling.cpu.enabled=true", apm_server["command"])
self.assertIn("apm-server.instrumentation.profiling.heap.enabled=true", apm_server["command"])

# self instrumentation comes with profiling by default but can be disabled
apm_server = ApmServer(
version="8.0.0", apm_server_self_instrument=True, apm_server_profile=False).render()["apm-server"]
self.assertIn("apm-server.instrumentation.enabled=true", apm_server["command"])
self.assertFalse(
any(e.startswith("apm-server.instrumentation.profiling") for e in apm_server["command"]),
"no self profiling settings expected"
)

# need self instrumentation enabled to get profiling
apm_server = ApmServer(
version="8.0.0", apm_server_self_instrument=False, apm_server_profile=True).render()["apm-server"]
self.assertNotIn("apm-server.instrumentation.enabled=true", apm_server["command"])
self.assertNotIn("apm-server.instrumentation.profiling.cpu.enabled=true", apm_server["command"])
self.assertNotIn("apm-server.instrumentation.profiling.heap.enabled=true", apm_server["command"])

def test_apm_server_build_branch(self):
apm_server = ApmServer(version="6.3.100", apm_server_build="foo.git@bar", release=True).render()["apm-server"]
self.assertIsNone(apm_server.get("image"))
Expand Down