rocketmq-client-nodejs 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +61 -0
  2. package/dist/client/BaseClient.d.ts +36 -1
  3. package/dist/client/BaseClient.js +176 -12
  4. package/dist/client/RpcClient.js +14 -2
  5. package/dist/client/RpcClientManager.d.ts +5 -0
  6. package/dist/client/RpcClientManager.js +25 -8
  7. package/dist/client/TelemetrySession.js +45 -10
  8. package/dist/consumer/ConsumeService.d.ts +2 -1
  9. package/dist/consumer/ConsumeService.js +7 -3
  10. package/dist/consumer/ConsumeTask.d.ts +6 -1
  11. package/dist/consumer/ConsumeTask.js +36 -5
  12. package/dist/consumer/Consumer.d.ts +13 -5
  13. package/dist/consumer/Consumer.js +85 -24
  14. package/dist/consumer/FifoConsumeService.d.ts +2 -1
  15. package/dist/consumer/FifoConsumeService.js +3 -3
  16. package/dist/consumer/LiteFifoConsumeService.d.ts +2 -1
  17. package/dist/consumer/LiteFifoConsumeService.js +3 -3
  18. package/dist/consumer/LitePushConsumerImpl.d.ts +12 -1
  19. package/dist/consumer/LitePushConsumerImpl.js +19 -4
  20. package/dist/consumer/LiteSimpleConsumer.d.ts +177 -0
  21. package/dist/consumer/LiteSimpleConsumer.js +126 -0
  22. package/dist/consumer/LiteSimpleConsumerImpl.d.ts +133 -0
  23. package/dist/consumer/LiteSimpleConsumerImpl.js +187 -0
  24. package/dist/consumer/LiteStandardConsumeService.d.ts +2 -1
  25. package/dist/consumer/LiteStandardConsumeService.js +3 -3
  26. package/dist/consumer/LiteSubscriptionManager.d.ts +27 -6
  27. package/dist/consumer/LiteSubscriptionManager.js +32 -24
  28. package/dist/consumer/ProcessQueue.d.ts +10 -0
  29. package/dist/consumer/ProcessQueue.js +43 -5
  30. package/dist/consumer/PushConsumer.d.ts +17 -0
  31. package/dist/consumer/PushConsumer.js +43 -4
  32. package/dist/consumer/PushConsumerGaugeObserver.d.ts +33 -0
  33. package/dist/consumer/PushConsumerGaugeObserver.js +60 -0
  34. package/dist/consumer/PushSubscriptionSettings.d.ts +8 -1
  35. package/dist/consumer/PushSubscriptionSettings.js +33 -6
  36. package/dist/consumer/SimpleConsumer.js +10 -1
  37. package/dist/consumer/StandardConsumeService.d.ts +2 -1
  38. package/dist/consumer/StandardConsumeService.js +3 -3
  39. package/dist/consumer/index.d.ts +1 -0
  40. package/dist/consumer/index.js +2 -1
  41. package/dist/exception/PayloadEmptyException.d.ts +20 -0
  42. package/dist/exception/PayloadEmptyException.js +28 -0
  43. package/dist/exception/StatusChecker.js +8 -1
  44. package/dist/exception/index.d.ts +1 -0
  45. package/dist/exception/index.js +2 -1
  46. package/dist/hook/Attribute.d.ts +26 -0
  47. package/dist/hook/Attribute.js +37 -0
  48. package/dist/hook/AttributeKey.d.ts +32 -0
  49. package/dist/hook/AttributeKey.js +43 -0
  50. package/dist/hook/CompositedMessageInterceptor.d.ts +31 -0
  51. package/dist/hook/CompositedMessageInterceptor.js +84 -0
  52. package/dist/hook/InflightRequestCountInterceptor.d.ts +28 -0
  53. package/dist/hook/InflightRequestCountInterceptor.js +44 -0
  54. package/dist/hook/MessageHookPoints.d.ts +54 -0
  55. package/dist/hook/MessageHookPoints.js +59 -0
  56. package/dist/hook/MessageHookPointsStatus.d.ts +24 -0
  57. package/dist/hook/MessageHookPointsStatus.js +29 -0
  58. package/dist/hook/MessageInterceptor.d.ts +34 -0
  59. package/dist/hook/MessageInterceptor.js +19 -0
  60. package/dist/hook/MessageInterceptorContext.d.ts +31 -0
  61. package/dist/hook/MessageInterceptorContext.js +19 -0
  62. package/dist/hook/MessageInterceptorContextImpl.d.ts +39 -0
  63. package/dist/hook/MessageInterceptorContextImpl.js +57 -0
  64. package/dist/hook/MessageMeterInterceptor.d.ts +39 -0
  65. package/dist/hook/MessageMeterInterceptor.js +149 -0
  66. package/dist/hook/index.d.ts +26 -0
  67. package/dist/hook/index.js +43 -0
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +2 -1
  70. package/dist/metrics/ClientMeter.d.ts +42 -0
  71. package/dist/metrics/ClientMeter.js +75 -0
  72. package/dist/metrics/ClientMeterManager.d.ts +42 -0
  73. package/dist/metrics/ClientMeterManager.js +127 -0
  74. package/dist/metrics/EmptyGaugeObserver.d.ts +28 -0
  75. package/dist/metrics/EmptyGaugeObserver.js +34 -0
  76. package/dist/metrics/GaugeEnum.d.ts +32 -0
  77. package/dist/metrics/GaugeEnum.js +37 -0
  78. package/dist/metrics/GaugeObserver.d.ts +29 -0
  79. package/dist/metrics/GaugeObserver.js +19 -0
  80. package/dist/metrics/HistogramEnum.d.ts +54 -0
  81. package/dist/metrics/HistogramEnum.js +71 -0
  82. package/dist/metrics/InvocationStatus.d.ts +26 -0
  83. package/dist/metrics/InvocationStatus.js +33 -0
  84. package/dist/metrics/Metric.d.ts +30 -0
  85. package/dist/metrics/Metric.js +44 -0
  86. package/dist/metrics/MetricLabels.d.ts +27 -0
  87. package/dist/metrics/MetricLabels.js +34 -0
  88. package/dist/metrics/index.d.ts +25 -0
  89. package/dist/metrics/index.js +42 -0
  90. package/dist/producer/Producer.js +33 -5
  91. package/dist/producer/PublishingLoadBalancer.js +9 -3
  92. package/dist/retry/CustomizedBackoffRetryPolicy.d.ts +37 -0
  93. package/dist/retry/CustomizedBackoffRetryPolicy.js +72 -0
  94. package/dist/retry/ExponentialBackoffRetryPolicy.js +10 -6
  95. package/dist/retry/RetryPolicy.d.ts +1 -1
  96. package/dist/retry/index.d.ts +1 -0
  97. package/dist/retry/index.js +2 -1
  98. package/dist/route/Endpoints.d.ts +6 -0
  99. package/dist/route/Endpoints.js +56 -4
  100. package/dist/route/IpNameResolver.d.ts +28 -0
  101. package/dist/route/IpNameResolver.js +104 -0
  102. package/dist/util/Semaphore.d.ts +47 -0
  103. package/dist/util/Semaphore.js +82 -0
  104. package/package.json +6 -2
  105. package/src/client/BaseClient.ts +202 -12
  106. package/src/client/RpcClient.ts +14 -1
  107. package/src/client/RpcClientManager.ts +27 -8
  108. package/src/client/TelemetrySession.ts +47 -9
  109. package/src/consumer/ConsumeService.ts +9 -2
  110. package/src/consumer/ConsumeTask.ts +43 -3
  111. package/src/consumer/Consumer.ts +103 -23
  112. package/src/consumer/FifoConsumeService.ts +4 -2
  113. package/src/consumer/LiteFifoConsumeService.ts +4 -2
  114. package/src/consumer/LitePushConsumerImpl.ts +21 -3
  115. package/src/consumer/LiteSimpleConsumer.ts +251 -0
  116. package/src/consumer/LiteSimpleConsumerImpl.ts +221 -0
  117. package/src/consumer/LiteStandardConsumeService.ts +4 -2
  118. package/src/consumer/LiteSubscriptionManager.ts +63 -36
  119. package/src/consumer/ProcessQueue.ts +44 -1
  120. package/src/consumer/PushConsumer.ts +54 -2
  121. package/src/consumer/PushConsumerGaugeObserver.ts +60 -0
  122. package/src/consumer/PushSubscriptionSettings.ts +38 -7
  123. package/src/consumer/SimpleConsumer.ts +9 -0
  124. package/src/consumer/StandardConsumeService.ts +4 -2
  125. package/src/consumer/index.ts +1 -0
  126. package/src/exception/PayloadEmptyException.ts +25 -0
  127. package/src/exception/StatusChecker.ts +7 -0
  128. package/src/exception/index.ts +1 -0
  129. package/src/hook/Attribute.ts +36 -0
  130. package/src/hook/AttributeKey.ts +42 -0
  131. package/src/hook/CompositedMessageInterceptor.ts +92 -0
  132. package/src/hook/InflightRequestCountInterceptor.ts +46 -0
  133. package/src/hook/MessageHookPoints.ts +55 -0
  134. package/src/hook/MessageHookPointsStatus.ts +25 -0
  135. package/src/hook/MessageInterceptor.ts +35 -0
  136. package/src/hook/MessageInterceptorContext.ts +33 -0
  137. package/src/hook/MessageInterceptorContextImpl.ts +68 -0
  138. package/src/hook/MessageMeterInterceptor.ts +162 -0
  139. package/src/hook/index.ts +27 -0
  140. package/src/index.ts +1 -0
  141. package/src/metrics/ClientMeter.ts +81 -0
  142. package/src/metrics/ClientMeterManager.ts +145 -0
  143. package/src/metrics/EmptyGaugeObserver.ts +36 -0
  144. package/src/metrics/GaugeEnum.ts +33 -0
  145. package/src/metrics/GaugeObserver.ts +32 -0
  146. package/src/metrics/HistogramEnum.ts +69 -0
  147. package/src/metrics/InvocationStatus.ts +28 -0
  148. package/src/metrics/Metric.ts +42 -0
  149. package/src/metrics/MetricLabels.ts +31 -0
  150. package/src/metrics/index.ts +26 -0
  151. package/src/producer/Producer.ts +37 -6
  152. package/src/producer/PublishingLoadBalancer.ts +8 -2
  153. package/src/retry/CustomizedBackoffRetryPolicy.ts +81 -0
  154. package/src/retry/ExponentialBackoffRetryPolicy.ts +11 -6
  155. package/src/retry/RetryPolicy.ts +1 -1
  156. package/src/retry/index.ts +1 -0
  157. package/src/route/Endpoints.ts +52 -3
  158. package/src/route/IpNameResolver.ts +119 -0
  159. package/src/util/Semaphore.ts +82 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export * from './Attribute';
