|
21 | 21 | import com.ibm.mq.headers.pcf.MQCFIL;
|
22 | 22 | import com.ibm.mq.headers.pcf.PCFException;
|
23 | 23 | import com.ibm.mq.headers.pcf.PCFMessage;
|
| 24 | +import io.opentelemetry.api.common.AttributeKey; |
| 25 | +import io.opentelemetry.api.common.Attributes; |
24 | 26 | import java.util.List;
|
25 | 27 | import java.util.Set;
|
26 | 28 | import org.jetbrains.annotations.NotNull;
|
@@ -112,17 +114,51 @@ public void publishMetrics() {
|
112 | 114 | private @NotNull List<Metric> getMetrics(PCFMessage message, String channelName)
|
113 | 115 | throws PCFException {
|
114 | 116 | 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 | + } |
126 | 162 | return responseMetrics;
|
127 | 163 | }
|
128 | 164 | }
|
0 commit comments