@opentelemetry/instrumentation-xml-http-request 0.219.0 → 0.221.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.
Files changed (40) hide show
  1. package/README.md +9 -25
  2. package/build/esm/semconv.d.ts +0 -84
  3. package/build/esm/semconv.js +0 -84
  4. package/build/esm/semconv.js.map +1 -1
  5. package/build/esm/version.d.ts +1 -1
  6. package/build/esm/version.js +1 -1
  7. package/build/esm/version.js.map +1 -1
  8. package/build/esm/xhr.d.ts +1 -5
  9. package/build/esm/xhr.js +34 -77
  10. package/build/esm/xhr.js.map +1 -1
  11. package/build/esnext/semconv.d.ts +0 -84
  12. package/build/esnext/semconv.js +0 -84
  13. package/build/esnext/semconv.js.map +1 -1
  14. package/build/esnext/version.d.ts +1 -1
  15. package/build/esnext/version.js +1 -1
  16. package/build/esnext/version.js.map +1 -1
  17. package/build/esnext/xhr.d.ts +1 -5
  18. package/build/esnext/xhr.js +34 -77
  19. package/build/esnext/xhr.js.map +1 -1
  20. package/build/src/enums/EventNames.js +1 -1
  21. package/build/src/enums/EventNames.js.map +1 -1
  22. package/build/src/semconv.d.ts +0 -84
  23. package/build/src/semconv.js +1 -85
  24. package/build/src/semconv.js.map +1 -1
  25. package/build/src/version.d.ts +1 -1
  26. package/build/src/version.js +1 -1
  27. package/build/src/version.js.map +1 -1
  28. package/build/src/xhr.d.ts +1 -5
  29. package/build/src/xhr.js +32 -75
  30. package/build/src/xhr.js.map +1 -1
  31. package/package.json +16 -16
  32. package/build/esm/enums/AttributeNames.d.ts +0 -7
  33. package/build/esm/enums/AttributeNames.js +0 -12
  34. package/build/esm/enums/AttributeNames.js.map +0 -1
  35. package/build/esnext/enums/AttributeNames.d.ts +0 -7
  36. package/build/esnext/enums/AttributeNames.js +0 -12
  37. package/build/esnext/enums/AttributeNames.js.map +0 -1
  38. package/build/src/enums/AttributeNames.d.ts +0 -7
  39. package/build/src/enums/AttributeNames.js +0 -15
  40. package/build/src/enums/AttributeNames.js.map +0 -1
package/README.md CHANGED
@@ -73,37 +73,21 @@ XHR instrumentation plugin has few options available to choose from. You can set
73
73
  | `applyCustomAttributesOnSpan` | `XHRCustomAttributeFunction` | Function for adding custom attributes |
74
74
  | `ignoreNetworkEvents` | boolean | Disable network events being added as span events (network events are added by default) |
75
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
76
 
78
77
  ## Semantic Conventions
79
78
 
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.
79
+ The `instrumentation-xml-http-request` versions v0.220.0 and later emit the stable v1.23.0+ semantic conventions.
91
80
 
92
81
  **Span attributes:**