18
+ export * from './AttributeKey';
19
+ export * from './CompositedMessageInterceptor';
20
+ export * from './InflightRequestCountInterceptor';
21
+ export * from './MessageHookPoints';
22
+ export * from './MessageHookPointsStatus';
23
+ export * from './MessageInterceptor';
24
+ export * from './MessageInterceptorContext';
25
+ export * from './MessageInterceptorContextImpl';
26
+ export * from './MessageMeterInterceptor';
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
+ if (k2 === undefined) k2 = k;
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
25
+ }) : (function(o, m, k, k2) {
26
+ if (k2 === undefined) k2 = k;
27
+ o[k2] = m[k];
28
+ }));
29
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
+ };
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ __exportStar(require("./Attribute"), exports);
34
+ __exportStar(require("./AttributeKey"), exports);
35
+ __exportStar(require("./CompositedMessageInterceptor"), exports);
36
+ __exportStar(require("./InflightRequestCountInterceptor"), exports);
37
+ __exportStar(require("./MessageHookPoints"), exports);
38
+ __exportStar(require("./MessageHookPointsStatus"), exports);
39
+ __exportStar(require("./MessageInterceptor"), exports);
40
+ __exportStar(require("./MessageInterceptorContext"), exports);
41
+ __exportStar(require("./MessageInterceptorContextImpl"), exports);
42
+ __exportStar(require("./MessageMeterInterceptor"), exports);
43
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvaG9vay9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7Ozs7Ozs7Ozs7Ozs7O0FBRUgsOENBQTRCO0FBQzVCLGlEQUErQjtBQUMvQixpRUFBK0M7QUFDL0Msb0VBQWtEO0FBQ2xELHNEQUFvQztBQUNwQyw0REFBMEM7QUFDMUMsdURBQXFDO0FBQ3JDLDhEQUE0QztBQUM1QyxrRUFBZ0Q7QUFDaEQsNERBQTBDIn0=
package/dist/index.d.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  */
17
17
  export * from './consumer';
