Skip to content

Commit afe24ba

Browse files
Move inquire channel command to bypass translator
1 parent 7ced8f3 commit afe24ba

File tree

2 files changed

+49
-11
lines changed

2 files changed

+49
-11
lines changed

src/main/java/com/splunk/ibm/mq/metricscollector/InquireChannelCmdCollector.java

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.ibm.mq.headers.pcf.MQCFIL;
2222
import com.ibm.mq.headers.pcf.PCFException;
2323
import com.ibm.mq.headers.pcf.PCFMessage;
24+
import io.opentelemetry.api.common.AttributeKey;
25+
import io.opentelemetry.api.common.Attributes;
2426
import java.util.List;
2527
import java.util.Set;
2628
import org.jetbrains.annotations.NotNull;
@@ -112,17 +114,51 @@ public void publishMetrics() {
112114
private @NotNull List<Metric> getMetrics(PCFMessage message, String channelName)
113115
throws PCFException {
114116
List<Metric> responseMetrics = Lists.newArrayList();
115-
context.forEachMetric(
116-
(metrickey, wmqOverride) -> {
117-
if (message.getParameter(wmqOverride.getConstantValue()) == null) {
118-
logger.debug("Missing property {} on {}", metrickey, channelName);
119-
return;
120-
}
121-
int metricVal = message.getIntParameterValue(wmqOverride.getConstantValue());
122-
Metric metric =
123-
metricCreator.createMetric(metrickey, metricVal, wmqOverride, channelName, metrickey);
124-
responseMetrics.add(metric);
125-
});
117+
{
118+
int maxInstances = message.getIntParameterValue(CMQCFC.MQIACH_MAX_INSTANCES);
119+
Metric metric =
120+
metricCreator.createMetric(
121+
"mq.max.instances",
122+
maxInstances,
123+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
124+
responseMetrics.add(metric);
125+
}
126+
{
127+
int maxInstancesPerClient = message.getIntParameterValue(CMQCFC.MQIACH_MAX_INSTS_PER_CLIENT);
128+
Metric metric =
129+
metricCreator.createMetric(
130+
"mq.instances.per.client",
131+
maxInstancesPerClient,
132+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
133+
responseMetrics.add(metric);
134+
}
135+
{
136+
int count = message.getIntParameterValue(CMQCFC.MQIACH_MR_COUNT);
137+
Metric metric =
138+
metricCreator.createMetric(
139+
"mq.message.retry.count",
140+
count,
141+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
142+
responseMetrics.add(metric);
143+
}
144+
{
145+
int received = message.getIntParameterValue(CMQCFC.MQIACH_MSGS_RECEIVED);
146+
Metric metric =
147+
metricCreator.createMetric(
148+
"mq.message.received.count",
149+
received,
150+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
151+
responseMetrics.add(metric);
152+
}
153+
{
154+
int count = message.getIntParameterValue(CMQCFC.MQIACH_MSGS_SENT);
155+
Metric metric =
156+
metricCreator.createMetric(
157+
"mq.message.sent.count",
158+
count,
159+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
160+
responseMetrics.add(metric);
161+
}
126162
return responseMetrics;
127163
}
128164
}

src/test/java/com/splunk/ibm/mq/metricscollector/InquireChannelCmdCollectorTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ private PCFMessage[] createPCFResponseForInquireChannelCmd() {
135135
response1.addParameter(CMQCFC.MQIACH_MR_COUNT, 22);
136136
response1.addParameter(CMQCFC.MQIACH_MSGS_RECEIVED, 42);
137137
response1.addParameter(CMQCFC.MQIACH_MSGS_SENT, 64);
138+
response1.addParameter(CMQCFC.MQIACH_MAX_INSTANCES, 3);
139+
response1.addParameter(CMQCFC.MQIACH_MAX_INSTS_PER_CLIENT, 3);
138140

139141
return new PCFMessage[] {response1};
140142
}

0 commit comments

Comments
 (0)