@opentelemetry/instrumentation-tedious 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/LICENSE +201 -0
- package/README.md +58 -0
- package/build/src/index.d.ts +5 -0
- package/build/src/index.js +31 -0
- package/build/src/index.js.map +1 -0
- package/build/src/instrumentation.d.ts +12 -0
- package/build/src/instrumentation.js +168 -0
- package/build/src/instrumentation.js.map +1 -0
- package/build/src/types.d.ts +3 -0
- package/build/src/types.js +18 -0
- package/build/src/types.js.map +1 -0
- package/build/src/utils.d.ts +9 -0
- package/build/src/utils.js +53 -0
- package/build/src/utils.js.map +1 -0
- package/build/src/version.d.ts +2 -0
- package/build/src/version.js +21 -0
- package/build/src/version.js.map +1 -0
- package/package.json +73 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2022-01-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* implement instrumentation for `tedious` ([#799](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/799)) ([9326c99](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/9326c99f3cdf3e0166f74093a8093066be78bd0a))
|
|
9
|
+
* re-enable TAV ([#823](https://www.github.com/open-telemetry/opentelemetry-js-contrib/issues/823)) ([2e14f46](https://www.github.com/open-telemetry/opentelemetry-js-contrib/commit/2e14f46b3f7221ae51ffa12313997f007c300e21))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Dependencies
|
|
14
|
+
|
|
15
|
+
* The following workspace dependencies were updated
|
|
16
|
+
* devDependencies
|
|
17
|
+
* @opentelemetry/contrib-test-utils bumped from ^0.28.0 to ^0.29.0
|
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 [yyyy] [name of copyright owner]
|
|
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,58 @@
|
|
|
1
|
+
# OpenTelemetry Tedious 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 [`tedious`](https://github.com/tediousjs/tedious).
|
|
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-tedious
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Supported Versions
|
|
20
|
+
|
|
21
|
+
- `>=1.11.0`
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
OpenTelemetry Tedious 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 [`tedious`](https://github.com/tediousjs/tedious).
|
|
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 { TediousInstrumentation } = require('@opentelemetry/instrumentation-tedious');
|
|
32
|
+
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
|
|
33
|
+
|
|
34
|
+
const provider = new NodeTracerProvider();
|
|
35
|
+
provider.register();
|
|
36
|
+
|
|
37
|
+
registerInstrumentations({
|
|
38
|
+
instrumentations: [
|
|
39
|
+
new TediousInstrumentation(),
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Useful links
|
|
45
|
+
|
|
46
|
+
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
|
47
|
+
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
|
|
48
|
+
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
53
|
+
|
|
54
|
+
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
|
55
|
+
[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE
|
|
56
|
+
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
|
57
|
+
[npm-url]: https://www.npmjs.com/package/@opentelemetry/instrumentation-tedious
|
|
58
|
+
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-tedious.svg
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
const instrumentation_1 = require("./instrumentation");
|
|
29
|
+
__exportStar(require("./instrumentation"), exports);
|
|
30
|
+
exports.default = instrumentation_1.TediousInstrumentation;
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,uDAA2D;AAE3D,oDAAkC;AAClC,kBAAe,wCAAsB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import type * as tedious from 'tedious';
|
|
3
|
+
import { TediousInstrumentationConfig } from './types';
|
|
4
|
+
export declare class TediousInstrumentation extends InstrumentationBase<typeof tedious> {
|
|
5
|
+
static readonly COMPONENT = "tedious";
|
|
6
|
+
constructor(config?: TediousInstrumentationConfig);
|
|
7
|
+
protected init(): InstrumentationNodeModuleDefinition<typeof tedious>[];
|
|
8
|
+
private _patchConnect;
|
|
9
|
+
private _patchQuery;
|
|
10
|
+
private _patchCallbackQuery;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1,168 @@
|
|
|
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.TediousInstrumentation = void 0;
|
|
19
|
+
const api = require("@opentelemetry/api");
|
|
20
|
+
const events_1 = require("events");
|
|
21
|
+
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
22
|
+
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
23
|
+
const utils_1 = require("./utils");
|
|
24
|
+
const version_1 = require("./version");
|
|
25
|
+
const CURRENT_DATABASE = Symbol('opentelemetry.instrumentation-tedious.current-database');
|
|
26
|
+
const PATCHED_METHODS = [
|
|
27
|
+
'callProcedure',
|
|
28
|
+
'execSql',
|
|
29
|
+
'execSqlBatch',
|
|
30
|
+
'execBulkLoad',
|
|
31
|
+
'prepare',
|
|
32
|
+
'execute',
|
|
33
|
+
];
|
|
34
|
+
function setDatabase(databaseName) {
|
|
35
|
+
Object.defineProperty(this, CURRENT_DATABASE, {
|
|
36
|
+
value: databaseName,
|
|
37
|
+
writable: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
class TediousInstrumentation extends instrumentation_1.InstrumentationBase {
|
|
41
|
+
constructor(config) {
|
|
42
|
+
super('@opentelemetry/instrumentation-tedious', version_1.VERSION, config);
|
|
43
|
+
}
|
|
44
|
+
init() {
|
|
45
|
+
return [
|
|
46
|
+
new instrumentation_1.InstrumentationNodeModuleDefinition(TediousInstrumentation.COMPONENT, ['*'], (moduleExports, moduleVersion) => {
|
|
47
|
+
this._diag.debug(`Patching tedious@${moduleVersion}`);
|
|
48
|
+
const ConnectionPrototype = moduleExports.Connection.prototype;
|
|
49
|
+
for (const method of PATCHED_METHODS) {
|
|
50
|
+
if (instrumentation_1.isWrapped(ConnectionPrototype[method])) {
|
|
51
|
+
this._unwrap(ConnectionPrototype, method);
|
|
52
|
+
}
|
|
53
|
+
this._wrap(ConnectionPrototype, method, this._patchQuery(method));
|
|
54
|
+
}
|
|
55
|
+
if (instrumentation_1.isWrapped(ConnectionPrototype.connect)) {
|
|
56
|
+
this._unwrap(ConnectionPrototype, 'connect');
|
|
57
|
+
}
|
|
58
|
+
this._wrap(ConnectionPrototype, 'connect', this._patchConnect);
|
|
59
|
+
return moduleExports;
|
|
60
|
+
}, (moduleExports) => {
|
|
61
|
+
if (moduleExports === undefined)
|
|
62
|
+
return;
|
|
63
|
+
const ConnectionPrototype = moduleExports.Connection.prototype;
|
|
64
|
+
for (const method of PATCHED_METHODS) {
|
|
65
|
+
this._unwrap(ConnectionPrototype, method);
|
|
66
|
+
}
|
|
67
|
+
this._unwrap(ConnectionPrototype, 'connect');
|
|
68
|
+
}),
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
_patchConnect(original) {
|
|
72
|
+
return function patchedConnect() {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
setDatabase.call(this, (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.database);
|
|
75
|
+
// remove the listener first in case it's already added
|
|
76
|
+
this.removeListener('databaseChange', setDatabase);
|
|
77
|
+
this.on('databaseChange', setDatabase);
|
|
78
|
+
this.once('end', () => {
|
|
79
|
+
this.removeListener('databaseChange', setDatabase);
|
|
80
|
+
});
|
|
81
|
+
return original.apply(this, arguments);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
_patchQuery(operation) {
|
|
85
|
+
return (originalMethod) => {
|
|
86
|
+
const thisPlugin = this;
|
|
87
|
+
this._diag.debug(`TediousInstrumentation: patched Connection.prototype.${operation}`);
|
|
88
|
+
function patchedMethod(request) {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
90
|
+
if (!(request instanceof events_1.EventEmitter)) {
|
|
91
|
+
thisPlugin._diag.warn(`Unexpected invocation of patched ${operation} method. Span not recorded`);
|
|
92
|
+
return originalMethod.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
let procCount = 0;
|
|
95
|
+
let statementCount = 0;
|
|
96
|
+
const incrementStatementCount = () => statementCount++;
|
|
97
|
+
const incrementProcCount = () => procCount++;
|
|
98
|
+
const databaseName = this[CURRENT_DATABASE];
|
|
99
|
+
const sql = (request => {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
// Required for <11.0.9
|
|
102
|
+
if (request.sqlTextOrProcedure === 'sp_prepare' &&
|
|
103
|
+
((_b = (_a = request.parametersByName) === null || _a === void 0 ? void 0 : _a.stmt) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
104
|
+
return request.parametersByName.stmt.value;
|
|
105
|
+
}
|
|
106
|
+
return request.sqlTextOrProcedure;
|
|
107
|
+
})(request);
|
|
108
|
+
const span = thisPlugin.tracer.startSpan(utils_1.getSpanName(operation, databaseName, sql, request.table), {
|
|
109
|
+
kind: api.SpanKind.CLIENT,
|
|
110
|
+
attributes: {
|
|
111
|
+
[semantic_conventions_1.SemanticAttributes.DB_SYSTEM]: semantic_conventions_1.DbSystemValues.MSSQL,
|
|
112
|
+
[semantic_conventions_1.SemanticAttributes.DB_NAME]: databaseName,
|
|
113
|
+
[semantic_conventions_1.SemanticAttributes.NET_PEER_PORT]: (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.port,
|
|
114
|
+
[semantic_conventions_1.SemanticAttributes.NET_PEER_NAME]: (_c = this.config) === null || _c === void 0 ? void 0 : _c.server,
|
|
115
|
+
// >=4 uses `authentication` object, older versions just userName and password pair
|
|
116
|
+
[semantic_conventions_1.SemanticAttributes.DB_USER]: (_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.userName) !== null && _e !== void 0 ? _e : (_h = (_g = (_f = this.config) === null || _f === void 0 ? void 0 : _f.authentication) === null || _g === void 0 ? void 0 : _g.options) === null || _h === void 0 ? void 0 : _h.userName,
|
|
117
|
+
[semantic_conventions_1.SemanticAttributes.DB_STATEMENT]: sql,
|
|
118
|
+
[semantic_conventions_1.SemanticAttributes.DB_SQL_TABLE]: request.table,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const endSpan = utils_1.once((err) => {
|
|
122
|
+
request.removeListener('done', incrementStatementCount);
|
|
123
|
+
request.removeListener('doneInProc', incrementStatementCount);
|
|
124
|
+
request.removeListener('doneProc', incrementProcCount);
|
|
125
|
+
request.removeListener('error', endSpan);
|
|
126
|
+
this.removeListener('end', endSpan);
|
|
127
|
+
span.setAttribute('tedious.procedure_count', procCount);
|
|
128
|
+
span.setAttribute('tedious.statement_count', statementCount);
|
|
129
|
+
if (err) {
|
|
130
|
+
span.setStatus({
|
|
131
|
+
code: api.SpanStatusCode.ERROR,
|
|
132
|
+
message: err.message,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
span.end();
|
|
136
|
+
});
|
|
137
|
+
request.on('done', incrementStatementCount);
|
|
138
|
+
request.on('doneInProc', incrementStatementCount);
|
|
139
|
+
request.on('doneProc', incrementProcCount);
|
|
140
|
+
request.once('error', endSpan);
|
|
141
|
+
this.on('end', endSpan);
|
|
142
|
+
if (typeof request.callback === 'function') {
|
|
143
|
+
thisPlugin._wrap(request, 'callback', thisPlugin._patchCallbackQuery(endSpan));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
thisPlugin._diag.error('Expected request.callback to be a function');
|
|
147
|
+
}
|
|
148
|
+
return api.context.with(api.trace.setSpan(api.context.active(), span), originalMethod, this, ...arguments);
|
|
149
|
+
}
|
|
150
|
+
Object.defineProperty(patchedMethod, 'length', {
|
|
151
|
+
value: originalMethod.length,
|
|
152
|
+
writable: false,
|
|
153
|
+
});
|
|
154
|
+
return patchedMethod;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
_patchCallbackQuery(endSpan) {
|
|
158
|
+
return (originalCallback) => {
|
|
159
|
+
return function (err, rowCount, rows) {
|
|
160
|
+
endSpan(err);
|
|
161
|
+
return originalCallback.apply(this, arguments);
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.TediousInstrumentation = TediousInstrumentation;
|
|
167
|
+
TediousInstrumentation.COMPONENT = 'tedious';
|
|
168
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0CAA0C;AAC1C,mCAAsC;AACtC,oEAIwC;AACxC,8EAG6C;AAG7C,mCAA4C;AAC5C,uCAAoC;AAEpC,MAAM,gBAAgB,GAAG,MAAM,CAC7B,wDAAwD,CACzD,CAAC;AACF,MAAM,eAAe,GAAG;IACtB,eAAe;IACf,SAAS;IACT,cAAc;IACd,cAAc;IACd,SAAS;IACT,SAAS;CACV,CAAC;AAcF,SAAS,WAAW,CAAyB,YAAoB;IAC/D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE;QAC5C,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;AACL,CAAC;AAED,MAAa,sBAAuB,SAAQ,qCAE3C;IAGC,YAAY,MAAqC;QAC/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AK,CAAC,4CAA4C,CAAC,CAAC;iBACtE;gBAED,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CACrB,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,EAC7C,cAAc,EACd,IAAI,EACJ,GAAG,SAAS,CACb,CAAC;YACJ,CAAC;YAED,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,QAAQ,EAAE;gBAC7C,KAAK,EAAE,cAAc,CAAC,MAAM;gBAC5B,QAAQ,EAAE,KAAK;aAChB,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,OAAiB;QAC3C,OAAO,CAAC,gBAA0B,EAAE,EAAE;YACpC,OAAO,UAEL,GAA6B,EAC7B,QAAiB,EACjB,IAAU;gBAEV,OAAO,CAAC,GAAG,CAAC,CAAC;gBACb,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACjD,CAAC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;;AA/KH,wDAgLC;AA7KiB,gCAAS,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The span name SHOULD be set to a low cardinality value
|
|
3
|
+
* representing the statement executed on the database.
|
|
4
|
+
*
|
|
5
|
+
* @returns Operation executed on Tedious Connection. Does not map to SQL statement in any way.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSpanName(operation: string, db: string | undefined, sql: string | undefined, bulkLoadTable: string | undefined): string;
|
|
8
|
+
export declare const once: (fn: Function) => (...args: unknown[]) => any;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
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.once = exports.getSpanName = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* The span name SHOULD be set to a low cardinality value
|
|
21
|
+
* representing the statement executed on the database.
|
|
22
|
+
*
|
|
23
|
+
* @returns Operation executed on Tedious Connection. Does not map to SQL statement in any way.
|
|
24
|
+
*/
|
|
25
|
+
function getSpanName(operation, db, sql, bulkLoadTable) {
|
|
26
|
+
if (operation === 'execBulkLoad' && bulkLoadTable && db) {
|
|
27
|
+
return `${operation} ${bulkLoadTable} ${db}`;
|
|
28
|
+
}
|
|
29
|
+
if (operation === 'callProcedure') {
|
|
30
|
+
// `sql` refers to procedure name with `callProcedure`
|
|
31
|
+
if (db) {
|
|
32
|
+
return `${operation} ${sql} ${db}`;
|
|
33
|
+
}
|
|
34
|
+
return `${operation} ${sql}`;
|
|
35
|
+
}
|
|
36
|
+
// do not use `sql` in general case because of high-cardinality
|
|
37
|
+
if (db) {
|
|
38
|
+
return `${operation} ${db}`;
|
|
39
|
+
}
|
|
40
|
+
return `${operation}`;
|
|
41
|
+
}
|
|
42
|
+
exports.getSpanName = getSpanName;
|
|
43
|
+
const once = (fn) => {
|
|
44
|
+
let called = false;
|
|
45
|
+
return (...args) => {
|
|
46
|
+
if (called)
|
|
47
|
+
return;
|
|
48
|
+
called = true;
|
|
49
|
+
return fn(...args);
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.once = once;
|
|
53
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,SAAiB,EACjB,EAAsB,EACtB,GAAuB,EACvB,aAAiC;IAEjC,IAAI,SAAS,KAAK,cAAc,IAAI,aAAa,IAAI,EAAE,EAAE;QACvD,OAAO,GAAG,SAAS,IAAI,aAAa,IAAI,EAAE,EAAE,CAAC;KAC9C;IACD,IAAI,SAAS,KAAK,eAAe,EAAE;QACjC,sDAAsD;QACtD,IAAI,EAAE,EAAE;YACN,OAAO,GAAG,SAAS,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;SACpC;QACD,OAAO,GAAG,SAAS,IAAI,GAAG,EAAE,CAAC;KAC9B;IACD,+DAA+D;IAC/D,IAAI,EAAE,EAAE;QACN,OAAO,GAAG,SAAS,IAAI,EAAE,EAAE,CAAC;KAC7B;IACD,OAAO,GAAG,SAAS,EAAE,CAAC;AACxB,CAAC;AArBD,kCAqBC;AAEM,MAAM,IAAI,GAAG,CAAC,EAAY,EAAE,EAAE;IACnC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,IAAI,QAOf"}
|
|
@@ -0,0 +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.1.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,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentelemetry/instrumentation-tedious",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenTelemetry instrumentation for `tedious`",
|
|
5
|
+
"main": "build/src/index.js",
|
|
6
|
+
"types": "build/src/index.d.ts",
|
|
7
|
+
"repository": "open-telemetry/opentelemetry-js-contrib",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"clean": "rimraf build/*",
|
|
10
|
+
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
|
|
11
|
+
"compile": "npm run version:update && tsc -p .",
|
|
12
|
+
"lint:fix": "eslint . --ext .ts --fix",
|
|
13
|
+
"lint": "eslint . --ext .ts",
|
|
14
|
+
"precompile": "tsc --version && lerna run version --scope @opentelemetry/instrumentation-tedious --include-dependencies",
|
|
15
|
+
"prewatch": "npm run precompile",
|
|
16
|
+
"prepare": "npm run compile",
|
|
17
|
+
"tdd": "npm run test -- --watch-extensions ts --watch",
|
|
18
|
+
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
|
|
19
|
+
"test-all-versions": "tav",
|
|
20
|
+
"version:update": "node ../../../scripts/version-update.js"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"instrumentation",
|
|
24
|
+
"microsoft",
|
|
25
|
+
"mssql",
|
|
26
|
+
"nodejs",
|
|
27
|
+
"opentelemetry",
|
|
28
|
+
"profiling",
|
|
29
|
+
"sql server",
|
|
30
|
+
"tds",
|
|
31
|
+
"tedious",
|
|
32
|
+
"tracing"
|
|
33
|
+
],
|
|
34
|
+
"author": "OpenTelemetry Authors",
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=8.5.0"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"build/src/**/*.js",
|
|
41
|
+
"build/src/**/*.js.map",
|
|
42
|
+
"build/src/**/*.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"@opentelemetry/api": "^1.0.2"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@opentelemetry/api": "1.0.2",
|
|
52
|
+
"@opentelemetry/context-async-hooks": "1.0.1",
|
|
53
|
+
"@opentelemetry/contrib-test-utils": "^0.29.0",
|
|
54
|
+
"@opentelemetry/sdk-trace-base": "1.0.1",
|
|
55
|
+
"@types/mocha": "7.0.2",
|
|
56
|
+
"@types/node": "14.17.9",
|
|
57
|
+
"codecov": "3.8.3",
|
|
58
|
+
"gts": "3.1.0",
|
|
59
|
+
"mocha": "^7.2.0",
|
|
60
|
+
"nyc": "15.1.0",
|
|
61
|
+
"rimraf": "3.0.2",
|
|
62
|
+
"tedious": "^14.0.0",
|
|
63
|
+
"test-all-versions": "5.0.1",
|
|
64
|
+
"ts-mocha": "8.0.0",
|
|
65
|
+
"typescript": "4.3.5"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@opentelemetry/instrumentation": "^0.27.0",
|
|
69
|
+
"@opentelemetry/semantic-conventions": "^1.0.0",
|
|
70
|
+
"@types/tedious": "^4.0.6"
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "edfc04cbe3e7faaa365724ddc26bf702b68cc008"
|
|
73
|
+
}
|