18
18
  export * from './exception';
19
+ export * from './hook';
19
20
  export * from './message';
20
21
  export * from './producer';
21
22
  export * from './retry';
package/dist/index.js CHANGED
@@ -32,9 +32,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
33
  __exportStar(require("./consumer"), exports);
34
34
  __exportStar(require("./exception"), exports);
35
+ __exportStar(require("./hook"), exports);
35
36
  __exportStar(require("./message"), exports);
36
37
  __exportStar(require("./producer"), exports);
37
38
  __exportStar(require("./retry"), exports);
38
39
  __exportStar(require("./route"), exports);
39
40
  __exportStar(require("./client"), exports);
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILDZDQUEyQjtBQUMzQiw4Q0FBNEI7QUFDNUIsNENBQTBCO0FBQzFCLDZDQUEyQjtBQUMzQiwwQ0FBd0I7QUFDeEIsMENBQXdCO0FBQ3hCLDJDQUF5QiJ9
41
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILDZDQUEyQjtBQUMzQiw4Q0FBNEI7QUFDNUIseUNBQXVCO0FBQ3ZCLDRDQUEwQjtBQUMxQiw2Q0FBMkI7QUFDM0IsMENBQXdCO0FBQ3hCLDBDQUF3QjtBQUN4QiwyQ0FBeUIifQ==
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Attributes, Meter } from '@opentelemetry/api';
18
+ import { MeterProvider as SdkMeterProvider } from '@opentelemetry/sdk-metrics';
19
+ import { Endpoints } from '../route';
20
+ import { HistogramEnum } from './HistogramEnum';
21
+ import { Metric } from './Metric';
22
+ /**
23
+ * Wraps an OpenTelemetry {@link Meter} and records the four RocketMQ histograms.
24
+ * When metrics are disabled it is a no-op instance, mirroring
25
+ * org.apache.rocketmq.client.java.metrics.ClientMeter.
26
+ */
27
+ export declare class ClientMeter {
28
+ readonly enabled: boolean;
29
+ private readonly meter?;
30
+ private readonly endpoints?;
31
+ private readonly provider?;
32
+ private readonly histogramMap;
33
+ constructor(meter: Meter | null, endpoints: Endpoints | null, provider: SdkMeterProvider | null);
34
+ static disabledInstance(): ClientMeter;
35
+ record(histogramEnum: HistogramEnum, attributes: Attributes, value: number): void;
36
+ shutdown(): Promise<void>;
37
+ /**
38
+ * Returns true if the supplied metric switch is already satisfied by this
39
+ * meter (so a rebuild is unnecessary), mirroring ClientMeter#satisfy.
40
+ */
41
+ satisfy(metric: Metric): boolean;
42
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ClientMeter = void 0;
20
+ /**
21
+ * Wraps an OpenTelemetry {@link Meter} and records the four RocketMQ histograms.
22
+ * When metrics are disabled it is a no-op instance, mirroring
23
+ * org.apache.rocketmq.client.java.metrics.ClientMeter.
24
+ */
25
+ class ClientMeter {
26
+ enabled;
27
+ meter;
28
+ endpoints;
29
+ provider;
30
+ histogramMap = new Map();
31
+ constructor(meter, endpoints, provider) {
32
+ this.enabled = meter != null && endpoints != null && provider != null;
33
+ this.meter = meter ?? undefined;
34
+ this.endpoints = endpoints ?? undefined;
35
+ this.provider = provider ?? undefined;
36
+ }
37
+ static disabledInstance() {
38
+ return new ClientMeter(null, null, null);
39
+ }
40
+ record(histogramEnum, attributes, value) {
41
+ if (!this.enabled || !this.meter) {
42
+ return;
43
+ }
44
+ let histogram = this.histogramMap.get(histogramEnum);
45
+ if (!histogram) {
46
+ histogram = this.meter.createHistogram(histogramEnum);
47
+ this.histogramMap.set(histogramEnum, histogram);
48
+ }
49
+ histogram.record(value, attributes);
50
+ }
51
+ async shutdown() {
52
+ if (!this.enabled || !this.provider) {
53
+ return;
54
+ }
55
+ try {
56
+ await this.provider.shutdown();
57
+ }
58
+ catch (t) {
59
+ // best-effort shutdown, ignore
60
+ }
61
+ }
62
+ /**
63
+ * Returns true if the supplied metric switch is already satisfied by this
64
+ * meter (so a rebuild is unnecessary), mirroring ClientMeter#satisfy.
65
+ */
66
+ satisfy(metric) {
67
+ if (this.enabled && metric.on && this.endpoints != null && metric.endpoints != null
68
+ && this.endpoints.equals(metric.endpoints)) {
69
+ return true;
70
+ }
71
+ return !this.enabled && !metric.on;
72
+ }
73
+ }
74
+ exports.ClientMeter = ClientMeter;
75
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpZW50TWV0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbWV0cmljcy9DbGllbnRNZXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7OztHQWVHOzs7QUFRSDs7OztHQUlHO0FBQ0gsTUFBYSxXQUFXO0lBQ2IsT0FBTyxDQUFVO0lBQ1QsS0FBSyxDQUFTO0lBQ2QsU0FBUyxDQUFhO0lBQ3RCLFFBQVEsQ0FBb0I7SUFDNUIsWUFBWSxHQUFHLElBQUksR0FBRyxFQUE0QixDQUFDO0lBRXBFLFlBQVksS0FBbUIsRUFBRSxTQUEyQixFQUFFLFFBQWlDO1FBQzdGLElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxJQUFJLElBQUksSUFBSSxTQUFTLElBQUksSUFBSSxJQUFJLFFBQVEsSUFBSSx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ZQUNILE1BQU0sSUFBSSxDQUFDLFFBQVEsQ0FBQyxRQUFRLEVBQUUsQ0FBQztRQUNqQyxDQUFDO1FBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQztZQUNYLCtCQUErQjtRQUNqQyxDQUFDO0lBQ0gsQ0FBQztJQUVEOzs7T0FHRztJQUNILE9BQU8sQ0FBQyxNQUFjO1FBQ3BCLElBQUksSUFBSSxDQUFDLE9BQU8sSUFBSSxNQUFNLENBQUMsRUFBRSxJQUFJLElBQUksQ0FBQyxTQUFTLElBQUksSUFBSSxJQUFJLE1BQU0sQ0FBQyxTQUFTLElBQUksSUFBSTtlQUM5RSxJQUFJLENBQUMsU0FBUyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQztZQUM3QyxPQUFPLElBQUksQ0FBQztRQUNkLENBQUM7UUFDRCxPQUFPLENBQUMsSUFBSSxDQUFDLE9BQU8sSUFBSSxDQUFDLE1BQU0sQ0FBQyxFQUFFLENBQUM7SUFDckMsQ0FBQztDQUNGO0FBcERELGtDQW9EQyJ9
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Attributes } from '@opentelemetry/api';
18
+ import { Metadata } from '@grpc/grpc-js';
19
+ import { ILogger } from '../client/Logger';
20
+ import { GaugeObserver } from './GaugeObserver';
21
+ import { HistogramEnum } from './HistogramEnum';
22
+ import { Metric } from './Metric';
23
+ /**
24
+ * Owns the OpenTelemetry metric pipeline for a single client. On every settings
25
+ * command it lazily (re)builds an SdkMeterProvider that exports the four
26
+ * RocketMQ histograms plus the consumer gauges to the broker-supplied metric
27
+ * endpoints over OTLP/gRPC, mirroring
28
+ * org.apache.rocketmq.client.java.metrics.ClientMeterManager.
29
+ */
30
+ export declare class ClientMeterManager {
31
+ private readonly clientId;
32
+ private readonly metadataProvider;
33
+ private readonly logger;
34
+ private clientMeter;
35
+ private gaugeObserver;
36
+ constructor(clientId: string, metadataProvider: () => Metadata, logger: ILogger);
37
+ setGaugeObserver(gaugeObserver: GaugeObserver): void;
38
+ record(histogramEnum: HistogramEnum, attributes: Attributes, value: number): void;
39
+ isEnabled(): boolean;
40
+ shutdown(): Promise<void>;
41
+ reset(metric: Metric): Promise<void>;
42
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.ClientMeterManager = void 0;
20
+ const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
21
+ const resources_1 = require("@opentelemetry/resources");
22
+ const exporter_metrics_otlp_grpc_1 = require("@opentelemetry/exporter-metrics-otlp-grpc");
23
+ const grpc_js_1 = require("@grpc/grpc-js");
24
+ const ClientMeter_1 = require("./ClientMeter");
25
+ const EmptyGaugeObserver_1 = require("./EmptyGaugeObserver");
26
+ const HistogramEnum_1 = require("./HistogramEnum");
27
+ const METRIC_EXPORTER_RPC_TIMEOUT = 5000;
28
+ const METRIC_READER_INTERVAL = 60000;
29
+ const METRIC_INSTRUMENTATION_NAME = 'org.apache.rocketmq.message';
30
+ /**
31
+ * Owns the OpenTelemetry metric pipeline for a single client. On every settings
32
+ * command it lazily (re)builds an SdkMeterProvider that exports the four
33
+ * RocketMQ histograms plus the consumer gauges to the broker-supplied metric
34
+ * endpoints over OTLP/gRPC, mirroring
35
+ * org.apache.rocketmq.client.java.metrics.ClientMeterManager.
36
+ */
37
+ class ClientMeterManager {
38
+ clientId;
39
+ metadataProvider;
40
+ logger;
41
+ clientMeter;
42
+ gaugeObserver = EmptyGaugeObserver_1.EmptyGaugeObserver.EMPTY;
43
+ constructor(clientId, metadataProvider, logger) {
44
+ this.clientId = clientId;
45
+ this.metadataProvider = metadataProvider;
46
+ this.logger = logger;
47
+ this.clientMeter = ClientMeter_1.ClientMeter.disabledInstance();
48
+ }
49
+ setGaugeObserver(gaugeObserver) {
50
+ this.gaugeObserver = gaugeObserver;
51
+ }
52
+ record(histogramEnum, attributes, value) {
53
+ this.clientMeter.record(histogramEnum, attributes, value);
54
+ }
55
+ isEnabled() {
56
+ return this.clientMeter.enabled;
57
+ }
58
+ async shutdown() {
59
+ await this.clientMeter.shutdown();
60
+ }
61
+ async reset(metric) {
62
+ try {
63
+ if (this.clientMeter.satisfy(metric)) {
64
+ this.logger.info('Metric settings is satisfied by the current message meter, metric=%j, clientId=%s', metric, this.clientId);
65
+ return;
66
+ }
67
+ if (!metric.on || !metric.endpoints) {
68
+ this.logger.info('Metric is off, clientId=%s', this.clientId);
69
+ await this.clientMeter.shutdown();
70
+ this.clientMeter = ClientMeter_1.ClientMeter.disabledInstance();
71
+ return;
72
+ }
73
+ const endpoints = metric.endpoints;
74
+ // Use the first address as the OTLP/gRPC target. The exporter's URL is
75
+ // normalized to "host:port" internally, which gRPC-js resolves through
76
+ // its default DNS resolver (a single IP works fine; the custom `ip`
77
+ // resolver is used for the primary RPC channels).
78
+ const address = endpoints.addressesList[0];
79
+ const url = `http://${address.host}:${address.port}`;
80
+ const exporter = new exporter_metrics_otlp_grpc_1.OTLPMetricExporter({
81
+ url,
82
+ credentials: grpc_js_1.ChannelCredentials.createInsecure(),
83
+ timeoutMillis: METRIC_EXPORTER_RPC_TIMEOUT,
84
+ // Per-request signing mirrors the Java client's AuthInterceptor. The
85
+ // d.ts types this field as `Metadata`, but the runtime (and the
86
+ // exporter's own merge logic in otlp-grpc-exporter-base) expects a
87
+ // function returning freshly-signed Metadata.
88
+ metadata: (() => this.metadataProvider()),
89
+ });
90
+ const reader = new sdk_metrics_1.PeriodicExportingMetricReader({
91
+ exporter,
92
+ exportIntervalMillis: METRIC_READER_INTERVAL,
93
+ exportTimeoutMillis: METRIC_EXPORTER_RPC_TIMEOUT,
94
+ });
95
+ const views = [
96
+ new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.SEND_COST_TIME)),
97
+ new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.DELIVERY_LATENCY)),
98
+ new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.AWAIT_TIME)),
99
+ new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.PROCESS_TIME)),
100
+ ];
101
+ const provider = new sdk_metrics_1.MeterProvider({
102
+ resource: resources_1.Resource.empty(),
103
+ readers: [reader],
104
+ views,
105
+ });
106
+ const meter = provider.getMeter(METRIC_INSTRUMENTATION_NAME);
107
+ const existedClientMeter = this.clientMeter;
108
+ this.clientMeter = new ClientMeter_1.ClientMeter(meter, endpoints, provider);
109
+ await existedClientMeter.shutdown();
110
+ this.logger.info('Metrics is on, endpoints=%s, clientId=%s', endpoints, this.clientId);
111
+ const gauges = this.gaugeObserver.getGauges();
112
+ for (const gauge of gauges) {
113
+ meter.createObservableGauge(gauge).addCallback(observableResult => {
114
+ const values = this.gaugeObserver.getValues(gauge);
115
+ for (const [attributes, value] of values) {
116
+ observableResult.observe(value, attributes);
117
+ }
118
+ });
119
+ }
120
+ }
121
+ catch (t) {
122
+ this.logger.error('Exception raised when resetting message meter, clientId=%s, error=%s', this.clientId, t);
123
+ }
124
+ }
125
+ }
126
+ exports.ClientMeterManager = ClientMeterManager;
127
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpZW50TWV0ZXJNYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21ldHJpY3MvQ2xpZW50TWV0ZXJNYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQUdILDREQUlvQztBQUNwQyx3REFBb0Q7QUFDcEQsMEZBQStFO0FBQy9FLDJDQUE2RDtBQUU3RCwrQ0FBNEM7QUFFNUMsNkRBQTBEO0FBQzFELG1EQUFvRTtBQUdwRSxNQUFNLDJCQUEyQixHQUFHLElBQUksQ0FBQztBQUN6QyxNQUFNLHNCQUFzQixHQUFHLEtBQUssQ0FBQztBQUNyQyxNQUFNLDJCQUEyQixHQUFHLDZCQUE2QixDQUFDO0FBRWxFOzs7Ozs7R0FNRztBQUNILE1BQWEsa0JBQWtCO0lBQ1osUUFBUSxDQUFTO0lBQ2pCLGdCQUFnQixDQUFpQjtJQUNqQyxNQUFNLENBQVU7SUFDekIsV0FBVyxDQUFjO0lBQ3pCLGFBQWEsR0FBa0IsdUNBQWtCLENBQUMsS0FBSyxDQUFDO0lBRWhFLFlBQVksUUFBZ0IsRUFBRSxnQkFBZ0MsRUFBRSxNQUFlO1FBQzdFLElBQUksQ0FBQyxRQUFRLEdBQUcsUU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FBSyxNQUFNLEtBQUssSUFBSSxNQUFNLEVBQUUsQ0FBQztnQkFDM0IsS0FBSyxDQUFDLHFCQUFxQixDQUFDLEtBQUssQ0FBQyxDQUFDLFdBQVcsQ0FBQyxnQkFBZ0IsQ0FBQyxFQUFFO29CQUNoRSxNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsQ0FBQztvQkFDbkQsS0FBSyxNQUFNLENBQUUsVUFBVSxFQUFFLEtBQUssQ0FBRSxJQUFJLE1BQU0sRUFBRSxDQUFDO3dCQUMzQyxnQkFBZ0IsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLFVBQVUsQ0FBQyxDQUFDO29CQUM5QyxDQUFDO2dCQUNILENBQUMsQ0FBQyxDQUFDO1lBQ0wsQ0FBQztRQUNILENBQUM7UUFBQyxPQUFPLENBQUMsRUFBRSxDQUFDO1lBQ1gsSUFBSSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsc0VBQXNFLEVBQUUsSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDLENBQUMsQ0FBQztRQUM5RyxDQUFDO0lBQ0gsQ0FBQztDQUNGO0FBcEdELGdEQW9HQyJ9
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Attributes } from '@opentelemetry/api';
18
+ import { GaugeEnum } from './GaugeEnum';
19
+ import { GaugeObserver } from './GaugeObserver';
20
+ /**
21
+ * Default no-op gauge observer used before a consumer registers a real one,
22
+ * mirroring org.apache.rocketmq.client.java.metrics.EmptyGaugeObserver.
23
+ */
24
+ export declare class EmptyGaugeObserver implements GaugeObserver {
25
+ static readonly EMPTY: EmptyGaugeObserver;
26
+ getGauges(): GaugeEnum[];
27
+ getValues(): Map<Attributes, number>;
28
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.EmptyGaugeObserver = void 0;
20
+ /**
21
+ * Default no-op gauge observer used before a consumer registers a real one,
22
+ * mirroring org.apache.rocketmq.client.java.metrics.EmptyGaugeObserver.
23
+ */
24
+ class EmptyGaugeObserver {
25
+ static EMPTY = new EmptyGaugeObserver();
26
+ getGauges() {
27
+ return [];
28
+ }
29
+ getValues() {
30
+ return new Map();
31
+ }
32
+ }
33
+ exports.EmptyGaugeObserver = EmptyGaugeObserver;
34
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRW1wdHlHYXVnZU9ic2VydmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21ldHJpY3MvRW1wdHlHYXVnZU9ic2VydmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQU1IOzs7R0FHRztBQUNILE1BQWEsa0JBQWtCO0lBQzdCLE1BQU0sQ0FBVSxLQUFLLEdBQXVCLElBQUksa0JBQWtCLEVBQUUsQ0FBQztJQUVyRSxTQUFTO1FBQ1AsT0FBTyxFQUFFLENBQUM7SUFDWixDQUFDO0lBRUQsU0FBUztRQUNQLE9BQU8sSUFBSSxHQUFHLEVBQUUsQ0FBQztJQUNuQixDQUFDOztBQVRILGdEQVVDIn0=
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * The two consumer gauges exported by the RocketMQ client, mirroring
19
+ * org.apache.rocketmq.client.java.metrics.GaugeEnum.
20
+ */
21
+ export declare enum GaugeEnum {
22
+ /**
23
+ * Cached message count of push consumer.
24
+ * Labels: topic, client_id, consumer_group.
25
+ */
26
+ CONSUMER_CACHED_MESSAGES = "rocketmq_consumer_cached_messages",
27
+ /**
28
+ * Cached message bytes of push consumer.
29
+ * Labels: topic, client_id, consumer_group.
30
+ */
31
+ CONSUMER_CACHED_BYTES = "rocketmq_consumer_cached_bytes"
32
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.GaugeEnum = void 0;
20
+ /**
21
+ * The two consumer gauges exported by the RocketMQ client, mirroring
22
+ * org.apache.rocketmq.client.java.metrics.GaugeEnum.
23
+ */
24
+ var GaugeEnum;
25
+ (function (GaugeEnum) {
26
+ /**
27
+ * Cached message count of push consumer.
28
+ * Labels: topic, client_id, consumer_group.
29
+ */
30
+ GaugeEnum["CONSUMER_CACHED_MESSAGES"] = "rocketmq_consumer_cached_messages";
31
+ /**
32
+ * Cached message bytes of push consumer.
33
+ * Labels: topic, client_id, consumer_group.
34
+ */
35
+ GaugeEnum["CONSUMER_CACHED_BYTES"] = "rocketmq_consumer_cached_bytes";
36
+ })(GaugeEnum || (exports.GaugeEnum = GaugeEnum = {}));
37
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR2F1Z2VFbnVtLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21ldHJpY3MvR2F1Z2VFbnVtLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQUVIOzs7R0FHRztBQUNILElBQVksU0FXWDtBQVhELFdBQVksU0FBUztJQUNuQjs7O09BR0c7SUFDSCwyRUFBOEQsQ0FBQTtJQUM5RDs7O09BR0c7SUFDSCxxRUFBd0QsQ0FBQTtBQUMxRCxDQUFDLEVBWFcsU0FBUyx5QkFBVCxTQUFTLFFBV3BCIn0=
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Attributes } from '@opentelemetry/api';
18
+ import { GaugeEnum } from './GaugeEnum';
19
+ /**
20
+ * Supplies the live values observed by the periodic metric reader for each
21
+ * consumer gauge, mirroring org.apache.rocketmq.client.java.metrics.GaugeObserver.
22
+ *
23
+ * The map key is the attribute set (topic / client_id / consumer_group) and the
24
+ * value is the observed gauge reading.
25
+ */
26
+ export interface GaugeObserver {
27
+ getGauges(): GaugeEnum[];
28
+ getValues(gauge: GaugeEnum): Map<Attributes, number>;
29
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ /**
3
+ * Licensed to the Apache Software Foundation (ASF) under one or more
4
+ * contributor license agreements. See the NOTICE file distributed with
5
+ * this work for additional information regarding copyright ownership.
6
+ * The ASF licenses this file to You under the Apache License, Version 2.0
7
+ * (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiR2F1Z2VPYnNlcnZlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tZXRyaWNzL0dhdWdlT2JzZXJ2ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7R0FlRyJ9
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ViewOptions } from '@opentelemetry/sdk-metrics';
18
+ /**
19
+ * The four histograms exported by the RocketMQ client, mirroring
20
+ * org.apache.rocketmq.client.java.metrics.HistogramEnum. The bucket
21
+ * boundaries (in milliseconds) are copied verbatim from the Java client.
22
+ */
23
+ export declare enum HistogramEnum {
24
+ /**
25
+ * Cost time of successful api calls of message publishing.
26
+ * Labels: topic, client_id, invocation_status.
27
+ */
28
+ SEND_COST_TIME = "rocketmq_send_cost_time",
29
+ /**
30
+ * Latency of message delivery from remote.
31
+ * Labels: topic, client_id, consumer_group.
32
+ */
33
+ DELIVERY_LATENCY = "rocketmq_delivery_latency",
34
+ /**
35
+ * Await time of message consumption.
36
+ * Labels: topic, client_id, consumer_group.
37
+ */
38
+ AWAIT_TIME = "rocketmq_await_time",
39
+ /**
40
+ * Process time of message consumption.
41
+ * Labels: topic, client_id, consumer_group, invocation_status.
42
+ */
43
+ PROCESS_TIME = "rocketmq_process_time"
44
+ }
45
+ /**
46
+ * Explicit bucket boundaries (milliseconds) for each histogram, identical to
47
+ * the Java client's Aggregation.explicitBucketHistogram(...) calls.
48
+ */
49
+ export declare const HISTOGRAM_BUCKETS: Record<HistogramEnum, number[]>;
50
+ /**
51
+ * Build the OpenTelemetry view that forces the given histogram onto the exact
52
+ * explicit-bucket aggregation used by the Java client.
53
+ */
54
+ export declare function buildHistogramView(histogramEnum: HistogramEnum): ViewOptions;