@opentelemetry/instrumentation-amqplib 0.28.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## [0.28.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/instrumentation-amqplib-v0.27.0...instrumentation-amqplib-v0.28.0) (2022-03-14)
4
+
5
+
6
+ ### Features
7
+
8
+ * amqplib instrumentation ([#892](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/892)) ([f6c16b6](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/f6c16b6e03f0984af79131e2607b6095350d796c))
9
+ * upstream mocha instrumentation testing plugin from ext-js [#621](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/621) ([#669](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/669)) ([a5170c4](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/a5170c494706a2bec3ba51e59966d0ca8a41d00e))
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2022] OpenTelemetry Authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # OpenTelemetry Amqplib (RabbitMQ) Instrumentation for Node.js
2
+
3
+ [![NPM Published Version][npm-img]][npm-url]
4
+ [![Apache License][license-image]][license-image]
5
+
6
+ This module provides automatic instrumentation for [`amqplib`](https://www.npmjs.com/package/amqplib) (RabbitMQ)
7
+
8
+ For automatic instrumentation see the
9
+ [`@opentelemetry/sdk-trace-node`](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package.
10
+
11
+ Compatible with OpenTelemetry JS API and SDK `1.0+`.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install --save @opentelemetry/instrumentation-amqplib
17
+ ```
18
+
19
+ ## Supported Versions
20
+
21
+ - `>=0.5.5`
22
+
23
+ ## Usage
24
+
25
+ OpenTelemetry amqplib Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [`amqplib`](https://github.com/amqp-node/amqplib) (RabbitMQ).
26
+
27
+ To load a specific plugin, specify it in the registerInstrumentations's configuration:
28
+
29
+ ```js
30
+ const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
31
+ const { AmqplibInstrumentation } = require('@opentelemetry/instrumentation-amqplib');
32
+ const { registerInstrumentations } = require('@opentelemetry/instrumentation');
33
+
34
+ const provider = new NodeTracerProvider();
35
+ provider.register();
36
+
37
+ registerInstrumentations({
38
+ instrumentations: [
39
+ new AmqplibInstrumentation({
40
+ // publishHook: (span: Span, publishInfo: PublishInfo) => { },
41
+ // publishConfirmHook: (span: Span, publishConfirmedInto: PublishConfirmedInfo) => { },
42
+ // consumeHook: (span: Span, consumeInfo: ConsumeInfo) => { },
43
+ // consumeEndHook: (span: Span, consumeEndInfo: ConsumeEndInfo) => { },
44
+ }),
45
+ ],
46
+ })
47
+ ```
48
+
49
+ ### amqplib Instrumentation Options
50
+
51
+ amqplib instrumentation has few options available to choose from. You can set the following:
52
+
53
+ | Options | Type | Description |
54
+ | --------------------------------- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
55
+ | `publishHook` | `AmqplibPublishCustomAttributeFunction` | hook for adding custom attributes before publish message is sent. |
56
+ | `publishConfirmHook` | `AmqplibPublishConfirmCustomAttributeFunction` | hook for adding custom attributes after publish message is confirmed by the broker. |
57
+ | `consumeHook` | `AmqplibConsumeCustomAttributeFunction` | hook for adding custom attributes before consumer message is processed. |
58
+ | `consumeEndHook` | `AmqplibConsumeEndCustomAttributeFunction` | hook for adding custom attributes after consumer message is acked to server. |
59
+ | `consumeTimeoutMs` | `number` | read [Consume Timeout](#ConsumeTimeout) below |
60
+
61
+ ### Consume Timeout
62
+
63
+ When user is setting up consume callback, it is user's responsibility to call ack/nack etc on the msg to resolve it in the server. If user is not calling the ack, the message will stay in the queue until channel is closed, or until server timeout expires (if configured).
64
+
65
+ While we wait for the ack, a reference to the message is stored in plugin, which
66
+ will never be garbage collected.
67
+ To prevent memory leak, plugin has it's own configuration of timeout, which will close the span if user did not call ack after this timeout.
68
+
69
+ If timeout is not big enough, span might be closed with 'InstrumentationTimeout', and then received valid ack from the user later which will not be instrumented.
70
+
71
+ Default is 1 minute
72
+
73
+ ## Migration From opentelemetry-instrumentation-amqplib
74
+
75
+ This instrumentation was originally published under the name `"opentelemetry-instrumentation-amqplib"` in [this repo](https://github.com/aspecto-io/opentelemetry-ext-js). Few breaking changes were made during porting to the contrib repo to align with conventions:
76
+
77
+ ### Hook Info
78
+
79
+ The instrumentation's config `publishHook`, `publishConfirmHook`, `consumeHook` and `consumeEndHook` functions signature changed, so the second function parameter is info object, containing the relevant hook data.
80
+
81
+ ### `moduleVersionAttributeName` config option
82
+
83
+ The `moduleVersionAttributeName` config option is removed. To add the amqplib package version to spans, use the `moduleVersion` attribute in hook info for `publishHook` and `consumeHook` functions.
84
+
85
+ ## Useful links
86
+
87
+ - For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
88
+ - For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
89
+ - For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
90
+
91
+ ## License
92
+
93
+ Apache 2.0 - See [LICENSE][license-url] for more information.
94
+
95
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
96
+ [license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
97
+ [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
98
+ [npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-amqplib
99
+ [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-amqplib.svg
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import { InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation';
3
+ import type * as amqp from 'amqplib';
4
+ import { AmqplibInstrumentationConfig } from './types';
5
+ import { InstrumentationConsumeChannel, InstrumentationPublishChannel } from './utils';
6
+ export declare class AmqplibInstrumentation extends InstrumentationBase<typeof amqp> {
7
+ protected _config: AmqplibInstrumentationConfig;
8
+ constructor(config?: AmqplibInstrumentationConfig);
9
+ setConfig(config?: AmqplibInstrumentationConfig): void;
10
+ protected init(): InstrumentationModuleDefinition<typeof amqp>;
11
+ private patchConnect;
12
+ private unpatchConnect;
13
+ private patchChannelModel;
14
+ private unpatchChannelModel;
15
+ private getConnectPatch;
16
+ private getChannelEmitPatch;
17
+ private getAckAllPatch;
18
+ private getAckPatch;
19
+ protected getConsumePatch(moduleVersion: string | undefined, original: Function): (this: InstrumentationConsumeChannel, queue: string, onMessage: (msg: amqp.ConsumeMessage | null) => void, options?: amqp.Options.Consume | undefined) => Promise<amqp.Replies.Consume>;
20
+ protected getConfirmedPublishPatch(moduleVersion: string | undefined, original: Function): (this: InstrumentationConsumeChannel, exchange: string, routingKey: string, content: Buffer, options?: amqp.Options.Publish | undefined, callback?: ((err: any, ok: amqp.Replies.Empty) => void) | undefined) => boolean;
21
+ protected getPublishPatch(moduleVersion: string | undefined, original: Function): (this: InstrumentationPublishChannel, exchange: string, routingKey: string, content: Buffer, options?: amqp.Options.Publish | undefined) => boolean;
22
+ private createPublishSpan;
23
+ private endConsumerSpan;
24
+ private endAllSpansOnChannel;
25
+ private callConsumeEndHook;
26
+ private checkConsumeTimeoutOnChannel;
27
+ }
28
+ //# sourceMappingURL=amqplib.d.ts.map
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmqplibInstrumentation = void 0;
4
+ /*
5
+ * Copyright The OpenTelemetry Authors
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const api_1 = require("@opentelemetry/api");
20
+ const core_1 = require("@opentelemetry/core");
21
+ const instrumentation_1 = require("@opentelemetry/instrumentation");
22
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
23
+ const types_1 = require("./types");
24
+ const utils_1 = require("./utils");
25
+ const version_1 = require("./version");
26
+ class AmqplibInstrumentation extends instrumentation_1.InstrumentationBase {
27
+ constructor(config) {
28
+ super('@opentelemetry/instrumentation-amqplib', version_1.VERSION, Object.assign({}, types_1.DEFAULT_CONFIG, config));
29
+ }
30
+ setConfig(config = {}) {
31
+ this._config = Object.assign({}, types_1.DEFAULT_CONFIG, config);
32
+ }
33
+ init() {
34
+ const channelModelModuleFile = new instrumentation_1.InstrumentationNodeModuleFile('amqplib/lib/channel_model.js', ['>=0.5.5'], this.patchChannelModel.bind(this), this.unpatchChannelModel.bind(this));
35
+ const callbackModelModuleFile = new instrumentation_1.InstrumentationNodeModuleFile('amqplib/lib/callback_model.js', ['>=0.5.5'], this.patchChannelModel.bind(this), this.unpatchChannelModel.bind(this));
36
+ const connectModuleFile = new instrumentation_1.InstrumentationNodeModuleFile('amqplib/lib/connect.js', ['>=0.5.5'], this.patchConnect.bind(this), this.unpatchConnect.bind(this));
37
+ const module = new instrumentation_1.InstrumentationNodeModuleDefinition('amqplib', ['>=0.5.5'], undefined, undefined, [channelModelModuleFile, connectModuleFile, callbackModelModuleFile]);
38
+ return module;
39
+ }
40
+ patchConnect(moduleExports) {
41
+ moduleExports = this.unpatchConnect(moduleExports);
42
+ if (!instrumentation_1.isWrapped(moduleExports.connect)) {
43
+ this._wrap(moduleExports, 'connect', this.getConnectPatch.bind(this));
44
+ }
45
+ return moduleExports;
46
+ }
47
+ unpatchConnect(moduleExports) {
48
+ if (instrumentation_1.isWrapped(moduleExports.connect)) {
49
+ this._unwrap(moduleExports, 'connect');
50
+ }
51
+ return moduleExports;
52
+ }
53
+ patchChannelModel(moduleExports, moduleVersion) {
54
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.publish)) {
55
+ this._wrap(moduleExports.Channel.prototype, 'publish', this.getPublishPatch.bind(this, moduleVersion));
56
+ }
57
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.consume)) {
58
+ this._wrap(moduleExports.Channel.prototype, 'consume', this.getConsumePatch.bind(this, moduleVersion));
59
+ }
60
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.ack)) {
61
+ this._wrap(moduleExports.Channel.prototype, 'ack', this.getAckPatch.bind(this, false, types_1.EndOperation.Ack));
62
+ }
63
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.nack)) {
64
+ this._wrap(moduleExports.Channel.prototype, 'nack', this.getAckPatch.bind(this, true, types_1.EndOperation.Nack));
65
+ }
66
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.reject)) {
67
+ this._wrap(moduleExports.Channel.prototype, 'reject', this.getAckPatch.bind(this, true, types_1.EndOperation.Reject));
68
+ }
69
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.ackAll)) {
70
+ this._wrap(moduleExports.Channel.prototype, 'ackAll', this.getAckAllPatch.bind(this, false, types_1.EndOperation.AckAll));
71
+ }
72
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.nackAll)) {
73
+ this._wrap(moduleExports.Channel.prototype, 'nackAll', this.getAckAllPatch.bind(this, true, types_1.EndOperation.NackAll));
74
+ }
75
+ if (!instrumentation_1.isWrapped(moduleExports.Channel.prototype.emit)) {
76
+ this._wrap(moduleExports.Channel.prototype, 'emit', this.getChannelEmitPatch.bind(this));
77
+ }
78
+ if (!instrumentation_1.isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {
79
+ this._wrap(moduleExports.ConfirmChannel.prototype, 'publish', this.getConfirmedPublishPatch.bind(this, moduleVersion));
80
+ }
81
+ return moduleExports;
82
+ }
83
+ unpatchChannelModel(moduleExports) {
84
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.publish)) {
85
+ this._unwrap(moduleExports.Channel.prototype, 'publish');
86
+ }
87
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.consume)) {
88
+ this._unwrap(moduleExports.Channel.prototype, 'consume');
89
+ }
90
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.ack)) {
91
+ this._unwrap(moduleExports.Channel.prototype, 'ack');
92
+ }
93
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.nack)) {
94
+ this._unwrap(moduleExports.Channel.prototype, 'nack');
95
+ }
96
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.reject)) {
97
+ this._unwrap(moduleExports.Channel.prototype, 'reject');
98
+ }
99
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.ackAll)) {
100
+ this._unwrap(moduleExports.Channel.prototype, 'ackAll');
101
+ }
102
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.nackAll)) {
103
+ this._unwrap(moduleExports.Channel.prototype, 'nackAll');
104
+ }
105
+ if (instrumentation_1.isWrapped(moduleExports.Channel.prototype.emit)) {
106
+ this._unwrap(moduleExports.Channel.prototype, 'emit');
107
+ }
108
+ if (instrumentation_1.isWrapped(moduleExports.ConfirmChannel.prototype.publish)) {
109
+ this._unwrap(moduleExports.ConfirmChannel.prototype, 'publish');
110
+ }
111
+ return moduleExports;
112
+ }
113
+ getConnectPatch(original) {
114
+ return function patchedConnect(url, socketOptions, openCallback) {
115
+ return original.call(this, url, socketOptions, function (err, conn) {
116
+ if (err == null) {
117
+ const urlAttributes = utils_1.getConnectionAttributesFromUrl(url);
118
+ // the type of conn in @types/amqplib is amqp.Connection, but in practice the library send the
119
+ // `serverProperties` on the `conn` and not in a property `connection`.
120
+ // I don't have capacity to debug it currently but it should probably be fixed in @types or
121
+ // in the package itself
122
+ // currently setting as any to calm typescript
123
+ const serverAttributes = utils_1.getConnectionAttributesFromServer(conn);
124
+ conn[utils_1.CONNECTION_ATTRIBUTES] = Object.assign(Object.assign({}, urlAttributes), serverAttributes);
125
+ }
126
+ openCallback.apply(this, arguments);
127
+ });
128
+ };
129
+ }
130
+ getChannelEmitPatch(original) {
131
+ const self = this;
132
+ return function emit(eventName) {
133
+ if (eventName === 'close') {
134
+ self.endAllSpansOnChannel(this, true, types_1.EndOperation.ChannelClosed, undefined);
135
+ const activeTimer = this[utils_1.CHANNEL_CONSUME_TIMEOUT_TIMER];
136
+ if (activeTimer) {
137
+ clearInterval(activeTimer);
138
+ }
139
+ this[utils_1.CHANNEL_CONSUME_TIMEOUT_TIMER] = undefined;
140
+ }
141
+ else if (eventName === 'error') {
142
+ self.endAllSpansOnChannel(this, true, types_1.EndOperation.ChannelError, undefined);
143
+ }
144
+ return original.apply(this, arguments);
145
+ };
146
+ }
147
+ getAckAllPatch(isRejected, endOperation, original) {
148
+ const self = this;
149
+ return function ackAll(requeueOrEmpty) {
150
+ self.endAllSpansOnChannel(this, isRejected, endOperation, requeueOrEmpty);
151
+ return original.apply(this, arguments);
152
+ };
153
+ }
154
+ getAckPatch(isRejected, endOperation, original) {
155
+ const self = this;
156
+ return function ack(message, allUpToOrRequeue, requeue) {
157
+ var _a;
158
+ const channel = this;
159
+ // we use this patch in reject function as well, but it has different signature
160
+ const requeueResolved = endOperation === types_1.EndOperation.Reject ? allUpToOrRequeue : requeue;
161
+ const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
162
+ const msgIndex = spansNotEnded.findIndex(msgDetails => msgDetails.msg === message);
163
+ if (msgIndex < 0) {
164
+ // should not happen in happy flow
165
+ // but possible if user is calling the api function ack twice with same message
166
+ self.endConsumerSpan(message, isRejected, endOperation, requeueResolved);
167
+ }
168
+ else if (endOperation !== types_1.EndOperation.Reject && allUpToOrRequeue) {
169
+ for (let i = 0; i <= msgIndex; i++) {
170
+ self.endConsumerSpan(spansNotEnded[i].msg, isRejected, endOperation, requeueResolved);
171
+ }
172
+ spansNotEnded.splice(0, msgIndex + 1);
173
+ }
174
+ else {
175
+ self.endConsumerSpan(message, isRejected, endOperation, requeueResolved);
176
+ spansNotEnded.splice(msgIndex, 1);
177
+ }
178
+ return original.apply(this, arguments);
179
+ };
180
+ }
181
+ getConsumePatch(moduleVersion, original) {
182
+ const self = this;
183
+ return function consume(queue, onMessage, options) {
184
+ const channel = this;
185
+ if (!Object.prototype.hasOwnProperty.call(channel, utils_1.CHANNEL_SPANS_NOT_ENDED)) {
186
+ if (self._config.consumeTimeoutMs) {
187
+ const timer = setInterval(() => {
188
+ self.checkConsumeTimeoutOnChannel(channel);
189
+ }, self._config.consumeTimeoutMs);
190
+ timer.unref();
191
+ channel[utils_1.CHANNEL_CONSUME_TIMEOUT_TIMER] = timer;
192
+ }
193
+ channel[utils_1.CHANNEL_SPANS_NOT_ENDED] = [];
194
+ }
195
+ const patchedOnMessage = function (msg) {
196
+ var _a, _b, _c, _d;
197
+ // msg is expected to be null for signaling consumer cancel notification
198
+ // https://www.rabbitmq.com/consumer-cancel.html
199
+ // in this case, we do not start a span, as this is not a real message.
200
+ if (!msg) {
201
+ return onMessage.call(this, msg);
202
+ }
203
+ const headers = (_a = msg.properties.headers) !== null && _a !== void 0 ? _a : {};
204
+ const parentContext = api_1.propagation.extract(api_1.ROOT_CONTEXT, headers);
205
+ const exchange = (_b = msg.fields) === null || _b === void 0 ? void 0 : _b.exchange;
206
+ const span = self.tracer.startSpan(`${queue} process`, {
207
+ kind: api_1.SpanKind.CONSUMER,
208
+ attributes: Object.assign(Object.assign({}, (_c = channel === null || channel === void 0 ? void 0 : channel.connection) === null || _c === void 0 ? void 0 : _c[utils_1.CONNECTION_ATTRIBUTES]), { [semantic_conventions_1.SemanticAttributes.MESSAGING_DESTINATION]: exchange, [semantic_conventions_1.SemanticAttributes.MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MessagingDestinationKindValues.TOPIC, [semantic_conventions_1.SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY]: (_d = msg.fields) === null || _d === void 0 ? void 0 : _d.routingKey, [semantic_conventions_1.SemanticAttributes.MESSAGING_OPERATION]: semantic_conventions_1.MessagingOperationValues.PROCESS, [semantic_conventions_1.SemanticAttributes.MESSAGING_MESSAGE_ID]: msg === null || msg === void 0 ? void 0 : msg.properties.messageId, [semantic_conventions_1.SemanticAttributes.MESSAGING_CONVERSATION_ID]: msg === null || msg === void 0 ? void 0 : msg.properties.correlationId }),
209
+ }, parentContext);
210
+ if (self._config.consumeHook) {
211
+ instrumentation_1.safeExecuteInTheMiddle(() => self._config.consumeHook(span, { moduleVersion, msg }), e => {
212
+ if (e) {
213
+ api_1.diag.error('amqplib instrumentation: consumerHook error', e);
214
+ }
215
+ }, true);
216
+ }
217
+ if (!(options === null || options === void 0 ? void 0 : options.noAck)) {
218
+ // store the message on the channel so we can close the span on ackAll etc
219
+ channel[utils_1.CHANNEL_SPANS_NOT_ENDED].push({
220
+ msg,
221
+ timeOfConsume: core_1.hrTime(),
222
+ });
223
+ // store the span on the message, so we can end it when user call 'ack' on it
224
+ msg[utils_1.MESSAGE_STORED_SPAN] = span;
225
+ }
226
+ api_1.context.with(api_1.trace.setSpan(api_1.context.active(), span), () => {
227
+ onMessage.call(this, msg);
228
+ });
229
+ if (options === null || options === void 0 ? void 0 : options.noAck) {
230
+ self.callConsumeEndHook(span, msg, false, types_1.EndOperation.AutoAck);
231
+ span.end();
232
+ }
233
+ };
234
+ arguments[1] = patchedOnMessage;
235
+ return original.apply(this, arguments);
236
+ };
237
+ }
238
+ getConfirmedPublishPatch(moduleVersion, original) {
239
+ const self = this;
240
+ return function confirmedPublish(exchange, routingKey, content, options, callback) {
241
+ const channel = this;
242
+ const { span, modifiedOptions } = self.createPublishSpan(self, exchange, routingKey, channel, options);
243
+ if (self._config.publishHook) {
244
+ instrumentation_1.safeExecuteInTheMiddle(() => self._config.publishHook(span, {
245
+ moduleVersion,
246
+ exchange,
247
+ routingKey,
248
+ content,
249
+ options: modifiedOptions,
250
+ isConfirmChannel: true,
251
+ }), e => {
252
+ if (e) {
253
+ api_1.diag.error('amqplib instrumentation: publishHook error', e);
254
+ }
255
+ }, true);
256
+ }
257
+ const patchedOnConfirm = function (err, ok) {
258
+ try {
259
+ callback === null || callback === void 0 ? void 0 : callback.call(this, err, ok);
260
+ }
261
+ finally {
262
+ if (self._config.publishConfirmHook) {
263
+ instrumentation_1.safeExecuteInTheMiddle(() => self._config.publishConfirmHook(span, {
264
+ moduleVersion,
265
+ exchange,
266
+ routingKey,
267
+ content,
268
+ options,
269
+ isConfirmChannel: true,
270
+ confirmError: err,
271
+ }), e => {
272
+ if (e) {
273
+ api_1.diag.error('amqplib instrumentation: publishConfirmHook error', e);
274
+ }
275
+ }, true);
276
+ }
277
+ if (err) {
278
+ span.setStatus({
279
+ code: api_1.SpanStatusCode.ERROR,
280
+ message: "message confirmation has been nack'ed",
281
+ });
282
+ }
283
+ span.end();
284
+ }
285
+ };
286
+ // calling confirm channel publish function is storing the message in queue and registering the callback for broker confirm.
287
+ // span ends in the patched callback.
288
+ const markedContext = utils_1.markConfirmChannelTracing(api_1.context.active());
289
+ const argumentsCopy = [...arguments];
290
+ argumentsCopy[3] = modifiedOptions;
291
+ argumentsCopy[4] = api_1.context.bind(utils_1.unmarkConfirmChannelTracing(api_1.trace.setSpan(markedContext, span)), patchedOnConfirm);
292
+ return api_1.context.with(markedContext, original.bind(this, ...argumentsCopy));
293
+ };
294
+ }
295
+ getPublishPatch(moduleVersion, original) {
296
+ const self = this;
297
+ return function publish(exchange, routingKey, content, options) {
298
+ if (utils_1.isConfirmChannelTracing(api_1.context.active())) {
299
+ // work already done
300
+ return original.apply(this, arguments);
301
+ }
302
+ else {
303
+ const channel = this;
304
+ const { span, modifiedOptions } = self.createPublishSpan(self, exchange, routingKey, channel, options);
305
+ if (self._config.publishHook) {
306
+ instrumentation_1.safeExecuteInTheMiddle(() => self._config.publishHook(span, {
307
+ moduleVersion,
308
+ exchange,
309
+ routingKey,
310
+ content,
311
+ options: modifiedOptions,
312
+ isConfirmChannel: false,
313
+ }), e => {
314
+ if (e) {
315
+ api_1.diag.error('amqplib instrumentation: publishHook error', e);
316
+ }
317
+ }, true);
318
+ }
319
+ // calling normal channel publish function is only storing the message in queue.
320
+ // it does not send it and waits for an ack, so the span duration is expected to be very short.
321
+ const argumentsCopy = [...arguments];
322
+ argumentsCopy[3] = modifiedOptions;
323
+ const originalRes = original.apply(this, argumentsCopy);
324
+ span.end();
325
+ return originalRes;
326
+ }
327
+ };
328
+ }
329
+ createPublishSpan(self, exchange, routingKey, channel, options) {
330
+ var _a;
331
+ const normalizedExchange = utils_1.normalizeExchange(exchange);
332
+ const span = self.tracer.startSpan(`${normalizedExchange} -> ${routingKey} send`, {
333
+ kind: api_1.SpanKind.PRODUCER,
334
+ attributes: Object.assign(Object.assign({}, channel.connection[utils_1.CONNECTION_ATTRIBUTES]), { [semantic_conventions_1.SemanticAttributes.MESSAGING_DESTINATION]: exchange, [semantic_conventions_1.SemanticAttributes.MESSAGING_DESTINATION_KIND]: semantic_conventions_1.MessagingDestinationKindValues.TOPIC, [semantic_conventions_1.SemanticAttributes.MESSAGING_RABBITMQ_ROUTING_KEY]: routingKey, [semantic_conventions_1.SemanticAttributes.MESSAGING_MESSAGE_ID]: options === null || options === void 0 ? void 0 : options.messageId, [semantic_conventions_1.SemanticAttributes.MESSAGING_CONVERSATION_ID]: options === null || options === void 0 ? void 0 : options.correlationId }),
335
+ });
336
+ const modifiedOptions = options !== null && options !== void 0 ? options : {};
337
+ modifiedOptions.headers = (_a = modifiedOptions.headers) !== null && _a !== void 0 ? _a : {};
338
+ api_1.propagation.inject(api_1.trace.setSpan(api_1.context.active(), span), modifiedOptions.headers);
339
+ return { span, modifiedOptions };
340
+ }
341
+ endConsumerSpan(message, isRejected, operation, requeue) {
342
+ const storedSpan = message[utils_1.MESSAGE_STORED_SPAN];
343
+ if (!storedSpan)
344
+ return;
345
+ if (isRejected !== false) {
346
+ storedSpan.setStatus({
347
+ code: api_1.SpanStatusCode.ERROR,
348
+ message: operation !== types_1.EndOperation.ChannelClosed &&
349
+ operation !== types_1.EndOperation.ChannelError
350
+ ? `${operation} called on message${requeue === true
351
+ ? ' with requeue'
352
+ : requeue === false
353
+ ? ' without requeue'
354
+ : ''}`
355
+ : operation,
356
+ });
357
+ }
358
+ this.callConsumeEndHook(storedSpan, message, isRejected, operation);
359
+ storedSpan.end();
360
+ message[utils_1.MESSAGE_STORED_SPAN] = undefined;
361
+ }
362
+ endAllSpansOnChannel(channel, isRejected, operation, requeue) {
363
+ var _a;
364
+ const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
365
+ spansNotEnded.forEach(msgDetails => {
366
+ this.endConsumerSpan(msgDetails.msg, isRejected, operation, requeue);
367
+ });
368
+ channel[utils_1.CHANNEL_SPANS_NOT_ENDED] = [];
369
+ }
370
+ callConsumeEndHook(span, msg, rejected, endOperation) {
371
+ if (!this._config.consumeEndHook)
372
+ return;
373
+ instrumentation_1.safeExecuteInTheMiddle(() => this._config.consumeEndHook(span, { msg, rejected, endOperation }), e => {
374
+ if (e) {
375
+ api_1.diag.error('amqplib instrumentation: consumerEndHook error', e);
376
+ }
377
+ }, true);
378
+ }
379
+ checkConsumeTimeoutOnChannel(channel) {
380
+ var _a;
381
+ const currentTime = core_1.hrTime();
382
+ const spansNotEnded = (_a = channel[utils_1.CHANNEL_SPANS_NOT_ENDED]) !== null && _a !== void 0 ? _a : [];
383
+ let i;
384
+ for (i = 0; i < spansNotEnded.length; i++) {
385
+ const currMessage = spansNotEnded[i];
386
+ const timeFromConsume = core_1.hrTimeDuration(currMessage.timeOfConsume, currentTime);
387
+ if (core_1.hrTimeToMilliseconds(timeFromConsume) < this._config.consumeTimeoutMs) {
388
+ break;
389
+ }
390
+ this.endConsumerSpan(currMessage.msg, null, types_1.EndOperation.InstrumentationTimeout, true);
391
+ }
392
+ spansNotEnded.splice(0, i);
393
+ }
394
+ }
395
+ exports.AmqplibInstrumentation = AmqplibInstrumentation;
396
+ //# sourceMappingURL=amqplib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amqplib.js","sourceRoot":"","sources":["../../src/amqplib.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAS4B;AAC5B,8CAI6B;AAC7B,oEAOwC;AACxC,8EAI6C;AAE7C,mCAIiB;AACjB,mCAciB;AACjB,uCAAoC;AAEpC,MAAa,sBAAuB,SAAQ,qCAAgC;IAG1E,YAAY,MAAqC;QAC/C,KAAK,CACH,wCAAwC,EACxC,iBAAO,EACP,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAc,EAAE,MAAM,CAAC,CAC1C,CAAC;IACJ,CAAC;IAEQ,SAAS,CAAC,SAAuC,EAAE;QAC1D,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,sBAAc,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IAES,IAAI;QACZ,MAAM,sBAAsB,GAC1B,IAAI,+CAA6B,CAC/B,8BAA8B,EAC9B,CAAC,SAAS,CAAC,EACX,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CACpC,CAAC;QAEJ,MAAM,uBAAuB,GAC3B,IAAI,+CAA6B,CAC/B,+BAA+B,EAC/B,CAAC,SAAS,CAAC,EACX,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CACpC,CAAC;QAEJ,MAAM,iBAAiB,GAAG,IAAI,+CAA6B,CACzD,wBAAwB,EACxB,CAAC,SAAS,CAAC,EACX,IAAI,CAAC,YAAY,CAAC,IA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ts.map
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /*
14
+ * Copyright The OpenTelemetry Authors
15
+ *
16
+ * Licensed under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License.
18
+ * You may obtain a copy of the License at
19
+ *
20
+ * https://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software
23
+ * distributed under the License is distributed on an "AS IS" BASIS,
24
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
+ * See the License for the specific language governing permissions and
26
+ * limitations under the License.
27
+ */
28
+ __exportStar(require("./amqplib"), exports);
29
+ __exportStar(require("./types"), exports);
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAA0B;AAC1B,0CAAwB"}
@@ -0,0 +1,74 @@
1
+ /// <reference types="node" />
2
+ import { Span } from '@opentelemetry/api';
3
+ import { InstrumentationConfig } from '@opentelemetry/instrumentation';
4
+ import type * as amqp from 'amqplib';
5
+ export interface PublishInfo {
6
+ moduleVersion: string | undefined;
7
+ exchange: string;
8
+ routingKey: string;
9
+ content: Buffer;
10
+ options?: amqp.Options.Publish;
11
+ isConfirmChannel?: boolean;
12
+ }
13
+ export interface PublishConfirmedInfo extends PublishInfo {
14
+ confirmError?: any;
15
+ }
16
+ export interface ConsumeInfo {
17
+ moduleVersion: string | undefined;
18
+ msg: amqp.ConsumeMessage;
19
+ }
20
+ export interface ConsumeEndInfo {
21
+ msg: amqp.ConsumeMessage;
22
+ rejected: boolean | null;
23
+ endOperation: EndOperation;
24
+ }
25
+ export interface AmqplibPublishCustomAttributeFunction {
26
+ (span: Span, publishInfo: PublishInfo): void;
27
+ }
28
+ export interface AmqplibPublishConfirmCustomAttributeFunction {
29
+ (span: Span, publishConfirmedInto: PublishConfirmedInfo): void;
30
+ }
31
+ export interface AmqplibConsumeCustomAttributeFunction {
32
+ (span: Span, consumeInfo: ConsumeInfo): void;
33
+ }
34
+ export interface AmqplibConsumeEndCustomAttributeFunction {
35
+ (span: Span, consumeEndInfo: ConsumeEndInfo): void;
36
+ }
37
+ export declare enum EndOperation {
38
+ AutoAck = "auto ack",
39
+ Ack = "ack",
40
+ AckAll = "ackAll",
41
+ Reject = "reject",
42
+ Nack = "nack",
43
+ NackAll = "nackAll",
44
+ ChannelClosed = "channel closed",
45
+ ChannelError = "channel error",
46
+ InstrumentationTimeout = "instrumentation timeout"
47
+ }
48
+ export interface AmqplibInstrumentationConfig extends InstrumentationConfig {
49
+ /** hook for adding custom attributes before publish message is sent */
50
+ publishHook?: AmqplibPublishCustomAttributeFunction;
51
+ /** hook for adding custom attributes after publish message is confirmed by the broker */
52
+ publishConfirmHook?: AmqplibPublishConfirmCustomAttributeFunction;
53
+ /** hook for adding custom attributes before consumer message is processed */
54
+ consumeHook?: AmqplibConsumeCustomAttributeFunction;
55
+ /** hook for adding custom attributes after consumer message is acked to server */
56
+ consumeEndHook?: AmqplibConsumeEndCustomAttributeFunction;
57
+ /**
58
+ * When user is setting up consume callback, it is user's responsibility to call
59
+ * ack/nack etc on the msg to resolve it in the server.
60
+ * If user is not calling the ack, the message will stay in the queue until
61
+ * channel is closed, or until server timeout expires (if configured).
62
+ * While we wait for the ack, a reference to the message is stored in plugin, which
63
+ * will never be garbage collected.
64
+ * To prevent memory leak, plugin has it's own configuration of timeout, which
65
+ * will close the span if user did not call ack after this timeout.
66
+ * If timeout is not big enough, span might be closed with 'InstrumentationTimeout',
67
+ * and then received valid ack from the user later which will not be instrumented.
68
+ *
69
+ * Default is 1 minute
70
+ */
71
+ consumeTimeoutMs?: number;
72
+ }
73
+ export declare const DEFAULT_CONFIG: AmqplibInstrumentationConfig;
74
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONFIG = exports.EndOperation = void 0;
4
+ var EndOperation;
5
+ (function (EndOperation) {
6
+ EndOperation["AutoAck"] = "auto ack";
7
+ EndOperation["Ack"] = "ack";
8
+ EndOperation["AckAll"] = "ackAll";
9
+ EndOperation["Reject"] = "reject";
10
+ EndOperation["Nack"] = "nack";
11
+ EndOperation["NackAll"] = "nackAll";
12
+ EndOperation["ChannelClosed"] = "channel closed";
13
+ EndOperation["ChannelError"] = "channel error";
14
+ EndOperation["InstrumentationTimeout"] = "instrumentation timeout";
15
+ })(EndOperation = exports.EndOperation || (exports.EndOperation = {}));
16
+ exports.DEFAULT_CONFIG = {
17
+ consumeTimeoutMs: 1000 * 60, // 1 minute
18
+ };
19
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA2DA,IAAY,YAUX;AAVD,WAAY,YAAY;IACtB,oCAAoB,CAAA;IACpB,2BAAW,CAAA;IACX,iCAAiB,CAAA;IACjB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,mCAAmB,CAAA;IACnB,gDAAgC,CAAA;IAChC,8CAA8B,CAAA;IAC9B,kEAAkD,CAAA;AACpD,CAAC,EAVW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAUvB;AAgCY,QAAA,cAAc,GAAiC;IAC1D,gBAAgB,EAAE,IAAI,GAAG,EAAE,EAAE,WAAW;CACzC,CAAC"}
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import { Context, HrTime, Span, SpanAttributes } from '@opentelemetry/api';
3
+ import type * as amqp from 'amqplib';
4
+ export declare const MESSAGE_STORED_SPAN: unique symbol;
5
+ export declare const CHANNEL_SPANS_NOT_ENDED: unique symbol;
6
+ export declare const CHANNEL_CONSUME_TIMEOUT_TIMER: unique symbol;
7
+ export declare const CONNECTION_ATTRIBUTES: unique symbol;
8
+ export declare type InstrumentationPublishChannel = (amqp.Channel | amqp.ConfirmChannel) & {
9
+ connection: {
10
+ [CONNECTION_ATTRIBUTES]: SpanAttributes;
11
+ };
12
+ };
13
+ export declare type InstrumentationConsumeChannel = amqp.Channel & {
14
+ connection: {
15
+ [CONNECTION_ATTRIBUTES]: SpanAttributes;
16
+ };
17
+ [CHANNEL_SPANS_NOT_ENDED]?: {
18
+ msg: amqp.ConsumeMessage;
19
+ timeOfConsume: HrTime;
20
+ }[];
21
+ [CHANNEL_CONSUME_TIMEOUT_TIMER]?: NodeJS.Timer;
22
+ };
23
+ export declare type InstrumentationMessage = amqp.Message & {
24
+ [MESSAGE_STORED_SPAN]?: Span;
25
+ };
26
+ export declare const normalizeExchange: (exchangeName: string) => string;
27
+ export declare const getConnectionAttributesFromServer: (conn: amqp.Connection['connection']) => SpanAttributes;
28
+ export declare const getConnectionAttributesFromUrl: (url: string | amqp.Options.Connect) => SpanAttributes;
29
+ export declare const markConfirmChannelTracing: (context: Context) => Context;
30
+ export declare const unmarkConfirmChannelTracing: (context: Context) => Context;
31
+ export declare const isConfirmChannelTracing: (context: Context) => boolean;
32
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isConfirmChannelTracing = exports.unmarkConfirmChannelTracing = exports.markConfirmChannelTracing = exports.getConnectionAttributesFromUrl = exports.getConnectionAttributesFromServer = exports.normalizeExchange = exports.CONNECTION_ATTRIBUTES = exports.CHANNEL_CONSUME_TIMEOUT_TIMER = exports.CHANNEL_SPANS_NOT_ENDED = exports.MESSAGE_STORED_SPAN = void 0;
4
+ /*
5
+ * Copyright The OpenTelemetry Authors
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * https://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const api_1 = require("@opentelemetry/api");
20
+ const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
21
+ exports.MESSAGE_STORED_SPAN = Symbol('opentelemetry.amqplib.message.stored-span');
22
+ exports.CHANNEL_SPANS_NOT_ENDED = Symbol('opentelemetry.amqplib.channel.spans-not-ended');
23
+ exports.CHANNEL_CONSUME_TIMEOUT_TIMER = Symbol('opentelemetry.amqplib.channel.consumer-timeout-timer');
24
+ exports.CONNECTION_ATTRIBUTES = Symbol('opentelemetry.amqplib.connection.attributes');
25
+ const IS_CONFIRM_CHANNEL_CONTEXT_KEY = api_1.createContextKey('opentelemetry.amqplib.channel.is-confirm-channel');
26
+ const normalizeExchange = (exchangeName) => exchangeName !== '' ? exchangeName : '<default>';
27
+ exports.normalizeExchange = normalizeExchange;
28
+ const censorPassword = (url) => {
29
+ return url.replace(/:[^:@/]*@/, ':***@');
30
+ };
31
+ const getPort = (portFromUrl, resolvedProtocol) => {
32
+ // we are using the resolved protocol which is upper case
33
+ // this code mimic the behavior of the amqplib which is used to set connection params
34
+ return portFromUrl || (resolvedProtocol === 'AMQP' ? 5672 : 5671);
35
+ };
36
+ const getProtocol = (protocolFromUrl) => {
37
+ const resolvedProtocol = protocolFromUrl || 'amqp';
38
+ // the substring removed the ':' part of the protocol ('amqp:' -> 'amqp')
39
+ const noEndingColon = resolvedProtocol.endsWith(':')
40
+ ? resolvedProtocol.substring(0, resolvedProtocol.length - 1)
41
+ : resolvedProtocol;
42
+ // upper cases to match spec
43
+ return noEndingColon.toUpperCase();
44
+ };
45
+ const getHostname = (hostnameFromUrl) => {
46
+ // if user supplies empty hostname, it gets forwarded to 'net' package which default it to localhost.
47
+ // https://nodejs.org/docs/latest-v12.x/api/net.html#net_socket_connect_options_connectlistener
48
+ return hostnameFromUrl || 'localhost';
49
+ };
50
+ const extractConnectionAttributeOrLog = (url, attributeKey, attributeValue, nameForLog) => {
51
+ if (attributeValue) {
52
+ return { [attributeKey]: attributeValue };
53
+ }
54
+ else {
55
+ api_1.diag.error(`amqplib instrumentation: could not extract connection attribute ${nameForLog} from user supplied url`, {
56
+ url,
57
+ });
58
+ return {};
59
+ }
60
+ };
61
+ const getConnectionAttributesFromServer = (conn) => {
62
+ var _a, _b;
63
+ const product = (_b = (_a = conn.serverProperties.product) === null || _a === void 0 ? void 0 : _a.toLowerCase) === null || _b === void 0 ? void 0 : _b.call(_a);
64
+ if (product) {
65
+ return {
66
+ [semantic_conventions_1.SemanticAttributes.MESSAGING_SYSTEM]: product,
67
+ };
68
+ }
69
+ else {
70
+ return {};
71
+ }
72
+ };
73
+ exports.getConnectionAttributesFromServer = getConnectionAttributesFromServer;
74
+ const getConnectionAttributesFromUrl = (url) => {
75
+ const attributes = {
76
+ [semantic_conventions_1.SemanticAttributes.MESSAGING_PROTOCOL_VERSION]: '0.9.1', // this is the only protocol supported by the instrumented library
77
+ };
78
+ url = url || 'amqp://localhost';
79
+ if (typeof url === 'object') {
80
+ const connectOptions = url;
81
+ const protocol = getProtocol(connectOptions === null || connectOptions === void 0 ? void 0 : connectOptions.protocol);
82
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SemanticAttributes.MESSAGING_PROTOCOL, protocol, 'protocol')));
83
+ const hostname = getHostname(connectOptions === null || connectOptions === void 0 ? void 0 : connectOptions.hostname);
84
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SemanticAttributes.NET_PEER_NAME, hostname, 'hostname')));
85
+ const port = getPort(connectOptions.port, protocol);
86
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(url, semantic_conventions_1.SemanticAttributes.NET_PEER_PORT, port, 'port')));
87
+ }
88
+ else {
89
+ const censoredUrl = censorPassword(url);
90
+ attributes[semantic_conventions_1.SemanticAttributes.MESSAGING_URL] = censoredUrl;
91
+ try {
92
+ const urlParts = new URL(censoredUrl);
93
+ const protocol = getProtocol(urlParts.protocol);
94
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SemanticAttributes.MESSAGING_PROTOCOL, protocol, 'protocol')));
95
+ const hostname = getHostname(urlParts.hostname);
96
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SemanticAttributes.NET_PEER_NAME, hostname, 'hostname')));
97
+ const port = getPort(urlParts.port ? parseInt(urlParts.port) : undefined, protocol);
98
+ Object.assign(attributes, Object.assign({}, extractConnectionAttributeOrLog(censoredUrl, semantic_conventions_1.SemanticAttributes.NET_PEER_PORT, port, 'port')));
99
+ }
100
+ catch (err) {
101
+ api_1.diag.error('amqplib instrumentation: error while extracting connection details from connection url', {
102
+ censoredUrl,
103
+ err,
104
+ });
105
+ }
106
+ }
107
+ return attributes;
108
+ };
109
+ exports.getConnectionAttributesFromUrl = getConnectionAttributesFromUrl;
110
+ const markConfirmChannelTracing = (context) => {
111
+ return context.setValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY, true);
112
+ };
113
+ exports.markConfirmChannelTracing = markConfirmChannelTracing;
114
+ const unmarkConfirmChannelTracing = (context) => {
115
+ return context.deleteValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY);
116
+ };
117
+ exports.unmarkConfirmChannelTracing = unmarkConfirmChannelTracing;
118
+ const isConfirmChannelTracing = (context) => {
119
+ return context.getValue(IS_CONFIRM_CHANNEL_CONTEXT_KEY) === true;
120
+ };
121
+ exports.isConfirmChannelTracing = isConfirmChannelTracing;
122
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,4CAQ4B;AAC5B,8EAAyE;AAG5D,QAAA,mBAAmB,GAAkB,MAAM,CACtD,2CAA2C,CAC5C,CAAC;AACW,QAAA,uBAAuB,GAAkB,MAAM,CAC1D,+CAA+C,CAChD,CAAC;AACW,QAAA,6BAA6B,GAAkB,MAAM,CAChE,sDAAsD,CACvD,CAAC;AACW,QAAA,qBAAqB,GAAkB,MAAM,CACxD,6CAA6C,CAC9C,CAAC;AAkBF,MAAM,8BAA8B,GAAW,sBAAgB,CAC7D,kDAAkD,CACnD,CAAC;AAEK,MAAM,iBAAiB,GAAG,CAAC,YAAoB,EAAE,EAAE,CACxD,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;AADtC,QAAA,iBAAiB,qBACqB;AAEnD,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;IAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,CACd,WAA+B,EAC/B,gBAAwB,EAChB,EAAE;IACV,yDAAyD;IACzD,qFAAqF;IACrF,OAAO,WAAW,IAAI,CAAC,gBAAgB,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,eAAmC,EAAU,EAAE;IAClE,MAAM,gBAAgB,GAAG,eA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 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.VERSION = void 0;
19
+ // this is autogenerated file, see scripts/version-update.js
20
+ exports.VERSION = '0.28.0';
21
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@opentelemetry/instrumentation-amqplib",
3
+ "version": "0.28.0",
4
+ "description": "OpenTelemetry automatic instrumentation for the `amqplib` package",
5
+ "keywords": [
6
+ "amqplib",
7
+ "opentelemetry",
8
+ "rabbitmq",
9
+ "AMQP 0-9-1"
10
+ ],
11
+ "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib#readme",
12
+ "license": "Apache-2.0",
13
+ "author": "OpenTelemetry Authors",
14
+ "bugs": {
15
+ "url": "https://github.com/open-telemetry/opentelemetry-js-contrib/issues"
16
+ },
17
+ "main": "build/src/index.js",
18
+ "types": "build/src/index.d.ts",
19
+ "files": [
20
+ "build/src/**/*.js",
21
+ "build/src/**/*.js.map",
22
+ "build/src/**/*.d.ts",
23
+ "LICENSE",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "repository": "open-telemetry/opentelemetry-js-contrib",
30
+ "scripts": {
31
+ "clean": "rimraf build/*",
32
+ "compile": "npm run version:update && tsc -p .",
33
+ "lint": "eslint . --ext .ts",
34
+ "lint:fix": "eslint . --ext .ts --fix",
35
+ "precompile": "tsc --version && lerna run version --scope $(npm pkg get name) --include-dependencies",
36
+ "prewatch": "npm run precompile",
37
+ "prepare": "npm run compile",
38
+ "tdd": "npm run test -- --watch-extensions ts --watch",
39
+ "test": "nyc ts-mocha -p tsconfig.json --require '@opentelemetry/contrib-test-utils' 'test/**/*.test.ts'",
40
+ "test-all-versions": "tav",
41
+ "version:update": "node ../../../scripts/version-update.js",
42
+ "watch": "tsc -w",
43
+ "test:docker:run": "docker run -d --hostname demo-amqplib-rabbit --name amqplib-unittests -p 22221:5672 --env RABBITMQ_DEFAULT_USER=username --env RABBITMQ_DEFAULT_PASS=password rabbitmq:3"
44
+ },
45
+ "peerDependencies": {
46
+ "@opentelemetry/api": "^1.0.1"
47
+ },
48
+ "dependencies": {
49
+ "@opentelemetry/core": "^1.0.0",
50
+ "@opentelemetry/instrumentation": "^0.27.0",
51
+ "@opentelemetry/semantic-conventions": "^1.0.0",
52
+ "@types/amqplib": "^0.5.17"
53
+ },
54
+ "devDependencies": {
55
+ "@opentelemetry/api": "1.0.1",
56
+ "@opentelemetry/contrib-test-utils": "^0.28.0",
57
+ "@types/lodash": "4.14.178",
58
+ "@types/mocha": "8.2.3",
59
+ "@types/node": "16.11.21",
60
+ "@types/sinon": "10.0.2",
61
+ "amqplib": "0.8.0",
62
+ "expect": "27.4.2",
63
+ "gts": "3.1.0",
64
+ "lodash": "4.17.21",
65
+ "mocha": "7.2.0",
66
+ "nyc": "15.1.0",
67
+ "sinon": "13.0.1",
68
+ "test-all-versions": "5.0.1",
69
+ "ts-mocha": "8.0.0",
70
+ "typescript": "4.3.5"
71
+ },
72
+ "engines": {
73
+ "node": ">=10.0.0"
74
+ },
75
+ "gitHead": "491588f7245e48268bea438cc475e87ae1ed8ad6"
76
+ }