rocketmq-client-nodejs 1.0.8 → 1.1.1
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.
- package/README.md +61 -0
- package/dist/client/BaseClient.d.ts +44 -1
- package/dist/client/BaseClient.js +353 -85
- package/dist/client/Logger.js +9 -6
- package/dist/client/RpcClient.js +42 -134
- package/dist/client/RpcClientManager.d.ts +22 -17
- package/dist/client/RpcClientManager.js +61 -56
- package/dist/client/TelemetrySession.js +107 -17
- package/dist/consumer/ConsumeService.d.ts +2 -1
- package/dist/consumer/ConsumeService.js +12 -6
- package/dist/consumer/ConsumeTask.d.ts +6 -1
- package/dist/consumer/ConsumeTask.js +36 -5
- package/dist/consumer/Consumer.d.ts +13 -5
- package/dist/consumer/Consumer.js +94 -33
- package/dist/consumer/FifoConsumeService.d.ts +3 -1
- package/dist/consumer/FifoConsumeService.js +4 -4
- package/dist/consumer/LiteConsumerSupport.d.ts +25 -0
- package/dist/consumer/LiteConsumerSupport.js +47 -0
- package/dist/consumer/LiteFifoConsumeService.d.ts +3 -1
- package/dist/consumer/LiteFifoConsumeService.js +4 -4
- package/dist/consumer/LitePushConsumerImpl.d.ts +15 -4
- package/dist/consumer/LitePushConsumerImpl.js +26 -30
- package/dist/consumer/LiteSimpleConsumer.d.ts +177 -0
- package/dist/consumer/LiteSimpleConsumer.js +126 -0
- package/dist/consumer/LiteSimpleConsumerImpl.d.ts +133 -0
- package/dist/consumer/LiteSimpleConsumerImpl.js +179 -0
- package/dist/consumer/LiteStandardConsumeService.d.ts +3 -1
- package/dist/consumer/LiteStandardConsumeService.js +4 -4
- package/dist/consumer/LiteSubscriptionManager.d.ts +27 -6
- package/dist/consumer/LiteSubscriptionManager.js +36 -27
- package/dist/consumer/OffsetOption.d.ts +1 -0
- package/dist/consumer/OffsetOption.js +10 -4
- package/dist/consumer/ProcessQueue.d.ts +17 -1
- package/dist/consumer/ProcessQueue.js +134 -91
- package/dist/consumer/PushConsumer.d.ts +17 -0
- package/dist/consumer/PushConsumer.js +117 -26
- package/dist/consumer/PushConsumerGaugeObserver.d.ts +33 -0
- package/dist/consumer/PushConsumerGaugeObserver.js +60 -0
- package/dist/consumer/PushSubscriptionSettings.d.ts +8 -1
- package/dist/consumer/PushSubscriptionSettings.js +35 -8
- package/dist/consumer/SimpleConsumer.d.ts +5 -0
- package/dist/consumer/SimpleConsumer.js +33 -20
- package/dist/consumer/SimpleSubscriptionSettings.js +3 -3
- package/dist/consumer/StandardConsumeService.d.ts +3 -1
- package/dist/consumer/StandardConsumeService.js +17 -8
- package/dist/consumer/SubscriptionLoadBalancer.js +3 -3
- package/dist/consumer/index.d.ts +1 -0
- package/dist/consumer/index.js +2 -1
- package/dist/exception/InternalErrorException.d.ts +1 -0
- package/dist/exception/InternalErrorException.js +3 -2
- package/dist/exception/PayloadEmptyException.d.ts +20 -0
- package/dist/exception/PayloadEmptyException.js +28 -0
- package/dist/exception/StatusChecker.js +11 -4
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.js +2 -1
- package/dist/exception/receiveStatus.d.ts +18 -0
- package/dist/exception/receiveStatus.js +28 -0
- package/dist/hook/Attribute.d.ts +26 -0
- package/dist/hook/Attribute.js +37 -0
- package/dist/hook/AttributeKey.d.ts +32 -0
- package/dist/hook/AttributeKey.js +43 -0
- package/dist/hook/CompositedMessageInterceptor.d.ts +32 -0
- package/dist/hook/CompositedMessageInterceptor.js +87 -0
- package/dist/hook/InflightRequestCountInterceptor.d.ts +28 -0
- package/dist/hook/InflightRequestCountInterceptor.js +44 -0
- package/dist/hook/MessageHookPoints.d.ts +54 -0
- package/dist/hook/MessageHookPoints.js +59 -0
- package/dist/hook/MessageHookPointsStatus.d.ts +24 -0
- package/dist/hook/MessageHookPointsStatus.js +29 -0
- package/dist/hook/MessageInterceptor.d.ts +34 -0
- package/dist/hook/MessageInterceptor.js +19 -0
- package/dist/hook/MessageInterceptorContext.d.ts +31 -0
- package/dist/hook/MessageInterceptorContext.js +19 -0
- package/dist/hook/MessageInterceptorContextImpl.d.ts +40 -0
- package/dist/hook/MessageInterceptorContextImpl.js +71 -0
- package/dist/hook/MessageMeterInterceptor.d.ts +39 -0
- package/dist/hook/MessageMeterInterceptor.js +149 -0
- package/dist/hook/index.d.ts +26 -0
- package/dist/hook/index.js +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/message/Message.js +26 -4
- package/dist/message/MessageView.js +15 -5
- package/dist/message/PublishingMessage.js +4 -4
- package/dist/metrics/ClientMeter.d.ts +42 -0
- package/dist/metrics/ClientMeter.js +75 -0
- package/dist/metrics/ClientMeterManager.d.ts +46 -0
- package/dist/metrics/ClientMeterManager.js +203 -0
- package/dist/metrics/EmptyGaugeObserver.d.ts +28 -0
- package/dist/metrics/EmptyGaugeObserver.js +34 -0
- package/dist/metrics/GaugeEnum.d.ts +32 -0
- package/dist/metrics/GaugeEnum.js +37 -0
- package/dist/metrics/GaugeObserver.d.ts +29 -0
- package/dist/metrics/GaugeObserver.js +19 -0
- package/dist/metrics/HistogramEnum.d.ts +54 -0
- package/dist/metrics/HistogramEnum.js +71 -0
- package/dist/metrics/InvocationStatus.d.ts +26 -0
- package/dist/metrics/InvocationStatus.js +33 -0
- package/dist/metrics/Metric.d.ts +30 -0
- package/dist/metrics/Metric.js +44 -0
- package/dist/metrics/MetricLabels.d.ts +27 -0
- package/dist/metrics/MetricLabels.js +34 -0
- package/dist/metrics/index.d.ts +25 -0
- package/dist/metrics/index.js +42 -0
- package/dist/producer/Producer.d.ts +8 -2
- package/dist/producer/Producer.js +83 -34
- package/dist/producer/PublishingLoadBalancer.js +11 -5
- package/dist/producer/PublishingSettings.js +1 -3
- package/dist/producer/SendReceipt.js +3 -2
- package/dist/producer/Transaction.d.ts +2 -1
- package/dist/producer/Transaction.js +9 -8
- package/dist/producer/index.d.ts +1 -0
- package/dist/producer/index.js +2 -2
- package/dist/retry/CustomizedBackoffRetryPolicy.d.ts +37 -0
- package/dist/retry/CustomizedBackoffRetryPolicy.js +72 -0
- package/dist/retry/ExponentialBackoffRetryPolicy.js +10 -6
- package/dist/retry/RetryPolicy.d.ts +1 -1
- package/dist/retry/index.d.ts +1 -0
- package/dist/retry/index.js +2 -1
- package/dist/route/Endpoints.d.ts +6 -0
- package/dist/route/Endpoints.js +69 -9
- package/dist/route/IpNameResolver.d.ts +28 -0
- package/dist/route/IpNameResolver.js +104 -0
- package/dist/route/MessageQueue.js +7 -2
- package/dist/route/TopicRouteData.d.ts +5 -0
- package/dist/route/TopicRouteData.js +22 -1
- package/dist/util/Semaphore.d.ts +47 -0
- package/dist/util/Semaphore.js +82 -0
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js +9 -6
- package/dist/util/rpcContext.d.ts +20 -0
- package/dist/util/rpcContext.js +35 -0
- package/package.json +11 -4
- package/src/client/BaseClient.ts +392 -91
- package/src/client/Logger.ts +9 -5
- package/src/client/RpcClient.ts +62 -133
- package/src/client/RpcClientManager.ts +103 -60
- package/src/client/TelemetrySession.ts +112 -17
- package/src/consumer/ConsumeService.ts +16 -5
- package/src/consumer/ConsumeTask.ts +43 -3
- package/src/consumer/Consumer.ts +116 -35
- package/src/consumer/FifoConsumeService.ts +5 -3
- package/src/consumer/LiteConsumerSupport.ts +49 -0
- package/src/consumer/LiteFifoConsumeService.ts +5 -3
- package/src/consumer/LitePushConsumerImpl.ts +34 -23
- package/src/consumer/LiteSimpleConsumer.ts +251 -0
- package/src/consumer/LiteSimpleConsumerImpl.ts +214 -0
- package/src/consumer/LiteStandardConsumeService.ts +5 -3
- package/src/consumer/LiteSubscriptionManager.ts +66 -41
- package/src/consumer/OffsetOption.ts +10 -3
- package/src/consumer/ProcessQueue.ts +165 -107
- package/src/consumer/PushConsumer.ts +133 -24
- package/src/consumer/PushConsumerGaugeObserver.ts +60 -0
- package/src/consumer/PushSubscriptionSettings.ts +40 -9
- package/src/consumer/SimpleConsumer.ts +39 -23
- package/src/consumer/SimpleSubscriptionSettings.ts +2 -2
- package/src/consumer/StandardConsumeService.ts +18 -7
- package/src/consumer/SubscriptionLoadBalancer.ts +2 -2
- package/src/consumer/index.ts +1 -0
- package/src/exception/InternalErrorException.ts +3 -1
- package/src/exception/PayloadEmptyException.ts +25 -0
- package/src/exception/StatusChecker.ts +10 -2
- package/src/exception/index.ts +1 -0
- package/src/exception/receiveStatus.ts +25 -0
- package/src/hook/Attribute.ts +36 -0
- package/src/hook/AttributeKey.ts +42 -0
- package/src/hook/CompositedMessageInterceptor.ts +96 -0
- package/src/hook/InflightRequestCountInterceptor.ts +46 -0
- package/src/hook/MessageHookPoints.ts +55 -0
- package/src/hook/MessageHookPointsStatus.ts +25 -0
- package/src/hook/MessageInterceptor.ts +35 -0
- package/src/hook/MessageInterceptorContext.ts +33 -0
- package/src/hook/MessageInterceptorContextImpl.ts +83 -0
- package/src/hook/MessageMeterInterceptor.ts +162 -0
- package/src/hook/index.ts +27 -0
- package/src/index.ts +1 -0
- package/src/message/Message.ts +25 -3
- package/src/message/MessageView.ts +13 -4
- package/src/message/PublishingMessage.ts +3 -3
- package/src/metrics/ClientMeter.ts +81 -0
- package/src/metrics/ClientMeterManager.ts +227 -0
- package/src/metrics/EmptyGaugeObserver.ts +36 -0
- package/src/metrics/GaugeEnum.ts +33 -0
- package/src/metrics/GaugeObserver.ts +32 -0
- package/src/metrics/HistogramEnum.ts +69 -0
- package/src/metrics/InvocationStatus.ts +28 -0
- package/src/metrics/Metric.ts +42 -0
- package/src/metrics/MetricLabels.ts +31 -0
- package/src/metrics/index.ts +26 -0
- package/src/producer/Producer.ts +94 -38
- package/src/producer/PublishingLoadBalancer.ts +10 -4
- package/src/producer/PublishingSettings.ts +0 -2
- package/src/producer/SendReceipt.ts +2 -1
- package/src/producer/Transaction.ts +12 -11
- package/src/producer/index.ts +1 -1
- package/src/retry/CustomizedBackoffRetryPolicy.ts +81 -0
- package/src/retry/ExponentialBackoffRetryPolicy.ts +11 -6
- package/src/retry/RetryPolicy.ts +1 -1
- package/src/retry/index.ts +1 -0
- package/src/route/Endpoints.ts +65 -8
- package/src/route/IpNameResolver.ts +119 -0
- package/src/route/MessageQueue.ts +6 -1
- package/src/route/TopicRouteData.ts +22 -1
- package/src/util/Semaphore.ts +82 -0
- package/src/util/index.ts +8 -5
- package/src/util/rpcContext.ts +34 -0
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpZW50TWV0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbWV0cmljcy9DbGllbnRNZXRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzI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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
|
+
private pending;
|
|
37
|
+
private shutdownPromise?;
|
|
38
|
+
constructor(clientId: string, metadataProvider: () => Metadata, logger: ILogger);
|
|
39
|
+
setGaugeObserver(gaugeObserver: GaugeObserver): void;
|
|
40
|
+
record(histogramEnum: HistogramEnum, attributes: Attributes, value: number): void;
|
|
41
|
+
isEnabled(): boolean;
|
|
42
|
+
shutdown(): Promise<void>;
|
|
43
|
+
reset(metric: Metric): Promise<void>;
|
|
44
|
+
private enqueue;
|
|
45
|
+
private resetMeter;
|
|
46
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
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 node_net_1 = require("node:net");
|
|
25
|
+
const ClientMeter_1 = require("./ClientMeter");
|
|
26
|
+
const EmptyGaugeObserver_1 = require("./EmptyGaugeObserver");
|
|
27
|
+
const HistogramEnum_1 = require("./HistogramEnum");
|
|
28
|
+
const METRIC_EXPORTER_RPC_TIMEOUT = 5000;
|
|
29
|
+
const METRIC_READER_INTERVAL = 60000;
|
|
30
|
+
const METRIC_INSTRUMENTATION_NAME = 'org.apache.rocketmq.message';
|
|
31
|
+
// OTel 0.57.2 accepts a Metadata instance and caches it on the first export. Use a fresh exporter
|
|
32
|
+
// per round to refresh signatures and close its channel afterward; inherit aggregation/temporality choices.
|
|
33
|
+
class SignedMetricExporter extends exporter_metrics_otlp_grpc_1.OTLPMetricExporter {
|
|
34
|
+
urls;
|
|
35
|
+
metadataProvider;
|
|
36
|
+
pending = new Set();
|
|
37
|
+
closed = false;
|
|
38
|
+
constructor(urls, metadataProvider) {
|
|
39
|
+
super({ url: urls[0], credentials: grpc_js_1.ChannelCredentials.createInsecure() });
|
|
40
|
+
this.urls = urls;
|
|
41
|
+
this.metadataProvider = metadataProvider;
|
|
42
|
+
}
|
|
43
|
+
export(metrics, callback) {
|
|
44
|
+
if (this.closed) {
|
|
45
|
+
callback({ code: 1, error: new Error('Metric exporter is shut down') });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const completion = this.exportOnce(metrics).then(callback, error => {
|
|
49
|
+
callback({ code: 1, error: error instanceof Error ? error : new Error(String(error)) });
|
|
50
|
+
});
|
|
51
|
+
this.pending.add(completion);
|
|
52
|
+
void completion.then(() => this.pending.delete(completion), () => this.pending.delete(completion));
|
|
53
|
+
}
|
|
54
|
+
async exportOnce(metrics) {
|
|
55
|
+
const deadline = Date.now() + METRIC_EXPORTER_RPC_TIMEOUT;
|
|
56
|
+
const start = Math.floor(Math.random() * this.urls.length);
|
|
57
|
+
let result = { code: 1, error: new Error('No metric endpoint is available') };
|
|
58
|
+
// Randomize the starting address and fail over as Java's multi-address resolver does; all attempts share one timeout.
|
|
59
|
+
for (let index = 0; index < this.urls.length; index++) {
|
|
60
|
+
const remaining = deadline - Date.now();
|
|
61
|
+
if (remaining <= 0) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
let exporter;
|
|
65
|
+
try {
|
|
66
|
+
exporter = new exporter_metrics_otlp_grpc_1.OTLPMetricExporter({
|
|
67
|
+
url: this.urls[(start + index) % this.urls.length],
|
|
68
|
+
credentials: grpc_js_1.ChannelCredentials.createInsecure(),
|
|
69
|
+
timeoutMillis: Math.max(1, Math.floor(remaining / (this.urls.length - index))),
|
|
70
|
+
metadata: this.metadataProvider(),
|
|
71
|
+
});
|
|
72
|
+
result = await new Promise(resolve => exporter.export(metrics, resolve));
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
result = { code: 1, error: error instanceof Error ? error : new Error(String(error)) };
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
await exporter?.shutdown();
|
|
79
|
+
}
|
|
80
|
+
if (result.code === 0) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
async forceFlush() {
|
|
87
|
+
await Promise.all(this.pending);
|
|
88
|
+
}
|
|
89
|
+
async shutdown() {
|
|
90
|
+
this.closed = true;
|
|
91
|
+
await this.forceFlush();
|
|
92
|
+
await super.shutdown();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Owns the OpenTelemetry metric pipeline for a single client. On every settings
|
|
97
|
+
* command it lazily (re)builds an SdkMeterProvider that exports the four
|
|
98
|
+
* RocketMQ histograms plus the consumer gauges to the broker-supplied metric
|
|
99
|
+
* endpoints over OTLP/gRPC, mirroring
|
|
100
|
+
* org.apache.rocketmq.client.java.metrics.ClientMeterManager.
|
|
101
|
+
*/
|
|
102
|
+
class ClientMeterManager {
|
|
103
|
+
clientId;
|
|
104
|
+
metadataProvider;
|
|
105
|
+
logger;
|
|
106
|
+
clientMeter;
|
|
107
|
+
gaugeObserver = EmptyGaugeObserver_1.EmptyGaugeObserver.EMPTY;
|
|
108
|
+
pending = Promise.resolve();
|
|
109
|
+
shutdownPromise;
|
|
110
|
+
constructor(clientId, metadataProvider, logger) {
|
|
111
|
+
this.clientId = clientId;
|
|
112
|
+
this.metadataProvider = metadataProvider;
|
|
113
|
+
this.logger = logger;
|
|
114
|
+
this.clientMeter = ClientMeter_1.ClientMeter.disabledInstance();
|
|
115
|
+
}
|
|
116
|
+
setGaugeObserver(gaugeObserver) {
|
|
117
|
+
this.gaugeObserver = gaugeObserver;
|
|
118
|
+
}
|
|
119
|
+
record(histogramEnum, attributes, value) {
|
|
120
|
+
this.clientMeter.record(histogramEnum, attributes, value);
|
|
121
|
+
}
|
|
122
|
+
isEnabled() {
|
|
123
|
+
return this.clientMeter.enabled;
|
|
124
|
+
}
|
|
125
|
+
shutdown() {
|
|
126
|
+
this.shutdownPromise ??= this.enqueue(async () => {
|
|
127
|
+
const meter = this.clientMeter;
|
|
128
|
+
this.clientMeter = ClientMeter_1.ClientMeter.disabledInstance();
|
|
129
|
+
await meter.shutdown();
|
|
130
|
+
});
|
|
131
|
+
return this.shutdownPromise;
|
|
132
|
+
}
|
|
133
|
+
reset(metric) {
|
|
134
|
+
if (this.shutdownPromise) {
|
|
135
|
+
return this.shutdownPromise;
|
|
136
|
+
}
|
|
137
|
+
return this.enqueue(() => this.resetMeter(metric));
|
|
138
|
+
}
|
|
139
|
+
// Settings handlers do not await reset; serialize disable/enable and shutdown in invocation order.
|
|
140
|
+
enqueue(operation) {
|
|
141
|
+
const result = this.pending.then(operation);
|
|
142
|
+
this.pending = result.catch(() => undefined);
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
async resetMeter(metric) {
|
|
146
|
+
try {
|
|
147
|
+
if (this.clientMeter.satisfy(metric)) {
|
|
148
|
+
this.logger.info('Metric settings is satisfied by the current message meter, metric=%j, clientId=%s', metric, this.clientId);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (!metric.on || !metric.endpoints) {
|
|
152
|
+
this.logger.info('Metric is off, clientId=%s', this.clientId);
|
|
153
|
+
await this.clientMeter.shutdown();
|
|
154
|
+
this.clientMeter = ClientMeter_1.ClientMeter.disabledInstance();
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const endpoints = metric.endpoints;
|
|
158
|
+
const urls = endpoints.addressesList.map(address => {
|
|
159
|
+
const host = (0, node_net_1.isIPv6)(address.host) ? `[${address.host}]` : address.host;
|
|
160
|
+
return `http://${host}:${address.port}`;
|
|
161
|
+
});
|
|
162
|
+
if (urls.length === 0) {
|
|
163
|
+
throw new Error('Metric endpoints must contain at least one address');
|
|
164
|
+
}
|
|
165
|
+
const exporter = new SignedMetricExporter(urls, this.metadataProvider);
|
|
166
|
+
const reader = new sdk_metrics_1.PeriodicExportingMetricReader({
|
|
167
|
+
exporter,
|
|
168
|
+
exportIntervalMillis: METRIC_READER_INTERVAL,
|
|
169
|
+
exportTimeoutMillis: METRIC_EXPORTER_RPC_TIMEOUT,
|
|
170
|
+
});
|
|
171
|
+
const views = [
|
|
172
|
+
new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.SEND_COST_TIME)),
|
|
173
|
+
new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.DELIVERY_LATENCY)),
|
|
174
|
+
new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.AWAIT_TIME)),
|
|
175
|
+
new sdk_metrics_1.View((0, HistogramEnum_1.buildHistogramView)(HistogramEnum_1.HistogramEnum.PROCESS_TIME)),
|
|
176
|
+
];
|
|
177
|
+
const provider = new sdk_metrics_1.MeterProvider({
|
|
178
|
+
resource: resources_1.Resource.empty(),
|
|
179
|
+
readers: [reader],
|
|
180
|
+
views,
|
|
181
|
+
});
|
|
182
|
+
const meter = provider.getMeter(METRIC_INSTRUMENTATION_NAME);
|
|
183
|
+
const existedClientMeter = this.clientMeter;
|
|
184
|
+
this.clientMeter = new ClientMeter_1.ClientMeter(meter, endpoints, provider);
|
|
185
|
+
await existedClientMeter.shutdown();
|
|
186
|
+
this.logger.info('Metrics is on, endpoints=%s, clientId=%s', endpoints, this.clientId);
|
|
187
|
+
const gauges = this.gaugeObserver.getGauges();
|
|
188
|
+
for (const gauge of gauges) {
|
|
189
|
+
meter.createObservableGauge(gauge).addCallback(observableResult => {
|
|
190
|
+
const values = this.gaugeObserver.getValues(gauge);
|
|
191
|
+
for (const [attributes, value] of values) {
|
|
192
|
+
observableResult.observe(value, attributes);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
catch (t) {
|
|
198
|
+
this.logger.error('Exception raised when resetting message meter, clientId=%s, error=%s', this.clientId, t);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
exports.ClientMeterManager = ClientMeterManager;
|
|
203
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ2xpZW50TWV0ZXJNYW5hZ2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL21ldHJpY3MvQ2xpZW50TWV0ZXJNYW5hZ2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7OztBQUdILDREQUtvQztBQUNwQyx3REFBb0Q7QUFDcEQsMEZBQStFO0FBQy9FLDJDQUE2RDtBQUM3RCx1Q0FBa0M7QUFFbEMsK0NBQTRDO0FBRTVDLDZEQUEwRDtBQUMxRCxtREFBb0U7QUFHcEUsTUFBTSwyQkFBMkIsR0FBRyxJQUFJLENBQUM7QUFDekMsTUFBTSxzQkFBc0IsR0FBRyxLQUFLLENBQUM7QUFDckMsTUFBTSwyQkFBMkIsR0FBRyw2QkFBNkIsQ0FBQztBQUtsRSxrR0FBa0c7QUFDbEcsNEdBQTRHO0FBQzVHLE1BQU0sb0JBQXFCLFNBQVEsK0NBQWtCO0lBSXRCO0lBQWlDO0lBSDdDLE9BQU8sR0FBRyxJQUFJLEdBQUcsRUFBaUIsQ0FBQztJQUM1QyxNQUFNLE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QUFLLEVBQUUsU0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFDO1lBQy9ELE1BQU0sa0JBQWtCLENBQUMsUUFBUSxFQUFFLENBQUM7WUFDcEMsSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsMENBQTBDLEVBQUUsU0FBUyxFQUFFLElBQUksQ0FBQyxRQUFRLENBQUMsQ0FBQztZQUV2RixNQUFNLE1BQU0sR0FBRyxJQUFJLENBQUMsYUFBYSxDQUFDLFNBQVMsRUFBRSxDQUFDO1lBQzlDLEtBQUssTUFBTSxLQUFLLElBQUksTUFBTSxFQUFFLENBQUM7Z0JBQzNCLEtBQUssQ0FBQyxxQkFBcUIsQ0FBQyxLQUFLLENBQUMsQ0FBQyxXQUFXLENBQUMsZ0JBQWdCLENBQUMsRUFBRTtvQkFDaEUsTUFBTSxNQUFNLEdBQUcsSUFBSSxDQUFDLGFBQWEsQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLENBQUM7b0JBQ25ELEtBQUssTUFBTSxDQUFFLFVBQVUsRUFBRSxLQUFLLENBQUUsSUFBSSxNQUFNLEVBQUUsQ0FBQzt3QkFDM0MsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLEtBQUssRUFBRSxVQUFVLENBQUMsQ0FBQztvQkFDOUMsQ0FBQztnQkFDSCxDQUFDLENBQUMsQ0FBQztZQUNMLENBQUM7UUFDSCxDQUFDO1FBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQztZQUNYLElBQUksQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLHNFQUFzRSxFQUFFLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDLENBQUM7UUFDOUcsQ0FBQztJQUNILENBQUM7Q0FDRjtBQWpIRCxnREFpSEMifQ==
|
|
@@ -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;
|
|
@@ -0,0 +1,71 @@
|
|
|
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.HISTOGRAM_BUCKETS = exports.HistogramEnum = void 0;
|
|
20
|
+
exports.buildHistogramView = buildHistogramView;
|
|
21
|
+
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
|
|
22
|
+
/**
|
|
23
|
+
* The four histograms exported by the RocketMQ client, mirroring
|
|
24
|
+
* org.apache.rocketmq.client.java.metrics.HistogramEnum. The bucket
|
|
25
|
+
* boundaries (in milliseconds) are copied verbatim from the Java client.
|
|
26
|
+
*/
|
|
27
|
+
var HistogramEnum;
|
|
28
|
+
(function (HistogramEnum) {
|
|
29
|
+
/**
|
|
30
|
+
* Cost time of successful api calls of message publishing.
|
|
31
|
+
* Labels: topic, client_id, invocation_status.
|
|
32
|
+
*/
|
|
33
|
+
HistogramEnum["SEND_COST_TIME"] = "rocketmq_send_cost_time";
|
|
34
|
+
/**
|
|
35
|
+
* Latency of message delivery from remote.
|
|
36
|
+
* Labels: topic, client_id, consumer_group.
|
|
37
|
+
*/
|
|
38
|
+
HistogramEnum["DELIVERY_LATENCY"] = "rocketmq_delivery_latency";
|
|
39
|
+
/**
|
|
40
|
+
* Await time of message consumption.
|
|
41
|
+
* Labels: topic, client_id, consumer_group.
|
|
42
|
+
*/
|
|
43
|
+
HistogramEnum["AWAIT_TIME"] = "rocketmq_await_time";
|
|
44
|
+
/**
|
|
45
|
+
* Process time of message consumption.
|
|
46
|
+
* Labels: topic, client_id, consumer_group, invocation_status.
|
|
47
|
+
*/
|
|
48
|
+
HistogramEnum["PROCESS_TIME"] = "rocketmq_process_time";
|
|
49
|
+
})(HistogramEnum || (exports.HistogramEnum = HistogramEnum = {}));
|
|
50
|
+
/**
|
|
51
|
+
* Explicit bucket boundaries (milliseconds) for each histogram, identical to
|
|
52
|
+
* the Java client's Aggregation.explicitBucketHistogram(...) calls.
|
|
53
|
+
*/
|
|
54
|
+
exports.HISTOGRAM_BUCKETS = {
|
|
55
|
+
[HistogramEnum.SEND_COST_TIME]: [1.0, 5.0, 10.0, 20.0, 50.0, 200.0, 500.0],
|
|
56
|
+
[HistogramEnum.DELIVERY_LATENCY]: [1.0, 5.0, 10.0, 20.0, 50.0, 200.0, 500.0],
|
|
57
|
+
[HistogramEnum.AWAIT_TIME]: [1.0, 5.0, 20.0, 100.0, 1000.0, 5 * 1000.0, 10 * 1000.0],
|
|
58
|
+
[HistogramEnum.PROCESS_TIME]: [1.0, 5.0, 10.0, 100.0, 1000.0, 10 * 1000.0, 60 * 1000.0],
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Build the OpenTelemetry view that forces the given histogram onto the exact
|
|
62
|
+
* explicit-bucket aggregation used by the Java client.
|
|
63
|
+
*/
|
|
64
|
+
function buildHistogramView(histogramEnum) {
|
|
65
|
+
return {
|
|
66
|
+
instrumentName: histogramEnum,
|
|
67
|
+
instrumentType: sdk_metrics_1.InstrumentType.HISTOGRAM,
|
|
68
|
+
aggregation: new sdk_metrics_1.ExplicitBucket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