93
82
 
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. |
83
+ | v1.23.0 semconv | Notes |
84
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85
+ | `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). |
86
+ | `url.full` | Full HTTP request URL |
87
+ | `server.address` and `server.port` | The hostname and port of the request URL |
88
+ | `http.response.status_code` | HTTP response status code |
89
+ | `http.request.body.size` | This is only added if `measureRequestSize` is `true`. |
90
+ | `error.type` | The response status (as a string), if the response status was `>=400`, or one of these possible request errors: 'timeout' and 'error'. |
107
91
 
108
92
  ## Example Screenshots
109
93
 
@@ -1,25 +1,3 @@
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
1
  /**
24
2
  * 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
3
  *
@@ -28,66 +6,4 @@ export declare const ATTR_HTTP_METHOD: "http.method";
28
6
  * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
29
7
  */
30
8
  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
9
  //# sourceMappingURL=semconv.d.ts.map
@@ -7,28 +7,6 @@
7
7
  * used by this package.
8
8
  * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
9
9
  */
10
- /**
11
- * Deprecated, use one of `server.address`, `client.address` or `http.request.header.host` instead, depending on the usage.
12
- *
13
- * @example www.example.org
14
- *
15
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
16
- *
17
- * @deprecated Replaced by one of `server.address`, `client.address` or `http.request.header.host`, depending on the usage.
18
- */
19
- export const ATTR_HTTP_HOST = 'http.host';
20
- /**
21
- * Deprecated, use `http.request.method` instead.
22
- *
23
- * @example GET
24
- * @example POST
25
- * @example HEAD
26
- *
27
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
28
- *
29
- * @deprecated Replaced by `http.request.method`.
30
- */
31
- export const ATTR_HTTP_METHOD = 'http.method';
32
10
  /**
33
11
  * 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.
34
12
  *
@@ -37,66 +15,4 @@ export const ATTR_HTTP_METHOD = 'http.method';
37
15
  * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
38
16
  */
39
17
  export const ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size';
40
- /**
41
- * Deprecated, use `http.request.body.size` instead.
42
- *
43
- * @example 5493
44
- *
45
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
46
- *
47
- * @deprecated Replaced by `http.request.body.size`.
48
- */
49
- export const ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED = 'http.request_content_length_uncompressed';
50
- /**
51
- * Deprecated, use `http.response.header.<key>` instead.
52
- *
53
- * @example 3495
54
- *
55
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
56
- *
57
- * @deprecated Replaced by `http.response.header.<key>`.
58
- */
59
- export const ATTR_HTTP_RESPONSE_CONTENT_LENGTH = 'http.response_content_length';
60
- /**
61
- * Deprecated, use `url.scheme` instead.
62
- *
63
- * @example http
64
- * @example https
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 `url.scheme` instead.
69
- */
70
- export const ATTR_HTTP_SCHEME = 'http.scheme';
71
- /**
72
- * Deprecated, use `http.response.status_code` instead.
73
- *
74
- * @example 200
75
- *
76
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
77
- *
78
- * @deprecated Replaced by `http.response.status_code`.
79
- */
80
- export const ATTR_HTTP_STATUS_CODE = 'http.status_code';
81
- /**
82
- * Deprecated, use `url.full` instead.
83
- *
84
- * @example https://www.foo.bar/search?q=OpenTelemetry#SemConv
85
- *
86
- * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
87
- *
88
- * @deprecated Replaced by `url.full`.
89
- */
90
- export const ATTR_HTTP_URL = 'http.url';
91
- /**
92
- * Deprecated, use `user_agent.original` instead.
93
- *
94
- * @example CERN-LineMode/2.15 libwww/2.17b3
95
- * @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
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 `user_agent.original`.
100
- */
101
- export const ATTR_HTTP_USER_AGENT = 'http.user_agent';
102
18
  //# sourceMappingURL=semconv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;GAGG;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 * SPDX-License-Identifier: Apache-2.0\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"]}
1
+ {"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAiC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\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 * 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"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.219.0";
1
+ export declare const VERSION = "0.221.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -3,5 +3,5 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  // this is autogenerated file, see scripts/version-update.js
6
- export const VERSION = '0.219.0';
6
+ export const VERSION = '0.221.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.219.0';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.221.0';\n"]}
@@ -29,8 +29,6 @@ export interface XMLHttpRequestInstrumentationConfig extends InstrumentationConf
29
29
  ignoreNetworkEvents?: boolean;
30
30
  /** Measure outgoing request size */
31
31
  measureRequestSize?: boolean;
32
- /** Select the HTTP semantic conventions version(s) used. */
33
- semconvStabilityOptIn?: string;
34
32
  }
35
33
  /**
36
34
  * This class represents a XMLHttpRequest plugin for auto instrumentation
@@ -42,7 +40,6 @@ export declare class XMLHttpRequestInstrumentation extends InstrumentationBase<X
42
40
  private _tasksCount;
43
41
  private _xhrMem;
44
42
  private _usedResources;
45
- private _semconvStability;
46
43
  private _isEnabled;
47
44
  private _isXhrPatched;
48
45
  constructor(config?: XMLHttpRequestInstrumentationConfig);
@@ -65,10 +62,9 @@ export declare class XMLHttpRequestInstrumentation extends InstrumentationBase<X
65
62
  * Add attributes when span is going to end
66
63
  * @param span
67
64
  * @param xhr
68
- * @param spanUrl
69
65
  * @private
70
66
  */
71
- _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem, spanUrl?: string): void;
67
+ _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem): void;
72
68
  private _applyAttributesAfterXHR;
73
69
  /**
74
70
  * will collect information about all resources created
package/build/esm/xhr.js CHANGED
@@ -3,15 +3,14 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import * as api from '@opentelemetry/api';
6
- import { SemconvStability, semconvStabilityFromStr, InstrumentationBase, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation';
6
+ import { InstrumentationBase, safeExecuteInTheMiddle, } from '@opentelemetry/instrumentation';
7
7
  import { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';
8
8
  import { addSpanNetworkEvents, getResource, PerformanceTimingNames as PTN, shouldPropagateTraceHeaders, parseUrl, } from '@opentelemetry/sdk-trace-web';
9
9
  import { ATTR_ERROR_TYPE, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_REQUEST_METHOD_ORIGINAL, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, ATTR_URL_FULL, } from '@opentelemetry/semantic-conventions';
10
- import { ATTR_HTTP_HOST, ATTR_HTTP_METHOD, ATTR_HTTP_SCHEME, ATTR_HTTP_STATUS_CODE, ATTR_HTTP_URL, ATTR_HTTP_USER_AGENT, ATTR_HTTP_REQUEST_BODY_SIZE, ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, } from './semconv';
10
+ import { ATTR_HTTP_REQUEST_BODY_SIZE } from './semconv';
11
11
  import { EventNames } from './enums/EventNames';
12
12
  import { normalizeHttpRequestMethod, serverPortFromUrl, getXHRBodyLength, } from './utils';
13
13
  import { VERSION } from './version';
14
- import { AttributeNames } from './enums/AttributeNames';
15
14
  // how long to wait for observer to collect information about resources
16
15
  // this is needed as event "load" is called before observer
17
16
  // hard to say how long it should really wait, seems like 300ms is
@@ -27,10 +26,8 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
27
26
  _tasksCount = 0;
28
27
  _xhrMem = new WeakMap();
29
28
  _usedResources = new WeakSet();
30
- _semconvStability;
31
29
  constructor(config = {}) {
32
30
  super('@opentelemetry/instrumentation-xml-http-request', VERSION, config);
33
- this._semconvStability = semconvStabilityFromStr('http', config?.semconvStabilityOptIn);
34
31
  }
35
32
  init() { }
36
33
  /**
@@ -66,8 +63,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
66
63
  const childSpan = this.tracer.startSpan('CORS Preflight', {
67
64
  startTime: corsPreFlightRequest[PTN.FETCH_START],
68
65
  });
69
- const skipOldSemconvContentLengthAttrs = !(this._semconvStability & SemconvStability.OLD);
70
- addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined, skipOldSemconvContentLengthAttrs);
66
+ addSpanNetworkEvents(childSpan, corsPreFlightRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
71
67
  childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);
72
68
  });
73
69
  }
@@ -75,33 +71,14 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
75
71
  * Add attributes when span is going to end
76
72
  * @param span
77
73
  * @param xhr
78
- * @param spanUrl
79
74
  * @private
80
75
  */
81
- _addFinalSpanAttributes(span, xhrMem, spanUrl) {
82
- if (this._semconvStability & SemconvStability.OLD) {
83
- if (xhrMem.status !== undefined) {
84
- span.setAttribute(ATTR_HTTP_STATUS_CODE, xhrMem.status);
85
- }
86
- if (xhrMem.statusText !== undefined) {
87
- span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);
88
- }
89
- if (typeof spanUrl === 'string') {
90
- const parsedUrl = parseUrl(spanUrl);
91
- span.setAttribute(ATTR_HTTP_HOST, parsedUrl.host);
92
- span.setAttribute(ATTR_HTTP_SCHEME, parsedUrl.protocol.replace(':', ''));
93
- }
94
- // @TODO do we want to collect this or it will be collected earlier once only or
95
- // maybe when parent span is not available ?
96
- span.setAttribute(ATTR_HTTP_USER_AGENT, navigator.userAgent);
97
- }
98
- if (this._semconvStability & SemconvStability.STABLE) {
99
- if (xhrMem.status) {
100
- // Intentionally exclude status=0, because XHR uses 0 for before a
101
- // response is received and semconv says to only add the attribute if
102
- // received a response.
103
- span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, xhrMem.status);
104
- }
76
+ _addFinalSpanAttributes(span, xhrMem) {
77
+ if (xhrMem.status) {
78
+ // Intentionally exclude status=0, because XHR uses 0 for before a
79
+ // response is received and semconv says to only add the attribute if
80
+ // received a response.
81
+ span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, xhrMem.status);
105
82
  }
106
83
  }
107
84
  _applyAttributesAfterXHR(span, xhr) {
@@ -186,8 +163,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
186
163
  this._addChildSpan(span, corsPreFlightRequest);
187
164
  this._markResourceAsUsed(corsPreFlightRequest);
188
165
  }
189
- const skipOldSemconvContentLengthAttrs = !(this._semconvStability & SemconvStability.OLD);
190
- addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined, skipOldSemconvContentLengthAttrs);
166
+ addSpanNetworkEvents(span, mainRequest, this.getConfig().ignoreNetworkEvents, undefined, true);
191
167
  }
192
168
  }
193
169
  /**
@@ -219,31 +195,19 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
219
195
  this._diag.debug('ignoring span as url matches ignored url');
220
196
  return;
221
197
  }
222
- let name = '';
223
198
  const attributes = {};
224
- if (this._semconvStability & SemconvStability.OLD) {
225
- name = method.toUpperCase();
226
- attributes[ATTR_HTTP_METHOD] = method;
227
- attributes[ATTR_HTTP_URL] = parsedUrl.toString();
199
+ const origMethod = method;
200
+ const normMethod = normalizeHttpRequestMethod(method);
201
+ const name = normMethod;
202
+ attributes[ATTR_HTTP_REQUEST_METHOD] = normMethod;
203
+ if (normMethod !== origMethod) {
204
+ attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = origMethod;
228
205
  }
229
- if (this._semconvStability & SemconvStability.STABLE) {
230
- const origMethod = method;
231
- const normMethod = normalizeHttpRequestMethod(method);
232
- if (!name) {
233
- // The "old" span name wins if emitting both old and stable semconv
234
- // ('http/dup').
235
- name = normMethod;
236
- }
237
- attributes[ATTR_HTTP_REQUEST_METHOD] = normMethod;
238
- if (normMethod !== origMethod) {
239
- attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = origMethod;
240
- }
241
- attributes[ATTR_URL_FULL] = parsedUrl.toString();
242
- attributes[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;
243
- const serverPort = serverPortFromUrl(parsedUrl);
244
- if (serverPort) {
245
- attributes[ATTR_SERVER_PORT] = serverPort;
246
- }
206
+ attributes[ATTR_URL_FULL] = parsedUrl.toString();
207
+ attributes[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;
208
+ const serverPort = serverPortFromUrl(parsedUrl);
209
+ if (serverPort) {
210
+ attributes[ATTR_SERVER_PORT] = serverPort;
247
211
  }
248
212
  const currentSpan = this.tracer.startSpan(name, {
249
213
  kind: api.SpanKind.CLIENT,
@@ -300,7 +264,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
300
264
  if (span) {
301
265
  plugin._findResourceAndAddNetworkEvents(xhrMem, span, spanUrl, sendStartTime, performanceEndTime);
302
266
  span.addEvent(eventName, endTime);
303
- plugin._addFinalSpanAttributes(span, xhrMem, spanUrl);
267
+ plugin._addFinalSpanAttributes(span, xhrMem);
304
268
  span.end(endTime);
305
269
  plugin._tasksCount--;
306
270
  }
@@ -317,21 +281,19 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
317
281
  if (xhrMem.span) {
318
282
  const span = xhrMem.span;
319
283
  plugin._applyAttributesAfterXHR(span, xhr);
320
- if (plugin._semconvStability & SemconvStability.STABLE) {
321
- if (isError) {
322
- if (errorType) {
323
- span.setStatus({
324
- code: api.SpanStatusCode.ERROR,
325
- message: errorType,
326
- });
327
- span.setAttribute(ATTR_ERROR_TYPE, errorType);
328
- }
329
- }
330
- else if (xhrMem.status && xhrMem.status >= 400) {
331
- span.setStatus({ code: api.SpanStatusCode.ERROR });
332
- span.setAttribute(ATTR_ERROR_TYPE, String(xhrMem.status));
284
+ if (isError) {
285
+ if (errorType) {
286
+ span.setStatus({
287
+ code: api.SpanStatusCode.ERROR,
288
+ message: errorType,
289
+ });
290
+ span.setAttribute(ATTR_ERROR_TYPE, errorType);
333
291
  }
334
292
  }
293
+ else if (xhrMem.status && xhrMem.status >= 400) {
294
+ span.setStatus({ code: api.SpanStatusCode.ERROR });
295
+ span.setAttribute(ATTR_ERROR_TYPE, String(xhrMem.status));
296
+ }
335
297
  }
336
298
  const performanceEndTime = hrTime();
337
299
  const endTime = Date.now();
@@ -385,12 +347,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase {
385
347
  const body = args[0];
386
348
  const bodyLength = getXHRBodyLength(body);
387
349
  if (bodyLength !== undefined) {
388
- if (plugin._semconvStability & SemconvStability.OLD) {
389
- currentSpan.setAttribute(ATTR_HTTP_REQUEST_CONTENT_LENGTH_UNCOMPRESSED, bodyLength);
390
- }
391
- if (plugin._semconvStability & SemconvStability.STABLE) {
392
- currentSpan.setAttribute(ATTR_HTTP_REQUEST_BODY_SIZE, bodyLength);
393
- }
350
+ currentSpan.setAttribute(ATTR_HTTP_REQUEST_BODY_SIZE, bodyLength);
394
351
  }
395
352
  }
396
353
  api.context.with(api.trace.setSpan(api.context.active(), currentSpan), () => {