Skip to content

Commit 2eb5642

Browse files
committed
feat: test alias usage for custom jmx metrics
1 parent 361908b commit 2eb5642

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

buildpack/telemetry/datadog.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from buildpack import util
2323
from buildpack.core import runtime
2424
from buildpack.infrastructure import database
25+
from buildpack.telemetry.metrics import deny_all_apm_metrics
2526
from lib.m2ee.version import MXVersion
2627
from lib.m2ee.util import strtobool
2728

@@ -253,7 +254,7 @@ def _set_up_dd_java_agent(m2ee, model_version, runtime_version, jmx_config_files
253254
util.upsert_javaopts(
254255
m2ee,
255256
[
256-
"-Ddd.jmxfetch.enabled=true",
257+
f"-Ddd.jmxfetch.enabled=true",
257258
f"-Ddd.jmxfetch.statsd.port={get_statsd_port()}",
258259
],
259260
)
@@ -287,7 +288,7 @@ def _get_runtime_jmx_config(extra_jmx_instance_config=None):
287288
# NamedUserSessions = 0;
288289
# AnonymousSessions = 0;
289290
"attribute": {
290-
"NamedUsers": {"metrics_type": "gauge"},
291+
"NamedUsers": {"metrics_type": "gauge", "alias": "mx.ekrem_test_named_users"},
291292
"NamedUserSessions": {"metrics_type": "gauge"},
292293
"AnonymousSessions": {"metrics_type": "gauge"},
293294
},
@@ -493,18 +494,19 @@ def update_config(
493494
},
494495
)
495496

496-
# Set up runtime JMX configuration
497-
with open(_get_jmx_conf_file(), "w") as file_handler:
498-
file_handler.write(
499-
yaml.safe_dump(
500-
_get_runtime_jmx_config(
501-
extra_jmx_instance_config=extra_jmx_instance_config,
497+
if not deny_all_apm_metrics():
498+
# Set up runtime JMX configuration
499+
with open(_get_jmx_conf_file(), "w") as file_handler:
500+
file_handler.write(
501+
yaml.safe_dump(
502+
_get_runtime_jmx_config(
503+
extra_jmx_instance_config=extra_jmx_instance_config,
504+
)
502505
)
503506
)
504-
)
507+
jmx_config_files.append(_get_jmx_conf_file())
505508

506509
# Set up Datadog Java Trace Agent
507-
jmx_config_files.append(_get_jmx_conf_file())
508510
_set_up_dd_java_agent(
509511
m2ee,
510512
model_version,

0 commit comments

Comments
 (0)