@opentelemetry/instrumentation-xml-http-request 0.200.0 → 0.201.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -19
- package/build/esm/semconv.d.ts +93 -0
- package/build/esm/semconv.js +113 -0
- package/build/esm/semconv.js.map +1 -0
- package/build/esm/utils.d.ts +7 -0
- package/build/esm/utils.js +56 -0
- package/build/esm/utils.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/xhr.d.ts +3 -0
- package/build/esm/xhr.js +84 -25
- package/build/esm/xhr.js.map +1 -1
- package/build/esnext/semconv.d.ts +93 -0
- package/build/esnext/semconv.js +113 -0
- package/build/esnext/semconv.js.map +1 -0
- package/build/esnext/utils.d.ts +7 -0
- package/build/esnext/utils.js +56 -0
- package/build/esnext/utils.js.map +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/esnext/xhr.d.ts +3 -0
- package/build/esnext/xhr.js +84 -25
- package/build/esnext/xhr.js.map +1 -1
- package/build/src/semconv.d.ts +93 -0
- package/build/src/semconv.js +116 -0
- package/build/src/semconv.js.map +1 -0
- package/build/src/utils.d.ts +7 -0
- package/build/src/utils.js +59 -1
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/build/src/xhr.d.ts +3 -0
- package/build/src/xhr.js +82 -23
- package/build/src/xhr.js.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
[![NPM Published Version][npm-img]][npm-url]
|
|
4
4
|
[![Apache License][license-image]][license-image]
|
|
5
5
|
|
|
6
|
-
**Note: This is an experimental package
|
|
6
|
+
**Note: This is an experimental package. New releases may include breaking changes.**
|
|
7
7
|
|
|
8
|
-
This module provides auto instrumentation for web using XMLHttpRequest
|
|
8
|
+
This module provides auto instrumentation for web using XMLHttpRequest.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -62,34 +62,48 @@ xmlHttpRequestInstrumentation.setTracerProvider(providerWithZone);
|
|
|
62
62
|
const req = new XMLHttpRequest();
|
|
63
63
|
req.open('GET', 'http://localhost:8090/xml-http-request.js', true);
|
|
64
64
|
req.send();
|
|
65
|
-
|
|
66
65
|
```
|
|
67
66
|
|
|
68
67
|
### XHR Instrumentation options
|
|
69
68
|
|
|
70
69
|
XHR instrumentation plugin has few options available to choose from. You can set the following:
|
|
71
70
|
|
|
72
|
-
| Options
|
|
73
|
-
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
71
|
+
| Options | Type | Description |
|
|
72
|
+
| ----------------------------- | ---------------------------- | ----------- |
|
|
73
|
+
| `applyCustomAttributesOnSpan` | `XHRCustomAttributeFunction` | Function for adding custom attributes |
|
|
74
|
+
| `ignoreNetworkEvents` | boolean | Disable network events being added as span events (network events are added by default) |
|
|
75
|
+
| `measureRequestSize` | boolean | Measure outgoing request length (outgoing request length is not measured by default) |
|
|
76
|
+
| `semconvStabilityOptIn` | string | A comma-separated string of tokens as described for `OTEL_SEMCONV_STABILITY_OPT_IN` in the [HTTP semantic convention stability migration](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md) guide. See the "Semantic Conventions" section below. |
|
|
77
77
|
|
|
78
78
|
## Semantic Conventions
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Up to and including v0.200.0, `instrumentation-xml-http-request` generates telemetry using [Semantic Conventions v1.7.0](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.7.0/semantic_conventions/README.md).
|
|
81
|
+
|
|
82
|
+
HTTP semantic conventions (semconv) were stabilized in semconv v1.23.0, and a [migration process](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md#http-semantic-convention-stability-migration) was defined. `instrumentation-xml-http-request` versions 0.201.0 and later include support for migrating to stable HTTP semantic conventions, as described below. The intent is to provide an approximate 6 month time window for users of this instrumentation to migrate to the new HTTP semconv, after which a new minor version will change to use the *new* semconv by default and drop support for the old semconv. See the [HTTP semconv migration plan for OpenTelemetry JS instrumentations](https://github.com/open-telemetry/opentelemetry-js/issues/5646).
|
|
83
|
+
|
|
84
|
+
To select which semconv version(s) is emitted from this instrumentation, use the `semconvStabilityOptIn` configuration option. This option works [as described for `OTEL_SEMCONV_STABILITY_OPT_IN`](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/non-normative/http-migration.md):
|
|
85
|
+
|
|
86
|
+
- `http`: emit the new (stable) v1.23.0 semantics
|
|
87
|
+
- `http/dup`: emit **both** the old v1.7.0 and the new (stable) v1.23.0 semantics
|
|
88
|
+
- By default, if `semconvStabilityOptIn` includes neither of the above tokens, the old v1.7.0 semconv is used.
|
|
89
|
+
|
|
90
|
+
**Span status:** When the stable semconv is selected, the [span status](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#status) is set to ERROR when the response status code is `>=400` or when the response fails with an 'error' or 'timeout' XHR event. When just the old semconv is select, the span status is not set.
|
|
81
91
|
|
|
82
|
-
|
|
92
|
+
**Span attributes:**
|
|
83
93
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
| `http.
|
|
87
|
-
| `http.
|
|
88
|
-
| `http.
|
|
89
|
-
| `http.
|
|
90
|
-
| `http.
|
|
91
|
-
| `http.
|
|
92
|
-
| `http.
|
|
94
|
+
| v1.7.0 semconv | v1.23.0 semconv | Notes |
|
|
95
|
+
| ---------------------- | ---------------------------------- | ----- |
|
|
96
|
+
| `http.method` | `http.request.method` | HTTP request method. With v1.23.0 semconv [`http.request.method_original` may also be included](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#common-attributes). |
|
|
97
|
+
| `http.url` | `url.full` | Full HTTP request URL |
|
|
98
|
+
| `http.host` | `server.address` and `server.port` | The hostname and port of the request URL |
|
|
99
|
+
| `http.status_code` | `http.response.status_code` | HTTP response status code |
|
|
100
|
+
| `http.request_content_length_uncompressed` | `http.request.body.size` | This is only added if `measureRequestSize` is `true`. |
|
|
101
|
+
| `http.response_content_length_uncompressed` | (not included) | Stable HTTP semconv would use `http.response.body.size`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |
|
|
102
|
+
| `http.response_content_length` | (not included) | Stable HTTP semconv would use `http.response.header.<key>`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |
|
|
103
|
+
| (no equivalent) | `error.type` | The response status (as a string), if the response status was `>=400`, or one of these possible request errors: 'timeout' and 'error'.|
|
|
104
|
+
| `http.user_agent` | (not included) | Stable HTTP semconv would use `user_agent.original`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |
|
|
105
|
+
| `http.scheme` | (not included) | Stable HTTP semconv would use `url.scheme`, but this is an [`Opt-In` attribute](https://github.com/open-telemetry/semantic-conventions/blob/v1.23.1/docs/http/http-spans.md#http-client), so would require adding a configuration option to this instrumentation to enable. |
|
|
106
|
+
| `http.status_text` | (not included) | This is no longer a documented semantic conventions attribute. |
|
|
93
107
|
|
|
94
108
|
## Example Screenshots
|
|
95
109
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated, use one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.
|
|
3
|
+
*
|
|
4
|
+
* @example www.example.org
|
|
5
|
+
*
|
|
6
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
7
|
+
*
|
|
8
|
+
* @deprecated Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ATTR_HTTP_HOST: "http.host";
|
|
11
|
+
/**
|
|
12
|
+
* Deprecated, use `http.request.method` instead.
|
|
13
|
+
*
|
|
14
|
+
* @example GET
|
|
15
|
+
* @example POST
|
|
16
|
+
* @example HEAD
|
|
17
|
+
*
|
|
18
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Replaced by `http.request.method`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ATTR_HTTP_METHOD: "http.method";
|
|
23
|
+
/**
|
|
24
|
+
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
|
|
25
|
+
*
|
|
26
|
+
* @example 3495
|
|
27
|
+
*
|
|
28
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const ATTR_HTTP_REQUEST_BODY_SIZE: "http.request.body.size";
|
|
31
|
+
/**
|
|
32
|
+
* Deprecated, use `http.request.body.size` instead.
|
|
33
|
+
*
|
|
34
|
+
* @example 5493
|
|
35
|
+
*
|
|
36
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Replaced by `http.request.body.size`.
|
|
39
|
+
*/
|
|
40
|
+
export declare const ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED: "http.request_content_length_uncompressed";
|
|
41
|
+
/**
|
|
42
|
+
* Deprecated, use `http.response.header.<key>` instead.
|
|
43
|
+
*
|
|
44
|
+
* @example 3495
|
|
45
|
+
*
|
|
46
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
47
|
+
*
|
|
48
|
+
* @deprecated Replaced by `http.response.header.<key>`.
|
|
49
|
+
*/
|
|
50
|
+
export declare const ATTR_HTTP_RESPONSE_CONTENT_LENGTH: "http.response_content_length";
|
|
51
|
+
/**
|
|
52
|
+
* Deprecated, use `url.scheme` instead.
|
|
53
|
+
*
|
|
54
|
+
* @example http
|
|
55
|
+
* @example https
|
|
56
|
+
*
|
|
57
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
58
|
+
*
|
|
59
|
+
* @deprecated Replaced by `url.scheme` instead.
|
|
60
|
+
*/
|
|
61
|
+
export declare const ATTR_HTTP_SCHEME: "http.scheme";
|
|
62
|
+
/**
|
|
63
|
+
* Deprecated, use `http.response.status_code` instead.
|
|
64
|
+
*
|
|
65
|
+
* @example 200
|
|
66
|
+
*
|
|
67
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
68
|
+
*
|
|
69
|
+
* @deprecated Replaced by `http.response.status_code`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const ATTR_HTTP_STATUS_CODE: "http.status_code";
|
|
72
|
+
/**
|
|
73
|
+
* Deprecated, use `url.full` instead.
|
|
74
|
+
*
|
|
75
|
+
* @example https://www.foo.bar/search?q=OpenTelemetry#SemConv
|
|
76
|
+
*
|
|
77
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Replaced by `url.full`.
|
|
80
|
+
*/
|
|
81
|
+
export declare const ATTR_HTTP_URL: "http.url";
|
|
82
|
+
/**
|
|
83
|
+
* Deprecated, use `user_agent.original` instead.
|
|
84
|
+
*
|
|
85
|
+
* @example CERN-LineMode/2.15 libwww/2.17b3
|
|
86
|
+
* @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1
|
|
87
|
+
*
|
|
88
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
89
|
+
*
|
|
90
|
+
* @deprecated Replaced by `user_agent.original`.
|
|
91
|
+
*/
|
|
92
|
+
export declare const ATTR_HTTP_USER_AGENT: "http.user_agent";
|
|
93
|
+
//# sourceMappingURL=semconv.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
/*
|
|
17
|
+
* This file contains a copy of unstable semantic convention definitions
|
|
18
|
+
* used by this package.
|
|
19
|
+
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Deprecated, use one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.
|
|
23
|
+
*
|
|
24
|
+
* @example www.example.org
|
|
25
|
+
*
|
|
26
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
27
|
+
*
|
|
28
|
+
* @deprecated Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.
|
|
29
|
+
*/
|
|
30
|
+
export const ATTR_HTTP_HOST = 'http.host';
|
|
31
|
+
/**
|
|
32
|
+
* Deprecated, use `http.request.method` instead.
|
|
33
|
+
*
|
|
34
|
+
* @example GET
|
|
35
|
+
* @example POST
|
|
36
|
+
* @example HEAD
|
|
37
|
+
*
|
|
38
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Replaced by `http.request.method`.
|
|
41
|
+
*/
|
|
42
|
+
export const ATTR_HTTP_METHOD = 'http.method';
|
|
43
|
+
/**
|
|
44
|
+
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
|
|
45
|
+
*
|
|
46
|
+
* @example 3495
|
|
47
|
+
*
|
|
48
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
49
|
+
*/
|
|
50
|
+
export const ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size';
|
|
51
|
+
/**
|
|
52
|
+
* Deprecated, use `http.request.body.size` instead.
|
|
53
|
+
*
|
|
54
|
+
* @example 5493
|
|
55
|
+
*
|
|
56
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated Replaced by `http.request.body.size`.
|
|
59
|
+
*/
|
|
60
|
+
export const ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = 'http.request_content_length_uncompressed';
|
|
61
|
+
/**
|
|
62
|
+
* Deprecated, use `http.response.header.<key>` instead.
|
|
63
|
+
*
|
|
64
|
+
* @example 3495
|
|
65
|
+
*
|
|
66
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Replaced by `http.response.header.<key>`.
|
|
69
|
+
*/
|
|
70
|
+
export const ATTR_HTTP_RESPONSE_CONTENT_LENGTH = 'http.response_content_length';
|
|
71
|
+
/**
|
|
72
|
+
* Deprecated, use `url.scheme` instead.
|
|
73
|
+
*
|
|
74
|
+
* @example http
|
|
75
|
+
* @example https
|
|
76
|
+
*
|
|
77
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Replaced by `url.scheme` instead.
|
|
80
|
+
*/
|
|
81
|
+
export const ATTR_HTTP_SCHEME = 'http.scheme';
|
|
82
|
+
/**
|
|
83
|
+
* Deprecated, use `http.response.status_code` instead.
|
|
84
|
+
*
|
|
85
|
+
* @example 200
|
|
86
|
+
*
|
|
87
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
88
|
+
*
|
|
89
|
+
* @deprecated Replaced by `http.response.status_code`.
|
|
90
|
+
*/
|
|
91
|
+
export const ATTR_HTTP_STATUS_CODE = 'http.status_code';
|
|
92
|
+
/**
|
|
93
|
+
* Deprecated, use `url.full` instead.
|
|
94
|
+
*
|
|
95
|
+
* @example https://www.foo.bar/search?q=OpenTelemetry#SemConv
|
|
96
|
+
*
|
|
97
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
98
|
+
*
|
|
99
|
+
* @deprecated Replaced by `url.full`.
|
|
100
|
+
*/
|
|
101
|
+
export const ATTR_HTTP_URL = 'http.url';
|
|
102
|
+
/**
|
|
103
|
+
* Deprecated, use `user_agent.original` instead.
|
|
104
|
+
*
|
|
105
|
+
* @example CERN-LineMode/2.15 libwww/2.17b3
|
|
106
|
+
* @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1
|
|
107
|
+
*
|
|
108
|
+
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
109
|
+
*
|
|
110
|
+
* @deprecated Replaced by `user_agent.original`.
|
|
111
|
+
*/
|
|
112
|
+
export const ATTR_HTTP_USER_AGENT = 'http.user_agent';
|
|
113
|
+
//# sourceMappingURL=semconv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAoB,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAiC,CAAC;AAE7E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,6CAA6C,GACxD,0CAAmD,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAC5C,8BAAuC,CAAC;AAE1C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAsB,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAA2B,CAAC;AAEjE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAmB,CAAC;AAEjD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAA0B,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Deprecated, use one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.\n *\n * @example www.example.org\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.\n */\nexport const ATTR_HTTP_HOST = 'http.host' as const;\n\n/**\n * Deprecated, use `http.request.method` instead.\n *\n * @example GET\n * @example POST\n * @example HEAD\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.request.method`.\n */\nexport const ATTR_HTTP_METHOD = 'http.method' as const;\n\n/**\n * The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.\n *\n * @example 3495\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size' as const;\n\n/**\n * Deprecated, use `http.request.body.size` instead.\n *\n * @example 5493\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.request.body.size`.\n */\nexport const ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED =\n 'http.request_content_length_uncompressed' as const;\n\n/**\n * Deprecated, use `http.response.header.<key>` instead.\n *\n * @example 3495\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.header.<key>`.\n */\nexport const ATTR_HTTP_RESPONSE_CONTENT_LENGTH =\n 'http.response_content_length' as const;\n\n/**\n * Deprecated, use `url.scheme` instead.\n *\n * @example http\n * @example https\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `url.scheme` instead.\n */\nexport const ATTR_HTTP_SCHEME = 'http.scheme' as const;\n\n/**\n * Deprecated, use `http.response.status_code` instead.\n *\n * @example 200\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `http.response.status_code`.\n */\nexport const ATTR_HTTP_STATUS_CODE = 'http.status_code' as const;\n\n/**\n * Deprecated, use `url.full` instead.\n *\n * @example https://www.foo.bar/search?q=OpenTelemetry#SemConv\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `url.full`.\n */\nexport const ATTR_HTTP_URL = 'http.url' as const;\n\n/**\n * Deprecated, use `user_agent.original` instead.\n *\n * @example CERN-LineMode/2.15 libwww/2.17b3\n * @example Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n *\n * @deprecated Replaced by `user_agent.original`.\n */\nexport const ATTR_HTTP_USER_AGENT = 'http.user_agent' as const;\n"]}
|
package/build/esm/utils.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { URLLike } from '@opentelemetry/sdk-trace-web';
|
|
1
2
|
/**
|
|
2
3
|
* Helper function to determine payload content length for XHR requests
|
|
3
4
|
* @param body
|
|
4
5
|
* @returns content length
|
|
5
6
|
*/
|
|
6
7
|
export declare function getXHRBodyLength(body: Document | XMLHttpRequestBodyInit): number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Normalize an HTTP request method string per `http.request.method` spec
|
|
10
|
+
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeHttpRequestMethod(method: string): string;
|
|
13
|
+
export declare function serverPortFromUrl(url: URLLike): number | undefined;
|
|
7
14
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/esm/utils.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch
|
|
17
17
|
// These may be unified in the future.
|
|
18
18
|
import * as api from '@opentelemetry/api';
|
|
19
|
+
import { getStringListFromEnv } from '@opentelemetry/core';
|
|
19
20
|
const DIAG_LOGGER = api.diag.createComponentLogger({
|
|
20
21
|
namespace: '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',
|
|
21
22
|
});
|
|
@@ -68,4 +69,59 @@ function getFormDataSize(formData) {
|
|
|
68
69
|
}
|
|
69
70
|
return size;
|
|
70
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Normalize an HTTP request method string per `http.request.method` spec
|
|
74
|
+
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
75
|
+
*/
|
|
76
|
+
export function normalizeHttpRequestMethod(method) {
|
|
77
|
+
const knownMethods = getKnownMethods();
|
|
78
|
+
const methUpper = method.toUpperCase();
|
|
79
|
+
if (methUpper in knownMethods) {
|
|
80
|
+
return methUpper;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return '_OTHER';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const DEFAULT_KNOWN_METHODS = {
|
|
87
|
+
CONNECT: true,
|
|
88
|
+
DELETE: true,
|
|
89
|
+
GET: true,
|
|
90
|
+
HEAD: true,
|
|
91
|
+
OPTIONS: true,
|
|
92
|
+
PATCH: true,
|
|
93
|
+
POST: true,
|
|
94
|
+
PUT: true,
|
|
95
|
+
TRACE: true,
|
|
96
|
+
};
|
|
97
|
+
let knownMethods;
|
|
98
|
+
function getKnownMethods() {
|
|
99
|
+
if (knownMethods === undefined) {
|
|
100
|
+
const cfgMethods = getStringListFromEnv('OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS');
|
|
101
|
+
if (cfgMethods && cfgMethods.length > 0) {
|
|
102
|
+
knownMethods = {};
|
|
103
|
+
cfgMethods.forEach(m => {
|
|
104
|
+
knownMethods[m] = true;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
knownMethods = DEFAULT_KNOWN_METHODS;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return knownMethods;
|
|
112
|
+
}
|
|
113
|
+
const HTTP_PORT_FROM_PROTOCOL = {
|
|
114
|
+
'https:': '443',
|
|
115
|
+
'http:': '80',
|
|
116
|
+
};
|
|
117
|
+
export function serverPortFromUrl(url) {
|
|
118
|
+
const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);
|
|
119
|
+
// Guard with `if (serverPort)` because `Number('') === 0`.
|
|
120
|
+
if (serverPort && !isNaN(serverPort)) {
|
|
121
|
+
return serverPort;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
71
127
|
//# sourceMappingURL=utils.js.map
|
package/build/esm/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,OAAO,KAAK,GAAG,MAAM,oBAAoB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ACF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,uBAAuB,GAA8B;IACzD,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,IAAI;CACd,CAAC;AACF,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7E,2DAA2D;IAC3D,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch\n// These may be unified in the future.\n\nimport * as api from '@opentelemetry/api';\nimport { getStringListFromEnv } from '@opentelemetry/core';\nimport { URLLike } from '@opentelemetry/sdk-trace-web';\n\nconst DIAG_LOGGER = api.diag.createComponentLogger({\n namespace:\n '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',\n});\n\nfunction isDocument(value: unknown): value is Document {\n return typeof Document !== 'undefined' && value instanceof Document;\n}\n\n/**\n * Helper function to determine payload content length for XHR requests\n * @param body\n * @returns content length\n */\nexport function getXHRBodyLength(\n body: Document | XMLHttpRequestBodyInit\n): number | undefined {\n if (isDocument(body)) {\n return new XMLSerializer().serializeToString(document).length;\n }\n\n // XMLHttpRequestBodyInit expands to the following:\n if (typeof body === 'string') {\n return getByteLength(body);\n }\n\n if (body instanceof Blob) {\n return body.size;\n }\n\n if (body instanceof FormData) {\n return getFormDataSize(body);\n }\n\n if (body instanceof URLSearchParams) {\n return getByteLength(body.toString());\n }\n\n // ArrayBuffer | ArrayBufferView\n if (body.byteLength !== undefined) {\n return body.byteLength;\n }\n\n DIAG_LOGGER.warn('unknown body type');\n return undefined;\n}\n\nconst TEXT_ENCODER = new TextEncoder();\nfunction getByteLength(s: string): number {\n return TEXT_ENCODER.encode(s).byteLength;\n}\n\nfunction getFormDataSize(formData: FormData): number {\n let size = 0;\n for (const [key, value] of formData.entries()) {\n size += key.length;\n if (value instanceof Blob) {\n size += value.size;\n } else {\n size += value.length;\n }\n }\n return size;\n}\n\n/**\n * Normalize an HTTP request method string per `http.request.method` spec\n * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span\n */\nexport function normalizeHttpRequestMethod(method: string): string {\n const knownMethods = getKnownMethods();\n const methUpper = method.toUpperCase();\n if (methUpper in knownMethods) {\n return methUpper;\n } else {\n return '_OTHER';\n }\n}\n\nconst DEFAULT_KNOWN_METHODS = {\n CONNECT: true,\n DELETE: true,\n GET: true,\n HEAD: true,\n OPTIONS: true,\n PATCH: true,\n POST: true,\n PUT: true,\n TRACE: true,\n};\nlet knownMethods: { [key: string]: boolean };\nfunction getKnownMethods() {\n if (knownMethods === undefined) {\n const cfgMethods = getStringListFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS'\n );\n if (cfgMethods && cfgMethods.length > 0) {\n knownMethods = {};\n cfgMethods.forEach(m => {\n knownMethods[m] = true;\n });\n } else {\n knownMethods = DEFAULT_KNOWN_METHODS;\n }\n }\n return knownMethods;\n}\n\nconst HTTP_PORT_FROM_PROTOCOL: { [key: string]: string } = {\n 'https:': '443',\n 'http:': '80',\n};\nexport function serverPortFromUrl(url: URLLike): number | undefined {\n const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);\n // Guard with `if (serverPort)` because `Number('') === 0`.\n if (serverPort && !isNaN(serverPort)) {\n return serverPort;\n } else {\n return undefined;\n }\n}\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.201.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.201.1';\n"]}
|
package/build/esm/xhr.d.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface XMLHttpRequestInstrumentationConfig extends InstrumentationConf
|
|
|
28
28
|
ignoreNetworkEvents?: boolean;
|
|
29
29
|
/** Measure outgoing request size */
|
|
30
30
|
measureRequestSize?: boolean;
|
|
31
|
+
/** Select the HTTP semantic conventions version(s) used. */
|
|
32
|
+
semconvStabilityOptIn?: string;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
33
35
|
* This class represents a XMLHttpRequest plugin for auto instrumentation
|
|
@@ -39,6 +41,7 @@ export declare class XMLHttpRequestInstrumentation extends InstrumentationBase<X
|
|
|
39
41
|
private _tasksCount;
|
|
40
42
|
private _xhrMem;
|
|
41
43
|
private _usedResources;
|
|
44
|
+
private _semconvStability;
|
|
42
45
|
constructor(config?: XMLHttpRequestInstrumentationConfig);
|
|
43
46
|
init(): void;
|
|
44
47
|
/**
|