From f6aa45d5eb58f0a4e04fe7e5436ac1b95dd0b473 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Sun, 30 Jul 2023 17:46:46 -0400 Subject: [PATCH] Change thread group label to snake_case (#130) * use snake_case for thread group label * add test case for thread_group --- .../github/johrstrom/listener/updater/AbstractUpdater.java | 4 ++-- .../johrstrom/listener/updater/AbstractUpdaterTest.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/johrstrom/listener/updater/AbstractUpdater.java b/src/main/java/com/github/johrstrom/listener/updater/AbstractUpdater.java index 1db3af3..002e30a 100644 --- a/src/main/java/com/github/johrstrom/listener/updater/AbstractUpdater.java +++ b/src/main/java/com/github/johrstrom/listener/updater/AbstractUpdater.java @@ -77,13 +77,13 @@ protected String[] labelValues(SampleEvent event) { String name = labels[i]; String value = null; - // reserved keyword for the sampler's label (the name) + // reserved keywords for the sampler's label name. if (name.equalsIgnoreCase("label")) { value = event.getResult().getSampleLabel(); } else if (name.equalsIgnoreCase("code")) { // code also reserved value = event.getResult().getResponseCode(); - } else if (name.equalsIgnoreCase("threadGroup")) { + } else if (name.equalsIgnoreCase("thread_group")) { value = event.getThreadGroup(); // try to find it as a plain'ol variable. diff --git a/src/test/java/com/github/johrstrom/listener/updater/AbstractUpdaterTest.java b/src/test/java/com/github/johrstrom/listener/updater/AbstractUpdaterTest.java index e46d76a..efc3172 100644 --- a/src/test/java/com/github/johrstrom/listener/updater/AbstractUpdaterTest.java +++ b/src/test/java/com/github/johrstrom/listener/updater/AbstractUpdaterTest.java @@ -29,7 +29,7 @@ public void update(SampleEvent e) { @Test public void testKeywords() { BaseCollectorConfig base = TestUtilities.simpleCounterCfg(); - base.setLabels(new String[] {"label","code"}); + base.setLabels(new String[] {"label","code", "thread_group"}); ListenerCollectorConfig cfg = new ListenerCollectorConfig(base); TestUpdater u = new TestUpdater(cfg); @@ -42,8 +42,8 @@ public void testKeywords() { String[] labels = u.labelValues(event); - Assert.assertTrue(labels.length == 2); - Assert.assertArrayEquals(new String[] {"test_label", "204"}, labels); + Assert.assertTrue(labels.length == 3); + Assert.assertArrayEquals(new String[] {"test_label", "204", "test_tg"}, labels); } @Test