@opentelemetry/plugin-react-load 0.25.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/LICENSE +201 -0
- package/README.md +55 -0
- package/build/esm/BaseOpenTelemetryComponent.d.ts +106 -0
- package/build/esm/BaseOpenTelemetryComponent.d.ts.map +1 -0
- package/build/esm/BaseOpenTelemetryComponent.js +438 -0
- package/build/esm/BaseOpenTelemetryComponent.js.map +1 -0
- package/build/esm/enums/AttributeNames.d.ts +10 -0
- package/build/esm/enums/AttributeNames.d.ts.map +1 -0
- package/build/esm/enums/AttributeNames.js +26 -0
- package/build/esm/enums/AttributeNames.js.map +1 -0
- package/build/esm/index.d.ts +2 -0
- package/build/esm/index.d.ts.map +1 -0
- package/build/esm/index.js +17 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/types.d.ts +10 -0
- package/build/esm/types.d.ts.map +1 -0
- package/build/esm/types.js +17 -0
- package/build/esm/types.js.map +1 -0
- package/build/esm/version.d.ts +2 -0
- package/build/esm/version.d.ts.map +1 -0
- package/build/esm/version.js +18 -0
- package/build/esm/version.js.map +1 -0
- package/build/src/BaseOpenTelemetryComponent.d.ts +106 -0
- package/build/src/BaseOpenTelemetryComponent.d.ts.map +1 -0
- package/build/src/BaseOpenTelemetryComponent.js +374 -0
- package/build/src/BaseOpenTelemetryComponent.js.map +1 -0
- package/build/src/enums/AttributeNames.d.ts +10 -0
- package/build/src/enums/AttributeNames.d.ts.map +1 -0
- package/build/src/enums/AttributeNames.js +29 -0
- package/build/src/enums/AttributeNames.js.map +1 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +29 -0
- package/build/src/index.js.map +1 -0
- package/build/src/types.d.ts +10 -0
- package/build/src/types.d.ts.map +1 -0
- package/build/src/types.js +18 -0
- package/build/src/types.js.map +1 -0
- package/build/src/version.d.ts +2 -0
- package/build/src/version.d.ts.map +1 -0
- package/build/src/version.js +21 -0
- package/build/src/version.js.map +1 -0
- package/package.json +97 -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,55 @@
|
|
|
1
|
+
# OpenTelemetry Plugin React Load
|
|
2
|
+
|
|
3
|
+
[![NPM Published Version][npm-img]][npm-url]
|
|
4
|
+
[![dependencies][dependencies-image]][dependencies-url]
|
|
5
|
+
[![devDependencies][devDependencies-image]][devDependencies-url]
|
|
6
|
+
[![peerDependencies][peerDependencies-image]][peerDependencies-url]
|
|
7
|
+
[![Apache License][license-image]][license-image]
|
|
8
|
+
|
|
9
|
+
This module provides *automated instrumentation for React lifecycles* for Web applications.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save @opentelemetry/plugin-react-load
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { BaseOpenTelemetryComponent } from '@opentelemetry/plugin-react-load';
|
|
21
|
+
|
|
22
|
+
// Set once for the entire plugin
|
|
23
|
+
BaseOpenTelemetryComponent.setLogger(logger);
|
|
24
|
+
BaseOpenTelemetryComponent.setTracer('name', 'version');
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
To instrument components, extend `BaseOpenTelemetryComponent`:
|
|
28
|
+
```js
|
|
29
|
+
import { BaseOpenTelemetryComponent } from '@opentelemetry/plugin-react-load';
|
|
30
|
+
|
|
31
|
+
export class Component1 extends BaseOpenTelemetryComponent { ... }
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
See [/examples/react-load](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/react-load) for a short example.
|
|
35
|
+
|
|
36
|
+
## Useful links
|
|
37
|
+
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/>
|
|
38
|
+
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js>
|
|
39
|
+
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Apache 2.0 - See [LICENSE][license-url] for more information.
|
|
44
|
+
|
|
45
|
+
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
|
|
46
|
+
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE
|
|
47
|
+
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
|
|
48
|
+
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load
|
|
49
|
+
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load
|
|
50
|
+
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load&type=dev
|
|
51
|
+
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load&type=dev
|
|
52
|
+
[peerDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-contrib.svg?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load&type=peer
|
|
53
|
+
[peerDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins%2Fweb%2Fopentelemetry-plugin-react-load&type=peer
|
|
54
|
+
[npm-url]: https://www.npmjs.com/package/@opentelemetry/plugin-react-load
|
|
55
|
+
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fplugin-react-load.svg
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as api from '@opentelemetry/api';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* This class is the base component for a React component with lifecycle instrumentation
|
|
5
|
+
*/
|
|
6
|
+
export declare class BaseOpenTelemetryComponent extends React.Component {
|
|
7
|
+
readonly component: string;
|
|
8
|
+
moduleName: string;
|
|
9
|
+
private _parentSpanMap;
|
|
10
|
+
private static _tracer;
|
|
11
|
+
private static _logger;
|
|
12
|
+
/**
|
|
13
|
+
* @param props Props of the React component
|
|
14
|
+
*/
|
|
15
|
+
constructor(props: Readonly<any>);
|
|
16
|
+
/**
|
|
17
|
+
* Sets the tracer for all components being instrumented
|
|
18
|
+
* @param name Name of tracer
|
|
19
|
+
* @param version Version of tracer, this is optional. When not provided it will use the latest.
|
|
20
|
+
*/
|
|
21
|
+
static setTracer(name: string, version?: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the logger for all components being instrumented
|
|
24
|
+
* @param logger
|
|
25
|
+
*/
|
|
26
|
+
static setLogger(logger: api.DiagLogger): void;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new span as a child of the current parent span.
|
|
29
|
+
* If parent span is undefined, just the child is created.
|
|
30
|
+
* @param react React component currently being instrumented
|
|
31
|
+
* @param name Name of span
|
|
32
|
+
* @param parentSpan parent span
|
|
33
|
+
*/
|
|
34
|
+
private _createSpanWithParent;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new span
|
|
37
|
+
* @param react React component currently being instrumented
|
|
38
|
+
* @param name Name of span
|
|
39
|
+
*/
|
|
40
|
+
private _createSpan;
|
|
41
|
+
/**
|
|
42
|
+
* Provides instrumentation for a function
|
|
43
|
+
* @param react React component currently instrumenting.
|
|
44
|
+
* @param spanName Name to set the span of the instrumented function to.
|
|
45
|
+
* @param original Original function currently being wrapped.
|
|
46
|
+
* @parentName Name to set parent span to on error.
|
|
47
|
+
*/
|
|
48
|
+
private _instrumentFunction;
|
|
49
|
+
/**
|
|
50
|
+
* Ends the current parent span.
|
|
51
|
+
* @param react React component parent span belongs to.
|
|
52
|
+
*/
|
|
53
|
+
private _endParentSpan;
|
|
54
|
+
/**
|
|
55
|
+
* Returns attributes object for spans
|
|
56
|
+
* @param react React component currently being instrumented
|
|
57
|
+
**/
|
|
58
|
+
private _getAttributes;
|
|
59
|
+
/**
|
|
60
|
+
* This function returns a parent span. If the parent doesn't
|
|
61
|
+
* exist, the function creates one
|
|
62
|
+
* @param react React component parent span belongs to.
|
|
63
|
+
*/
|
|
64
|
+
private _getParentSpan;
|
|
65
|
+
/**
|
|
66
|
+
* Patches the render lifecycle method
|
|
67
|
+
*/
|
|
68
|
+
private _patchRender;
|
|
69
|
+
/**
|
|
70
|
+
* Patches the componentDidMount lifecycle method
|
|
71
|
+
*/
|
|
72
|
+
private _patchComponentDidMount;
|
|
73
|
+
/**
|
|
74
|
+
* Patches the setState function
|
|
75
|
+
*/
|
|
76
|
+
private _patchSetState;
|
|
77
|
+
/**
|
|
78
|
+
* Patches the forceUpdate function
|
|
79
|
+
*/
|
|
80
|
+
private _patchForceUpdate;
|
|
81
|
+
/**
|
|
82
|
+
* Patches the shouldComponentUpdate lifecycle method
|
|
83
|
+
*/
|
|
84
|
+
private _patchShouldComponentUpdate;
|
|
85
|
+
/**
|
|
86
|
+
* Patches the shouldComponentUpdate lifecycle method
|
|
87
|
+
*/
|
|
88
|
+
private _patchGetSnapshotBeforeUpdate;
|
|
89
|
+
/**
|
|
90
|
+
* Patches the componentDidUpdate lifecycle method
|
|
91
|
+
*/
|
|
92
|
+
private _patchComponentDidUpdate;
|
|
93
|
+
/**
|
|
94
|
+
* Patches the componentWillUnmount lifecycle method
|
|
95
|
+
*/
|
|
96
|
+
private _patchComponentWillUnmount;
|
|
97
|
+
/**
|
|
98
|
+
* patch function which wraps all the lifecycle methods
|
|
99
|
+
*/
|
|
100
|
+
patch(): void;
|
|
101
|
+
/**
|
|
102
|
+
* unpatch function to unwrap all the lifecycle methods
|
|
103
|
+
*/
|
|
104
|
+
unpatch(): void;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=BaseOpenTelemetryComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseOpenTelemetryComponent.d.ts","sourceRoot":"","sources":["../../src/BaseOpenTelemetryComponent.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;AAI1C,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAa/B;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,KAAK,CAAC,SAAS;IAC7D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAgB;IAC1C,UAAU,SAAkB;IAC5B,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,MAAM,CAAC,OAAO,CAAa;IACnC,OAAO,CAAC,MAAM,CAAC,OAAO,CAA4B;IAElD;;OAEG;gBACS,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;IAMhC;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI;IAOtD;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,GAAG,IAAI;IAK9C;;;;;;OAMG;IACH,OAAO,CAAC,qBAAqB;IAgB7B;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAMnB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IA2B3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAQtB;;;QAGI;IACJ,OAAO,CAAC,cAAc;IActB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IA4BpB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IA0B/B;;OAEG;IACH,OAAO,CAAC,cAAc;IAoBtB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAiCnC;;OAEG;IACH,OAAO,CAAC,6BAA6B;IA0BrC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA4BhC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;OAEG;IACI,KAAK,IAAI,IAAI;IA8GpB;;OAEG;IACI,OAAO,IAAI,IAAI;CAqBvB"}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright The OpenTelemetry Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var __extends = (this && this.__extends) || (function () {
|
|
17
|
+
var extendStatics = function (d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf ||
|
|
19
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
+
return extendStatics(d, b);
|
|
22
|
+
};
|
|
23
|
+
return function (d, b) {
|
|
24
|
+
if (typeof b !== "function" && b !== null)
|
|
25
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
+
extendStatics(d, b);
|
|
27
|
+
function __() { this.constructor = d; }
|
|
28
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
|
+
};
|
|
30
|
+
})();
|
|
31
|
+
import * as api from '@opentelemetry/api';
|
|
32
|
+
import { isWrapped } from '@opentelemetry/core';
|
|
33
|
+
import * as shimmer from 'shimmer';
|
|
34
|
+
import { AttributeNames } from './enums/AttributeNames';
|
|
35
|
+
import * as React from 'react';
|
|
36
|
+
import { VERSION } from './version';
|
|
37
|
+
/**
|
|
38
|
+
* This class is the base component for a React component with lifecycle instrumentation
|
|
39
|
+
*/
|
|
40
|
+
var BaseOpenTelemetryComponent = /** @class */ (function (_super) {
|
|
41
|
+
__extends(BaseOpenTelemetryComponent, _super);
|
|
42
|
+
/**
|
|
43
|
+
* @param props Props of the React component
|
|
44
|
+
*/
|
|
45
|
+
function BaseOpenTelemetryComponent(props) {
|
|
46
|
+
var _this = _super.call(this, props) || this;
|
|
47
|
+
_this.component = 'react-load';
|
|
48
|
+
_this.moduleName = _this.component;
|
|
49
|
+
_this._parentSpanMap = new WeakMap();
|
|
50
|
+
_this.patch();
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets the tracer for all components being instrumented
|
|
55
|
+
* @param name Name of tracer
|
|
56
|
+
* @param version Version of tracer, this is optional. When not provided it will use the latest.
|
|
57
|
+
*/
|
|
58
|
+
BaseOpenTelemetryComponent.setTracer = function (name, version) {
|
|
59
|
+
BaseOpenTelemetryComponent._tracer = api.trace.getTracer(name, version ? version : VERSION);
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Sets the logger for all components being instrumented
|
|
63
|
+
* @param logger
|
|
64
|
+
*/
|
|
65
|
+
BaseOpenTelemetryComponent.setLogger = function (logger) {
|
|
66
|
+
api.diag.setLogger(logger);
|
|
67
|
+
BaseOpenTelemetryComponent._logger = logger;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new span as a child of the current parent span.
|
|
71
|
+
* If parent span is undefined, just the child is created.
|
|
72
|
+
* @param react React component currently being instrumented
|
|
73
|
+
* @param name Name of span
|
|
74
|
+
* @param parentSpan parent span
|
|
75
|
+
*/
|
|
76
|
+
BaseOpenTelemetryComponent.prototype._createSpanWithParent = function (react, name, parentSpan) {
|
|
77
|
+
return BaseOpenTelemetryComponent._tracer.startSpan(name, {
|
|
78
|
+
attributes: this._getAttributes(react),
|
|
79
|
+
}, parentSpan
|
|
80
|
+
? api.trace.setSpan(api.context.active(), parentSpan)
|
|
81
|
+
: undefined);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Creates a new span
|
|
85
|
+
* @param react React component currently being instrumented
|
|
86
|
+
* @param name Name of span
|
|
87
|
+
*/
|
|
88
|
+
BaseOpenTelemetryComponent.prototype._createSpan = function (react, name) {
|
|
89
|
+
return BaseOpenTelemetryComponent._tracer.startSpan(name, {
|
|
90
|
+
attributes: this._getAttributes(react),
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Provides instrumentation for a function
|
|
95
|
+
* @param react React component currently instrumenting.
|
|
96
|
+
* @param spanName Name to set the span of the instrumented function to.
|
|
97
|
+
* @param original Original function currently being wrapped.
|
|
98
|
+
* @parentName Name to set parent span to on error.
|
|
99
|
+
*/
|
|
100
|
+
BaseOpenTelemetryComponent.prototype._instrumentFunction = function (react, spanName, parent, original) {
|
|
101
|
+
var span = this._createSpanWithParent(react, spanName, parent);
|
|
102
|
+
var wasError = false;
|
|
103
|
+
try {
|
|
104
|
+
return api.context.with(api.trace.setSpan(api.context.active(), span), function () {
|
|
105
|
+
return original();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
span.setAttribute(AttributeNames.REACT_ERROR, err.stack);
|
|
110
|
+
wasError = true;
|
|
111
|
+
throw err;
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
span.end();
|
|
115
|
+
if (wasError) {
|
|
116
|
+
this._endParentSpan(react);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Ends the current parent span.
|
|
122
|
+
* @param react React component parent span belongs to.
|
|
123
|
+
*/
|
|
124
|
+
BaseOpenTelemetryComponent.prototype._endParentSpan = function (react) {
|
|
125
|
+
var parentSpan = this._parentSpanMap.get(react);
|
|
126
|
+
if (parentSpan) {
|
|
127
|
+
parentSpan.end();
|
|
128
|
+
this._parentSpanMap.delete(react);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Returns attributes object for spans
|
|
133
|
+
* @param react React component currently being instrumented
|
|
134
|
+
**/
|
|
135
|
+
BaseOpenTelemetryComponent.prototype._getAttributes = function (react) {
|
|
136
|
+
var _a;
|
|
137
|
+
var state;
|
|
138
|
+
try {
|
|
139
|
+
state = JSON.stringify(react.state);
|
|
140
|
+
}
|
|
141
|
+
catch (_b) {
|
|
142
|
+
state = '{"message": "state could not be turned into string"}';
|
|
143
|
+
}
|
|
144
|
+
return _a = {},
|
|
145
|
+
_a[AttributeNames.LOCATION_URL] = window.location.href,
|
|
146
|
+
_a[AttributeNames.REACT_NAME] = react.constructor.name,
|
|
147
|
+
_a[AttributeNames.REACT_STATE] = state,
|
|
148
|
+
_a;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* This function returns a parent span. If the parent doesn't
|
|
152
|
+
* exist, the function creates one
|
|
153
|
+
* @param react React component parent span belongs to.
|
|
154
|
+
*/
|
|
155
|
+
BaseOpenTelemetryComponent.prototype._getParentSpan = function (react, parentName) {
|
|
156
|
+
var parentSpan = this._parentSpanMap.get(react);
|
|
157
|
+
if (!parentSpan) {
|
|
158
|
+
var span = this._createSpan(react, parentName);
|
|
159
|
+
this._parentSpanMap.set(react, span);
|
|
160
|
+
}
|
|
161
|
+
return this._parentSpanMap.get(react);
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Patches the render lifecycle method
|
|
165
|
+
*/
|
|
166
|
+
BaseOpenTelemetryComponent.prototype._patchRender = function () {
|
|
167
|
+
var _this = this;
|
|
168
|
+
return function (original) {
|
|
169
|
+
var plugin = _this;
|
|
170
|
+
return function patchRender() {
|
|
171
|
+
var _this = this;
|
|
172
|
+
var args = [];
|
|
173
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
174
|
+
args[_i] = arguments[_i];
|
|
175
|
+
}
|
|
176
|
+
// Render is the first method in the mounting flow, if a parent span wasn't created already then we're in the mounting flow
|
|
177
|
+
var parentSpan;
|
|
178
|
+
if (!plugin._parentSpanMap.get(this)) {
|
|
179
|
+
parentSpan = plugin._getParentSpan(this, AttributeNames.MOUNTING_SPAN);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
183
|
+
}
|
|
184
|
+
return plugin._instrumentFunction(this, 'render', parentSpan, function () {
|
|
185
|
+
return original.apply(_this, args);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Patches the componentDidMount lifecycle method
|
|
192
|
+
*/
|
|
193
|
+
BaseOpenTelemetryComponent.prototype._patchComponentDidMount = function () {
|
|
194
|
+
var _this = this;
|
|
195
|
+
return function (original) {
|
|
196
|
+
var plugin = _this;
|
|
197
|
+
return function patchComponentDidMount() {
|
|
198
|
+
var _this = this;
|
|
199
|
+
var args = [];
|
|
200
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
201
|
+
args[_i] = arguments[_i];
|
|
202
|
+
}
|
|
203
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.MOUNTING_SPAN);
|
|
204
|
+
var apply = plugin._instrumentFunction(this, 'componentDidMount', parentSpan, function () {
|
|
205
|
+
return original.apply(_this, args);
|
|
206
|
+
});
|
|
207
|
+
plugin._endParentSpan(this);
|
|
208
|
+
return apply;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Patches the setState function
|
|
214
|
+
*/
|
|
215
|
+
BaseOpenTelemetryComponent.prototype._patchSetState = function () {
|
|
216
|
+
var _this = this;
|
|
217
|
+
return function (original) {
|
|
218
|
+
var plugin = _this;
|
|
219
|
+
return function patchSetState() {
|
|
220
|
+
var _this = this;
|
|
221
|
+
var args = [];
|
|
222
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
223
|
+
args[_i] = arguments[_i];
|
|
224
|
+
}
|
|
225
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
226
|
+
return plugin._instrumentFunction(this, 'setState()', parentSpan, function () {
|
|
227
|
+
return original.apply(_this, args);
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Patches the forceUpdate function
|
|
234
|
+
*/
|
|
235
|
+
BaseOpenTelemetryComponent.prototype._patchForceUpdate = function () {
|
|
236
|
+
var _this = this;
|
|
237
|
+
return function (original) {
|
|
238
|
+
var plugin = _this;
|
|
239
|
+
return function patchForceUpdate() {
|
|
240
|
+
var _this = this;
|
|
241
|
+
var args = [];
|
|
242
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
243
|
+
args[_i] = arguments[_i];
|
|
244
|
+
}
|
|
245
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
246
|
+
return plugin._instrumentFunction(this, 'forceUpdate()', parentSpan, function () {
|
|
247
|
+
return original.apply(_this, args);
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Patches the shouldComponentUpdate lifecycle method
|
|
254
|
+
*/
|
|
255
|
+
BaseOpenTelemetryComponent.prototype._patchShouldComponentUpdate = function () {
|
|
256
|
+
var _this = this;
|
|
257
|
+
return function (original) {
|
|
258
|
+
var plugin = _this;
|
|
259
|
+
return function patchShouldComponentUpdate() {
|
|
260
|
+
var _this = this;
|
|
261
|
+
var args = [];
|
|
262
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
263
|
+
args[_i] = arguments[_i];
|
|
264
|
+
}
|
|
265
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
266
|
+
var apply = plugin._instrumentFunction(this, 'shouldComponentUpdate', parentSpan, function () {
|
|
267
|
+
return original.apply(_this, args);
|
|
268
|
+
});
|
|
269
|
+
// if shouldComponentUpdate returns false, the component does not get
|
|
270
|
+
// updated and no other lifecycle methods get called
|
|
271
|
+
if (!apply) {
|
|
272
|
+
plugin._endParentSpan(this);
|
|
273
|
+
}
|
|
274
|
+
return apply;
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Patches the shouldComponentUpdate lifecycle method
|
|
280
|
+
*/
|
|
281
|
+
BaseOpenTelemetryComponent.prototype._patchGetSnapshotBeforeUpdate = function () {
|
|
282
|
+
var _this = this;
|
|
283
|
+
return function (original) {
|
|
284
|
+
var plugin = _this;
|
|
285
|
+
return function patchGetSnapshotBeforeUpdate() {
|
|
286
|
+
var _this = this;
|
|
287
|
+
var args = [];
|
|
288
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
289
|
+
args[_i] = arguments[_i];
|
|
290
|
+
}
|
|
291
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
292
|
+
return plugin._instrumentFunction(this, 'getSnapshotBeforeUpdate', parentSpan, function () {
|
|
293
|
+
return original.apply(_this, args);
|
|
294
|
+
});
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
/**
|
|
299
|
+
* Patches the componentDidUpdate lifecycle method
|
|
300
|
+
*/
|
|
301
|
+
BaseOpenTelemetryComponent.prototype._patchComponentDidUpdate = function () {
|
|
302
|
+
var _this = this;
|
|
303
|
+
return function (original) {
|
|
304
|
+
var plugin = _this;
|
|
305
|
+
return function patchComponentDidUpdate() {
|
|
306
|
+
var _this = this;
|
|
307
|
+
var args = [];
|
|
308
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
309
|
+
args[_i] = arguments[_i];
|
|
310
|
+
}
|
|
311
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UPDATING_SPAN);
|
|
312
|
+
var apply = plugin._instrumentFunction(this, 'componentDidUpdate', parentSpan, function () {
|
|
313
|
+
return original.apply(_this, args);
|
|
314
|
+
});
|
|
315
|
+
plugin._endParentSpan(this);
|
|
316
|
+
return apply;
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Patches the componentWillUnmount lifecycle method
|
|
322
|
+
*/
|
|
323
|
+
BaseOpenTelemetryComponent.prototype._patchComponentWillUnmount = function () {
|
|
324
|
+
var _this = this;
|
|
325
|
+
return function (original) {
|
|
326
|
+
var plugin = _this;
|
|
327
|
+
return function patchComponentWillUnmount() {
|
|
328
|
+
var _this = this;
|
|
329
|
+
var args = [];
|
|
330
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
331
|
+
args[_i] = arguments[_i];
|
|
332
|
+
}
|
|
333
|
+
var parentSpan = plugin._getParentSpan(this, AttributeNames.UNMOUNTING_SPAN);
|
|
334
|
+
var apply = plugin._instrumentFunction(this, 'componentWillUnmount', parentSpan, function () {
|
|
335
|
+
return original.apply(_this, args);
|
|
336
|
+
});
|
|
337
|
+
plugin._endParentSpan(this);
|
|
338
|
+
return apply;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
/**
|
|
343
|
+
* patch function which wraps all the lifecycle methods
|
|
344
|
+
*/
|
|
345
|
+
BaseOpenTelemetryComponent.prototype.patch = function () {
|
|
346
|
+
BaseOpenTelemetryComponent._logger.debug('applying patch to', this.moduleName, VERSION);
|
|
347
|
+
if (isWrapped(this.render)) {
|
|
348
|
+
shimmer.unwrap(this, 'render');
|
|
349
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method render');
|
|
350
|
+
}
|
|
351
|
+
if (isWrapped(this.componentDidMount)) {
|
|
352
|
+
shimmer.unwrap(this, 'componentDidMount');
|
|
353
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentDidMount');
|
|
354
|
+
}
|
|
355
|
+
if (isWrapped(this.shouldComponentUpdate)) {
|
|
356
|
+
shimmer.unwrap(this, 'shouldComponentUpdate');
|
|
357
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method shouldComponentUpdate');
|
|
358
|
+
}
|
|
359
|
+
if (isWrapped(this.getSnapshotBeforeUpdate)) {
|
|
360
|
+
shimmer.unwrap(this, 'getSnapshotBeforeUpdate');
|
|
361
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method getSnapshotBeforeUpdate');
|
|
362
|
+
}
|
|
363
|
+
if (isWrapped(this.setState)) {
|
|
364
|
+
shimmer.unwrap(this, 'setState');
|
|
365
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method setState');
|
|
366
|
+
}
|
|
367
|
+
if (isWrapped(this.forceUpdate)) {
|
|
368
|
+
shimmer.unwrap(this, 'forceUpdate');
|
|
369
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method forceUpdate');
|
|
370
|
+
}
|
|
371
|
+
if (isWrapped(this.componentDidUpdate)) {
|
|
372
|
+
shimmer.unwrap(this, 'componentDidUpdate');
|
|
373
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentDidUpdate');
|
|
374
|
+
}
|
|
375
|
+
if (isWrapped(this.componentWillUnmount)) {
|
|
376
|
+
shimmer.unwrap(this, 'componentWillUnmount');
|
|
377
|
+
BaseOpenTelemetryComponent._logger.warn('removing previous patch from method componentWillUnmount');
|
|
378
|
+
}
|
|
379
|
+
// Lifecycle methods must exist when patching, even if not defined in component
|
|
380
|
+
if (!this.render) {
|
|
381
|
+
this.render = function () {
|
|
382
|
+
return null;
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (!this.componentDidMount) {
|
|
386
|
+
this.componentDidMount = function () {
|
|
387
|
+
return;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
if (!this.shouldComponentUpdate) {
|
|
391
|
+
this.shouldComponentUpdate = function () {
|
|
392
|
+
return true;
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
if (!this.getSnapshotBeforeUpdate) {
|
|
396
|
+
this.getSnapshotBeforeUpdate = function () {
|
|
397
|
+
return null;
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
if (!this.componentDidUpdate) {
|
|
401
|
+
this.componentDidUpdate = function () {
|
|
402
|
+
return;
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (!this.componentWillUnmount) {
|
|
406
|
+
this.componentWillUnmount = function () {
|
|
407
|
+
return;
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
shimmer.wrap(this, 'render', this._patchRender());
|
|
411
|
+
shimmer.wrap(this, 'componentDidMount', this._patchComponentDidMount());
|
|
412
|
+
shimmer.wrap(this, 'setState', this._patchSetState());
|
|
413
|
+
shimmer.wrap(this, 'forceUpdate', this._patchForceUpdate());
|
|
414
|
+
shimmer.wrap(this, 'shouldComponentUpdate', this._patchShouldComponentUpdate());
|
|
415
|
+
shimmer.wrap(this, 'getSnapshotBeforeUpdate', this._patchGetSnapshotBeforeUpdate());
|
|
416
|
+
shimmer.wrap(this, 'componentDidUpdate', this._patchComponentDidUpdate());
|
|
417
|
+
shimmer.wrap(this, 'componentWillUnmount', this._patchComponentWillUnmount());
|
|
418
|
+
};
|
|
419
|
+
/**
|
|
420
|
+
* unpatch function to unwrap all the lifecycle methods
|
|
421
|
+
*/
|
|
422
|
+
BaseOpenTelemetryComponent.prototype.unpatch = function () {
|
|
423
|
+
BaseOpenTelemetryComponent._logger.debug('removing patch from', this.moduleName, VERSION);
|
|
424
|
+
shimmer.unwrap(this, 'render');
|
|
425
|
+
shimmer.unwrap(this, 'componentDidMount');
|
|
426
|
+
shimmer.unwrap(this, 'setState');
|
|
427
|
+
shimmer.unwrap(this, 'forceUpdate');
|
|
428
|
+
shimmer.unwrap(this, 'shouldComponentUpdate');
|
|
429
|
+
shimmer.unwrap(this, 'getSnapshotBeforeUpdate');
|
|
430
|
+
shimmer.unwrap(this, 'componentDidUpdate');
|
|
431
|
+
shimmer.unwrap(this, 'componentWillUnmount');
|
|
432
|
+
this._parentSpanMap = new WeakMap();
|
|
433
|
+
};
|
|
434
|
+
BaseOpenTelemetryComponent._logger = api.diag;
|
|
435
|
+
return BaseOpenTelemetryComponent;
|
|
436
|
+
}(React.Component));
|
|
437
|
+
export { BaseOpenTelemetryComponent };
|
|
438
|
+
//# sourceMappingURL=BaseOpenTelemetryComponent.js.map
|