Skip to content

Commit ffdc3e5

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

File tree

2 files changed

+58
-11
lines changed

2 files changed

+58
-11
lines changed

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

Lines changed: 56 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,60 @@ 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 = 0;
137+
if (message.getParameter(CMQCFC.MQIACH_MR_COUNT) != null) {
138+
count = message.getIntParameterValue(CMQCFC.MQIACH_MR_COUNT);
139+
}
140+
Metric metric =
141+
metricCreator.createMetric(
142+
"mq.message.retry.count",
143+
count,
144+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
145+
responseMetrics.add(metric);
146+
}
147+
{
148+
int received = 0;
149+
if (message.getParameter(CMQCFC.MQIACH_MSGS_RECEIVED) != null) {
150+
received = message.getIntParameterValue(CMQCFC.MQIACH_MSGS_RECEIVED);
151+
}
152+
Metric metric =
153+
metricCreator.createMetric(
154+
"mq.message.received.count",
155+
received,
156+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
157+
responseMetrics.add(metric);
158+
}
159+
{
160+
int count = 0;
161+
if (message.getParameter(CMQCFC.MQIACH_MSGS_SENT) != null) {
162+
count = message.getIntParameterValue(CMQCFC.MQIACH_MSGS_SENT);
163+
}
164+
Metric metric =
165+
metricCreator.createMetric(
166+
"mq.message.sent.count",
167+
count,
168+
Attributes.of(AttributeKey.stringKey("channel.name"), channelName));
169+
responseMetrics.add(metric);
170+
}
126171
return responseMetrics;
127172
}
128173
}

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)