diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 97b1da014c..00411e7fac 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -12,4 +12,4 @@
# https://help.github.com/en/articles/about-code-owners
#
-* @dyladan @mayurkale22 @rochdev @bg451 @OlivierAlbertini @vmarchaud @markwolff @obecny @mwear @naseemkullah
+* @dyladan @mayurkale22 @rochdev @bg451 @OlivierAlbertini @vmarchaud @markwolff @obecny @mwear @naseemkullah @legendecas
diff --git a/README.md b/README.md
index 64722444d5..6347bef679 100644
--- a/README.md
+++ b/README.md
@@ -135,6 +135,7 @@ Approvers ([@open-telemetry/js-approvers](https://github.com/orgs/open-telemetry
- [Bartlomiej Obecny](https://github.com/obecny), LightStep
- [Matthew Wear](https://github.com/mwear), LightStep
- [Naseem K. Ullah](https://github.com/naseemkullah), Transit
+- [Chengzhong Wu](https://github.com/legendecas), Alibaba
*Find more about the approver role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#approver).*
@@ -205,6 +206,7 @@ These plugins are hosted at and make sure you have the browser console open. The application is using the `ConsoleSpanExporter` and will post the created spans to the browser console.
+
## Useful links
- For more information on OpenTelemetry, visit:
diff --git a/examples/tracer-web/examples/fetch/index.html b/examples/tracer-web/examples/fetch/index.html
new file mode 100644
index 0000000000..c8311c8e05
--- /dev/null
+++ b/examples/tracer-web/examples/fetch/index.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+ Fetch Plugin Example
+
+
+
+
+
+
+ Example of using Web Tracer with Fetch plugin with console exporter and collector exporter
+
+
+
+
+
+
+
diff --git a/examples/tracer-web/examples/fetch/index.js b/examples/tracer-web/examples/fetch/index.js
new file mode 100644
index 0000000000..5be984bbbe
--- /dev/null
+++ b/examples/tracer-web/examples/fetch/index.js
@@ -0,0 +1,71 @@
+'use strict';
+
+import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
+import { CollectorExporter } from '@opentelemetry/exporter-collector';
+import { WebTracerProvider } from '@opentelemetry/web';
+import { FetchPlugin } from '@opentelemetry/plugin-fetch';
+import { ZoneContextManager } from '@opentelemetry/context-zone';
+import { B3Propagator } from '@opentelemetry/core';
+
+const provider = new WebTracerProvider({
+ plugins: [
+ new FetchPlugin({
+ ignoreUrls: [/localhost:8090\/sockjs-node/],
+ propagateTraceHeaderCorsUrls: [
+ 'https://cors-test.appspot.com/test',
+ 'https://httpbin.org/get',
+ ],
+ clearTimingResources: true
+ }),
+ ],
+});
+
+provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
+provider.addSpanProcessor(new SimpleSpanProcessor(new CollectorExporter()));
+provider.register({
+ contextManager: new ZoneContextManager(),
+ propagator: new B3Propagator(),
+});
+
+const webTracerWithZone = provider.getTracer('example-tracer-web');
+
+const getData = (url) => fetch(url, {
+ method: 'GET',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json',
+ },
+});
+
+// example of keeping track of context between async operations
+const prepareClickEvent = () => {
+ const url1 = 'https://httpbin.org/get';
+
+ const element = document.getElementById('button1');
+
+ const onClick = () => {
+ const span1 = webTracerWithZone.startSpan(`files-series-info`, {
+ parent: webTracerWithZone.getCurrentSpan(),
+ });
+ webTracerWithZone.withSpan(span1, () => {
+ getData(url1).then((_data) => {
+ webTracerWithZone.getCurrentSpan().addEvent('fetching-span1-completed');
+ span1.end();
+ });
+ });
+ for (let i = 0, j = 5; i < j; i += 1) {
+ const span1 = webTracerWithZone.startSpan(`files-series-info-${i}`, {
+ parent: webTracerWithZone.getCurrentSpan(),
+ });
+ webTracerWithZone.withSpan(span1, () => {
+ getData(url1).then((_data) => {
+ webTracerWithZone.getCurrentSpan().addEvent('fetching-span1-completed');
+ span1.end();
+ });
+ });
+ }
+ };
+ element.addEventListener('click', onClick);
+};
+
+window.addEventListener('load', prepareClickEvent);
diff --git a/examples/tracer-web/package.json b/examples/tracer-web/package.json
index ecf4b1a222..bb8a3e4fe5 100644
--- a/examples/tracer-web/package.json
+++ b/examples/tracer-web/package.json
@@ -38,6 +38,7 @@
"@opentelemetry/core": "^0.8.3",
"@opentelemetry/exporter-collector": "^0.8.3",
"@opentelemetry/plugin-document-load": "^0.6.1",
+ "@opentelemetry/plugin-fetch": "^0.8.3",
"@opentelemetry/plugin-user-interaction": "^0.6.1",
"@opentelemetry/plugin-xml-http-request": "^0.8.3",
"@opentelemetry/tracing": "^0.8.3",
diff --git a/examples/tracer-web/webpack.config.js b/examples/tracer-web/webpack.config.js
index b23949d731..3e1c14ef2f 100644
--- a/examples/tracer-web/webpack.config.js
+++ b/examples/tracer-web/webpack.config.js
@@ -8,6 +8,7 @@ const common = {
mode: 'development',
entry: {
'document-load': 'examples/document-load/index.js',
+ fetch: 'examples/fetch/index.js',
'xml-http-request': 'examples/xml-http-request/index.js',
'user-interaction': 'examples/user-interaction/index.js',
},
diff --git a/karma.base.js b/karma.base.js
index 088ac3f987..cbae813f7b 100644
--- a/karma.base.js
+++ b/karma.base.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ module.exports = {
browsers: ['ChromeHeadless'],
frameworks: ['mocha'],
coverageIstanbulReporter: {
- reports: ['json'],
+ reports: ['html', 'json'],
dir: '.nyc_output',
fixWebpackSourcePaths: true
},
diff --git a/karma.webpack.js b/karma.webpack.js
index d62d6292c5..bc8eb3a790 100644
--- a/karma.webpack.js
+++ b/karma.webpack.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/metapackages/plugins-node-all/README.md b/metapackages/plugins-node-all/README.md
new file mode 100644
index 0000000000..3b63827b5b
--- /dev/null
+++ b/metapackages/plugins-node-all/README.md
@@ -0,0 +1,51 @@
+# OpenTelemetry Plugins Node Core
+[![Gitter chat][gitter-image]][gitter-url]
+[![NPM Published Version][npm-img]][npm-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![Apache License][license-image]][license-image]
+
+This package depends on all node plugins maintained by OpenTelemetry authors.
+Installing it will also install all plugins.
+
+## Plugins
+
+In addition to all [node core plugins][otel-plugins-node-core], the following plugins will be installed by this package:
+
+- [@opentelemetry/plugin-express][otel-plugin-express]
+- [@opentelemetry/plugin-ioredis][otel-plugin-ioredis]
+- [@opentelemetry/plugin-mongodb][otel-plugin-mongodb]
+- [@opentelemetry/plugin-mysql][otel-plugin-mysql]
+- [@opentelemetry/plugin-pg-pool][otel-plugin-pg-pool]
+- [@opentelemetry/plugin-pg][otel-plugin-pg]
+- [@opentelemetry/plugin-redis][otel-plugin-redis]
+
+Note: [@opentelemetry/plugin-dns][otel-plugin-dns] is excluded by default because it requires some manual configuration to prevent infinite loops with exporters.
+
+## Useful links
+- For more information on OpenTelemetry, visit:
+- For more about OpenTelemetry JavaScript:
+- For help or feedback on this project, join us on [gitter][gitter-url]
+
+## License
+
+Apache 2.0 - See [LICENSE][license-url] for more information.
+
+[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg
+[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE
+[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
+[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=metapackages/plugins-node-core
+[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetryplugins-node-core
+[npm-url]: https://www.npmjs.com/package/@opentelemetry/plugins-node-core
+[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fplugins-node-core.svg
+
+[otel-plugins-node-core]: https://www.npmjs.com/package/@opentelemetry/plugins-node-core
+
+[otel-plugin-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-dns
+[otel-plugin-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-express
+[otel-plugin-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-ioredis
+[otel-plugin-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-mongodb
+[otel-plugin-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-mysql
+[otel-plugin-pg-pool]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-pg-pool
+[otel-plugin-pg]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-pg
+[otel-plugin-redis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-redis
diff --git a/metapackages/plugins-node-all/package.json b/metapackages/plugins-node-all/package.json
new file mode 100644
index 0000000000..427c3f88ab
--- /dev/null
+++ b/metapackages/plugins-node-all/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "@opentelemetry/plugins-node-all",
+ "version": "0.8.3",
+ "description": "Metapackage which bundles opentelemetry node core and contrib plugins",
+ "author": "OpenTelemetry Authors",
+ "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme",
+ "license": "Apache-2.0",
+ "publishConfig": {
+ "access": "public"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/open-telemetry/opentelemetry-js.git"
+ },
+ "bugs": {
+ "url": "https://github.com/open-telemetry/opentelemetry-js/issues"
+ },
+ "dependencies": {
+ "@opentelemetry/plugins-node-core": "^0.8.3",
+ "@opentelemetry/plugin-express": "0.8.0",
+ "@opentelemetry/plugin-ioredis": "0.8.0",
+ "@opentelemetry/plugin-mongodb": "0.8.0",
+ "@opentelemetry/plugin-mysql": "0.8.0",
+ "@opentelemetry/plugin-pg-pool": "0.8.0",
+ "@opentelemetry/plugin-pg": "0.8.0",
+ "@opentelemetry/plugin-redis": "0.8.0"
+ }
+}
diff --git a/package.json b/package.json
index 78cd12033d..ff88fb72e3 100644
--- a/package.json
+++ b/package.json
@@ -42,12 +42,12 @@
"@commitlint/config-conventional": "8.3.4",
"beautify-benchmark": "0.2.4",
"benchmark": "2.1.4",
- "eslint": "6.8.0",
- "eslint-config-airbnb-base": "14.1.0",
+ "eslint": "7.2.0",
+ "eslint-config-airbnb-base": "14.2.0",
"eslint-plugin-import": "2.21.2",
"eslint-plugin-header": "3.0.0",
- "@typescript-eslint/eslint-plugin": "3.2.0",
- "@typescript-eslint/parser": "3.2.0",
+ "@typescript-eslint/eslint-plugin": "3.3.0",
+ "@typescript-eslint/parser": "3.3.0",
"gh-pages": "3.0.0",
"gts": "2.0.2",
"husky": "4.2.5",
diff --git a/packages/opentelemetry-api/karma.conf.js b/packages/opentelemetry-api/karma.conf.js
index 7183aab033..3019564a15 100644
--- a/packages/opentelemetry-api/karma.conf.js
+++ b/packages/opentelemetry-api/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json
index 5c538564da..13f820977b 100644
--- a/packages/opentelemetry-api/package.json
+++ b/packages/opentelemetry-api/package.json
@@ -60,7 +60,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/packages/opentelemetry-api/src/api/context.ts b/packages/opentelemetry-api/src/api/context.ts
index b127917990..ac5aff2cdd 100644
--- a/packages/opentelemetry-api/src/api/context.ts
+++ b/packages/opentelemetry-api/src/api/context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/api/global-utils.ts b/packages/opentelemetry-api/src/api/global-utils.ts
index 00b73f8ce8..a294f345d5 100644
--- a/packages/opentelemetry-api/src/api/global-utils.ts
+++ b/packages/opentelemetry-api/src/api/global-utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/api/metrics.ts b/packages/opentelemetry-api/src/api/metrics.ts
index dedf58be54..f06b09fa36 100644
--- a/packages/opentelemetry-api/src/api/metrics.ts
+++ b/packages/opentelemetry-api/src/api/metrics.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/api/propagation.ts b/packages/opentelemetry-api/src/api/propagation.ts
index a8af524244..989e497b66 100644
--- a/packages/opentelemetry-api/src/api/propagation.ts
+++ b/packages/opentelemetry-api/src/api/propagation.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/api/trace.ts b/packages/opentelemetry-api/src/api/trace.ts
index bae7353e08..0ba58af77a 100644
--- a/packages/opentelemetry-api/src/api/trace.ts
+++ b/packages/opentelemetry-api/src/api/trace.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/common/Logger.ts b/packages/opentelemetry-api/src/common/Logger.ts
index abb8885a15..f4bccbe9db 100644
--- a/packages/opentelemetry-api/src/common/Logger.ts
+++ b/packages/opentelemetry-api/src/common/Logger.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/common/Time.ts b/packages/opentelemetry-api/src/common/Time.ts
index 0723d9cc43..5cf0dbb46b 100644
--- a/packages/opentelemetry-api/src/common/Time.ts
+++ b/packages/opentelemetry-api/src/common/Time.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/** High resolution HrTime: [seconds: number, nanoseconds: number] */
export type HrTime = [number, number];
/**
diff --git a/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts b/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts
index a95a0a4384..6c6f61d668 100644
--- a/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts
+++ b/packages/opentelemetry-api/src/context/propagation/HttpTextPropagator.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts b/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts
index f36922d875..7782ba30b9 100644
--- a/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts
+++ b/packages/opentelemetry-api/src/context/propagation/NoopHttpTextPropagator.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/context/propagation/getter.ts b/packages/opentelemetry-api/src/context/propagation/getter.ts
index 158bd0fdd1..7565010728 100644
--- a/packages/opentelemetry-api/src/context/propagation/getter.ts
+++ b/packages/opentelemetry-api/src/context/propagation/getter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/context/propagation/setter.ts b/packages/opentelemetry-api/src/context/propagation/setter.ts
index 29c6abed73..2eb56adf46 100644
--- a/packages/opentelemetry-api/src/context/propagation/setter.ts
+++ b/packages/opentelemetry-api/src/context/propagation/setter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/correlation_context/CorrelationContext.ts b/packages/opentelemetry-api/src/correlation_context/CorrelationContext.ts
index e0de5eca1a..c7bd5668b9 100644
--- a/packages/opentelemetry-api/src/correlation_context/CorrelationContext.ts
+++ b/packages/opentelemetry-api/src/correlation_context/CorrelationContext.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/correlation_context/EntryValue.ts b/packages/opentelemetry-api/src/correlation_context/EntryValue.ts
index 5db17aff63..59ec73cc2a 100644
--- a/packages/opentelemetry-api/src/correlation_context/EntryValue.ts
+++ b/packages/opentelemetry-api/src/correlation_context/EntryValue.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * {@link EntryValue} contains properties associated with a {@link
- * CorrelationContext}.
- */
export interface EntryValue {
/** `String` value of the `EntryValue`. */
value: string;
diff --git a/packages/opentelemetry-api/src/index.ts b/packages/opentelemetry-api/src/index.ts
index 6b77e9dd15..2f5f81ac99 100644
--- a/packages/opentelemetry-api/src/index.ts
+++ b/packages/opentelemetry-api/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/metrics/BoundInstrument.ts b/packages/opentelemetry-api/src/metrics/BoundInstrument.ts
index 0be696d43a..5b77158356 100644
--- a/packages/opentelemetry-api/src/metrics/BoundInstrument.ts
+++ b/packages/opentelemetry-api/src/metrics/BoundInstrument.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/metrics/Meter.ts b/packages/opentelemetry-api/src/metrics/Meter.ts
index 5ed8bbf3a9..cf6d15df04 100644
--- a/packages/opentelemetry-api/src/metrics/Meter.ts
+++ b/packages/opentelemetry-api/src/metrics/Meter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,13 @@
* limitations under the License.
*/
-import { MetricOptions, Counter, ValueRecorder, Observer } from './Metric';
+import {
+ MetricOptions,
+ Counter,
+ ValueRecorder,
+ Observer,
+ UpDownCounter,
+} from './Metric';
/**
* An interface to allow the recording metrics.
@@ -40,6 +46,25 @@ export interface Meter {
*/
createCounter(name: string, options?: MetricOptions): Counter;
+ /**
+ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
+ * instrument and very similar to Counter except that Add(increment)
+ * supports negative increments. It is generally useful for capturing changes
+ * in an amount of resources used, or any quantity that rises and falls
+ * during a request.
+ * Example uses for UpDownCounter:
+ *
+ *
count the number of active requests.
+ *
count memory in use by instrumenting new and delete.
+ *
count queue size by instrumenting enqueue and dequeue.
+ *
count semaphore up and down operations.
+ *
+ *
+ * @param name the name of the metric.
+ * @param [options] the metric options.
+ */
+ createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter;
+
/**
* Creates a new `Observer` metric.
* @param name the name of the metric.
diff --git a/packages/opentelemetry-api/src/metrics/MeterProvider.ts b/packages/opentelemetry-api/src/metrics/MeterProvider.ts
index 465dff91fe..981218ad59 100644
--- a/packages/opentelemetry-api/src/metrics/MeterProvider.ts
+++ b/packages/opentelemetry-api/src/metrics/MeterProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/metrics/Metric.ts b/packages/opentelemetry-api/src/metrics/Metric.ts
index 23118369fa..24f36cfd05 100644
--- a/packages/opentelemetry-api/src/metrics/Metric.ts
+++ b/packages/opentelemetry-api/src/metrics/Metric.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,12 +48,7 @@ export interface MetricOptions {
disabled?: boolean;
/**
- * Asserts that this metric may only increase (e.g. time spent).
- */
- monotonic?: boolean;
-
- /**
- * (ValueRecorder only, default true) Asserts that this metric will only accept
+ * (Measure only, default true) Asserts that this metric will only accept
* non-negative values (e.g. disk usage).
*/
absolute?: boolean;
@@ -125,6 +120,13 @@ export interface Counter extends UnboundMetric {
add(value: number, labels?: Labels): void;
}
+export interface UpDownCounter extends UnboundMetric {
+ /**
+ * Adds the given value to the current value. Values can be negative.
+ */
+ add(value: number, labels?: Labels): void;
+}
+
export interface ValueRecorder extends UnboundMetric {
/**
* Records the given value to this value recorder.
diff --git a/packages/opentelemetry-api/src/metrics/MetricObservable.ts b/packages/opentelemetry-api/src/metrics/MetricObservable.ts
index 4e25dce4e5..161d2919f4 100644
--- a/packages/opentelemetry-api/src/metrics/MetricObservable.ts
+++ b/packages/opentelemetry-api/src/metrics/MetricObservable.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Metric Observable class to handle asynchronous metrics
- */
export interface MetricObservable {
/**
* Sets the next value for observable metric
diff --git a/packages/opentelemetry-api/src/metrics/NoopMeter.ts b/packages/opentelemetry-api/src/metrics/NoopMeter.ts
index eed8c4e9bf..075a1e544e 100644
--- a/packages/opentelemetry-api/src/metrics/NoopMeter.ts
+++ b/packages/opentelemetry-api/src/metrics/NoopMeter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import {
Counter,
ValueRecorder,
Observer,
+ UpDownCounter,
} from './Metric';
import { BoundValueRecorder, BoundCounter } from './BoundInstrument';
import { CorrelationContext } from '../correlation_context/CorrelationContext';
@@ -53,6 +54,15 @@ export class NoopMeter implements Meter {
return NOOP_COUNTER_METRIC;
}
+ /**
+ * Returns a constant noop UpDownCounter.
+ * @param name the name of the metric.
+ * @param [options] the metric options.
+ */
+ createUpDownCounter(name: string, options?: MetricOptions): UpDownCounter {
+ return NOOP_COUNTER_METRIC;
+ }
+
/**
* Returns constant noop observer.
* @param name the name of the metric.
diff --git a/packages/opentelemetry-api/src/metrics/NoopMeterProvider.ts b/packages/opentelemetry-api/src/metrics/NoopMeterProvider.ts
index 182463611c..13e73c0e2f 100644
--- a/packages/opentelemetry-api/src/metrics/NoopMeterProvider.ts
+++ b/packages/opentelemetry-api/src/metrics/NoopMeterProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/metrics/ObserverResult.ts b/packages/opentelemetry-api/src/metrics/ObserverResult.ts
index 47c3d595c4..0b7286ac38 100644
--- a/packages/opentelemetry-api/src/metrics/ObserverResult.ts
+++ b/packages/opentelemetry-api/src/metrics/ObserverResult.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/platform/browser/globalThis.ts b/packages/opentelemetry-api/src/platform/browser/globalThis.ts
index df2b5b247f..34a8254b88 100644
--- a/packages/opentelemetry-api/src/platform/browser/globalThis.ts
+++ b/packages/opentelemetry-api/src/platform/browser/globalThis.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/platform/browser/index.ts b/packages/opentelemetry-api/src/platform/browser/index.ts
index c3608dbed7..e9d6ebed71 100644
--- a/packages/opentelemetry-api/src/platform/browser/index.ts
+++ b/packages/opentelemetry-api/src/platform/browser/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/platform/index.ts b/packages/opentelemetry-api/src/platform/index.ts
index e4361f1724..cdaf8858ce 100644
--- a/packages/opentelemetry-api/src/platform/index.ts
+++ b/packages/opentelemetry-api/src/platform/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/platform/node/globalThis.ts b/packages/opentelemetry-api/src/platform/node/globalThis.ts
index 8e24cf207e..36e97e2732 100644
--- a/packages/opentelemetry-api/src/platform/node/globalThis.ts
+++ b/packages/opentelemetry-api/src/platform/node/globalThis.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/platform/node/index.ts b/packages/opentelemetry-api/src/platform/node/index.ts
index c3608dbed7..e9d6ebed71 100644
--- a/packages/opentelemetry-api/src/platform/node/index.ts
+++ b/packages/opentelemetry-api/src/platform/node/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/Event.ts b/packages/opentelemetry-api/src/trace/Event.ts
index c3238c5393..5c974ccaa9 100644
--- a/packages/opentelemetry-api/src/trace/Event.ts
+++ b/packages/opentelemetry-api/src/trace/Event.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/NoopSpan.ts b/packages/opentelemetry-api/src/trace/NoopSpan.ts
index 342a587413..a2a3bcef9f 100644
--- a/packages/opentelemetry-api/src/trace/NoopSpan.ts
+++ b/packages/opentelemetry-api/src/trace/NoopSpan.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/NoopTracer.ts b/packages/opentelemetry-api/src/trace/NoopTracer.ts
index ed4c63f834..2fdc4dc310 100644
--- a/packages/opentelemetry-api/src/trace/NoopTracer.ts
+++ b/packages/opentelemetry-api/src/trace/NoopTracer.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/NoopTracerProvider.ts b/packages/opentelemetry-api/src/trace/NoopTracerProvider.ts
index 4eb66c056b..09c86bd7d9 100644
--- a/packages/opentelemetry-api/src/trace/NoopTracerProvider.ts
+++ b/packages/opentelemetry-api/src/trace/NoopTracerProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/Sampler.ts b/packages/opentelemetry-api/src/trace/Sampler.ts
index 5e8621572f..0d23f51e09 100644
--- a/packages/opentelemetry-api/src/trace/Sampler.ts
+++ b/packages/opentelemetry-api/src/trace/Sampler.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/SamplingResult.ts b/packages/opentelemetry-api/src/trace/SamplingResult.ts
index 84957f8297..dca3a3952f 100644
--- a/packages/opentelemetry-api/src/trace/SamplingResult.ts
+++ b/packages/opentelemetry-api/src/trace/SamplingResult.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/SpanOptions.ts b/packages/opentelemetry-api/src/trace/SpanOptions.ts
index 13a2c2f389..e20f243eac 100644
--- a/packages/opentelemetry-api/src/trace/SpanOptions.ts
+++ b/packages/opentelemetry-api/src/trace/SpanOptions.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/TimedEvent.ts b/packages/opentelemetry-api/src/trace/TimedEvent.ts
index 3218bfa604..632107b260 100644
--- a/packages/opentelemetry-api/src/trace/TimedEvent.ts
+++ b/packages/opentelemetry-api/src/trace/TimedEvent.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/attributes.ts b/packages/opentelemetry-api/src/trace/attributes.ts
index e0f0e922e3..f5ee8f6188 100644
--- a/packages/opentelemetry-api/src/trace/attributes.ts
+++ b/packages/opentelemetry-api/src/trace/attributes.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Defines a attributes interface.
- * These attributes provides additional data about the {@link Span}.
- */
export interface Attributes {
[attributeKey: string]: unknown;
}
diff --git a/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts b/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts
index 2206d4b0e0..11d96fed2b 100644
--- a/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts
+++ b/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/link.ts b/packages/opentelemetry-api/src/trace/link.ts
index 4226bf1830..b442555a4e 100644
--- a/packages/opentelemetry-api/src/trace/link.ts
+++ b/packages/opentelemetry-api/src/trace/link.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/link_context.ts b/packages/opentelemetry-api/src/trace/link_context.ts
index 5493f039a6..c52245975d 100644
--- a/packages/opentelemetry-api/src/trace/link_context.ts
+++ b/packages/opentelemetry-api/src/trace/link_context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/span.ts b/packages/opentelemetry-api/src/trace/span.ts
index 8408a48d20..13124fff3c 100644
--- a/packages/opentelemetry-api/src/trace/span.ts
+++ b/packages/opentelemetry-api/src/trace/span.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/span_context.ts b/packages/opentelemetry-api/src/trace/span_context.ts
index b99be63fc9..82eafe4332 100644
--- a/packages/opentelemetry-api/src/trace/span_context.ts
+++ b/packages/opentelemetry-api/src/trace/span_context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/span_kind.ts b/packages/opentelemetry-api/src/trace/span_kind.ts
index a6ca9b522c..d0ed18123e 100644
--- a/packages/opentelemetry-api/src/trace/span_kind.ts
+++ b/packages/opentelemetry-api/src/trace/span_kind.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Type of span. Can be used to specify additional relationships between spans
- * in addition to a parent/child relationship.
- */
export enum SpanKind {
/** Default value. Indicates that the span is used internally. */
INTERNAL = 0,
diff --git a/packages/opentelemetry-api/src/trace/status.ts b/packages/opentelemetry-api/src/trace/status.ts
index e9fa7201d8..12504992f7 100644
--- a/packages/opentelemetry-api/src/trace/status.ts
+++ b/packages/opentelemetry-api/src/trace/status.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * The status of a Span by providing a standard CanonicalCode in conjunction
- * with an optional descriptive message.
- */
export interface Status {
/** The canonical code of this message. */
code: CanonicalCode;
diff --git a/packages/opentelemetry-api/src/trace/trace_flags.ts b/packages/opentelemetry-api/src/trace/trace_flags.ts
index 8a593ec254..fd282010c7 100644
--- a/packages/opentelemetry-api/src/trace/trace_flags.ts
+++ b/packages/opentelemetry-api/src/trace/trace_flags.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * An enumeration that represents global trace flags. These flags are
- * propagated to all child {@link Span}. These determine features such as
- * whether a Span should be traced. It is implemented as a bitmask.
- */
export enum TraceFlags {
/** Represents no flag set. */
NONE = 0x0,
diff --git a/packages/opentelemetry-api/src/trace/trace_state.ts b/packages/opentelemetry-api/src/trace/trace_state.ts
index b137eba60b..074633633e 100644
--- a/packages/opentelemetry-api/src/trace/trace_state.ts
+++ b/packages/opentelemetry-api/src/trace/trace_state.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Tracestate carries system-specific configuration data, represented as a list
- * of key-value pairs. TraceState allows multiple tracing systems to
- * participate in the same trace.
- */
export interface TraceState {
/**
* Adds or updates the TraceState that has the given `key` if it is
diff --git a/packages/opentelemetry-api/src/trace/tracer.ts b/packages/opentelemetry-api/src/trace/tracer.ts
index f7edc856a0..c0657ffed0 100644
--- a/packages/opentelemetry-api/src/trace/tracer.ts
+++ b/packages/opentelemetry-api/src/trace/tracer.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/trace/tracer_provider.ts b/packages/opentelemetry-api/src/trace/tracer_provider.ts
index df5e576e90..6919cc1e26 100644
--- a/packages/opentelemetry-api/src/trace/tracer_provider.ts
+++ b/packages/opentelemetry-api/src/trace/tracer_provider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/src/version.ts b/packages/opentelemetry-api/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-api/src/version.ts
+++ b/packages/opentelemetry-api/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/test/api/api.test.ts b/packages/opentelemetry-api/test/api/api.test.ts
index d02453d252..77ecf8f70b 100644
--- a/packages/opentelemetry-api/test/api/api.test.ts
+++ b/packages/opentelemetry-api/test/api/api.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/test/api/global.test.ts b/packages/opentelemetry-api/test/api/global.test.ts
index 5ff4e25a2b..7d9ea5b9ca 100644
--- a/packages/opentelemetry-api/test/api/global.test.ts
+++ b/packages/opentelemetry-api/test/api/global.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/test/index-webpack.ts b/packages/opentelemetry-api/test/index-webpack.ts
index 7731f09091..061a48ccfa 100644
--- a/packages/opentelemetry-api/test/index-webpack.ts
+++ b/packages/opentelemetry-api/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('.', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts
index 8738708eba..cbfe044a9f 100644
--- a/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts
+++ b/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts
index 76b9a14621..177d60d7bf 100644
--- a/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts
+++ b/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts
index e49d0c0388..62ed24bb8e 100644
--- a/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts
+++ b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts b/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
index adeef82c25..0d22c1fd5e 100644
--- a/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
+++ b/packages/opentelemetry-context-async-hooks/src/AsyncHooksContextManager.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-async-hooks/src/index.ts b/packages/opentelemetry-context-async-hooks/src/index.ts
index 8a45a59477..9213cb8ae7 100644
--- a/packages/opentelemetry-context-async-hooks/src/index.ts
+++ b/packages/opentelemetry-context-async-hooks/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-async-hooks/src/version.ts b/packages/opentelemetry-context-async-hooks/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-context-async-hooks/src/version.ts
+++ b/packages/opentelemetry-context-async-hooks/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts b/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts
index 15f403d622..15814dd196 100644
--- a/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts
+++ b/packages/opentelemetry-context-async-hooks/test/AsyncHooksContextManager.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-base/src/NoopContextManager.ts b/packages/opentelemetry-context-base/src/NoopContextManager.ts
index 62fbb88068..e02816f221 100644
--- a/packages/opentelemetry-context-base/src/NoopContextManager.ts
+++ b/packages/opentelemetry-context-base/src/NoopContextManager.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-base/src/context.ts b/packages/opentelemetry-context-base/src/context.ts
index 8b42d7e9af..a4486fd3ed 100644
--- a/packages/opentelemetry-context-base/src/context.ts
+++ b/packages/opentelemetry-context-base/src/context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Class which stores and manages current context values. All methods which
- * update context such as get and delete do not modify an existing context,
- * but create a new one with updated values.
- */
export class Context {
private _currentContext: Map;
diff --git a/packages/opentelemetry-context-base/src/index.ts b/packages/opentelemetry-context-base/src/index.ts
index edbc18c622..d9e53ab004 100644
--- a/packages/opentelemetry-context-base/src/index.ts
+++ b/packages/opentelemetry-context-base/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-base/src/types.ts b/packages/opentelemetry-context-base/src/types.ts
index 9624387ac7..e58a4990cf 100644
--- a/packages/opentelemetry-context-base/src/types.ts
+++ b/packages/opentelemetry-context-base/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-base/src/version.ts b/packages/opentelemetry-context-base/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-context-base/src/version.ts
+++ b/packages/opentelemetry-context-base/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-base/test/NoopContextManager.test.ts b/packages/opentelemetry-context-base/test/NoopContextManager.test.ts
index af0323fedb..b35f979799 100644
--- a/packages/opentelemetry-context-base/test/NoopContextManager.test.ts
+++ b/packages/opentelemetry-context-base/test/NoopContextManager.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/karma.conf.js b/packages/opentelemetry-context-zone-peer-dep/karma.conf.js
index 7183aab033..3019564a15 100644
--- a/packages/opentelemetry-context-zone-peer-dep/karma.conf.js
+++ b/packages/opentelemetry-context-zone-peer-dep/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json
index ca61ffed52..7594f35d60 100644
--- a/packages/opentelemetry-context-zone-peer-dep/package.json
+++ b/packages/opentelemetry-context-zone-peer-dep/package.json
@@ -51,7 +51,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts
index c985738ff4..93ce9e1c6c 100644
--- a/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/src/ZoneContextManager.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ export class ZoneContextManager implements ContextManager {
* @param context A context (span) to be bind with Zone
*/
private _createZone(zoneName: string, context: unknown): Zone {
- return Zone.root.fork({
+ return Zone.current.fork({
name: zoneName,
properties: {
[ZONE_CONTEXT_KEY]: context,
diff --git a/packages/opentelemetry-context-zone-peer-dep/src/index.ts b/packages/opentelemetry-context-zone-peer-dep/src/index.ts
index 2c37135209..041e627912 100644
--- a/packages/opentelemetry-context-zone-peer-dep/src/index.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/src/types.ts b/packages/opentelemetry-context-zone-peer-dep/src/types.ts
index e67614be70..4c073178c1 100644
--- a/packages/opentelemetry-context-zone-peer-dep/src/types.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/src/util.ts b/packages/opentelemetry-context-zone-peer-dep/src/util.ts
index 98022f9219..2d5e87996f 100644
--- a/packages/opentelemetry-context-zone-peer-dep/src/util.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/src/util.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/src/version.ts b/packages/opentelemetry-context-zone-peer-dep/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-context-zone-peer-dep/src/version.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts b/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts
index 49571bf4bd..905348005c 100644
--- a/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/test/ZoneContextManager.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -199,6 +199,23 @@ describe('ZoneContextManager', () => {
});
});
});
+
+ it('should fork new zone from active one', () => {
+ const context = Context.ROOT_CONTEXT;
+ const rootZone = Zone.current;
+ contextManager.with(context, () => {
+ const zone1 = Zone.current;
+ assert.ok(zone1.parent === rootZone);
+ contextManager.with(context, () => {
+ const zone2 = Zone.current;
+ contextManager.with(context, () => {
+ const zone3 = Zone.current;
+ assert.ok(zone3.parent === zone2);
+ });
+ assert.ok(zone2.parent === zone1);
+ });
+ });
+ });
});
describe('.bind(function)', () => {
diff --git a/packages/opentelemetry-context-zone-peer-dep/test/index-webpack.ts b/packages/opentelemetry-context-zone-peer-dep/test/index-webpack.ts
index 7731f09091..061a48ccfa 100644
--- a/packages/opentelemetry-context-zone-peer-dep/test/index-webpack.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('.', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-context-zone-peer-dep/test/utils.test.ts b/packages/opentelemetry-context-zone-peer-dep/test/utils.test.ts
index 66e649e26d..21d9ef1aaf 100644
--- a/packages/opentelemetry-context-zone-peer-dep/test/utils.test.ts
+++ b/packages/opentelemetry-context-zone-peer-dep/test/utils.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json
index b4dba6cdd4..f9aaebceb2 100644
--- a/packages/opentelemetry-context-zone/package.json
+++ b/packages/opentelemetry-context-zone/package.json
@@ -46,7 +46,7 @@
"babel-loader": "8.1.0",
"codecov": "3.7.0",
"gts": "2.0.2",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.32",
diff --git a/packages/opentelemetry-context-zone/src/index.ts b/packages/opentelemetry-context-zone/src/index.ts
index df2ea15056..ba99ea33bd 100644
--- a/packages/opentelemetry-context-zone/src/index.ts
+++ b/packages/opentelemetry-context-zone/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-context-zone/src/version.ts b/packages/opentelemetry-context-zone/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-context-zone/src/version.ts
+++ b/packages/opentelemetry-context-zone/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/karma.conf.js b/packages/opentelemetry-core/karma.conf.js
index 7b8c9678db..bf2a41b799 100644
--- a/packages/opentelemetry-core/karma.conf.js
+++ b/packages/opentelemetry-core/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json
index 818eec738d..86c5223fd4 100644
--- a/packages/opentelemetry-core/package.json
+++ b/packages/opentelemetry-core/package.json
@@ -59,7 +59,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/packages/opentelemetry-core/src/ExportResult.ts b/packages/opentelemetry-core/src/ExportResult.ts
index 75eddbace3..bc73766e98 100644
--- a/packages/opentelemetry-core/src/ExportResult.ts
+++ b/packages/opentelemetry-core/src/ExportResult.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/common/ConsoleLogger.ts b/packages/opentelemetry-core/src/common/ConsoleLogger.ts
index 561fa74d95..c2cc8b58f4 100644
--- a/packages/opentelemetry-core/src/common/ConsoleLogger.ts
+++ b/packages/opentelemetry-core/src/common/ConsoleLogger.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/common/NoopLogger.ts b/packages/opentelemetry-core/src/common/NoopLogger.ts
index f0b1edd1d3..ad8cc8b639 100644
--- a/packages/opentelemetry-core/src/common/NoopLogger.ts
+++ b/packages/opentelemetry-core/src/common/NoopLogger.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts
index 13fdec0450..893fa03dc6 100644
--- a/packages/opentelemetry-core/src/common/time.ts
+++ b/packages/opentelemetry-core/src/common/time.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/common/types.ts b/packages/opentelemetry-core/src/common/types.ts
index eb84ba58b7..a5b2e553d0 100644
--- a/packages/opentelemetry-core/src/common/types.ts
+++ b/packages/opentelemetry-core/src/common/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/** Defines a log levels. */
export enum LogLevel {
ERROR,
WARN,
diff --git a/packages/opentelemetry-core/src/context/context.ts b/packages/opentelemetry-core/src/context/context.ts
index c1890915ce..c3a6dc33f5 100644
--- a/packages/opentelemetry-core/src/context/context.ts
+++ b/packages/opentelemetry-core/src/context/context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts b/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts
index 27689c5de9..126be42c17 100644
--- a/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts
+++ b/packages/opentelemetry-core/src/context/propagation/B3Propagator.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts
index 4a5d4d698b..6d5513bdf2 100644
--- a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts
+++ b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/context/propagation/composite.ts b/packages/opentelemetry-core/src/context/propagation/composite.ts
index c6010b319e..8b5d5d0857 100644
--- a/packages/opentelemetry-core/src/context/propagation/composite.ts
+++ b/packages/opentelemetry-core/src/context/propagation/composite.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/context/propagation/types.ts b/packages/opentelemetry-core/src/context/propagation/types.ts
index 7e32712b8c..9b7b2213d7 100644
--- a/packages/opentelemetry-core/src/context/propagation/types.ts
+++ b/packages/opentelemetry-core/src/context/propagation/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/correlation-context/correlation-context.ts b/packages/opentelemetry-core/src/correlation-context/correlation-context.ts
index 08df15bc0a..130bf24142 100644
--- a/packages/opentelemetry-core/src/correlation-context/correlation-context.ts
+++ b/packages/opentelemetry-core/src/correlation-context/correlation-context.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts b/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts
index 0415b7a4bf..0101e901f5 100644
--- a/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts
+++ b/packages/opentelemetry-core/src/correlation-context/propagation/HttpCorrelationContext.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts
index f9266cd2ce..ddf5fe4a67 100644
--- a/packages/opentelemetry-core/src/index.ts
+++ b/packages/opentelemetry-core/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/internal/validators.ts b/packages/opentelemetry-core/src/internal/validators.ts
index 5b1c941bed..78fbee8234 100644
--- a/packages/opentelemetry-core/src/internal/validators.ts
+++ b/packages/opentelemetry-core/src/internal/validators.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts b/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts
index 57ec582d2d..7a334310fd 100644
--- a/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts
+++ b/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts b/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts
index f9b99d05cb..4ace89ab48 100644
--- a/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts
+++ b/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/browser/hex-to-base64.ts b/packages/opentelemetry-core/src/platform/browser/hex-to-base64.ts
index d0441b7772..baf01bdc36 100644
--- a/packages/opentelemetry-core/src/platform/browser/hex-to-base64.ts
+++ b/packages/opentelemetry-core/src/platform/browser/hex-to-base64.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * converts id string into base64
- * @param hexStr - id of span
- */
export function hexToBase64(hexStr: string): string {
const hexStrLen = hexStr.length;
let hexAsciiCharsStr = '';
diff --git a/packages/opentelemetry-core/src/platform/browser/id.ts b/packages/opentelemetry-core/src/platform/browser/id.ts
index 02af4b220e..24f33972fd 100644
--- a/packages/opentelemetry-core/src/platform/browser/id.ts
+++ b/packages/opentelemetry-core/src/platform/browser/id.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// IE 11 exposes `crypto` as `msCrypto`.
declare type WindowWithMsCrypto = Window & {
msCrypto?: Crypto;
};
diff --git a/packages/opentelemetry-core/src/platform/browser/index.ts b/packages/opentelemetry-core/src/platform/browser/index.ts
index 15f8e3412d..d066951cf9 100644
--- a/packages/opentelemetry-core/src/platform/browser/index.ts
+++ b/packages/opentelemetry-core/src/platform/browser/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/browser/performance.ts b/packages/opentelemetry-core/src/platform/browser/performance.ts
index 2287803e65..e07b4ffb60 100644
--- a/packages/opentelemetry-core/src/platform/browser/performance.ts
+++ b/packages/opentelemetry-core/src/platform/browser/performance.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts
index f37897b468..b07b009dee 100644
--- a/packages/opentelemetry-core/src/platform/browser/sdk-info.ts
+++ b/packages/opentelemetry-core/src/platform/browser/sdk-info.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/browser/timer-util.ts b/packages/opentelemetry-core/src/platform/browser/timer-util.ts
index 81245de391..2798b6c0dc 100644
--- a/packages/opentelemetry-core/src/platform/browser/timer-util.ts
+++ b/packages/opentelemetry-core/src/platform/browser/timer-util.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,6 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/** This is Node specific, does nothing in case of browser */
export function unrefTimer(timer: number): void {}
diff --git a/packages/opentelemetry-core/src/platform/index.ts b/packages/opentelemetry-core/src/platform/index.ts
index ef7a1e50a8..a12506ffa9 100644
--- a/packages/opentelemetry-core/src/platform/index.ts
+++ b/packages/opentelemetry-core/src/platform/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,8 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// Use the node platform by default. The "browser" field of package.json is used
-// to override this file to use `./browser/index.ts` when packaged with
-// webpack, Rollup, etc.
export * from './node';
diff --git a/packages/opentelemetry-core/src/platform/node/BasePlugin.ts b/packages/opentelemetry-core/src/platform/node/BasePlugin.ts
index df79686802..d1ebc622cf 100644
--- a/packages/opentelemetry-core/src/platform/node/BasePlugin.ts
+++ b/packages/opentelemetry-core/src/platform/node/BasePlugin.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/node/hex-to-base64.ts b/packages/opentelemetry-core/src/platform/node/hex-to-base64.ts
index 1ed62f9cf9..9330aaa91f 100644
--- a/packages/opentelemetry-core/src/platform/node/hex-to-base64.ts
+++ b/packages/opentelemetry-core/src/platform/node/hex-to-base64.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * converts id string into base64
- * @param hexStr - id of span
- */
export function hexToBase64(hexStr: string): string {
const hexStrLen = hexStr.length;
let hexAsciiCharsStr = '';
diff --git a/packages/opentelemetry-core/src/platform/node/id.ts b/packages/opentelemetry-core/src/platform/node/id.ts
index fa4cd6a916..970025385c 100644
--- a/packages/opentelemetry-core/src/platform/node/id.ts
+++ b/packages/opentelemetry-core/src/platform/node/id.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/node/index.ts b/packages/opentelemetry-core/src/platform/node/index.ts
index 71f289fdf5..693bef3145 100644
--- a/packages/opentelemetry-core/src/platform/node/index.ts
+++ b/packages/opentelemetry-core/src/platform/node/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/node/performance.ts b/packages/opentelemetry-core/src/platform/node/performance.ts
index fd94ee83ed..6fbd9b31ff 100644
--- a/packages/opentelemetry-core/src/platform/node/performance.ts
+++ b/packages/opentelemetry-core/src/platform/node/performance.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/node/sdk-info.ts b/packages/opentelemetry-core/src/platform/node/sdk-info.ts
index 33c475d428..0a59c93d33 100644
--- a/packages/opentelemetry-core/src/platform/node/sdk-info.ts
+++ b/packages/opentelemetry-core/src/platform/node/sdk-info.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/platform/node/timer-util.ts b/packages/opentelemetry-core/src/platform/node/timer-util.ts
index 132ba860bc..92668d5ba1 100644
--- a/packages/opentelemetry-core/src/platform/node/timer-util.ts
+++ b/packages/opentelemetry-core/src/platform/node/timer-util.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,11 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * When called, the active Timeout object will not require the Node.js event
- * loop to remain active.
- */
export function unrefTimer(timer: NodeJS.Timeout): void {
timer.unref();
}
diff --git a/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts b/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts
index cf2920ab37..57c91f4108 100644
--- a/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts
+++ b/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/trace/TraceState.ts b/packages/opentelemetry-core/src/trace/TraceState.ts
index 951b04964b..0ef420dbe3 100644
--- a/packages/opentelemetry-core/src/trace/TraceState.ts
+++ b/packages/opentelemetry-core/src/trace/TraceState.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts b/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts
index 04e455e889..d4c7207f34 100644
--- a/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts
+++ b/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/trace/spancontext-utils.ts b/packages/opentelemetry-core/src/trace/spancontext-utils.ts
index 42f91368fd..31719aa6e1 100644
--- a/packages/opentelemetry-core/src/trace/spancontext-utils.ts
+++ b/packages/opentelemetry-core/src/trace/spancontext-utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/utils/url.ts b/packages/opentelemetry-core/src/utils/url.ts
index 8ed779bca2..a6122ae784 100644
--- a/packages/opentelemetry-core/src/utils/url.ts
+++ b/packages/opentelemetry-core/src/utils/url.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Check if {@param url} matches {@param urlToMatch}
- * @param url
- * @param urlToMatch
- */
export function urlMatches(url: string, urlToMatch: string | RegExp): boolean {
if (typeof urlToMatch === 'string') {
return url === urlToMatch;
diff --git a/packages/opentelemetry-core/src/utils/wrap.ts b/packages/opentelemetry-core/src/utils/wrap.ts
index ad3ac6b4c3..b566a78bbf 100644
--- a/packages/opentelemetry-core/src/utils/wrap.ts
+++ b/packages/opentelemetry-core/src/utils/wrap.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/src/version.ts b/packages/opentelemetry-core/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-core/src/version.ts
+++ b/packages/opentelemetry-core/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts b/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts
index f35dfe38e4..b00900e39f 100644
--- a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts
+++ b/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/common/time.test.ts b/packages/opentelemetry-core/test/common/time.test.ts
index 07c404c8c9..bfbace2df3 100644
--- a/packages/opentelemetry-core/test/common/time.test.ts
+++ b/packages/opentelemetry-core/test/common/time.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/context/B3Propagator.test.ts b/packages/opentelemetry-core/test/context/B3Propagator.test.ts
index 7b779c3b94..436033480e 100644
--- a/packages/opentelemetry-core/test/context/B3Propagator.test.ts
+++ b/packages/opentelemetry-core/test/context/B3Propagator.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts
index c82e50b636..aa28e5583e 100644
--- a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts
+++ b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/context/composite.test.ts b/packages/opentelemetry-core/test/context/composite.test.ts
index 080b802154..dce823dfe4 100644
--- a/packages/opentelemetry-core/test/context/composite.test.ts
+++ b/packages/opentelemetry-core/test/context/composite.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/correlation-context/HttpCorrelationContext.test.ts b/packages/opentelemetry-core/test/correlation-context/HttpCorrelationContext.test.ts
index da903819ac..8d294d8362 100644
--- a/packages/opentelemetry-core/test/correlation-context/HttpCorrelationContext.test.ts
+++ b/packages/opentelemetry-core/test/correlation-context/HttpCorrelationContext.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/index-webpack.ts b/packages/opentelemetry-core/test/index-webpack.ts
index 503a7b71dd..47db37c3f9 100644
--- a/packages/opentelemetry-core/test/index-webpack.ts
+++ b/packages/opentelemetry-core/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContextCommon = require.context('.', true, /test$/);
testsContextCommon.keys().forEach(key => {
if (key.indexOf('./platform/BasePlugin.test') >= 0) {
diff --git a/packages/opentelemetry-core/test/internal/validators.test.ts b/packages/opentelemetry-core/test/internal/validators.test.ts
index 9324842624..58dc7b596d 100644
--- a/packages/opentelemetry-core/test/internal/validators.test.ts
+++ b/packages/opentelemetry-core/test/internal/validators.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/platform/BasePlugin.test.ts b/packages/opentelemetry-core/test/platform/BasePlugin.test.ts
index 115c07627c..912d4bc4a1 100644
--- a/packages/opentelemetry-core/test/platform/BasePlugin.test.ts
+++ b/packages/opentelemetry-core/test/platform/BasePlugin.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts b/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts
index f9e08413ee..202d74e350 100644
--- a/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts
+++ b/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/platform/hex-to-base64.test.ts b/packages/opentelemetry-core/test/platform/hex-to-base64.test.ts
index 1165ef7b95..7f78ded3ef 100644
--- a/packages/opentelemetry-core/test/platform/hex-to-base64.test.ts
+++ b/packages/opentelemetry-core/test/platform/hex-to-base64.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/platform/id.test.ts b/packages/opentelemetry-core/test/platform/id.test.ts
index 8c4b7d0dc4..c73e09fb0e 100644
--- a/packages/opentelemetry-core/test/platform/id.test.ts
+++ b/packages/opentelemetry-core/test/platform/id.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts b/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts
index b5855280ed..87bc315c9e 100644
--- a/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts
+++ b/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts b/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts
index c6d7baed45..b7c90c581c 100644
--- a/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts
+++ b/packages/opentelemetry-core/test/trace/ProbabilitySampler.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/trace/fixtures/test-package/foo/bar/internal.d.ts b/packages/opentelemetry-core/test/trace/fixtures/test-package/foo/bar/internal.d.ts
index b2944765fa..59d191849c 100644
--- a/packages/opentelemetry-core/test/trace/fixtures/test-package/foo/bar/internal.d.ts
+++ b/packages/opentelemetry-core/test/trace/fixtures/test-package/foo/bar/internal.d.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts b/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts
index 5ffa807efa..9ac47df565 100644
--- a/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts
+++ b/packages/opentelemetry-core/test/trace/spancontext-utils.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/trace/tracestate.test.ts b/packages/opentelemetry-core/test/trace/tracestate.test.ts
index e59e8a0dca..2fc2a2a13a 100644
--- a/packages/opentelemetry-core/test/trace/tracestate.test.ts
+++ b/packages/opentelemetry-core/test/trace/tracestate.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/utils/url.test.ts b/packages/opentelemetry-core/test/utils/url.test.ts
index 205ec9aa07..8c9582989d 100644
--- a/packages/opentelemetry-core/test/utils/url.test.ts
+++ b/packages/opentelemetry-core/test/utils/url.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-core/test/utils/wrap.test.ts b/packages/opentelemetry-core/test/utils/wrap.test.ts
index eb92e0e799..25ef129718 100644
--- a/packages/opentelemetry-core/test/utils/wrap.test.ts
+++ b/packages/opentelemetry-core/test/utils/wrap.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md
index e046bbddb3..63fa55d13b 100644
--- a/packages/opentelemetry-exporter-collector/README.md
+++ b/packages/opentelemetry-exporter-collector/README.md
@@ -15,14 +15,16 @@ npm install --save @opentelemetry/exporter-collector
```
## Usage in Web
+The CollectorExporter in Web expects the endpoint to end in `/v1/trace`.
```js
import { SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerProvider } from '@opentelemetry/web';
-import { CollectorExporter } from '@opentelemetry/exporter-collector'
+import { CollectorExporter } from '@opentelemetry/exporter-collector';
const collectorOptions = {
- url: '' // url is optional and can be omitted - default is http://localhost:55678/v1/trace
+ url: '', // url is optional and can be omitted - default is http://localhost:55678/v1/trace
+ headers: {}, //an optional object containing custom headers to be sent with each request
};
const provider = new WebTracerProvider();
@@ -34,6 +36,7 @@ provider.register();
```
## Usage in Node
+The CollectorExporter in Node expects the URL to only be the hostname. It will not work with `/v1/trace`.
```js
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
@@ -41,7 +44,7 @@ const { CollectorExporter } = require('@opentelemetry/exporter-collector');
const collectorOptions = {
serviceName: 'basic-service',
- url: '' // url is optional and can be omitted - default is http://localhost:55678/v1/trace
+ url: '' // url is optional and can be omitted - default is localhost:55678
};
const provider = new BasicTracerProvider();
@@ -62,7 +65,7 @@ const { CollectorExporter } = require('@opentelemetry/exporter-collector');
const collectorOptions = {
serviceName: 'basic-service',
- url: '', // url is optional and can be omitted - default is http://localhost:55678/v1/trace
+ url: '', // url is optional and can be omitted - default is localhost:55678
credentials: grpc.credentials.createSsl(
fs.readFileSync('./ca.crt'),
fs.readFileSync('./client.key'),
@@ -79,6 +82,29 @@ provider.register();
To see how to generate credentials, you can refer to the script used to generate certificates for tests [here](./test/certs/regenerate.sh)
+The exporter can be configured to send custom metadata with each request as in the example below:
+
+```js
+const grpc = require('grpc');
+const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
+const { CollectorExporter } = require('@opentelemetry/exporter-collector');
+
+const metadata = new grpc.Metadata();
+metadata.set('k', 'v');
+
+const collectorOptions = {
+ serviceName: 'basic-service',
+ url: '', // url is optional and can be omitted - default is localhost:55678
+ metadata, // // an optional grpc.Metadata object to be sent with each request
+};
+
+const provider = new BasicTracerProvider();
+const exporter = new CollectorExporter(collectorOptions);
+provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
+
+provider.register();
+```
+
Note, that this will only work if TLS is also configured on the server.
## Running opentelemetry-collector locally to see the traces
diff --git a/packages/opentelemetry-exporter-collector/karma.conf.js b/packages/opentelemetry-exporter-collector/karma.conf.js
index 86965a0095..455b1437c8 100644
--- a/packages/opentelemetry-exporter-collector/karma.conf.js
+++ b/packages/opentelemetry-exporter-collector/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json
index 5d25eb5ced..bf9197929f 100644
--- a/packages/opentelemetry-exporter-collector/package.json
+++ b/packages/opentelemetry-exporter-collector/package.json
@@ -63,7 +63,7 @@
"cpx": "1.5.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts
index 1d93318aa4..0e6e052e9d 100644
--- a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts
+++ b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@ export interface CollectorExporterConfigBase {
}
const DEFAULT_SERVICE_NAME = 'collector-exporter';
-const DEFAULT_COLLECTOR_URL = 'http://localhost:55678/v1/trace';
/**
* Collector Exporter abstract base class
@@ -51,7 +50,7 @@ export abstract class CollectorExporterBase<
*/
constructor(config: T = {} as T) {
this.serviceName = config.serviceName || DEFAULT_SERVICE_NAME;
- this.url = config.url || DEFAULT_COLLECTOR_URL;
+ this.url = this.getDefaultUrl(config.url);
if (typeof config.hostName === 'string') {
this.hostName = config.hostName;
}
@@ -135,4 +134,5 @@ export abstract class CollectorExporterBase<
onSuccess: () => void,
onError: (error: CollectorExporterError) => void
): void;
+ abstract getDefaultUrl(url: string | undefined): string;
}
diff --git a/packages/opentelemetry-exporter-collector/src/index.ts b/packages/opentelemetry-exporter-collector/src/index.ts
index 1107c4d288..52ec5f71f5 100644
--- a/packages/opentelemetry-exporter-collector/src/index.ts
+++ b/packages/opentelemetry-exporter-collector/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts
index 28cabeb5f0..5e7f121ac6 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,14 @@ import { ReadableSpan } from '@opentelemetry/tracing';
import { toCollectorExportTraceServiceRequest } from '../../transform';
import * as collectorTypes from '../../types';
-export type CollectorExporterConfig = CollectorExporterConfigBase;
+/**
+ * Collector Exporter Config for Web
+ */
+export interface CollectorExporterConfig extends CollectorExporterConfigBase {
+ headers?: { [key: string]: string };
+}
+
+const DEFAULT_COLLECTOR_URL = 'http://localhost:55678/v1/trace';
/**
* Collector Exporter for Web
@@ -30,6 +37,22 @@ export type CollectorExporterConfig = CollectorExporterConfigBase;
export class CollectorExporter extends CollectorExporterBase<
CollectorExporterConfig
> {
+ DEFAULT_HEADERS: { [key: string]: string } = {
+ [collectorTypes.OT_REQUEST_HEADER]: '1',
+ };
+ private _headers: { [key: string]: string };
+ private _useXHR: boolean = false;
+
+ /**
+ * @param config
+ */
+ constructor(config: CollectorExporterConfig = {}) {
+ super(config);
+ this._headers = config.headers || this.DEFAULT_HEADERS;
+ this._useXHR =
+ !!config.headers || typeof navigator.sendBeacon !== 'function';
+ }
+
onInit(): void {
window.addEventListener('unload', this.shutdown);
}
@@ -38,6 +61,10 @@ export class CollectorExporter extends CollectorExporterBase<
window.removeEventListener('unload', this.shutdown);
}
+ getDefaultUrl(url: string | undefined) {
+ return url || DEFAULT_COLLECTOR_URL;
+ }
+
sendSpans(
spans: ReadableSpan[],
onSuccess: () => void,
@@ -47,13 +74,12 @@ export class CollectorExporter extends CollectorExporterBase<
spans,
this
);
-
const body = JSON.stringify(exportTraceServiceRequest);
- if (typeof navigator.sendBeacon === 'function') {
- this._sendSpansWithBeacon(body, onSuccess, onError);
- } else {
+ if (this._useXHR) {
this._sendSpansWithXhr(body, onSuccess, onError);
+ } else {
+ this._sendSpansWithBeacon(body, onSuccess, onError);
}
}
@@ -91,9 +117,12 @@ export class CollectorExporter extends CollectorExporterBase<
) {
const xhr = new XMLHttpRequest();
xhr.open('POST', this.url);
- xhr.setRequestHeader(collectorTypes.OT_REQUEST_HEADER, '1');
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
+ Object.entries(this._headers).forEach(([k, v]) => {
+ xhr.setRequestHeader(k, v);
+ });
+
xhr.send(body);
xhr.onreadystatechange = () => {
diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/index.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/index.ts
index df00fee615..f38bc0489f 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/browser/index.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/browser/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/platform/index.ts b/packages/opentelemetry-exporter-collector/src/platform/index.ts
index 16f6fd9be2..cdaf8858ce 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/index.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts
index 639d373685..e5c767ecf3 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,11 +29,14 @@ import { toCollectorExportTraceServiceRequest } from '../../transform';
import { GRPCQueueItem, TraceServiceClient } from './types';
import { removeProtocol } from './util';
+const DEFAULT_COLLECTOR_URL = 'localhost:55678';
+
/**
* Collector Exporter Config for Node
*/
export interface CollectorExporterConfig extends CollectorExporterConfigBase {
credentials?: grpc.ChannelCredentials;
+ metadata?: grpc.Metadata;
}
/**
@@ -45,12 +48,14 @@ export class CollectorExporter extends CollectorExporterBase<
isShutDown: boolean = false;
traceServiceClient?: TraceServiceClient = undefined;
grpcSpansQueue: GRPCQueueItem[] = [];
+ metadata?: grpc.Metadata;
/**
* @param config
*/
constructor(config: CollectorExporterConfig = {}) {
super(config);
+ this.metadata = config.metadata;
}
onShutdown(): void {
@@ -113,6 +118,7 @@ export class CollectorExporter extends CollectorExporterBase<
this.traceServiceClient.export(
exportTraceServiceRequest,
+ this.metadata,
(
err: collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceError
) => {
@@ -135,4 +141,8 @@ export class CollectorExporter extends CollectorExporterBase<
});
}
}
+
+ getDefaultUrl(url: string | undefined): string {
+ return url || DEFAULT_COLLECTOR_URL;
+ }
}
diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/index.ts b/packages/opentelemetry-exporter-collector/src/platform/node/index.ts
index df00fee615..f38bc0489f 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/node/index.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/node/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/types.ts b/packages/opentelemetry-exporter-collector/src/platform/node/types.ts
index b36b9a65ad..4674fadf90 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/node/types.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/node/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,5 +32,9 @@ export interface GRPCQueueItem {
* Trace Service Client for sending spans
*/
export interface TraceServiceClient extends grpc.Client {
- export: (request: any, callback: Function) => {};
+ export: (
+ request: any,
+ metadata: grpc.Metadata | undefined,
+ callback: Function
+ ) => {};
}
diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts
index 0aef79ba1c..9ad59d5690 100644
--- a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts
+++ b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * It will remove http or https from the link as grpc requires link without
- * protocol
- * @param url
- */
export function removeProtocol(url: string): string {
return url.replace(/^https?:\/\//, '');
}
diff --git a/packages/opentelemetry-exporter-collector/src/transform.ts b/packages/opentelemetry-exporter-collector/src/transform.ts
index 1e60930c38..8fed306770 100644
--- a/packages/opentelemetry-exporter-collector/src/transform.ts
+++ b/packages/opentelemetry-exporter-collector/src/transform.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/types.ts b/packages/opentelemetry-exporter-collector/src/types.ts
index 96fc2e13c0..ea10b0ca4b 100644
--- a/packages/opentelemetry-exporter-collector/src/types.ts
+++ b/packages/opentelemetry-exporter-collector/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/src/version.ts b/packages/opentelemetry-exporter-collector/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-exporter-collector/src/version.ts
+++ b/packages/opentelemetry-exporter-collector/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorExporter.test.ts
index 539997b8f2..265bf44136 100644
--- a/packages/opentelemetry-exporter-collector/test/browser/CollectorExporter.test.ts
+++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import {
ensureSpanIsCorrect,
ensureExportTraceServiceRequestIsSet,
ensureWebResourceIsCorrect,
+ ensureHeadersContain,
mockedReadableSpan,
} from '../helper';
const sendBeacon = navigator.sendBeacon;
@@ -44,14 +45,6 @@ describe('CollectorExporter - web', () => {
spyOpen = sinon.stub(XMLHttpRequest.prototype, 'open');
spySend = sinon.stub(XMLHttpRequest.prototype, 'send');
spyBeacon = sinon.stub(navigator, 'sendBeacon');
- collectorExporterConfig = {
- hostName: 'foo',
- logger: new NoopLogger(),
- serviceName: 'bar',
- attributes: {},
- url: 'http://foo.bar.com',
- };
- collectorExporter = new CollectorExporter(collectorExporterConfig);
spans = [];
spans.push(Object.assign({}, mockedReadableSpan));
});
@@ -64,7 +57,21 @@ describe('CollectorExporter - web', () => {
});
describe('export', () => {
+ beforeEach(() => {
+ collectorExporterConfig = {
+ hostName: 'foo',
+ logger: new NoopLogger(),
+ serviceName: 'bar',
+ attributes: {},
+ url: 'http://foo.bar.com',
+ };
+ });
+
describe('when "sendBeacon" is available', () => {
+ beforeEach(() => {
+ collectorExporter = new CollectorExporter(collectorExporterConfig);
+ });
+
it('should successfully send the spans using sendBeacon', done => {
collectorExporter.export(spans, () => {});
@@ -139,6 +146,7 @@ describe('CollectorExporter - web', () => {
let server: any;
beforeEach(() => {
(window.navigator as any).sendBeacon = false;
+ collectorExporter = new CollectorExporter(collectorExporterConfig);
server = sinon.fakeServer.create();
});
afterEach(() => {
@@ -216,6 +224,99 @@ describe('CollectorExporter - web', () => {
done();
});
});
+
+ it('should send custom headers', done => {
+ collectorExporter.export(spans, () => {});
+
+ setTimeout(() => {
+ const request = server.requests[0];
+ request.respond(200);
+
+ assert.strictEqual(spyBeacon.callCount, 0);
+ done();
+ });
+ });
+ });
+ });
+
+ describe('export with custom headers', () => {
+ let server: any;
+ const customHeaders = {
+ foo: 'bar',
+ bar: 'baz',
+ };
+
+ beforeEach(() => {
+ collectorExporterConfig = {
+ logger: new NoopLogger(),
+ headers: customHeaders,
+ };
+ server = sinon.fakeServer.create();
+ });
+
+ afterEach(() => {
+ server.restore();
+ });
+
+ describe('when "sendBeacon" is available', () => {
+ beforeEach(() => {
+ collectorExporter = new CollectorExporter(collectorExporterConfig);
+ });
+ it('should successfully send custom headers using XMLHTTPRequest', done => {
+ collectorExporter.export(spans, () => {});
+
+ setTimeout(() => {
+ const [{ requestHeaders }] = server.requests;
+
+ ensureHeadersContain(requestHeaders, customHeaders);
+ assert.strictEqual(spyBeacon.callCount, 0);
+ assert.strictEqual(spyOpen.callCount, 0);
+
+ done();
+ });
+ });
+ });
+
+ describe('when "sendBeacon" is NOT available', () => {
+ beforeEach(() => {
+ (window.navigator as any).sendBeacon = false;
+ collectorExporter = new CollectorExporter(collectorExporterConfig);
+ });
+
+ it('should successfully send spans using XMLHttpRequest', done => {
+ collectorExporter.export(spans, () => {});
+
+ setTimeout(() => {
+ const [{ requestHeaders }] = server.requests;
+
+ ensureHeadersContain(requestHeaders, customHeaders);
+ assert.strictEqual(spyBeacon.callCount, 0);
+ assert.strictEqual(spyOpen.callCount, 0);
+
+ done();
+ });
+ });
+ });
+ });
+});
+
+describe('CollectorExporter - browser (getDefaultUrl)', () => {
+ it('should default to v1/trace', done => {
+ const collectorExporter = new CollectorExporter({});
+ setTimeout(() => {
+ assert.strictEqual(
+ collectorExporter['url'],
+ 'http://localhost:55678/v1/trace'
+ );
+ done();
+ });
+ });
+ it('should keep the URL if included', done => {
+ const url = 'http://foo.bar.com';
+ const collectorExporter = new CollectorExporter({ url });
+ setTimeout(() => {
+ assert.strictEqual(collectorExporter['url'], url);
+ done();
});
});
});
diff --git a/packages/opentelemetry-exporter-collector/test/browser/index-webpack.ts b/packages/opentelemetry-exporter-collector/test/browser/index-webpack.ts
index 9fdb7117a2..99100a0f6e 100644
--- a/packages/opentelemetry-exporter-collector/test/browser/index-webpack.ts
+++ b/packages/opentelemetry-exporter-collector/test/browser/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('../browser', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts b/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts
index 60d482129b..e5d67d67db 100644
--- a/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts
+++ b/packages/opentelemetry-exporter-collector/test/common/CollectorExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,9 @@ class CollectorExporter extends CollectorExporterBase {
onInit() {}
onShutdown() {}
sendSpans() {}
+ getDefaultUrl(url: string | undefined) {
+ return url || '';
+ }
}
describe('CollectorExporter - common', () => {
diff --git a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts
index 266b83aa5c..665ef10391 100644
--- a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts
+++ b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-collector/test/helper.ts b/packages/opentelemetry-exporter-collector/test/helper.ts
index aed78dfb95..4737c66b96 100644
--- a/packages/opentelemetry-exporter-collector/test/helper.ts
+++ b/packages/opentelemetry-exporter-collector/test/helper.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import { Resource } from '@opentelemetry/resources';
import * as assert from 'assert';
import { opentelemetryProto } from '../src/types';
import * as collectorTypes from '../src/types';
+import * as grpc from 'grpc';
if (typeof Buffer === 'undefined') {
(window as any).Buffer = {
@@ -509,3 +510,26 @@ export function ensureExportTraceServiceRequestIsSet(
const spans = instrumentationLibrarySpans[0].spans;
assert.strictEqual(spans && spans.length, 1, 'spans are missing');
}
+
+export function ensureMetadataIsCorrect(
+ actual: grpc.Metadata,
+ expected: grpc.Metadata
+) {
+ //ignore user agent
+ expected.remove('user-agent');
+ actual.remove('user-agent');
+ assert.deepStrictEqual(actual.getMap(), expected.getMap());
+}
+
+export function ensureHeadersContain(
+ actual: { [key: string]: string },
+ expected: { [key: string]: string }
+) {
+ Object.entries(expected).forEach(([k, v]) => {
+ assert.strictEqual(
+ v,
+ actual[k],
+ `Expected ${actual} to contain ${k}: ${v}`
+ );
+ });
+}
diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorExporter.test.ts
index a76e35ea1f..13da3284a2 100644
--- a/packages/opentelemetry-exporter-collector/test/node/CollectorExporter.test.ts
+++ b/packages/opentelemetry-exporter-collector/test/node/CollectorExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@ import * as collectorTypes from '../../src/types';
import {
ensureResourceIsCorrect,
ensureExportedSpanIsCorrect,
+ ensureMetadataIsCorrect,
mockedReadableSpan,
} from '../helper';
@@ -41,18 +42,23 @@ const includeDirs = [path.resolve(__dirname, '../../src/platform/node/protos')];
const address = 'localhost:1501';
type TestParams = {
- useTLS: boolean;
+ useTLS?: boolean;
+ metadata?: grpc.Metadata;
};
+const metadata = new grpc.Metadata();
+metadata.set('k', 'v');
+
const testCollectorExporter = (params: TestParams) =>
describe(`CollectorExporter - node ${
- params.useTLS ? 'with TLS' : ''
- }`, () => {
+ params.useTLS ? 'with' : 'without'
+ } TLS, ${params.metadata ? 'with' : 'without'} metadata`, () => {
let collectorExporter: CollectorExporter;
let server: grpc.Server;
let exportedData:
| collectorTypes.opentelemetryProto.trace.v1.ResourceSpans
| undefined;
+ let reqMetadata: grpc.Metadata | undefined;
before(done => {
server = new grpc.Server();
@@ -75,9 +81,11 @@ const testCollectorExporter = (params: TestParams) =>
{
Export: (data: {
request: collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest;
+ metadata: grpc.Metadata;
}) => {
try {
exportedData = data.request.resourceSpans[0];
+ reqMetadata = data.metadata;
} catch (e) {
exportedData = undefined;
}
@@ -117,6 +125,7 @@ const testCollectorExporter = (params: TestParams) =>
serviceName: 'basic-service',
url: address,
credentials,
+ metadata: params.metadata,
});
const provider = new BasicTracerProvider();
@@ -126,6 +135,7 @@ const testCollectorExporter = (params: TestParams) =>
afterEach(() => {
exportedData = undefined;
+ reqMetadata = undefined;
});
describe('export', () => {
@@ -153,11 +163,33 @@ const testCollectorExporter = (params: TestParams) =>
ensureResourceIsCorrect(resource);
}
}
+ if (params.metadata && reqMetadata) {
+ ensureMetadataIsCorrect(reqMetadata, params.metadata);
+ }
done();
}, 200);
});
});
});
+describe('CollectorExporter - node (getDefaultUrl)', () => {
+ it('should default to localhost', done => {
+ const collectorExporter = new CollectorExporter({});
+ setTimeout(() => {
+ assert.strictEqual(collectorExporter['url'], 'localhost:55678');
+ done();
+ });
+ });
+ it('should keep the URL if included', done => {
+ const url = 'http://foo.bar.com';
+ const collectorExporter = new CollectorExporter({ url });
+ setTimeout(() => {
+ assert.strictEqual(collectorExporter['url'], url);
+ done();
+ });
+ });
+});
+
testCollectorExporter({ useTLS: true });
testCollectorExporter({ useTLS: false });
+testCollectorExporter({ metadata });
diff --git a/packages/opentelemetry-exporter-jaeger/src/index.ts b/packages/opentelemetry-exporter-jaeger/src/index.ts
index 0eeb94aad7..ca7eafd1d7 100644
--- a/packages/opentelemetry-exporter-jaeger/src/index.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts
index a08996ac1d..910bc6d837 100644
--- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/src/transform.ts b/packages/opentelemetry-exporter-jaeger/src/transform.ts
index 668576ce6e..e1ff8d88d2 100644
--- a/packages/opentelemetry-exporter-jaeger/src/transform.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/transform.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts
index b882848e4c..d721b96028 100644
--- a/packages/opentelemetry-exporter-jaeger/src/types.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/src/utils.ts b/packages/opentelemetry-exporter-jaeger/src/utils.ts
index 6e61f4e7bb..ff29a5a525 100644
--- a/packages/opentelemetry-exporter-jaeger/src/utils.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/src/version.ts b/packages/opentelemetry-exporter-jaeger/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-exporter-jaeger/src/version.ts
+++ b/packages/opentelemetry-exporter-jaeger/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
index 926baabdea..4b5d6ff7fe 100644
--- a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
+++ b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-jaeger/test/transform.test.ts b/packages/opentelemetry-exporter-jaeger/test/transform.test.ts
index 58477ad0fb..173ac26010 100644
--- a/packages/opentelemetry-exporter-jaeger/test/transform.test.ts
+++ b/packages/opentelemetry-exporter-jaeger/test/transform.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-prometheus/src/export/types.ts b/packages/opentelemetry-exporter-prometheus/src/export/types.ts
index c3a04f5d53..d4e320ecdb 100644
--- a/packages/opentelemetry-exporter-prometheus/src/export/types.ts
+++ b/packages/opentelemetry-exporter-prometheus/src/export/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-prometheus/src/index.ts b/packages/opentelemetry-exporter-prometheus/src/index.ts
index ff3d57cb44..be7bd5f868 100644
--- a/packages/opentelemetry-exporter-prometheus/src/index.ts
+++ b/packages/opentelemetry-exporter-prometheus/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts
index fa1bdc3a35..e2b23b33a2 100644
--- a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts
+++ b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -191,10 +191,9 @@ export class PrometheusExporter implements MetricExporter {
switch (record.descriptor.metricKind) {
case MetricKind.COUNTER:
- // there is no such thing as a non-monotonic counter in prometheus
- return record.descriptor.monotonic
- ? new Counter(metricObject)
- : new Gauge(metricObject);
+ return new Counter(metricObject);
+ case MetricKind.UP_DOWN_COUNTER:
+ return new Gauge(metricObject);
case MetricKind.OBSERVER:
return new Gauge(metricObject);
default:
diff --git a/packages/opentelemetry-exporter-prometheus/src/version.ts b/packages/opentelemetry-exporter-prometheus/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-exporter-prometheus/src/version.ts
+++ b/packages/opentelemetry-exporter-prometheus/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts b/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts
index 5e1e426862..f0a152e9b2 100644
--- a/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts
+++ b/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -384,10 +384,9 @@ describe('PrometheusExporter', () => {
});
});
- it('should export a non-monotonic counter as a gauge', done => {
- const counter = meter.createCounter('counter', {
+ it('should export a UpDownCounter as a gauge', done => {
+ const counter = meter.createUpDownCounter('counter', {
description: 'a test description',
- monotonic: false,
});
counter.bind({ key1: 'labelValue1' }).add(20);
diff --git a/packages/opentelemetry-exporter-zipkin/src/index.ts b/packages/opentelemetry-exporter-zipkin/src/index.ts
index 36741d5455..9a35ec9d07 100644
--- a/packages/opentelemetry-exporter-zipkin/src/index.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/src/transform.ts b/packages/opentelemetry-exporter-zipkin/src/transform.ts
index b92d3e2f23..aebd956a93 100644
--- a/packages/opentelemetry-exporter-zipkin/src/transform.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/transform.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/src/types.ts b/packages/opentelemetry-exporter-zipkin/src/types.ts
index 7667ef1783..812deed5f2 100644
--- a/packages/opentelemetry-exporter-zipkin/src/types.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/src/utils.ts b/packages/opentelemetry-exporter-zipkin/src/utils.ts
index dc5c69b08d..ff29a5a525 100644
--- a/packages/opentelemetry-exporter-zipkin/src/utils.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/src/version.ts b/packages/opentelemetry-exporter-zipkin/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-exporter-zipkin/src/version.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts
index 5ca0ff7c9d..8d2f72e5f6 100644
--- a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts
+++ b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/test/e2e.test.ts b/packages/opentelemetry-exporter-zipkin/test/e2e.test.ts
index 643a06a74c..96181daa51 100644
--- a/packages/opentelemetry-exporter-zipkin/test/e2e.test.ts
+++ b/packages/opentelemetry-exporter-zipkin/test/e2e.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-exporter-zipkin/test/transform.test.ts b/packages/opentelemetry-exporter-zipkin/test/transform.test.ts
index 0bb180c180..05cbbbfd0d 100644
--- a/packages/opentelemetry-exporter-zipkin/test/transform.test.ts
+++ b/packages/opentelemetry-exporter-zipkin/test/transform.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ const spanContext: api.SpanContext = {
traceFlags: api.TraceFlags.SAMPLED,
};
-const DUMMY_RESOUCE = new Resource({
+const DUMMY_RESOURCE = new Resource({
service: 'ui',
version: 1,
cost: 112.12,
@@ -202,7 +202,7 @@ describe('transform', () => {
span.status,
statusCodeTagName,
statusDescriptionTagName,
- DUMMY_RESOUCE
+ DUMMY_RESOURCE
);
assert.deepStrictEqual(tags, {
diff --git a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
index c4a7a24bc9..813a0a6185 100644
--- a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
+++ b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/BoundInstrument.ts b/packages/opentelemetry-metrics/src/BoundInstrument.ts
index 8f660c3722..dad6ce01ec 100644
--- a/packages/opentelemetry-metrics/src/BoundInstrument.ts
+++ b/packages/opentelemetry-metrics/src/BoundInstrument.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,19 +24,16 @@ import { Aggregator } from './export/types';
export class BaseBoundInstrument {
protected _labels: api.Labels;
protected _logger: api.Logger;
- protected _monotonic: boolean;
constructor(
labels: api.Labels,
logger: api.Logger,
- monotonic: boolean,
private readonly _disabled: boolean,
private readonly _valueType: api.ValueType,
private readonly _aggregator: Aggregator
) {
this._labels = labels;
this._logger = logger;
- this._monotonic = monotonic;
}
update(value: number): void {
@@ -72,18 +69,17 @@ export class BoundCounter extends BaseBoundInstrument
constructor(
labels: api.Labels,
disabled: boolean,
- monotonic: boolean,
valueType: api.ValueType,
logger: api.Logger,
aggregator: Aggregator
) {
- super(labels, logger, monotonic, disabled, valueType, aggregator);
+ super(labels, logger, disabled, valueType, aggregator);
}
add(value: number): void {
- if (this._monotonic && value < 0) {
+ if (value < 0) {
this._logger.error(
- `Monotonic counter cannot descend for ${Object.values(this._labels)}`
+ `Counter cannot descend for ${Object.values(this._labels)}`
);
return;
}
@@ -93,7 +89,29 @@ export class BoundCounter extends BaseBoundInstrument
}
/**
- * BoundValueRecorder is an implementation of the {@link BoundValueRecorder} interface.
+ * BoundUpDownCounter allows the SDK to observe/record a single metric event.
+ * The value of single instrument in the `UpDownCounter` associated with
+ * specified Labels.
+ */
+export class BoundUpDownCounter extends BaseBoundInstrument
+ implements api.BoundCounter {
+ constructor(
+ labels: api.Labels,
+ disabled: boolean,
+ valueType: api.ValueType,
+ logger: api.Logger,
+ aggregator: Aggregator
+ ) {
+ super(labels, logger, disabled, valueType, aggregator);
+ }
+
+ add(value: number): void {
+ this.update(value);
+ }
+}
+
+/**
+ * BoundMeasure is an implementation of the {@link BoundMeasure} interface.
*/
export class BoundValueRecorder extends BaseBoundInstrument
implements api.BoundValueRecorder {
@@ -102,13 +120,12 @@ export class BoundValueRecorder extends BaseBoundInstrument
constructor(
labels: api.Labels,
disabled: boolean,
- monotonic: boolean,
absolute: boolean,
valueType: api.ValueType,
logger: api.Logger,
aggregator: Aggregator
) {
- super(labels, logger, monotonic, disabled, valueType, aggregator);
+ super(labels, logger, disabled, valueType, aggregator);
this._absolute = absolute;
}
@@ -137,11 +154,10 @@ export class BoundObserver extends BaseBoundInstrument {
constructor(
labels: api.Labels,
disabled: boolean,
- monotonic: boolean,
valueType: api.ValueType,
logger: api.Logger,
aggregator: Aggregator
) {
- super(labels, logger, monotonic, disabled, valueType, aggregator);
+ super(labels, logger, disabled, valueType, aggregator);
}
}
diff --git a/packages/opentelemetry-metrics/src/Meter.ts b/packages/opentelemetry-metrics/src/Meter.ts
index dd760cc5a2..a632befae6 100644
--- a/packages/opentelemetry-metrics/src/Meter.ts
+++ b/packages/opentelemetry-metrics/src/Meter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@ import * as api from '@opentelemetry/api';
import { ConsoleLogger } from '@opentelemetry/core';
import { Resource } from '@opentelemetry/resources';
import { BaseBoundInstrument } from './BoundInstrument';
+import { UpDownCounterMetric } from './UpDownCounterMetric';
import {
Metric,
CounterMetric,
@@ -72,10 +73,9 @@ export class Meter implements api.Meter {
return api.NOOP_VALUE_RECORDER_METRIC;
}
const opt: MetricOptions = {
- absolute: true, // value recorders are defined as absolute by default
- monotonic: false, // not applicable to value recorder, set to false
logger: this._logger,
...DEFAULT_METRIC_OPTIONS,
+ absolute: true, // value recorders are defined as absolute by default
...options,
};
@@ -104,8 +104,6 @@ export class Meter implements api.Meter {
return api.NOOP_COUNTER_METRIC;
}
const opt: MetricOptions = {
- monotonic: true, // Counters are defined as monotonic by default
- absolute: false, // not applicable to counter, set to false
logger: this._logger,
...DEFAULT_METRIC_OPTIONS,
...options,
@@ -115,6 +113,41 @@ export class Meter implements api.Meter {
return counter;
}
+ /**
+ * Creates a new `UpDownCounter` metric. UpDownCounter is a synchronous
+ * instrument and very similar to Counter except that Add(increment)
+ * supports negative increments. It is generally useful for capturing changes
+ * in an amount of resources used, or any quantity that rises and falls
+ * during a request.
+ *
+ * @param name the name of the metric.
+ * @param [options] the metric options.
+ */
+ createUpDownCounter(
+ name: string,
+ options?: api.MetricOptions
+ ): api.UpDownCounter {
+ if (!this._isValidName(name)) {
+ this._logger.warn(
+ `Invalid metric name ${name}. Defaulting to noop metric implementation.`
+ );
+ return api.NOOP_COUNTER_METRIC;
+ }
+ const opt: MetricOptions = {
+ logger: this._logger,
+ ...DEFAULT_METRIC_OPTIONS,
+ ...options,
+ };
+ const upDownCounter = new UpDownCounterMetric(
+ name,
+ opt,
+ this._batcher,
+ this._resource
+ );
+ this._registerMetric(name, upDownCounter);
+ return upDownCounter;
+ }
+
/**
* Creates a new observer metric.
* @param name the name of the metric.
@@ -128,8 +161,6 @@ export class Meter implements api.Meter {
return api.NOOP_OBSERVER_METRIC;
}
const opt: MetricOptions = {
- monotonic: false, // Observers are defined as non-monotonic by default
- absolute: false, // not applicable to observer, set to false
logger: this._logger,
...DEFAULT_METRIC_OPTIONS,
...options,
@@ -188,7 +219,8 @@ export class Meter implements api.Meter {
*
* 2. The first character must be non-numeric, non-space, non-punctuation
*
- * 3. Subsequent characters must be belong to the alphanumeric characters, '_', '.', and '-'.
+ * 3. Subsequent characters must be belong to the alphanumeric characters,
+ * '_', '.', and '-'.
*
* Names are case insensitive
*
diff --git a/packages/opentelemetry-metrics/src/MeterProvider.ts b/packages/opentelemetry-metrics/src/MeterProvider.ts
index 0315a76e35..ae8ef64539 100644
--- a/packages/opentelemetry-metrics/src/MeterProvider.ts
+++ b/packages/opentelemetry-metrics/src/MeterProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts
index 09aa518028..a446e4ddc4 100644
--- a/packages/opentelemetry-metrics/src/Metric.ts
+++ b/packages/opentelemetry-metrics/src/Metric.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,6 @@ import { hashLabels } from './Utils';
/** This is a SDK implementation of {@link Metric} interface. */
export abstract class Metric
implements api.UnboundMetric {
- protected readonly _monotonic: boolean;
protected readonly _disabled: boolean;
protected readonly _valueType: api.ValueType;
protected readonly _logger: api.Logger;
@@ -44,7 +43,6 @@ export abstract class Metric
private readonly _kind: MetricKind,
readonly resource: Resource
) {
- this._monotonic = _options.monotonic;
this._disabled = _options.disabled;
this._valueType = _options.valueType;
this._logger = _options.logger;
@@ -98,7 +96,6 @@ export abstract class Metric
unit: this._options.unit,
metricKind: this._kind,
valueType: this._valueType,
- monotonic: this._monotonic,
};
}
@@ -119,7 +116,6 @@ export class CounterMetric extends Metric implements api.Counter {
return new BoundCounter(
labels,
this._disabled,
- this._monotonic,
this._valueType,
this._logger,
// @todo: consider to set to CounterSumAggregator always.
@@ -130,8 +126,8 @@ export class CounterMetric extends Metric implements api.Counter {
/**
* Adds the given value to the current value. Values cannot be negative.
* @param value the value to add.
- * @param [labels = {}] key-values pairs that are associated with a specific metric
- * that you want to record.
+ * @param [labels = {}] key-values pairs that are associated with a specific
+ * metric that you want to record.
*/
add(value: number, labels: api.Labels = {}) {
this.bind(labels).add(value);
@@ -156,7 +152,6 @@ export class ValueRecorderMetric extends Metric
return new BoundValueRecorder(
labels,
this._disabled,
- this._monotonic,
this._absolute,
this._valueType,
this._logger,
@@ -187,7 +182,6 @@ export class ObserverMetric extends Metric
return new BoundObserver(
labels,
this._disabled,
- this._monotonic,
this._valueType,
this._logger,
this._batcher.aggregatorFor(this._descriptor)
diff --git a/packages/opentelemetry-metrics/src/MetricObservable.ts b/packages/opentelemetry-metrics/src/MetricObservable.ts
index cd52774743..f6c751a1e9 100644
--- a/packages/opentelemetry-metrics/src/MetricObservable.ts
+++ b/packages/opentelemetry-metrics/src/MetricObservable.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/ObserverResult.ts b/packages/opentelemetry-metrics/src/ObserverResult.ts
index 2ed593351d..32793dcc9c 100644
--- a/packages/opentelemetry-metrics/src/ObserverResult.ts
+++ b/packages/opentelemetry-metrics/src/ObserverResult.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts
new file mode 100644
index 0000000000..3618ec2f50
--- /dev/null
+++ b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts
@@ -0,0 +1,55 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as api from '@opentelemetry/api';
+import { Resource } from '@opentelemetry/resources';
+import { BoundUpDownCounter } from './BoundInstrument';
+import { MetricOptions } from './types';
+import { MetricKind } from './export/types';
+import { Batcher } from './export/Batcher';
+import { Metric } from './Metric';
+
+/** This is a SDK implementation of UpDownCounter Metric. */
+export class UpDownCounterMetric extends Metric
+ implements api.UpDownCounter {
+ constructor(
+ name: string,
+ options: MetricOptions,
+ private readonly _batcher: Batcher,
+ resource: Resource
+ ) {
+ super(name, options, MetricKind.UP_DOWN_COUNTER, resource);
+ }
+ protected _makeInstrument(labels: api.Labels): BoundUpDownCounter {
+ return new BoundUpDownCounter(
+ labels,
+ this._disabled,
+ this._valueType,
+ this._logger,
+ this._batcher.aggregatorFor(this._descriptor)
+ );
+ }
+
+ /**
+ * Adds the given value to the current value. Values cannot be negative.
+ * @param value the value to add.
+ * @param [labels = {}] key-values pairs that are associated with a specific
+ * metric that you want to record.
+ */
+ add(value: number, labels: api.Labels = {}) {
+ this.bind(labels).add(value);
+ }
+}
diff --git a/packages/opentelemetry-metrics/src/Utils.ts b/packages/opentelemetry-metrics/src/Utils.ts
index 4b94defa89..de9e9eabfa 100644
--- a/packages/opentelemetry-metrics/src/Utils.ts
+++ b/packages/opentelemetry-metrics/src/Utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/Batcher.ts b/packages/opentelemetry-metrics/src/export/Batcher.ts
index 8b3dfa5392..de7d32c1fe 100644
--- a/packages/opentelemetry-metrics/src/export/Batcher.ts
+++ b/packages/opentelemetry-metrics/src/export/Batcher.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,6 +55,7 @@ export class UngroupedBatcher extends Batcher {
aggregatorFor(metricDescriptor: MetricDescriptor): Aggregator {
switch (metricDescriptor.metricKind) {
case MetricKind.COUNTER:
+ case MetricKind.UP_DOWN_COUNTER:
return new CounterSumAggregator();
case MetricKind.OBSERVER:
return new ObserverAggregator();
diff --git a/packages/opentelemetry-metrics/src/export/ConsoleMetricExporter.ts b/packages/opentelemetry-metrics/src/export/ConsoleMetricExporter.ts
index 90f2f6be5d..9f0d83eb39 100644
--- a/packages/opentelemetry-metrics/src/export/ConsoleMetricExporter.ts
+++ b/packages/opentelemetry-metrics/src/export/ConsoleMetricExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/Controller.ts b/packages/opentelemetry-metrics/src/export/Controller.ts
index 5ce3d0ee68..0b63ba12cf 100644
--- a/packages/opentelemetry-metrics/src/export/Controller.ts
+++ b/packages/opentelemetry-metrics/src/export/Controller.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/NoopExporter.ts b/packages/opentelemetry-metrics/src/export/NoopExporter.ts
index 05b3694939..ef748753b7 100644
--- a/packages/opentelemetry-metrics/src/export/NoopExporter.ts
+++ b/packages/opentelemetry-metrics/src/export/NoopExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/aggregators/ValueRecorderExact.ts b/packages/opentelemetry-metrics/src/export/aggregators/ValueRecorderExact.ts
index 0e70a5792e..5603ee45e7 100644
--- a/packages/opentelemetry-metrics/src/export/aggregators/ValueRecorderExact.ts
+++ b/packages/opentelemetry-metrics/src/export/aggregators/ValueRecorderExact.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/aggregators/countersum.ts b/packages/opentelemetry-metrics/src/export/aggregators/countersum.ts
index 6b1fdc1ee9..182e61ccb4 100644
--- a/packages/opentelemetry-metrics/src/export/aggregators/countersum.ts
+++ b/packages/opentelemetry-metrics/src/export/aggregators/countersum.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/aggregators/histogram.ts b/packages/opentelemetry-metrics/src/export/aggregators/histogram.ts
index 52755804c9..655afd8ff7 100644
--- a/packages/opentelemetry-metrics/src/export/aggregators/histogram.ts
+++ b/packages/opentelemetry-metrics/src/export/aggregators/histogram.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/aggregators/index.ts b/packages/opentelemetry-metrics/src/export/aggregators/index.ts
index 7d1bd01d7d..a46b10a624 100644
--- a/packages/opentelemetry-metrics/src/export/aggregators/index.ts
+++ b/packages/opentelemetry-metrics/src/export/aggregators/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/aggregators/observer.ts b/packages/opentelemetry-metrics/src/export/aggregators/observer.ts
index d1ba176c30..90b193896a 100644
--- a/packages/opentelemetry-metrics/src/export/aggregators/observer.ts
+++ b/packages/opentelemetry-metrics/src/export/aggregators/observer.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/src/export/types.ts b/packages/opentelemetry-metrics/src/export/types.ts
index a07ca8224e..94e6e57c0a 100644
--- a/packages/opentelemetry-metrics/src/export/types.ts
+++ b/packages/opentelemetry-metrics/src/export/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -82,7 +82,6 @@ export interface MetricDescriptor {
readonly unit: string;
readonly metricKind: MetricKind;
readonly valueType: ValueType;
- readonly monotonic: boolean;
}
/**
diff --git a/packages/opentelemetry-metrics/src/index.ts b/packages/opentelemetry-metrics/src/index.ts
index 6cb01ff9a8..cf3eff3026 100644
--- a/packages/opentelemetry-metrics/src/index.ts
+++ b/packages/opentelemetry-metrics/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,3 +22,4 @@ export * from './MetricObservable';
export * from './export/aggregators';
export * from './export/ConsoleMetricExporter';
export * from './export/types';
+export * from './UpDownCounterMetric';
diff --git a/packages/opentelemetry-metrics/src/types.ts b/packages/opentelemetry-metrics/src/types.ts
index 6f0fea05e7..ab05a53e83 100644
--- a/packages/opentelemetry-metrics/src/types.ts
+++ b/packages/opentelemetry-metrics/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,10 +37,7 @@ export interface MetricOptions {
/** Indicates the metric is a verbose metric that is disabled by default. */
disabled: boolean;
- /** Monotonic metrics may only increase. */
- monotonic: boolean;
-
- /** (ValueRecorder only) Asserts that this metric will only accept non-negative values. */
+ /** (Measure only) Asserts that this metric will only accept non-negative values. */
absolute: boolean;
/** User provided logger. */
@@ -79,6 +76,7 @@ export const DEFAULT_CONFIG = {
/** The default metric creation options value. */
export const DEFAULT_METRIC_OPTIONS = {
disabled: false,
+ absolute: false,
description: '',
unit: '1',
valueType: ValueType.DOUBLE,
diff --git a/packages/opentelemetry-metrics/src/version.ts b/packages/opentelemetry-metrics/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-metrics/src/version.ts
+++ b/packages/opentelemetry-metrics/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/test/Batcher.test.ts b/packages/opentelemetry-metrics/test/Batcher.test.ts
index a295883cc6..b5daf3b454 100644
--- a/packages/opentelemetry-metrics/test/Batcher.test.ts
+++ b/packages/opentelemetry-metrics/test/Batcher.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts
index a71c82b41f..5efdbb3499 100644
--- a/packages/opentelemetry-metrics/test/Meter.test.ts
+++ b/packages/opentelemetry-metrics/test/Meter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import {
Aggregator,
MetricObservable,
MetricDescriptor,
+ UpDownCounterMetric,
} from '../src';
import * as api from '@opentelemetry/api';
import { NoopLogger, hrTime, hrTimeToNanoseconds } from '@opentelemetry/core';
@@ -66,7 +67,6 @@ describe('Meter', () => {
description: 'desc',
unit: '1',
disabled: false,
- monotonic: false,
});
assert.ok(counter instanceof Metric);
});
@@ -97,7 +97,6 @@ describe('Meter', () => {
description: 'desc',
unit: '1',
disabled: false,
- monotonic: true,
});
counter.add(1);
meter.collect();
@@ -136,7 +135,7 @@ describe('Meter', () => {
assert.strictEqual(boundCounter.getLabels(), labels);
});
- it('should add positive values by default', () => {
+ it('should add positive values only', () => {
const counter = meter.createCounter('name') as CounterMetric;
const boundCounter = counter.bind(labels);
boundCounter.add(10);
@@ -160,17 +159,6 @@ describe('Meter', () => {
assert.strictEqual(record1.aggregator.toPoint().value, 0);
});
- it('should add negative value when monotonic is set to false', () => {
- const counter = meter.createCounter('name', {
- monotonic: false,
- }) as CounterMetric;
- const boundCounter = counter.bind(labels);
- boundCounter.add(-10);
- meter.collect();
- const [record1] = meter.getBatcher().checkPointSet();
- assert.strictEqual(record1.aggregator.toPoint().value, -10);
- });
-
it('should return same instrument on same label values', () => {
const counter = meter.createCounter('name') as CounterMetric;
const boundCounter = counter.bind(labels);
@@ -229,7 +217,201 @@ describe('Meter', () => {
assert.deepStrictEqual(record[0].descriptor, {
description: '',
metricKind: MetricKind.COUNTER,
- monotonic: true,
+ name: 'name1',
+ unit: '1',
+ valueType: ValueType.DOUBLE,
+ });
+ assert.strictEqual(record[0].aggregator.toPoint().value, 10);
+ });
+ });
+
+ describe('names', () => {
+ it('should create counter with valid names', () => {
+ const counter1 = meter.createCounter('name1');
+ const counter2 = meter.createCounter(
+ 'Name_with-all.valid_CharacterClasses'
+ );
+ assert.ok(counter1 instanceof CounterMetric);
+ assert.ok(counter2 instanceof CounterMetric);
+ });
+
+ it('should return no op metric if name is an empty string', () => {
+ const counter = meter.createCounter('');
+ assert.ok(counter instanceof api.NoopMetric);
+ });
+
+ it('should return no op metric if name does not start with a letter', () => {
+ const counter1 = meter.createCounter('1name');
+ const counter_ = meter.createCounter('_name');
+ assert.ok(counter1 instanceof api.NoopMetric);
+ assert.ok(counter_ instanceof api.NoopMetric);
+ });
+
+ it('should return no op metric if name is an empty string contain only letters, numbers, ".", "_", and "-"', () => {
+ const counter = meter.createCounter('name with invalid characters^&*(');
+ assert.ok(counter instanceof api.NoopMetric);
+ });
+ });
+ });
+
+ describe('#UpDownCounter', () => {
+ const performanceTimeOrigin = hrTime();
+
+ it('should create a UpDownCounter', () => {
+ const upDownCounter = meter.createUpDownCounter('name');
+ assert.ok(upDownCounter instanceof Metric);
+ });
+
+ it('should create a UpDownCounter with options', () => {
+ const upDownCounter = meter.createUpDownCounter('name', {
+ description: 'desc',
+ unit: '1',
+ disabled: false,
+ });
+ assert.ok(upDownCounter instanceof Metric);
+ });
+
+ it('should be able to call add() directly on UpDownCounter', () => {
+ const upDownCounter = meter.createUpDownCounter('name');
+ upDownCounter.add(10, labels);
+ meter.collect();
+ const [record1] = meter.getBatcher().checkPointSet();
+
+ assert.strictEqual(record1.aggregator.toPoint().value, 10);
+ const lastTimestamp = record1.aggregator.toPoint().timestamp;
+ assert.ok(
+ hrTimeToNanoseconds(lastTimestamp) >
+ hrTimeToNanoseconds(performanceTimeOrigin)
+ );
+ upDownCounter.add(10, labels);
+ assert.strictEqual(record1.aggregator.toPoint().value, 20);
+
+ assert.ok(
+ hrTimeToNanoseconds(record1.aggregator.toPoint().timestamp) >
+ hrTimeToNanoseconds(lastTimestamp)
+ );
+ });
+
+ it('should be able to call add with no labels', () => {
+ const upDownCounter = meter.createUpDownCounter('name', {
+ description: 'desc',
+ unit: '1',
+ disabled: false,
+ });
+ upDownCounter.add(1);
+ meter.collect();
+ const [record1] = meter.getBatcher().checkPointSet();
+ assert.strictEqual(record1.aggregator.toPoint().value, 1);
+ });
+
+ it('should pipe through resource', () => {
+ const upDownCounter = meter.createUpDownCounter(
+ 'name'
+ ) as UpDownCounterMetric;
+ assert.ok(upDownCounter.resource instanceof Resource);
+
+ upDownCounter.add(1, { foo: 'bar' });
+
+ const [record] = upDownCounter.getMetricRecord();
+ assert.ok(record.resource instanceof Resource);
+ });
+
+ describe('.bind()', () => {
+ it('should create a UpDownCounter instrument', () => {
+ const upDownCounter = meter.createUpDownCounter('name');
+ const boundCounter = upDownCounter.bind(labels);
+ boundCounter.add(10);
+ meter.collect();
+ const [record1] = meter.getBatcher().checkPointSet();
+
+ assert.strictEqual(record1.aggregator.toPoint().value, 10);
+ boundCounter.add(-200);
+ assert.strictEqual(record1.aggregator.toPoint().value, -190);
+ });
+
+ it('should return the aggregator', () => {
+ const upDownCounter = meter.createUpDownCounter(
+ 'name'
+ ) as UpDownCounterMetric;
+ const boundCounter = upDownCounter.bind(labels);
+ boundCounter.add(20);
+ assert.ok(boundCounter.getAggregator() instanceof CounterSumAggregator);
+ assert.strictEqual(boundCounter.getLabels(), labels);
+ });
+
+ it('should not add the instrument data when disabled', () => {
+ const upDownCounter = meter.createUpDownCounter('name', {
+ disabled: true,
+ });
+ const boundCounter = upDownCounter.bind(labels);
+ boundCounter.add(10);
+ meter.collect();
+ const [record1] = meter.getBatcher().checkPointSet();
+ assert.strictEqual(record1.aggregator.toPoint().value, 0);
+ });
+
+ it('should return same instrument on same label values', () => {
+ const upDownCounter = meter.createUpDownCounter('name');
+ const boundCounter = upDownCounter.bind(labels);
+ boundCounter.add(10);
+ const boundCounter1 = upDownCounter.bind(labels);
+ boundCounter1.add(10);
+ meter.collect();
+ const [record1] = meter.getBatcher().checkPointSet();
+
+ assert.strictEqual(record1.aggregator.toPoint().value, 20);
+ assert.strictEqual(boundCounter, boundCounter1);
+ });
+ });
+
+ describe('.unbind()', () => {
+ it('should remove a UpDownCounter instrument', () => {
+ const upDownCounter = meter.createUpDownCounter(
+ 'name'
+ ) as UpDownCounterMetric;
+ const boundCounter = upDownCounter.bind(labels);
+ assert.strictEqual(upDownCounter['_instruments'].size, 1);
+ upDownCounter.unbind(labels);
+ assert.strictEqual(upDownCounter['_instruments'].size, 0);
+ const boundCounter1 = upDownCounter.bind(labels);
+ assert.strictEqual(upDownCounter['_instruments'].size, 1);
+ assert.notStrictEqual(boundCounter, boundCounter1);
+ });
+
+ it('should not fail when removing non existing instrument', () => {
+ const upDownCounter = meter.createUpDownCounter('name');
+ upDownCounter.unbind({});
+ });
+
+ it('should clear all instruments', () => {
+ const upDownCounter = meter.createUpDownCounter(
+ 'name'
+ ) as CounterMetric;
+ upDownCounter.bind(labels);
+ assert.strictEqual(upDownCounter['_instruments'].size, 1);
+ upDownCounter.clear();
+ assert.strictEqual(upDownCounter['_instruments'].size, 0);
+ });
+ });
+
+ describe('.registerMetric()', () => {
+ it('skip already registered Metric', () => {
+ const counter1 = meter.createCounter('name1') as CounterMetric;
+ counter1.bind(labels).add(10);
+
+ // should skip below metric
+ const counter2 = meter.createCounter('name1', {
+ valueType: api.ValueType.INT,
+ }) as CounterMetric;
+ counter2.bind(labels).add(500);
+
+ meter.collect();
+ const record = meter.getBatcher().checkPointSet();
+
+ assert.strictEqual(record.length, 1);
+ assert.deepStrictEqual(record[0].descriptor, {
+ description: '',
+ metricKind: MetricKind.COUNTER,
name: 'name1',
unit: '1',
valueType: ValueType.DOUBLE,
@@ -557,7 +739,6 @@ describe('Meter', () => {
name: 'counter',
description: 'test',
metricKind: MetricKind.COUNTER,
- monotonic: true,
unit: '1',
valueType: ValueType.DOUBLE,
});
@@ -584,7 +765,6 @@ describe('Meter', () => {
name: 'counter',
description: 'test',
metricKind: MetricKind.COUNTER,
- monotonic: true,
unit: '1',
valueType: ValueType.INT,
});
@@ -630,5 +810,4 @@ function ensureMetric(metric: MetricRecord) {
assert.strictEqual(descriptor.unit, '1');
assert.strictEqual(descriptor.metricKind, MetricKind.OBSERVER);
assert.strictEqual(descriptor.valueType, ValueType.DOUBLE);
- assert.strictEqual(descriptor.monotonic, false);
}
diff --git a/packages/opentelemetry-metrics/test/MeterProvider.test.ts b/packages/opentelemetry-metrics/test/MeterProvider.test.ts
index 45c54db6bb..7156e12e7c 100644
--- a/packages/opentelemetry-metrics/test/MeterProvider.test.ts
+++ b/packages/opentelemetry-metrics/test/MeterProvider.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts b/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts
index d47bc2981c..08790ea8c5 100644
--- a/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts
+++ b/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,6 @@ describe('ConsoleMetricExporter', () => {
{
description: 'a test description',
metricKind: MetricKind.COUNTER,
- monotonic: true,
name: 'counter',
unit: '1',
valueType: ValueType.DOUBLE,
diff --git a/packages/opentelemetry-metrics/test/export/aggregators/histogram.test.ts b/packages/opentelemetry-metrics/test/export/aggregators/histogram.test.ts
index efb1c6519a..45f6fe80f6 100644
--- a/packages/opentelemetry-metrics/test/export/aggregators/histogram.test.ts
+++ b/packages/opentelemetry-metrics/test/export/aggregators/histogram.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/README.md b/packages/opentelemetry-node/README.md
index df932e2ed1..258e95ff80 100644
--- a/packages/opentelemetry-node/README.md
+++ b/packages/opentelemetry-node/README.md
@@ -102,6 +102,14 @@ const provider = new NodeTracerProvider({
});
```
+### Disable Plugins with Environment Variables
+
+Plugins can be disabled without modifying and redeploying code.
+`OTEL_NO_PATCH_MODULES` accepts a
+comma separated list of module names to disabled specific plugins.
+The names should match what you use to `require` the module into your application.
+For example, `OTEL_NO_PATCH_MODULES=pg,https` will disable the postgres plugin and the https plugin. To disable **all** plugins, set the environment variable to `*`.
+
## Examples
See how to automatically instrument [http](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/http) and [gRPC](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/grpc) using node-sdk.
diff --git a/packages/opentelemetry-node/src/NodeTracerProvider.ts b/packages/opentelemetry-node/src/NodeTracerProvider.ts
index 6d7f51737b..0abe4b9aa2 100644
--- a/packages/opentelemetry-node/src/NodeTracerProvider.ts
+++ b/packages/opentelemetry-node/src/NodeTracerProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/src/config.ts b/packages/opentelemetry-node/src/config.ts
index f9cacf7ec0..65b7630761 100644
--- a/packages/opentelemetry-node/src/config.ts
+++ b/packages/opentelemetry-node/src/config.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/src/index.ts b/packages/opentelemetry-node/src/index.ts
index 665900aefb..bece472ede 100644
--- a/packages/opentelemetry-node/src/index.ts
+++ b/packages/opentelemetry-node/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts b/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts
index be278696a8..1c3a2b3d11 100644
--- a/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts
+++ b/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,17 @@ export enum HookState {
DISABLED,
}
+/**
+ * Environment variable which will contain list of modules to not load corresponding plugins for
+ * e.g.OTEL_NO_PATCH_MODULES=pg,https,mongodb
+ */
+export const ENV_PLUGIN_DISABLED_LIST = 'OTEL_NO_PATCH_MODULES';
+
+/**
+ * Wildcard symbol. If ignore list is set to this, disable all plugins
+ */
+const DISABLE_ALL_PLUGINS = '*';
+
export interface Plugins {
[pluginName: string]: PluginConfig;
}
@@ -46,6 +57,18 @@ function filterPlugins(plugins: Plugins): Plugins {
}, {});
}
+/**
+ * Parse process.env[ENV_PLUGIN_DISABLED_LIST] for a list of modules
+ * not to load corresponding plugins for.
+ */
+function getIgnoreList(): string[] | typeof DISABLE_ALL_PLUGINS {
+ const envIgnoreList: string = process.env[ENV_PLUGIN_DISABLED_LIST] || '';
+ if (envIgnoreList === DISABLE_ALL_PLUGINS) {
+ return envIgnoreList;
+ }
+ return envIgnoreList.split(',').map(v => v.trim());
+}
+
/**
* The PluginLoader class can load instrumentation plugins that use a patch
* mechanism to enable automatic tracing for specific target modules.
@@ -74,6 +97,7 @@ export class PluginLoader {
if (this._hookState === HookState.UNINITIALIZED) {
const pluginsToLoad = filterPlugins(plugins);
const modulesToHook = Object.keys(pluginsToLoad);
+ const modulesToIgnore = getIgnoreList();
// Do not hook require when no module is provided. In this case it is
// not necessary. With skipping this step we lower our footprint in
// customer applications and require-in-the-middle won't show up in CPU
@@ -119,6 +143,21 @@ export class PluginLoader {
version = utils.getPackageVersion(this.logger, baseDir);
}
+ // Skip loading of all modules if '*' is provided
+ if (modulesToIgnore === DISABLE_ALL_PLUGINS) {
+ this.logger.info(
+ `PluginLoader#load: skipped patching module ${name} because all plugins are disabled (${ENV_PLUGIN_DISABLED_LIST})`
+ );
+ return exports;
+ }
+
+ if (modulesToIgnore.includes(name)) {
+ this.logger.info(
+ `PluginLoader#load: skipped patching module ${name} because it was on the ignore list (${ENV_PLUGIN_DISABLED_LIST})`
+ );
+ return exports;
+ }
+
this.logger.info(
`PluginLoader#load: trying to load ${name}@${version}`
);
diff --git a/packages/opentelemetry-node/src/instrumentation/ext-types.d.ts b/packages/opentelemetry-node/src/instrumentation/ext-types.d.ts
index fca4da1a3b..832cb09086 100644
--- a/packages/opentelemetry-node/src/instrumentation/ext-types.d.ts
+++ b/packages/opentelemetry-node/src/instrumentation/ext-types.d.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/src/instrumentation/utils.ts b/packages/opentelemetry-node/src/instrumentation/utils.ts
index 062682e3fb..238096cd06 100644
--- a/packages/opentelemetry-node/src/instrumentation/utils.ts
+++ b/packages/opentelemetry-node/src/instrumentation/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/src/version.ts b/packages/opentelemetry-node/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-node/src/version.ts
+++ b/packages/opentelemetry-node/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts
index 9c65719061..72745c535a 100644
--- a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts
+++ b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts b/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts
index ff977d4ad8..954cf7f8ed 100644
--- a/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts
+++ b/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import {
PluginLoader,
Plugins,
searchPathForTest,
+ ENV_PLUGIN_DISABLED_LIST,
} from '../../src/instrumentation/PluginLoader';
const INSTALLED_PLUGINS_PATH = path.join(__dirname, 'node_modules');
@@ -135,6 +136,10 @@ describe('PluginLoader', () => {
});
describe('.load()', () => {
+ afterEach(() => {
+ delete process.env[ENV_PLUGIN_DISABLED_LIST];
+ });
+
it('sanity check', () => {
// Ensure that module fixtures contain values that we expect.
const simpleModule = require('simple-module');
@@ -152,6 +157,86 @@ describe('PluginLoader', () => {
assert.throws(() => require('nonexistent-module'));
});
+ it('should not load a plugin on the ignore list environment variable', () => {
+ // Set ignore list env var
+ process.env[ENV_PLUGIN_DISABLED_LIST] = 'simple-module';
+ const pluginLoader = new PluginLoader(provider, logger);
+ pluginLoader.load({ ...simplePlugins, ...supportedVersionPlugins });
+
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+
+ const simpleModule = require('simple-module');
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+ assert.strictEqual(simpleModule.value(), 0);
+ assert.strictEqual(simpleModule.name(), 'simple-module');
+
+ const supportedModule = require('supported-module');
+ assert.strictEqual(pluginLoader['_plugins'].length, 1);
+ assert.strictEqual(supportedModule.value(), 1);
+ assert.strictEqual(supportedModule.name(), 'patched-supported-module');
+
+ pluginLoader.unload();
+ });
+
+ it('should not load plugins on the ignore list environment variable', () => {
+ // Set ignore list env var
+ process.env[ENV_PLUGIN_DISABLED_LIST] = 'simple-module,http';
+ const pluginLoader = new PluginLoader(provider, logger);
+ pluginLoader.load({
+ ...simplePlugins,
+ ...supportedVersionPlugins,
+ ...httpPlugins,
+ });
+
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+
+ const simpleModule = require('simple-module');
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+ assert.strictEqual(simpleModule.value(), 0);
+ assert.strictEqual(simpleModule.name(), 'simple-module');
+
+ const httpModule = require('http');
+ assert.ok(httpModule);
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+
+ const supportedModule = require('supported-module');
+ assert.strictEqual(pluginLoader['_plugins'].length, 1);
+ assert.strictEqual(supportedModule.value(), 1);
+ assert.strictEqual(supportedModule.name(), 'patched-supported-module');
+
+ pluginLoader.unload();
+ });
+
+ it('should not load any plugins if ignore list environment variable is set to "*"', () => {
+ // Set ignore list env var
+ process.env[ENV_PLUGIN_DISABLED_LIST] = '*';
+ const pluginLoader = new PluginLoader(provider, logger);
+ pluginLoader.load({
+ ...simplePlugins,
+ ...supportedVersionPlugins,
+ ...httpPlugins,
+ });
+
+ assert.strictEqual(pluginLoader['_plugins'].length, 0);
+
+ const simpleModule = require('simple-module');
+ const httpModule = require('http');
+ const supportedModule = require('supported-module');
+
+ assert.strictEqual(
+ pluginLoader['_plugins'].length,
+ 0,
+ 'No plugins were loaded'
+ );
+ assert.strictEqual(simpleModule.value(), 0);
+ assert.strictEqual(simpleModule.name(), 'simple-module');
+ assert.ok(httpModule);
+ assert.strictEqual(supportedModule.value(), 0);
+ assert.strictEqual(supportedModule.name(), 'supported-module');
+
+ pluginLoader.unload();
+ });
+
it('should load a plugin and patch the target modules', () => {
const pluginLoader = new PluginLoader(provider, logger);
assert.strictEqual(pluginLoader['_plugins'].length, 0);
diff --git a/packages/opentelemetry-node/test/instrumentation/utils.test.ts b/packages/opentelemetry-node/test/instrumentation/utils.test.ts
index 6d76572b76..0f2eb4f7ac 100644
--- a/packages/opentelemetry-node/test/instrumentation/utils.test.ts
+++ b/packages/opentelemetry-node/test/instrumentation/utils.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-node/test/registration.test.ts b/packages/opentelemetry-node/test/registration.test.ts
index a2bb5e6b94..af4f08183c 100644
--- a/packages/opentelemetry-node/test/registration.test.ts
+++ b/packages/opentelemetry-node/test/registration.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-fetch/.eslintignore b/packages/opentelemetry-plugin-fetch/.eslintignore
new file mode 100644
index 0000000000..378eac25d3
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/.eslintignore
@@ -0,0 +1 @@
+build
diff --git a/packages/opentelemetry-plugin-fetch/.eslintrc.js b/packages/opentelemetry-plugin-fetch/.eslintrc.js
new file mode 100644
index 0000000000..9dfe62f9b8
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/.eslintrc.js
@@ -0,0 +1,9 @@
+module.exports = {
+ "env": {
+ "mocha": true,
+ "commonjs": true,
+ "node": true,
+ "browser": true
+ },
+ ...require('../../eslint.config.js')
+}
diff --git a/packages/opentelemetry-plugin-fetch/.npmignore b/packages/opentelemetry-plugin-fetch/.npmignore
new file mode 100644
index 0000000000..9505ba9450
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/.npmignore
@@ -0,0 +1,4 @@
+/bin
+/coverage
+/doc
+/test
diff --git a/packages/opentelemetry-plugin-fetch/LICENSE b/packages/opentelemetry-plugin-fetch/LICENSE
new file mode 100644
index 0000000000..261eeb9e9f
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/opentelemetry-plugin-fetch/README.md b/packages/opentelemetry-plugin-fetch/README.md
new file mode 100644
index 0000000000..cdbbce00e8
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/README.md
@@ -0,0 +1,68 @@
+# OpenTelemetry Fetch Instrumentation for web
+[![Gitter chat][gitter-image]][gitter-url]
+[![NPM Published Version][npm-img]][npm-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![devDependencies][devDependencies-image]][devDependencies-url]
+[![Apache License][license-image]][license-image]
+
+This module provides auto instrumentation for web using fetch.
+
+## Installation
+
+```bash
+npm install --save @opentelemetry/plugin-fetch
+```
+
+## Usage
+
+```js
+'use strict';
+import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
+import { WebTracerProvider } from '@opentelemetry/web';
+import { FetchPlugin } from '@opentelemetry/plugin-fetch';
+import { ZoneContextManager } from '@opentelemetry/context-zone';
+
+const provider = new WebTracerProvider({
+ plugins: [
+ new FetchPlugin(),
+ ],
+});
+
+provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
+
+provider.register({
+ contextManager: new ZoneContextManager(),
+});
+
+// and some test
+
+fetch('http://localhost:8090/fetch.js');
+
+```
+
+## Example Screenshots
+![Screenshot of the running example](images/trace1.png)
+![Screenshot of the running example](images/trace2.png)
+![Screenshot of the running example](images/trace3.png)
+
+See [examples/tracer-web/fetch](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a short example.
+
+## Useful links
+- For more information on OpenTelemetry, visit:
+- For more about OpenTelemetry JavaScript:
+- For help or feedback on this project, join us on [gitter][gitter-url]
+
+## License
+
+Apache 2.0 - See [LICENSE][license-url] for more information.
+
+[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg
+[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE
+[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
+[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-plugin-fetch
+[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-fetch
+[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-plugin-fetch
+[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-fetch&type=dev
+[npm-url]: https://www.npmjs.com/package/@opentelemetry/plugin-fetch
+[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fplugin-fetch.svg
diff --git a/packages/opentelemetry-plugin-fetch/images/trace1.png b/packages/opentelemetry-plugin-fetch/images/trace1.png
new file mode 100644
index 0000000000..f26085537d
Binary files /dev/null and b/packages/opentelemetry-plugin-fetch/images/trace1.png differ
diff --git a/packages/opentelemetry-plugin-fetch/images/trace2.png b/packages/opentelemetry-plugin-fetch/images/trace2.png
new file mode 100644
index 0000000000..0f9130ce8a
Binary files /dev/null and b/packages/opentelemetry-plugin-fetch/images/trace2.png differ
diff --git a/packages/opentelemetry-plugin-fetch/images/trace3.png b/packages/opentelemetry-plugin-fetch/images/trace3.png
new file mode 100644
index 0000000000..e2a602f295
Binary files /dev/null and b/packages/opentelemetry-plugin-fetch/images/trace3.png differ
diff --git a/packages/opentelemetry-plugin-fetch/karma.conf.js b/packages/opentelemetry-plugin-fetch/karma.conf.js
new file mode 100644
index 0000000000..edcd9f055f
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/karma.conf.js
@@ -0,0 +1,24 @@
+/*!
+ * Copyright 2020, OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const karmaWebpackConfig = require('../../karma.webpack');
+const karmaBaseConfig = require('../../karma.base');
+
+module.exports = (config) => {
+ config.set(Object.assign({}, karmaBaseConfig, {
+ webpack: karmaWebpackConfig
+ }))
+};
diff --git a/packages/opentelemetry-plugin-fetch/package.json b/packages/opentelemetry-plugin-fetch/package.json
new file mode 100644
index 0000000000..6a0e3c943a
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/package.json
@@ -0,0 +1,82 @@
+{
+ "name": "@opentelemetry/plugin-fetch",
+ "version": "0.8.3",
+ "description": "OpenTelemetry fetch automatic instrumentation package.",
+ "main": "build/src/index.js",
+ "types": "build/src/index.d.ts",
+ "repository": "open-telemetry/opentelemetry-js",
+ "scripts": {
+ "lint": "eslint . --ext .ts",
+ "lint:fix": "eslint . --ext .ts --fix",
+ "clean": "rimraf build/*",
+ "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
+ "precompile": "tsc --version",
+ "version:update": "node ../../scripts/version-update.js",
+ "compile": "npm run version:update && tsc -p .",
+ "prepare": "npm run compile",
+ "tdd": "karma start",
+ "test:browser": "nyc karma start --single-run",
+ "watch": "tsc -w"
+ },
+ "keywords": [
+ "fetch",
+ "opentelemetry",
+ "browser",
+ "tracing",
+ "profiling",
+ "metrics",
+ "stats"
+ ],
+ "author": "OpenTelemetry Authors",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8.0.0"
+ },
+ "files": [
+ "build/src/**/*.js",
+ "build/src/**/*.d.ts",
+ "doc",
+ "LICENSE",
+ "README.md"
+ ],
+ "publishConfig": {
+ "access": "public"
+ },
+ "devDependencies": {
+ "@babel/core": "7.10.2",
+ "@opentelemetry/context-zone": "^0.8.2",
+ "@opentelemetry/tracing": "^0.8.2",
+ "@types/mocha": "7.0.2",
+ "@types/node": "14.0.13",
+ "@types/shimmer": "1.0.1",
+ "@types/sinon": "7.5.2",
+ "@types/webpack-env": "1.15.2",
+ "babel-loader": "8.1.0",
+ "codecov": "3.7.0",
+ "gts": "2.0.2",
+ "istanbul-instrumenter-loader": "3.0.1",
+ "karma": "5.1.0",
+ "karma-chrome-launcher": "3.1.0",
+ "karma-coverage-istanbul-reporter": "3.0.3",
+ "karma-mocha": "2.0.1",
+ "karma-spec-reporter": "0.0.32",
+ "karma-webpack": "4.0.2",
+ "mocha": "7.2.0",
+ "nyc": "15.1.0",
+ "rimraf": "3.0.2",
+ "sinon": "7.5.0",
+ "ts-loader": "6.2.2",
+ "ts-mocha": "7.0.0",
+ "ts-node": "8.10.2",
+ "typescript": "3.6.4",
+ "webpack": "4.43.0",
+ "webpack-cli": "3.3.11",
+ "webpack-merge": "4.2.2"
+ },
+ "dependencies": {
+ "@opentelemetry/api": "^0.8.3",
+ "@opentelemetry/core": "^0.8.3",
+ "@opentelemetry/web": "^0.8.3",
+ "shimmer": "^1.2.1"
+ }
+}
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/enums/AttributeNames.ts b/packages/opentelemetry-plugin-fetch/src/enums/AttributeNames.ts
similarity index 87%
rename from packages/opentelemetry-plugin-xml-http-request/src/enums/AttributeNames.ts
rename to packages/opentelemetry-plugin-fetch/src/enums/AttributeNames.ts
index 64112652d5..452a1111dd 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/enums/AttributeNames.ts
+++ b/packages/opentelemetry-plugin-fetch/src/enums/AttributeNames.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
/**
- * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#common-attributes
+ * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md
*/
export enum AttributeNames {
COMPONENT = 'component',
@@ -26,6 +26,6 @@ export enum AttributeNames {
HTTP_STATUS_CODE = 'http.status_code',
HTTP_STATUS_TEXT = 'http.status_text',
HTTP_URL = 'http.url',
- // NOT ON OFFICIAL SPEC
+ HTTP_TARGET = 'http.target',
HTTP_USER_AGENT = 'http.user_agent',
}
diff --git a/packages/opentelemetry-plugin-fetch/src/fetch.ts b/packages/opentelemetry-plugin-fetch/src/fetch.ts
new file mode 100644
index 0000000000..cccc7d43f9
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/src/fetch.ts
@@ -0,0 +1,351 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as shimmer from 'shimmer';
+import * as api from '@opentelemetry/api';
+import * as core from '@opentelemetry/core';
+import * as web from '@opentelemetry/web';
+import { AttributeNames } from './enums/AttributeNames';
+import { FetchError, FetchResponse, SpanData } from './types';
+import { VERSION } from './version';
+
+// how long to wait for observer to collect information about resources
+// this is needed as event "load" is called before observer
+// hard to say how long it should really wait, seems like 300ms is
+// safe enough
+const OBSERVER_WAIT_TIME_MS = 300;
+
+/**
+ * FetchPlugin Config
+ */
+export interface FetchPluginConfig extends api.PluginConfig {
+ // the number of timing resources is limited, after the limit
+ // (chrome 250, safari 150) the information is not collected anymore
+ // the only way to prevent that is to regularly clean the resources
+ // whenever it is possible, this is needed only when PerformanceObserver
+ // is not available
+ clearTimingResources?: boolean;
+ // urls which should include trace headers when origin doesn't match
+ propagateTraceHeaderCorsUrls?: web.PropagateTraceHeaderCorsUrls;
+}
+
+/**
+ * This class represents a fetch plugin for auto instrumentation
+ */
+export class FetchPlugin extends core.BasePlugin> {
+ moduleName = 'fetch';
+ private _usedResources = new WeakSet();
+ private _tasksCount = 0;
+
+ constructor(protected _config: FetchPluginConfig = {}) {
+ super('@opentelemetry/plugin-fetch', VERSION);
+ }
+
+ /**
+ * Add cors pre flight child span
+ * @param span
+ * @param corsPreFlightRequest
+ */
+ private _addChildSpan(
+ span: api.Span,
+ corsPreFlightRequest: PerformanceResourceTiming
+ ): void {
+ const childSpan = this._tracer.startSpan('CORS Preflight', {
+ parent: span,
+ startTime: corsPreFlightRequest[web.PerformanceTimingNames.FETCH_START],
+ });
+ web.addSpanNetworkEvents(childSpan, corsPreFlightRequest);
+ childSpan.end(
+ corsPreFlightRequest[web.PerformanceTimingNames.RESPONSE_END]
+ );
+ }
+
+ /**
+ * Adds more attributes to span just before ending it
+ * @param span
+ * @param response
+ */
+ private _addFinalSpanAttributes(
+ span: api.Span,
+ response: FetchResponse
+ ): void {
+ const parsedUrl = web.parseUrl(response.url);
+ span.setAttribute(AttributeNames.HTTP_STATUS_CODE, response.status);
+ span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, response.statusText);
+ span.setAttribute(AttributeNames.HTTP_HOST, parsedUrl.host);
+ span.setAttribute(
+ AttributeNames.HTTP_SCHEME,
+ parsedUrl.protocol.replace(':', '')
+ );
+ span.setAttribute(AttributeNames.HTTP_USER_AGENT, navigator.userAgent);
+ }
+
+ /**
+ * Add headers
+ * @param options
+ * @param spanUrl
+ */
+ private _addHeaders(options: RequestInit, spanUrl: string): void {
+ if (
+ !web.shouldPropagateTraceHeaders(
+ spanUrl,
+ this._config.propagateTraceHeaderCorsUrls
+ )
+ ) {
+ return;
+ }
+ const headers: { [key: string]: unknown } = {};
+ api.propagation.inject(headers);
+ options.headers = Object.assign({}, headers, options.headers || {});
+ }
+
+ /**
+ * Clears the resource timings and all resources assigned with spans
+ * when {@link FetchPluginConfig.clearTimingResources} is
+ * set to true (default false)
+ * @private
+ */
+ private _clearResources() {
+ if (this._tasksCount === 0 && this._config.clearTimingResources) {
+ performance.clearResourceTimings();
+ this._usedResources = new WeakSet();
+ }
+ }
+
+ /**
+ * Creates a new span
+ * @param url
+ * @param options
+ */
+ private _createSpan(
+ url: string,
+ options: Partial = {}
+ ): api.Span | undefined {
+ if (core.isUrlIgnored(url, this._config.ignoreUrls)) {
+ this._logger.debug('ignoring span as url matches ignored url');
+ return;
+ }
+ const method = (options.method || 'GET').toUpperCase();
+ const spanName = `HTTP ${method}`;
+ return this._tracer.startSpan(spanName, {
+ kind: api.SpanKind.CLIENT,
+ attributes: {
+ [AttributeNames.COMPONENT]: this.moduleName,
+ [AttributeNames.HTTP_METHOD]: method,
+ [AttributeNames.HTTP_URL]: url,
+ },
+ });
+ }
+
+ /**
+ * Finds appropriate resource and add network events to the span
+ * @param span
+ * @param resourcesObserver
+ * @param endTime
+ */
+ private _findResourceAndAddNetworkEvents(
+ span: api.Span,
+ resourcesObserver: SpanData,
+ endTime: api.HrTime
+ ): void {
+ let resources: PerformanceResourceTiming[] = resourcesObserver.entries;
+ if (!resources.length) {
+ // fallback - either Observer is not available or it took longer
+ // then OBSERVER_WAIT_TIME_MS and observer didn't collect enough
+ // information
+ resources = performance.getEntriesByType(
+ 'resource'
+ ) as PerformanceResourceTiming[];
+ }
+ const resource = web.getResource(
+ resourcesObserver.spanUrl,
+ resourcesObserver.startTime,
+ endTime,
+ resources,
+ this._usedResources,
+ 'fetch'
+ );
+
+ if (resource.mainRequest) {
+ const mainRequest = resource.mainRequest;
+ this._markResourceAsUsed(mainRequest);
+
+ const corsPreFlightRequest = resource.corsPreFlightRequest;
+ if (corsPreFlightRequest) {
+ this._addChildSpan(span, corsPreFlightRequest);
+ this._markResourceAsUsed(corsPreFlightRequest);
+ }
+ web.addSpanNetworkEvents(span, mainRequest);
+ }
+ }
+
+ /**
+ * Marks certain [resource]{@link PerformanceResourceTiming} when information
+ * from this is used to add events to span.
+ * This is done to avoid reusing the same resource again for next span
+ * @param resource
+ */
+ private _markResourceAsUsed(resource: PerformanceResourceTiming): void {
+ this._usedResources.add(resource);
+ }
+
+ /**
+ * Finish span, add attributes, network events etc.
+ * @param span
+ * @param spanData
+ * @param response
+ */
+ private _endSpan(
+ span: api.Span,
+ spanData: SpanData,
+ response: FetchResponse
+ ) {
+ const endTime = core.hrTime();
+ spanData.observer.disconnect();
+ this._addFinalSpanAttributes(span, response);
+
+ setTimeout(() => {
+ this._findResourceAndAddNetworkEvents(span, spanData, endTime);
+ this._tasksCount--;
+ this._clearResources();
+ span.end(endTime);
+ }, OBSERVER_WAIT_TIME_MS);
+ }
+
+ /**
+ * Patches the constructor of fetch
+ */
+ private _patchConstructor(): (
+ original: (input: RequestInfo, init?: RequestInit) => Promise
+ ) => (input: RequestInfo, init?: RequestInit) => Promise {
+ return (
+ original: (input: RequestInfo, init?: RequestInit) => Promise
+ ): ((input: RequestInfo, init?: RequestInit) => Promise) => {
+ const plugin = this;
+
+ return function patchConstructor(
+ this: (input: RequestInfo, init?: RequestInit) => Promise,
+ input: RequestInfo,
+ init?: RequestInit
+ ): Promise {
+ const url = input instanceof Request ? input.url : input;
+ const options: RequestInit =
+ input instanceof Request ? input : init || {};
+
+ const span = plugin._createSpan(url, options);
+ if (!span) {
+ return original.apply(this, [url, options]);
+ }
+ const spanData = plugin._prepareSpanData(url);
+
+ function onSuccess(
+ span: api.Span,
+ resolve: (
+ value?: Response | PromiseLike | undefined
+ ) => void,
+ response: Response
+ ) {
+ try {
+ if (response.status >= 200 && response.status < 400) {
+ plugin._endSpan(span, spanData, response);
+ } else {
+ plugin._endSpan(span, spanData, {
+ status: response.status,
+ statusText: response.statusText,
+ url,
+ });
+ }
+ } finally {
+ resolve(response);
+ }
+ }
+
+ function onError(
+ span: api.Span,
+ reject: (reason?: unknown) => void,
+ error: FetchError
+ ) {
+ try {
+ plugin._endSpan(span, spanData, {
+ status: error.status || 0,
+ statusText: error.message,
+ url,
+ });
+ } finally {
+ reject(error);
+ }
+ }
+
+ return new Promise((resolve, reject) => {
+ return plugin._tracer.withSpan(span, () => {
+ plugin._addHeaders(options, url);
+ plugin._tasksCount++;
+ return original
+ .apply(this, [url, options])
+ .then(
+ onSuccess.bind(this, span, resolve),
+ onError.bind(this, span, reject)
+ );
+ });
+ });
+ };
+ };
+ }
+
+ /**
+ * Prepares a span data - needed later for matching appropriate network
+ * resources
+ * @param spanUrl
+ */
+ private _prepareSpanData(spanUrl: string): SpanData {
+ const startTime = core.hrTime();
+ const entries: PerformanceResourceTiming[] = [];
+ const observer: PerformanceObserver = new PerformanceObserver(list => {
+ const entries = list.getEntries() as PerformanceResourceTiming[];
+ entries.forEach(entry => {
+ if (entry.initiatorType === 'fetch' && entry.name === spanUrl) {
+ entries.push(entry);
+ }
+ });
+ });
+ observer.observe({
+ entryTypes: ['resource'],
+ });
+ return { entries, observer, startTime, spanUrl };
+ }
+
+ /**
+ * implements patch function
+ */
+ patch() {
+ if (core.isWrapped(window.fetch)) {
+ shimmer.unwrap(window, 'fetch');
+ this._logger.debug('removing previous patch for constructor');
+ }
+
+ shimmer.wrap(window, 'fetch', this._patchConstructor());
+
+ return this._moduleExports;
+ }
+
+ /**
+ * implements unpatch function
+ */
+ unpatch() {
+ shimmer.unwrap(window, 'fetch');
+ this._usedResources = new WeakSet();
+ }
+}
diff --git a/packages/opentelemetry-plugin-fetch/src/index.ts b/packages/opentelemetry-plugin-fetch/src/index.ts
new file mode 100644
index 0000000000..1d39792560
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/src/index.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './fetch';
diff --git a/packages/opentelemetry-plugin-fetch/src/types.ts b/packages/opentelemetry-plugin-fetch/src/types.ts
new file mode 100644
index 0000000000..4144aceaa1
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/src/types.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import * as api from '@opentelemetry/api';
+
+/**
+ * Interface used to provide information to finish span on fetch response
+ */
+export interface FetchResponse {
+ status: number;
+ statusText?: string;
+ url: string;
+}
+
+/**
+ * Interface used to provide information to finish span on fetch error
+ */
+export interface FetchError {
+ status?: number;
+ message: string;
+}
+
+/**
+ * Interface used to keep information about span between creating and
+ * ending span
+ */
+export interface SpanData {
+ entries: PerformanceResourceTiming[];
+ observer: PerformanceObserver;
+ spanUrl: string;
+ startTime: api.HrTime;
+}
diff --git a/packages/opentelemetry-plugin-fetch/src/version.ts b/packages/opentelemetry-plugin-fetch/src/version.ts
new file mode 100644
index 0000000000..9e616149a4
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/src/version.ts
@@ -0,0 +1,18 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// this is autogenerated file, see scripts/version-update.js
+export const VERSION = '0.8.3';
diff --git a/packages/opentelemetry-plugin-fetch/test/fetch.test.ts b/packages/opentelemetry-plugin-fetch/test/fetch.test.ts
new file mode 100644
index 0000000000..cf27f84f40
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/test/fetch.test.ts
@@ -0,0 +1,563 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import * as api from '@opentelemetry/api';
+import * as core from '@opentelemetry/core';
+import { ZoneContextManager } from '@opentelemetry/context-zone';
+import * as tracing from '@opentelemetry/tracing';
+import {
+ PerformanceTimingNames as PTN,
+ WebTracerProvider,
+} from '@opentelemetry/web';
+import * as assert from 'assert';
+import * as sinon from 'sinon';
+import { FetchPlugin, FetchPluginConfig } from '../src';
+import { AttributeNames } from '../src/enums/AttributeNames';
+
+class DummySpanExporter implements tracing.SpanExporter {
+ export(spans: any) {}
+
+ shutdown() {}
+}
+
+const getData = (url: string, method?: string) =>
+ fetch(url, {
+ method: method || 'GET',
+ headers: {
+ foo: 'bar',
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ });
+
+const defaultResource = {
+ connectEnd: 15,
+ connectStart: 13,
+ decodedBodySize: 0,
+ domainLookupEnd: 12,
+ domainLookupStart: 11,
+ encodedBodySize: 0,
+ fetchStart: 10.1,
+ initiatorType: 'fetch',
+ nextHopProtocol: '',
+ redirectEnd: 0,
+ redirectStart: 0,
+ requestStart: 16,
+ responseEnd: 20.5,
+ responseStart: 17,
+ secureConnectionStart: 14,
+ transferSize: 0,
+ workerStart: 0,
+ duration: 0,
+ entryType: '',
+ name: '',
+ startTime: 0,
+};
+
+function createResource(resource = {}): PerformanceResourceTiming {
+ return Object.assign(
+ {},
+ defaultResource,
+ resource
+ ) as PerformanceResourceTiming;
+}
+
+function createMasterResource(resource = {}): PerformanceResourceTiming {
+ const masterResource: any = createResource(resource);
+ Object.keys(masterResource).forEach((key: string) => {
+ if (typeof masterResource[key] === 'number') {
+ masterResource[key] = masterResource[key] + 30;
+ }
+ });
+ return masterResource;
+}
+
+describe('fetch', () => {
+ let sandbox: sinon.SinonSandbox;
+ let contextManager: ZoneContextManager;
+ let lastResponse: any | undefined;
+ let webTracerWithZone: api.Tracer;
+ let webTracerProviderWithZone: WebTracerProvider;
+ let dummySpanExporter: DummySpanExporter;
+ let exportSpy: any;
+ let clearResourceTimingsSpy: any;
+ let rootSpan: api.Span;
+ let fakeNow = 0;
+ let fetchPlugin: FetchPlugin;
+
+ const url = 'http://localhost:8090/get';
+ const badUrl = 'http://foo.bar.com/get';
+
+ const clearData = () => {
+ sandbox.restore();
+ lastResponse = undefined;
+ };
+
+ const prepareData = (
+ done: any,
+ fileUrl: string,
+ config: FetchPluginConfig,
+ method?: string
+ ) => {
+ sandbox = sinon.createSandbox();
+ sandbox.useFakeTimers();
+
+ sandbox.stub(core.otperformance, 'timeOrigin').value(0);
+ sandbox.stub(core.otperformance, 'now').callsFake(() => fakeNow);
+
+ function fakeFetch(input: RequestInfo, init: RequestInit = {}) {
+ return new Promise((resolve, reject) => {
+ const response: any = {
+ args: {},
+ url: fileUrl,
+ };
+ response.headers = Object.assign({}, init.headers);
+
+ if (init.method === 'DELETE') {
+ response.status = 405;
+ response.statusText = 'OK';
+ resolve(new window.Response('foo', response));
+ } else if (input === url) {
+ response.status = 200;
+ response.statusText = 'OK';
+ resolve(new window.Response(JSON.stringify(response), response));
+ } else {
+ response.status = 404;
+ response.statusText = 'Bad request';
+ reject(new window.Response(JSON.stringify(response), response));
+ }
+ });
+ }
+
+ sandbox.stub(window, 'fetch').callsFake(fakeFetch as any);
+
+ const resources: PerformanceResourceTiming[] = [];
+ resources.push(
+ createResource({
+ name: fileUrl,
+ }),
+ createMasterResource({
+ name: fileUrl,
+ })
+ );
+
+ const spyEntries = sandbox.stub(performance, 'getEntriesByType');
+ spyEntries.withArgs('resource').returns(resources);
+ fetchPlugin = new FetchPlugin(config);
+ webTracerProviderWithZone = new WebTracerProvider({
+ logLevel: core.LogLevel.ERROR,
+ plugins: [fetchPlugin],
+ });
+ webTracerWithZone = webTracerProviderWithZone.getTracer('fetch-test');
+ dummySpanExporter = new DummySpanExporter();
+ exportSpy = sandbox.stub(dummySpanExporter, 'export');
+ clearResourceTimingsSpy = sandbox.stub(performance, 'clearResourceTimings');
+ webTracerProviderWithZone.addSpanProcessor(
+ new tracing.SimpleSpanProcessor(dummySpanExporter)
+ );
+
+ rootSpan = webTracerWithZone.startSpan('root');
+ webTracerWithZone.withSpan(rootSpan, () => {
+ fakeNow = 0;
+ getData(fileUrl, method).then(
+ response => {
+ // this is a bit tricky as the only way to get all request headers from
+ // fetch is to use json()
+ response.json().then(
+ json => {
+ lastResponse = json;
+ const headers: { [key: string]: string } = {};
+ Object.keys(lastResponse.headers).forEach(key => {
+ headers[key.toLowerCase()] = lastResponse.headers[key];
+ });
+ lastResponse.headers = headers;
+ // OBSERVER_WAIT_TIME_MS
+ sandbox.clock.tick(300);
+ done();
+ },
+ () => {
+ lastResponse = undefined;
+ // OBSERVER_WAIT_TIME_MS
+ sandbox.clock.tick(300);
+ done();
+ }
+ );
+ },
+ () => {
+ lastResponse = undefined;
+ // OBSERVER_WAIT_TIME_MS
+ sandbox.clock.tick(300);
+ done();
+ }
+ );
+ fakeNow = 300;
+ });
+ };
+
+ beforeEach(() => {
+ contextManager = new ZoneContextManager().enable();
+ api.context.setGlobalContextManager(contextManager);
+ });
+
+ afterEach(() => {
+ api.context.disable();
+ });
+
+ before(() => {
+ api.propagation.setGlobalPropagator(new core.B3Propagator());
+ });
+
+ describe('when request is successful', () => {
+ beforeEach(done => {
+ const propagateTraceHeaderCorsUrls = [url];
+ prepareData(done, url, { propagateTraceHeaderCorsUrls });
+ });
+
+ afterEach(() => {
+ clearData();
+ });
+
+ it('should wrap methods', () => {
+ assert.ok(core.isWrapped(window.fetch));
+ fetchPlugin.patch();
+ assert.ok(core.isWrapped(window.fetch));
+ });
+
+ it('should unwrap methods', () => {
+ assert.ok(core.isWrapped(window.fetch));
+ fetchPlugin.unpatch();
+ assert.ok(!core.isWrapped(window.fetch));
+ });
+
+ it('should create a span with correct root span', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(
+ span.parentSpanId,
+ rootSpan.context().spanId,
+ 'parent span is not root span'
+ );
+ });
+
+ it('span should have correct name', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(span.name, 'HTTP GET', 'span has wrong name');
+ });
+
+ it('span should have correct kind', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(span.kind, api.SpanKind.CLIENT, 'span has wrong kind');
+ });
+
+ it('span should have correct attributes', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ const attributes = span.attributes;
+ const keys = Object.keys(attributes);
+
+ assert.ok(
+ attributes[keys[0]] !== '',
+ `attributes ${AttributeNames.COMPONENT} is not defined`
+ );
+ assert.strictEqual(
+ attributes[keys[1]],
+ 'GET',
+ `attributes ${AttributeNames.HTTP_METHOD} is wrong`
+ );
+ assert.strictEqual(
+ attributes[keys[2]],
+ url,
+ `attributes ${AttributeNames.HTTP_URL} is wrong`
+ );
+ assert.strictEqual(
+ attributes[keys[3]],
+ 200,
+ `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong`
+ );
+ assert.ok(
+ attributes[keys[4]] === 'OK' || attributes[keys[4]] === '',
+ `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong`
+ );
+ assert.ok(
+ (attributes[keys[5]] as string).indexOf('localhost') === 0,
+ `attributes ${AttributeNames.HTTP_HOST} is wrong`
+ );
+ assert.ok(
+ attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https',
+ `attributes ${AttributeNames.HTTP_SCHEME} is wrong`
+ );
+ assert.ok(
+ attributes[keys[7]] !== '',
+ `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined`
+ );
+
+ assert.strictEqual(keys.length, 8, 'number of attributes is wrong');
+ });
+
+ it('span should have correct events', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ const events = span.events;
+ assert.strictEqual(events.length, 9, 'number of events is wrong');
+
+ assert.strictEqual(
+ events[0].name,
+ PTN.FETCH_START,
+ `event ${PTN.FETCH_START} is not defined`
+ );
+ assert.strictEqual(
+ events[1].name,
+ PTN.DOMAIN_LOOKUP_START,
+ `event ${PTN.DOMAIN_LOOKUP_START} is not defined`
+ );
+ assert.strictEqual(
+ events[2].name,
+ PTN.DOMAIN_LOOKUP_END,
+ `event ${PTN.DOMAIN_LOOKUP_END} is not defined`
+ );
+ assert.strictEqual(
+ events[3].name,
+ PTN.CONNECT_START,
+ `event ${PTN.CONNECT_START} is not defined`
+ );
+ assert.strictEqual(
+ events[4].name,
+ PTN.SECURE_CONNECTION_START,
+ `event ${PTN.SECURE_CONNECTION_START} is not defined`
+ );
+ assert.strictEqual(
+ events[5].name,
+ PTN.CONNECT_END,
+ `event ${PTN.CONNECT_END} is not defined`
+ );
+ assert.strictEqual(
+ events[6].name,
+ PTN.REQUEST_START,
+ `event ${PTN.REQUEST_START} is not defined`
+ );
+ assert.strictEqual(
+ events[7].name,
+ PTN.RESPONSE_START,
+ `event ${PTN.RESPONSE_START} is not defined`
+ );
+ assert.strictEqual(
+ events[8].name,
+ PTN.RESPONSE_END,
+ `event ${PTN.RESPONSE_END} is not defined`
+ );
+ });
+
+ it('should create a span for preflight request', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
+ const parentSpan: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(
+ span.parentSpanId,
+ parentSpan.spanContext.spanId,
+ 'parent span is not root span'
+ );
+ });
+
+ it('preflight request span should have correct name', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
+ assert.strictEqual(
+ span.name,
+ 'CORS Preflight',
+ 'preflight request span has wrong name'
+ );
+ });
+
+ it('preflight request span should have correct kind', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
+ assert.strictEqual(
+ span.kind,
+ api.SpanKind.INTERNAL,
+ 'span has wrong kind'
+ );
+ });
+
+ it('preflight request span should have correct events', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[0][0][0];
+ const events = span.events;
+ assert.strictEqual(events.length, 9, 'number of events is wrong');
+
+ assert.strictEqual(
+ events[0].name,
+ PTN.FETCH_START,
+ `event ${PTN.FETCH_START} is not defined`
+ );
+ assert.strictEqual(
+ events[1].name,
+ PTN.DOMAIN_LOOKUP_START,
+ `event ${PTN.DOMAIN_LOOKUP_START} is not defined`
+ );
+ assert.strictEqual(
+ events[2].name,
+ PTN.DOMAIN_LOOKUP_END,
+ `event ${PTN.DOMAIN_LOOKUP_END} is not defined`
+ );
+ assert.strictEqual(
+ events[3].name,
+ PTN.CONNECT_START,
+ `event ${PTN.CONNECT_START} is not defined`
+ );
+ assert.strictEqual(
+ events[4].name,
+ PTN.SECURE_CONNECTION_START,
+ `event ${PTN.SECURE_CONNECTION_START} is not defined`
+ );
+ assert.strictEqual(
+ events[5].name,
+ PTN.CONNECT_END,
+ `event ${PTN.CONNECT_END} is not defined`
+ );
+ assert.strictEqual(
+ events[6].name,
+ PTN.REQUEST_START,
+ `event ${PTN.REQUEST_START} is not defined`
+ );
+ assert.strictEqual(
+ events[7].name,
+ PTN.RESPONSE_START,
+ `event ${PTN.RESPONSE_START} is not defined`
+ );
+ assert.strictEqual(
+ events[8].name,
+ PTN.RESPONSE_END,
+ `event ${PTN.RESPONSE_END} is not defined`
+ );
+ });
+
+ it('should set trace headers', () => {
+ const span: api.Span = exportSpy.args[1][0][0];
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_TRACE_ID],
+ span.context().traceId,
+ `trace header '${core.X_B3_TRACE_ID}' not set`
+ );
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_SPAN_ID],
+ span.context().spanId,
+ `trace header '${core.X_B3_SPAN_ID}' not set`
+ );
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_SAMPLED],
+ String(span.context().traceFlags),
+ `trace header '${core.X_B3_SAMPLED}' not set`
+ );
+ });
+
+ it('should NOT clear the resources', () => {
+ assert.strictEqual(
+ clearResourceTimingsSpy.args.length,
+ 0,
+ 'resources have been cleared'
+ );
+ });
+
+ describe('when propagateTraceHeaderCorsUrls does NOT MATCH', () => {
+ beforeEach(done => {
+ clearData();
+ prepareData(done, url, {});
+ });
+ it('should NOT set trace headers', () => {
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_TRACE_ID],
+ undefined,
+ `trace header '${core.X_B3_TRACE_ID}' should not be set`
+ );
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_SPAN_ID],
+ undefined,
+ `trace header '${core.X_B3_SPAN_ID}' should not be set`
+ );
+ assert.strictEqual(
+ lastResponse.headers[core.X_B3_SAMPLED],
+ undefined,
+ `trace header '${core.X_B3_SAMPLED}' should not be set`
+ );
+ });
+ });
+ });
+
+ describe('when url is ignored', () => {
+ beforeEach(done => {
+ const propagateTraceHeaderCorsUrls = url;
+ prepareData(done, url, {
+ propagateTraceHeaderCorsUrls,
+ ignoreUrls: [propagateTraceHeaderCorsUrls],
+ });
+ });
+ afterEach(() => {
+ clearData();
+ });
+ it('should NOT create any span', () => {
+ assert.strictEqual(exportSpy.args.length, 0, "span shouldn't b exported");
+ });
+ });
+
+ describe('when clearTimingResources is TRUE', () => {
+ beforeEach(done => {
+ const propagateTraceHeaderCorsUrls = url;
+ prepareData(done, url, {
+ propagateTraceHeaderCorsUrls,
+ clearTimingResources: true,
+ });
+ });
+ afterEach(() => {
+ clearData();
+ });
+ it('should clear the resources', () => {
+ assert.strictEqual(
+ clearResourceTimingsSpy.args.length,
+ 1,
+ "resources haven't been cleared"
+ );
+ });
+ });
+
+ describe('when request is NOT successful (wrong url)', () => {
+ beforeEach(done => {
+ const propagateTraceHeaderCorsUrls = badUrl;
+ prepareData(done, badUrl, { propagateTraceHeaderCorsUrls });
+ });
+ afterEach(() => {
+ clearData();
+ });
+ it('should create a span with correct root span', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(
+ span.parentSpanId,
+ rootSpan.context().spanId,
+ 'parent span is not root span'
+ );
+ });
+ });
+
+ describe('when request is NOT successful (405)', () => {
+ beforeEach(done => {
+ const propagateTraceHeaderCorsUrls = url;
+ prepareData(done, url, { propagateTraceHeaderCorsUrls }, 'DELETE');
+ });
+ afterEach(() => {
+ clearData();
+ });
+
+ it('should create a span with correct root span', () => {
+ const span: tracing.ReadableSpan = exportSpy.args[1][0][0];
+ assert.strictEqual(
+ span.parentSpanId,
+ rootSpan.context().spanId,
+ 'parent span is not root span'
+ );
+ });
+ });
+});
diff --git a/packages/opentelemetry-plugin-fetch/test/index-webpack.ts b/packages/opentelemetry-plugin-fetch/test/index-webpack.ts
new file mode 100644
index 0000000000..061a48ccfa
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/test/index-webpack.ts
@@ -0,0 +1,20 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+const testsContext = require.context('.', true, /test$/);
+testsContext.keys().forEach(testsContext);
+
+const srcContext = require.context('.', true, /src$/);
+srcContext.keys().forEach(srcContext);
diff --git a/packages/opentelemetry-plugin-fetch/tsconfig.json b/packages/opentelemetry-plugin-fetch/tsconfig.json
new file mode 100644
index 0000000000..71661a842e
--- /dev/null
+++ b/packages/opentelemetry-plugin-fetch/tsconfig.json
@@ -0,0 +1,12 @@
+{
+ "extends": "../tsconfig.base",
+ "compilerOptions": {
+ "rootDir": ".",
+ "outDir": "build",
+ "skipLibCheck": true
+ },
+ "include": [
+ "src/**/*.ts",
+ "test/**/*.ts"
+ ]
+}
diff --git a/packages/opentelemetry-plugin-grpc-js/.eslintignore b/packages/opentelemetry-plugin-grpc-js/.eslintignore
new file mode 100644
index 0000000000..378eac25d3
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/.eslintignore
@@ -0,0 +1 @@
+build
diff --git a/packages/opentelemetry-plugin-grpc-js/.eslintrc.js b/packages/opentelemetry-plugin-grpc-js/.eslintrc.js
new file mode 100644
index 0000000000..f726f3becb
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/.eslintrc.js
@@ -0,0 +1,7 @@
+module.exports = {
+ "env": {
+ "mocha": true,
+ "node": true
+ },
+ ...require('../../eslint.config.js')
+}
diff --git a/packages/opentelemetry-plugin-grpc-js/.npmignore b/packages/opentelemetry-plugin-grpc-js/.npmignore
new file mode 100644
index 0000000000..9505ba9450
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/.npmignore
@@ -0,0 +1,4 @@
+/bin
+/coverage
+/doc
+/test
diff --git a/packages/opentelemetry-plugin-grpc-js/LICENSE b/packages/opentelemetry-plugin-grpc-js/LICENSE
new file mode 100644
index 0000000000..261eeb9e9f
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/opentelemetry-plugin-grpc-js/README.md b/packages/opentelemetry-plugin-grpc-js/README.md
new file mode 100644
index 0000000000..c46aff6b4e
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/README.md
@@ -0,0 +1,66 @@
+# OpenTelemetry @grpc/grpc-js Instrumentation for Node.js
+[![Gitter chat][gitter-image]][gitter-url]
+[![NPM Published Version][npm-img]][npm-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![devDependencies][devDependencies-image]][devDependencies-url]
+[![Apache License][license-image]][license-image]
+
+This module provides automatic instrumentation for [`@grpc/grpc-js`](https://grpc.io/blog/grpc-js-1.0/). Currently, version [`1.x`](https://www.npmjs.com/package/@grpc/grpc-js?activeTab=versions) of `@grpc/grpc-js` is supported.
+
+For automatic instrumentation see the
+[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package.
+
+## Installation
+
+```
+npm install --save @opentelemetry/plugin-grpc-js
+```
+
+## Usage
+
+OpenTelemetry gRPC Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [gRPC](https://www.npmjs.com/package/@grpc/grpc-js).
+
+To load a specific plugin (**gRPC** in this case), specify it in the Node Tracer's configuration.
+```javascript
+const { NodeTracerProvider } = require('@opentelemetry/node');
+
+const provider = new NodeTracerProvider({
+ plugins: {
+ '@grpc/grpc-js': {
+ enabled: true,
+ // You may use a package name or absolute path to the file.
+ path: '@opentelemetry/plugin-grpc-js',
+ }
+ }
+});
+```
+
+To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules.
+```javascript
+const { NodeTracerProvider } = require('@opentelemetry/node');
+
+const provider = new NodeTracerProvider();
+```
+
+
+
+
+## Useful links
+- For more information on OpenTelemetry, visit:
+- For more about OpenTelemetry JavaScript:
+- For help or feedback on this project, join us on [gitter][gitter-url]
+
+## License
+
+Apache 2.0 - See [LICENSE][license-url] for more information.
+
+[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg
+[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE
+[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
+[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-plugin-grpc-js
+[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-grpc-js
+[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-plugin-grpc-js
+[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-grpc-js&type=dev
+[npm-url]: https://www.npmjs.com/package/@opentelemetry/plugin-grpc-js
+[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fplugin-grpc-js.svg
diff --git a/packages/opentelemetry-plugin-grpc-js/package.json b/packages/opentelemetry-plugin-grpc-js/package.json
new file mode 100644
index 0000000000..c876699bcf
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/package.json
@@ -0,0 +1,72 @@
+{
+ "name": "@opentelemetry/plugin-grpc-js",
+ "private": true,
+ "version": "0.8.3",
+ "description": "OpenTelemetry @grpc/grpc-js automatic instrumentation package.",
+ "main": "build/src/index.js",
+ "types": "build/src/index.d.ts",
+ "repository": "open-telemetry/opentelemetry-js",
+ "scripts": {
+ "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts",
+ "tdd": "npm run test -- --watch-extensions ts --watch",
+ "clean": "rimraf build/*",
+ "lint": "eslint . --ext .ts",
+ "lint:fix": "eslint . --ext .ts --fix",
+ "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
+ "precompile": "tsc --version",
+ "version:update": "node ../../scripts/version-update.js",
+ "compile": "npm run version:update && tsc -p .",
+ "prepare": "npm run compile"
+ },
+ "keywords": [
+ "opentelemetry",
+ "grpc",
+ "grpc-js",
+ "nodejs",
+ "tracing",
+ "profiling",
+ "plugin"
+ ],
+ "author": "OpenTelemetry Authors",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8.0.0"
+ },
+ "files": [
+ "build/src/**/*.js",
+ "build/src/**/*.d.ts",
+ "doc",
+ "LICENSE",
+ "README.md"
+ ],
+ "publishConfig": {
+ "access": "public"
+ },
+ "devDependencies": {
+ "@grpc/grpc-js": "1.0.5",
+ "@opentelemetry/context-async-hooks": "^0.8.3",
+ "@opentelemetry/context-base": "^0.8.3",
+ "@opentelemetry/node": "^0.8.3",
+ "@opentelemetry/tracing": "^0.8.3",
+ "@types/mocha": "7.0.2",
+ "@types/node": "14.0.13",
+ "@types/semver": "7.2.0",
+ "@types/shimmer": "1.0.1",
+ "@types/sinon": "9.0.4",
+ "codecov": "3.7.0",
+ "gts": "2.0.2",
+ "mocha": "7.2.0",
+ "nyc": "15.1.0",
+ "rimraf": "3.0.2",
+ "semver": "7.3.2",
+ "sinon": "9.0.2",
+ "ts-mocha": "7.0.0",
+ "ts-node": "8.10.2",
+ "typescript": "3.9.5"
+ },
+ "dependencies": {
+ "@opentelemetry/api": "^0.8.3",
+ "@opentelemetry/core": "^0.8.3",
+ "shimmer": "1.2.1"
+ }
+}
diff --git a/packages/opentelemetry-plugin-grpc/src/enums/AttributeNames.ts b/packages/opentelemetry-plugin-grpc-js/src/enums/AttributeNames.ts
similarity index 94%
rename from packages/opentelemetry-plugin-grpc/src/enums/AttributeNames.ts
rename to packages/opentelemetry-plugin-grpc-js/src/enums/AttributeNames.ts
index 2e9c2a9244..3fdea85bc7 100644
--- a/packages/opentelemetry-plugin-grpc/src/enums/AttributeNames.ts
+++ b/packages/opentelemetry-plugin-grpc-js/src/enums/AttributeNames.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts b/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts
new file mode 100644
index 0000000000..6a2c6e89f8
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts
@@ -0,0 +1,45 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { BasePlugin } from '@opentelemetry/core';
+import { VERSION } from './version';
+import * as path from 'path';
+
+import * as grpcJs from '@grpc/grpc-js';
+
+/**
+ * @grpc/grpc-js gRPC instrumentation plugin for Opentelemetry
+ * https://www.npmjs.com/package/@grpc/grpc-js
+ */
+export class GrpcJsPlugin extends BasePlugin {
+ static readonly component = '@grpc/grpc-js';
+ readonly supportedVersions = ['1.*'];
+
+ constructor(readonly moduleName: string, readonly version: string) {
+ super('@opentelemetry/plugin-grpc-js', VERSION);
+ }
+
+ protected patch(): typeof grpcJs {
+ throw new Error('Method not implemented.');
+ }
+ protected unpatch(): void {
+ throw new Error('Method not implemented.');
+ }
+}
+
+const basedir = path.dirname(require.resolve(GrpcJsPlugin.component));
+const version = require(path.join(basedir, 'package.json')).version;
+export const plugin = new GrpcJsPlugin(GrpcJsPlugin.component, version);
diff --git a/packages/opentelemetry-plugin-grpc-js/src/version.ts b/packages/opentelemetry-plugin-grpc-js/src/version.ts
new file mode 100644
index 0000000000..9e616149a4
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/src/version.ts
@@ -0,0 +1,18 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// this is autogenerated file, see scripts/version-update.js
+export const VERSION = '0.8.3';
diff --git a/packages/opentelemetry-plugin-grpc-js/tsconfig.json b/packages/opentelemetry-plugin-grpc-js/tsconfig.json
new file mode 100644
index 0000000000..a2042cd68b
--- /dev/null
+++ b/packages/opentelemetry-plugin-grpc-js/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../tsconfig.base",
+ "compilerOptions": {
+ "rootDir": ".",
+ "outDir": "build"
+ },
+ "include": [
+ "src/**/*.ts",
+ "test/**/*.ts"
+ ]
+}
diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json
index 5192ae91ce..564cc4e829 100644
--- a/packages/opentelemetry-plugin-grpc/package.json
+++ b/packages/opentelemetry-plugin-grpc/package.json
@@ -66,6 +66,7 @@
"dependencies": {
"@opentelemetry/api": "^0.8.3",
"@opentelemetry/core": "^0.8.3",
+ "@opentelemetry/semantic-conventions": "^0.8.3",
"shimmer": "^1.2.1"
}
}
diff --git a/packages/opentelemetry-plugin-grpc/src/grpc.ts b/packages/opentelemetry-plugin-grpc/src/grpc.ts
index 0b7de00518..f0072ea569 100644
--- a/packages/opentelemetry-plugin-grpc/src/grpc.ts
+++ b/packages/opentelemetry-plugin-grpc/src/grpc.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,12 +23,15 @@ import {
SpanOptions,
Status,
} from '@opentelemetry/api';
+import {
+ GeneralAttribute,
+ RpcAttribute,
+} from '@opentelemetry/semantic-conventions';
import { BasePlugin } from '@opentelemetry/core';
import * as events from 'events';
import * as grpcTypes from 'grpc';
import * as path from 'path';
import * as shimmer from 'shimmer';
-import { AttributeNames } from './enums/AttributeNames';
import {
grpc,
GrpcClientFunc,
@@ -173,8 +176,8 @@ export class GrpcPlugin extends BasePlugin {
const span = plugin._tracer
.startSpan(spanName, spanOptions)
.setAttributes({
- [AttributeNames.GRPC_KIND]: spanOptions.kind,
- [AttributeNames.COMPONENT]: GrpcPlugin.component,
+ [RpcAttribute.GRPC_KIND]: spanOptions.kind,
+ [GeneralAttribute.COMPONENT]: GrpcPlugin.component,
});
plugin._tracer.withSpan(span, () => {
@@ -235,19 +238,16 @@ export class GrpcPlugin extends BasePlugin {
code: _grpcStatusCodeToCanonicalCode(err.code),
message: err.message,
});
- span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
- err.code.toString()
- );
+ span.setAttribute(RpcAttribute.GRPC_STATUS_CODE, err.code.toString());
}
span.setAttributes({
- [AttributeNames.GRPC_ERROR_NAME]: err.name,
- [AttributeNames.GRPC_ERROR_MESSAGE]: err.message,
+ [RpcAttribute.GRPC_ERROR_NAME]: err.name,
+ [RpcAttribute.GRPC_ERROR_MESSAGE]: err.message,
});
} else {
span.setStatus({ code: CanonicalCode.OK });
span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
+ RpcAttribute.GRPC_STATUS_CODE,
plugin._moduleExports.status.OK.toString()
);
}
@@ -281,7 +281,7 @@ export class GrpcPlugin extends BasePlugin {
call.on('finish', () => {
span.setStatus(_grpcStatusCodeToSpanStatus(call.status.code));
span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
+ RpcAttribute.GRPC_STATUS_CODE,
call.status.code.toString()
);
@@ -299,8 +299,8 @@ export class GrpcPlugin extends BasePlugin {
});
span.addEvent('finished with error');
span.setAttributes({
- [AttributeNames.GRPC_ERROR_NAME]: err.name,
- [AttributeNames.GRPC_ERROR_MESSAGE]: err.message,
+ [RpcAttribute.GRPC_ERROR_NAME]: err.name,
+ [RpcAttribute.GRPC_ERROR_MESSAGE]: err.message,
});
endSpan();
});
@@ -357,7 +357,7 @@ export class GrpcPlugin extends BasePlugin {
.startSpan(name, {
kind: SpanKind.CLIENT,
})
- .setAttribute(AttributeNames.COMPONENT, GrpcPlugin.component);
+ .setAttribute(GeneralAttribute.COMPONENT, GrpcPlugin.component);
return plugin._tracer.withSpan(span, () =>
plugin._makeGrpcClientRemoteCall(original, args, this, plugin)(span)
);
@@ -388,18 +388,18 @@ export class GrpcPlugin extends BasePlugin {
if (err.code) {
span.setStatus(_grpcStatusCodeToSpanStatus(err.code));
span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
+ RpcAttribute.GRPC_STATUS_CODE,
err.code.toString()
);
}
span.setAttributes({
- [AttributeNames.GRPC_ERROR_NAME]: err.name,
- [AttributeNames.GRPC_ERROR_MESSAGE]: err.message,
+ [RpcAttribute.GRPC_ERROR_NAME]: err.name,
+ [RpcAttribute.GRPC_ERROR_MESSAGE]: err.message,
});
} else {
span.setStatus({ code: CanonicalCode.OK });
span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
+ RpcAttribute.GRPC_STATUS_CODE,
plugin._moduleExports.status.OK.toString()
);
}
@@ -432,8 +432,8 @@ export class GrpcPlugin extends BasePlugin {
span.addEvent('sent');
span.setAttributes({
- [AttributeNames.GRPC_METHOD]: original.path,
- [AttributeNames.GRPC_KIND]: SpanKind.CLIENT,
+ [RpcAttribute.GRPC_METHOD]: original.path,
+ [RpcAttribute.GRPC_KIND]: SpanKind.CLIENT,
});
this._setSpanContext(metadata);
@@ -459,8 +459,8 @@ export class GrpcPlugin extends BasePlugin {
message: err.message,
});
span.setAttributes({
- [AttributeNames.GRPC_ERROR_NAME]: err.name,
- [AttributeNames.GRPC_ERROR_MESSAGE]: err.message,
+ [RpcAttribute.GRPC_ERROR_NAME]: err.name,
+ [RpcAttribute.GRPC_ERROR_MESSAGE]: err.message,
});
endSpan();
}
@@ -471,7 +471,7 @@ export class GrpcPlugin extends BasePlugin {
(status: Status) => {
span.setStatus({ code: CanonicalCode.OK });
span.setAttribute(
- AttributeNames.GRPC_STATUS_CODE,
+ RpcAttribute.GRPC_STATUS_CODE,
status.code.toString()
);
endSpan();
diff --git a/packages/opentelemetry-plugin-grpc/src/index.ts b/packages/opentelemetry-plugin-grpc/src/index.ts
index bf0385539c..4ffcf69671 100644
--- a/packages/opentelemetry-plugin-grpc/src/index.ts
+++ b/packages/opentelemetry-plugin-grpc/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc/src/types.ts b/packages/opentelemetry-plugin-grpc/src/types.ts
index f6198295fd..56ee679c63 100644
--- a/packages/opentelemetry-plugin-grpc/src/types.ts
+++ b/packages/opentelemetry-plugin-grpc/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc/src/utils.ts b/packages/opentelemetry-plugin-grpc/src/utils.ts
index f9d5c6dd79..9c9e5a336b 100644
--- a/packages/opentelemetry-plugin-grpc/src/utils.ts
+++ b/packages/opentelemetry-plugin-grpc/src/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc/src/version.ts b/packages/opentelemetry-plugin-grpc/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-plugin-grpc/src/version.ts
+++ b/packages/opentelemetry-plugin-grpc/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc/test/grpc.test.ts b/packages/opentelemetry-plugin-grpc/test/grpc.test.ts
index 12dd723c89..ac113b0e01 100644
--- a/packages/opentelemetry-plugin-grpc/test/grpc.test.ts
+++ b/packages/opentelemetry-plugin-grpc/test/grpc.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts b/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts
index b484a1561e..38b0069d1e 100644
--- a/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts
+++ b/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
import { SpanKind } from '@opentelemetry/api';
import * as assert from 'assert';
-import { AttributeNames } from '../../src/enums/AttributeNames';
import { GrpcPlugin } from '../../src/grpc';
import * as grpc from 'grpc';
import { ReadableSpan } from '@opentelemetry/tracing';
@@ -24,6 +23,7 @@ import {
hrTimeToMilliseconds,
hrTimeToMicroseconds,
} from '@opentelemetry/core';
+import { GeneralAttribute } from '@opentelemetry/semantic-conventions';
export const assertSpan = (
span: ReadableSpan,
@@ -35,7 +35,7 @@ export const assertSpan = (
assert.strictEqual(span.kind, kind);
assert.strictEqual(
- span.attributes[AttributeNames.COMPONENT],
+ span.attributes[GeneralAttribute.COMPONENT],
GrpcPlugin.component
);
assert.ok(span.endTime);
diff --git a/packages/opentelemetry-plugin-http/package.json b/packages/opentelemetry-plugin-http/package.json
index f375d22701..ceab9d8a15 100644
--- a/packages/opentelemetry-plugin-http/package.json
+++ b/packages/opentelemetry-plugin-http/package.json
@@ -72,6 +72,7 @@
"dependencies": {
"@opentelemetry/api": "^0.8.3",
"@opentelemetry/core": "^0.8.3",
+ "@opentelemetry/semantic-conventions": "^0.8.3",
"semver": "^7.1.3",
"shimmer": "^1.2.1"
}
diff --git a/packages/opentelemetry-plugin-http/src/enums/AttributeNames.ts b/packages/opentelemetry-plugin-http/src/enums/AttributeNames.ts
deleted file mode 100644
index 6ea8eb8983..0000000000
--- a/packages/opentelemetry-plugin-http/src/enums/AttributeNames.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2020, OpenTelemetry Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Attributes Names according to [OpenTelemetry attributes specs](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#common-attributes)
- */
-export enum AttributeNames {
- HTTP_HOST = 'http.host',
- COMPONENT = 'component',
- HTTP_METHOD = 'http.method',
- HTTP_TARGET = 'http.target',
- HTTP_ROUTE = 'http.route',
- HTTP_URL = 'http.url',
- HTTP_STATUS_CODE = 'http.status_code',
- HTTP_STATUS_TEXT = 'http.status_text',
- HTTP_FLAVOR = 'http.flavor',
- NET_PEER_IP = 'net.peer.ip',
- NET_PEER_PORT = 'net.peer.port',
- NET_PEER_NAME = 'net.peer.name',
- NET_HOST_IP = 'net.host.ip',
- NET_HOST_PORT = 'net.host.port',
- NET_HOST_NAME = 'net.host.name',
- NET_TRANSPORT = 'net.transport',
- IP_TCP = 'IP.TCP',
- IP_UDP = 'IP.UDP',
- HTTP_SERVER_NAME = 'http.server_name',
- HTTP_CLIENT_IP = 'http.client_ip',
- // NOT ON OFFICIAL SPEC
- HTTP_ERROR_NAME = 'http.error_name',
- HTTP_ERROR_MESSAGE = 'http.error_message',
- HTTP_USER_AGENT = 'http.user_agent',
-}
diff --git a/packages/opentelemetry-plugin-http/src/http.ts b/packages/opentelemetry-plugin-http/src/http.ts
index 9db4f207ab..83b2792e9e 100644
--- a/packages/opentelemetry-plugin-http/src/http.ts
+++ b/packages/opentelemetry-plugin-http/src/http.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ import {
NoRecordingSpan,
getExtractedSpanContext,
} from '@opentelemetry/core';
+import { GeneralAttribute } from '@opentelemetry/semantic-conventions';
import {
ClientRequest,
IncomingMessage,
@@ -40,7 +41,6 @@ import { Socket } from 'net';
import * as semver from 'semver';
import * as shimmer from 'shimmer';
import * as url from 'url';
-import { AttributeNames } from './enums/AttributeNames';
import {
Err,
Func,
@@ -463,7 +463,7 @@ export class HttpPlugin extends BasePlugin {
} else {
span = this._tracer
.startSpan(name, options)
- .setAttribute(AttributeNames.COMPONENT, this.component);
+ .setAttribute(GeneralAttribute.COMPONENT, this.component);
}
this._spanNotEnded.add(span);
return span;
diff --git a/packages/opentelemetry-plugin-http/src/index.ts b/packages/opentelemetry-plugin-http/src/index.ts
index 4d678a5f65..265bc235a7 100644
--- a/packages/opentelemetry-plugin-http/src/index.ts
+++ b/packages/opentelemetry-plugin-http/src/index.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,4 +17,3 @@
export * from './http';
export * from './types';
export * from './utils';
-export * from './enums/AttributeNames';
diff --git a/packages/opentelemetry-plugin-http/src/types.ts b/packages/opentelemetry-plugin-http/src/types.ts
index 4be2114657..9f1149e269 100644
--- a/packages/opentelemetry-plugin-http/src/types.ts
+++ b/packages/opentelemetry-plugin-http/src/types.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/src/utils.ts b/packages/opentelemetry-plugin-http/src/utils.ts
index baa7adf90a..90b4c0fe92 100644
--- a/packages/opentelemetry-plugin-http/src/utils.ts
+++ b/packages/opentelemetry-plugin-http/src/utils.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,6 +14,10 @@
* limitations under the License.
*/
import { Attributes, CanonicalCode, Span, Status } from '@opentelemetry/api';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import {
ClientRequest,
IncomingHttpHeaders,
@@ -24,7 +28,6 @@ import {
} from 'http';
import { Socket } from 'net';
import * as url from 'url';
-import { AttributeNames } from './enums/AttributeNames';
import {
Err,
IgnoreMatcher,
@@ -196,8 +199,8 @@ export const setSpanWithError = (
const message = error.message;
span.setAttributes({
- [AttributeNames.HTTP_ERROR_NAME]: error.name,
- [AttributeNames.HTTP_ERROR_MESSAGE]: message,
+ [HttpAttribute.HTTP_ERROR_NAME]: error.name,
+ [HttpAttribute.HTTP_ERROR_MESSAGE]: message,
});
if (!obj) {
@@ -334,18 +337,18 @@ export const getOutgoingRequestAttributes = (
const headers = requestOptions.headers || {};
const userAgent = headers['user-agent'];
const attributes: Attributes = {
- [AttributeNames.HTTP_URL]: getAbsoluteUrl(
+ [HttpAttribute.HTTP_URL]: getAbsoluteUrl(
requestOptions,
headers,
`${options.component}:`
),
- [AttributeNames.HTTP_METHOD]: method,
- [AttributeNames.HTTP_TARGET]: requestOptions.path || '/',
- [AttributeNames.NET_PEER_NAME]: hostname,
+ [HttpAttribute.HTTP_METHOD]: method,
+ [HttpAttribute.HTTP_TARGET]: requestOptions.path || '/',
+ [GeneralAttribute.NET_PEER_NAME]: hostname,
};
if (userAgent !== undefined) {
- attributes[AttributeNames.HTTP_USER_AGENT] = userAgent;
+ attributes[HttpAttribute.HTTP_USER_AGENT] = userAgent;
}
return attributes;
};
@@ -357,11 +360,11 @@ export const getOutgoingRequestAttributes = (
export const getAttributesFromHttpKind = (kind?: string): Attributes => {
const attributes: Attributes = {};
if (kind) {
- attributes[AttributeNames.HTTP_FLAVOR] = kind;
+ attributes[HttpAttribute.HTTP_FLAVOR] = kind;
if (kind.toUpperCase() !== 'QUIC') {
- attributes[AttributeNames.NET_TRANSPORT] = AttributeNames.IP_TCP;
+ attributes[GeneralAttribute.NET_TRANSPORT] = GeneralAttribute.IP_TCP;
} else {
- attributes[AttributeNames.NET_TRANSPORT] = AttributeNames.IP_UDP;
+ attributes[GeneralAttribute.NET_TRANSPORT] = GeneralAttribute.IP_UDP;
}
}
return attributes;
@@ -379,14 +382,14 @@ export const getOutgoingRequestAttributesOnResponse = (
const { statusCode, statusMessage, httpVersion, socket } = response;
const { remoteAddress, remotePort } = socket;
const attributes: Attributes = {
- [AttributeNames.NET_PEER_IP]: remoteAddress,
- [AttributeNames.NET_PEER_PORT]: remotePort,
- [AttributeNames.HTTP_HOST]: `${options.hostname}:${remotePort}`,
+ [GeneralAttribute.NET_PEER_IP]: remoteAddress,
+ [GeneralAttribute.NET_PEER_PORT]: remotePort,
+ [HttpAttribute.HTTP_HOST]: `${options.hostname}:${remotePort}`,
};
if (statusCode) {
- attributes[AttributeNames.HTTP_STATUS_CODE] = statusCode;
- attributes[AttributeNames.HTTP_STATUS_TEXT] = (
+ attributes[HttpAttribute.HTTP_STATUS_CODE] = statusCode;
+ attributes[HttpAttribute.HTTP_STATUS_TEXT] = (
statusMessage || ''
).toUpperCase();
}
@@ -417,31 +420,31 @@ export const getIncomingRequestAttributes = (
'localhost';
const serverName = options.serverName;
const attributes: Attributes = {
- [AttributeNames.HTTP_URL]: getAbsoluteUrl(
+ [HttpAttribute.HTTP_URL]: getAbsoluteUrl(
requestUrl,
headers,
`${options.component}:`
),
- [AttributeNames.HTTP_HOST]: host,
- [AttributeNames.NET_HOST_NAME]: hostname,
- [AttributeNames.HTTP_METHOD]: method,
+ [HttpAttribute.HTTP_HOST]: host,
+ [GeneralAttribute.NET_HOST_NAME]: hostname,
+ [HttpAttribute.HTTP_METHOD]: method,
};
if (typeof ips === 'string') {
- attributes[AttributeNames.HTTP_CLIENT_IP] = ips.split(',')[0];
+ attributes[HttpAttribute.HTTP_CLIENT_IP] = ips.split(',')[0];
}
if (typeof serverName === 'string') {
- attributes[AttributeNames.HTTP_SERVER_NAME] = serverName;
+ attributes[HttpAttribute.HTTP_SERVER_NAME] = serverName;
}
if (requestUrl) {
- attributes[AttributeNames.HTTP_ROUTE] = requestUrl.pathname || '/';
- attributes[AttributeNames.HTTP_TARGET] = requestUrl.pathname || '/';
+ attributes[HttpAttribute.HTTP_ROUTE] = requestUrl.pathname || '/';
+ attributes[HttpAttribute.HTTP_TARGET] = requestUrl.pathname || '/';
}
if (userAgent !== undefined) {
- attributes[AttributeNames.HTTP_USER_AGENT] = userAgent;
+ attributes[HttpAttribute.HTTP_USER_AGENT] = userAgent;
}
const httpKindAttributes = getAttributesFromHttpKind(httpVersion);
@@ -471,16 +474,16 @@ export const getIncomingRequestAttributesOnResponse = (
: undefined;
const attributes: Attributes = {
- [AttributeNames.NET_HOST_IP]: localAddress,
- [AttributeNames.NET_HOST_PORT]: localPort,
- [AttributeNames.NET_PEER_IP]: remoteAddress,
- [AttributeNames.NET_PEER_PORT]: remotePort,
- [AttributeNames.HTTP_STATUS_CODE]: statusCode,
- [AttributeNames.HTTP_STATUS_TEXT]: (statusMessage || '').toUpperCase(),
+ [GeneralAttribute.NET_HOST_IP]: localAddress,
+ [GeneralAttribute.NET_HOST_PORT]: localPort,
+ [GeneralAttribute.NET_PEER_IP]: remoteAddress,
+ [GeneralAttribute.NET_PEER_PORT]: remotePort,
+ [HttpAttribute.HTTP_STATUS_CODE]: statusCode,
+ [HttpAttribute.HTTP_STATUS_TEXT]: (statusMessage || '').toUpperCase(),
};
if (route !== undefined) {
- attributes[AttributeNames.HTTP_ROUTE] = route;
+ attributes[HttpAttribute.HTTP_ROUTE] = route;
}
return attributes;
};
diff --git a/packages/opentelemetry-plugin-http/src/version.ts b/packages/opentelemetry-plugin-http/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-plugin-http/src/version.ts
+++ b/packages/opentelemetry-plugin-http/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts
index 5a5d0407c7..3b80fe84ba 100644
--- a/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts
+++ b/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts
index 1c32b3156f..1cb350bf95 100644
--- a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts
+++ b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,11 +26,14 @@ import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
import * as nock from 'nock';
import * as path from 'path';
-import { AttributeNames } from '../../src/enums/AttributeNames';
import { HttpPlugin, plugin } from '../../src/http';
import { Http, HttpPluginConfig } from '../../src/types';
import { OT_REQUEST_HEADER } from '../../src/utils';
@@ -174,11 +177,11 @@ describe('HttpPlugin', () => {
assertSpan(incomingSpan, SpanKind.SERVER, validations);
assertSpan(outgoingSpan, SpanKind.CLIENT, validations);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.NET_HOST_PORT],
+ incomingSpan.attributes[GeneralAttribute.NET_HOST_PORT],
serverPort
);
assert.strictEqual(
- outgoingSpan.attributes[AttributeNames.NET_PEER_PORT],
+ outgoingSpan.attributes[GeneralAttribute.NET_PEER_PORT],
serverPort
);
});
@@ -276,28 +279,25 @@ describe('HttpPlugin', () => {
assert.strictEqual(spans.length, 2);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.HTTP_CLIENT_IP],
+ incomingSpan.attributes[HttpAttribute.HTTP_CLIENT_IP],
''
);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.NET_HOST_PORT],
+ incomingSpan.attributes[GeneralAttribute.NET_HOST_PORT],
serverPort
);
assert.strictEqual(
- outgoingSpan.attributes[AttributeNames.NET_PEER_PORT],
+ outgoingSpan.attributes[GeneralAttribute.NET_PEER_PORT],
serverPort
);
[
{ span: incomingSpan, kind: SpanKind.SERVER },
{ span: outgoingSpan, kind: SpanKind.CLIENT },
].forEach(({ span, kind }) => {
+ assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_FLAVOR],
- '1.1'
- );
- assert.strictEqual(
- span.attributes[AttributeNames.NET_TRANSPORT],
- AttributeNames.IP_TCP
+ span.attributes[GeneralAttribute.NET_TRANSPORT],
+ GeneralAttribute.IP_TCP
);
assertSpan(span, kind, validations);
});
@@ -708,7 +708,7 @@ describe('HttpPlugin', () => {
assert.strictEqual(spans.length, 1);
assert.ok(Object.keys(span.attributes).length > 6);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_STATUS_CODE],
+ span.attributes[HttpAttribute.HTTP_STATUS_CODE],
404
);
assert.strictEqual(span.status.code, CanonicalCode.NOT_FOUND);
diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts
index 57cbe57427..bb98825b39 100644
--- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts
+++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts
index af89fa51ed..2ecc280604 100644
--- a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts
+++ b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,13 @@
import { CanonicalCode, SpanKind, TraceFlags } from '@opentelemetry/api';
import { NoopLogger } from '@opentelemetry/core';
import { BasicTracerProvider, Span } from '@opentelemetry/tracing';
+import { HttpAttribute } from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
import { IncomingMessage, ServerResponse } from 'http';
import { Socket } from 'net';
import * as sinon from 'sinon';
import * as url from 'url';
-import { AttributeNames } from '../../src';
import { IgnoreMatcher } from '../../src/types';
import * as utils from '../../src/utils';
@@ -264,10 +264,10 @@ describe('Utility', () => {
utils.setSpanWithError(span, new Error(errorMessage), obj as any);
const attributes = span.attributes;
assert.strictEqual(
- attributes[AttributeNames.HTTP_ERROR_MESSAGE],
+ attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
errorMessage
);
- assert.ok(attributes[AttributeNames.HTTP_ERROR_NAME]);
+ assert.ok(attributes[HttpAttribute.HTTP_ERROR_NAME]);
}
});
});
@@ -325,7 +325,7 @@ describe('Utility', () => {
const attributes = utils.getIncomingRequestAttributesOnResponse(request, {
socket: {},
} as ServerResponse & { socket: Socket });
- assert.deepEqual(attributes[AttributeNames.HTTP_ROUTE], '/test/toto');
+ assert.deepEqual(attributes[HttpAttribute.HTTP_ROUTE], '/test/toto');
});
it('should succesfully process without middleware stack', () => {
@@ -333,7 +333,7 @@ describe('Utility', () => {
const attributes = utils.getIncomingRequestAttributesOnResponse(request, {
socket: {},
} as ServerResponse & { socket: Socket });
- assert.deepEqual(attributes[AttributeNames.HTTP_ROUTE], undefined);
+ assert.deepEqual(attributes[HttpAttribute.HTTP_ROUTE], undefined);
});
});
});
diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts
index 264eec94a8..9fd14f6ff0 100644
--- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts
+++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,10 @@
import { NoopLogger } from '@opentelemetry/core';
import { SpanKind, Span, context } from '@opentelemetry/api';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
import * as url from 'url';
@@ -30,7 +34,6 @@ import {
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
import { HttpPluginConfig } from '../../src/types';
-import { AttributeNames } from '../../src/enums/AttributeNames';
import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks';
const protocol = 'http';
const serverPort = 32345;
@@ -176,10 +179,10 @@ describe('HttpPlugin Integration tests', () => {
assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(result.reqHeaders['x-foo'], 'foo');
- assert.strictEqual(span.attributes[AttributeNames.HTTP_FLAVOR], '1.1');
+ assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
- span.attributes[AttributeNames.NET_TRANSPORT],
- AttributeNames.IP_TCP
+ span.attributes[GeneralAttribute.NET_TRANSPORT],
+ GeneralAttribute.IP_TCP
);
assertSpan(span, SpanKind.CLIENT, validations);
});
diff --git a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts
index f8ef3ed337..fe7ef01e51 100644
--- a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts
+++ b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
index aaf1f7aedb..77fbf04c12 100644
--- a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
+++ b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
import { SpanKind, Status } from '@opentelemetry/api';
import { hrTimeToNanoseconds } from '@opentelemetry/core';
import { ReadableSpan } from '@opentelemetry/tracing';
+import {
+ GeneralAttribute,
+ HttpAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
-import { AttributeNames } from '../../src/enums/AttributeNames';
import * as utils from '../../src/utils';
import { DummyPropagation } from './DummyPropagation';
@@ -46,23 +49,23 @@ export const assertSpan = (
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(
- span.attributes[AttributeNames.COMPONENT],
+ span.attributes[GeneralAttribute.COMPONENT],
validations.component
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_ERROR_MESSAGE],
+ span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_METHOD],
+ span.attributes[HttpAttribute.HTTP_METHOD],
validations.httpMethod
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_TARGET],
+ span.attributes[HttpAttribute.HTTP_TARGET],
validations.path || validations.pathname
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_STATUS_CODE],
+ span.attributes[HttpAttribute.HTTP_STATUS_CODE],
validations.httpStatusCode
);
@@ -82,25 +85,28 @@ export const assertSpan = (
const userAgent = validations.reqHeaders['user-agent'];
if (userAgent) {
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_USER_AGENT],
+ span.attributes[HttpAttribute.HTTP_USER_AGENT],
userAgent
);
}
}
if (span.kind === SpanKind.CLIENT) {
assert.strictEqual(
- span.attributes[AttributeNames.NET_PEER_NAME],
+ span.attributes[GeneralAttribute.NET_PEER_NAME],
validations.hostname,
'must be consistent (PEER_NAME and hostname)'
);
- assert.ok(span.attributes[AttributeNames.NET_PEER_IP], 'must have PEER_IP');
assert.ok(
- span.attributes[AttributeNames.NET_PEER_PORT],
+ span.attributes[GeneralAttribute.NET_PEER_IP],
+ 'must have PEER_IP'
+ );
+ assert.ok(
+ span.attributes[GeneralAttribute.NET_PEER_PORT],
'must have PEER_PORT'
);
assert.ok(
- (span.attributes[AttributeNames.HTTP_URL] as string).indexOf(
- span.attributes[AttributeNames.NET_PEER_NAME] as string
+ (span.attributes[HttpAttribute.HTTP_URL] as string).indexOf(
+ span.attributes[GeneralAttribute.NET_PEER_NAME] as string
) > -1,
'must be consistent'
);
@@ -108,16 +114,16 @@ export const assertSpan = (
if (span.kind === SpanKind.SERVER) {
if (validations.serverName) {
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_SERVER_NAME],
+ span.attributes[HttpAttribute.HTTP_SERVER_NAME],
validations.serverName,
' must have serverName attribute'
);
assert.ok(
- span.attributes[AttributeNames.NET_HOST_PORT],
+ span.attributes[GeneralAttribute.NET_HOST_PORT],
'must have HOST_PORT'
);
assert.ok(
- span.attributes[AttributeNames.NET_HOST_IP],
+ span.attributes[GeneralAttribute.NET_HOST_IP],
'must have HOST_IP'
);
}
diff --git a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts
index bf97c3bf91..f507b7f1f1 100644
--- a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts
+++ b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-http/test/utils/utils.ts b/packages/opentelemetry-plugin-http/test/utils/utils.ts
index 256afbfdc5..5d2e5cb3bc 100644
--- a/packages/opentelemetry-plugin-http/test/utils/utils.ts
+++ b/packages/opentelemetry-plugin-http/test/utils/utils.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json
index 52309a2511..fcf9aafe08 100644
--- a/packages/opentelemetry-plugin-https/package.json
+++ b/packages/opentelemetry-plugin-https/package.json
@@ -73,6 +73,7 @@
"@opentelemetry/api": "^0.8.3",
"@opentelemetry/core": "^0.8.3",
"@opentelemetry/plugin-http": "^0.8.3",
+ "@opentelemetry/semantic-conventions": "^0.8.3",
"semver": "^7.1.3",
"shimmer": "^1.2.1"
}
diff --git a/packages/opentelemetry-plugin-https/src/https.ts b/packages/opentelemetry-plugin-https/src/https.ts
index cbf5d1b919..396587eaca 100644
--- a/packages/opentelemetry-plugin-https/src/https.ts
+++ b/packages/opentelemetry-plugin-https/src/https.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/src/index.ts b/packages/opentelemetry-plugin-https/src/index.ts
index 19d7007d09..0c7c3d80af 100644
--- a/packages/opentelemetry-plugin-https/src/index.ts
+++ b/packages/opentelemetry-plugin-https/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/src/utils.ts b/packages/opentelemetry-plugin-https/src/utils.ts
index eed5c63d33..8d702bdfc0 100644
--- a/packages/opentelemetry-plugin-https/src/utils.ts
+++ b/packages/opentelemetry-plugin-https/src/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/src/version.ts b/packages/opentelemetry-plugin-https/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-plugin-https/src/version.ts
+++ b/packages/opentelemetry-plugin-https/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts
index d323be77ba..9d0e8dece6 100644
--- a/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts
+++ b/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts
index 21d43c39bd..39aa2e5493 100644
--- a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts
+++ b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import {
import { NoopLogger } from '@opentelemetry/core';
import { NodeTracerProvider } from '@opentelemetry/node';
import {
- AttributeNames,
Http,
HttpPluginConfig,
OT_REQUEST_HEADER,
@@ -35,6 +34,10 @@ import {
InMemorySpanExporter,
SimpleSpanProcessor,
} from '@opentelemetry/tracing';
+import {
+ GeneralAttribute,
+ HttpAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as fs from 'fs';
import * as http from 'http';
@@ -175,11 +178,11 @@ describe('HttpsPlugin', () => {
assertSpan(incomingSpan, SpanKind.SERVER, validations);
assertSpan(outgoingSpan, SpanKind.CLIENT, validations);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.NET_HOST_PORT],
+ incomingSpan.attributes[GeneralAttribute.NET_HOST_PORT],
serverPort
);
assert.strictEqual(
- outgoingSpan.attributes[AttributeNames.NET_PEER_PORT],
+ outgoingSpan.attributes[GeneralAttribute.NET_PEER_PORT],
serverPort
);
});
@@ -283,15 +286,15 @@ describe('HttpsPlugin', () => {
assert.strictEqual(spans.length, 2);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.HTTP_CLIENT_IP],
+ incomingSpan.attributes[HttpAttribute.HTTP_CLIENT_IP],
''
);
assert.strictEqual(
- incomingSpan.attributes[AttributeNames.NET_HOST_PORT],
+ incomingSpan.attributes[GeneralAttribute.NET_HOST_PORT],
serverPort
);
assert.strictEqual(
- outgoingSpan.attributes[AttributeNames.NET_PEER_PORT],
+ outgoingSpan.attributes[GeneralAttribute.NET_PEER_PORT],
serverPort
);
@@ -299,13 +302,10 @@ describe('HttpsPlugin', () => {
{ span: incomingSpan, kind: SpanKind.SERVER },
{ span: outgoingSpan, kind: SpanKind.CLIENT },
].forEach(({ span, kind }) => {
+ assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_FLAVOR],
- '1.1'
- );
- assert.strictEqual(
- span.attributes[AttributeNames.NET_TRANSPORT],
- AttributeNames.IP_TCP
+ span.attributes[GeneralAttribute.NET_TRANSPORT],
+ GeneralAttribute.IP_TCP
);
assertSpan(span, kind, validations);
});
@@ -686,7 +686,7 @@ describe('HttpsPlugin', () => {
assert.strictEqual(spans.length, 1);
assert.ok(Object.keys(span.attributes).length > 6);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_STATUS_CODE],
+ span.attributes[HttpAttribute.HTTP_STATUS_CODE],
404
);
assert.strictEqual(span.status.code, CanonicalCode.NOT_FOUND);
diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts
index e22ec5c246..a4463a4754 100644
--- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts
+++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts
index 9da20e1b07..a0a128bb0d 100644
--- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts
+++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
import { NoopLogger } from '@opentelemetry/core';
-import {
- HttpPluginConfig,
- Http,
- AttributeNames,
-} from '@opentelemetry/plugin-http';
+import { HttpPluginConfig, Http } from '@opentelemetry/plugin-http';
import { SpanKind, Span, context } from '@opentelemetry/api';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
import * as https from 'https';
@@ -184,10 +184,10 @@ describe('HttpsPlugin Integration tests', () => {
assert.strictEqual(spans.length, 1);
assert.ok(span.name.indexOf('GET /') >= 0);
assert.strictEqual(result.reqHeaders['x-foo'], 'foo');
- assert.strictEqual(span.attributes[AttributeNames.HTTP_FLAVOR], '1.1');
+ assert.strictEqual(span.attributes[HttpAttribute.HTTP_FLAVOR], '1.1');
assert.strictEqual(
- span.attributes[AttributeNames.NET_TRANSPORT],
- AttributeNames.IP_TCP
+ span.attributes[GeneralAttribute.NET_TRANSPORT],
+ GeneralAttribute.IP_TCP
);
assertSpan(span, SpanKind.CLIENT, validations);
});
diff --git a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts
index 02c85aa92e..906efe7968 100644
--- a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts
+++ b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts
index 91afcab170..019ecbd466 100644
--- a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts
+++ b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,14 +16,15 @@
import { SpanKind } from '@opentelemetry/api';
import { hrTimeToNanoseconds } from '@opentelemetry/core';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import * as assert from 'assert';
import * as http from 'http';
import { DummyPropagation } from './DummyPropagation';
import { ReadableSpan } from '@opentelemetry/tracing';
-import {
- AttributeNames,
- parseResponseStatus,
-} from '@opentelemetry/plugin-http';
+import { parseResponseStatus } from '@opentelemetry/plugin-http';
export const assertSpan = (
span: ReadableSpan,
@@ -48,23 +49,23 @@ export const assertSpan = (
`${validations.httpMethod} ${validations.pathname}`
);
assert.strictEqual(
- span.attributes[AttributeNames.COMPONENT],
+ span.attributes[GeneralAttribute.COMPONENT],
validations.component
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_ERROR_MESSAGE],
+ span.attributes[HttpAttribute.HTTP_ERROR_MESSAGE],
span.status.message
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_METHOD],
+ span.attributes[HttpAttribute.HTTP_METHOD],
validations.httpMethod
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_TARGET],
+ span.attributes[HttpAttribute.HTTP_TARGET],
validations.path || validations.pathname
);
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_STATUS_CODE],
+ span.attributes[HttpAttribute.HTTP_STATUS_CODE],
validations.httpStatusCode
);
assert.ok(span.endTime);
@@ -82,25 +83,28 @@ export const assertSpan = (
const userAgent = validations.reqHeaders['user-agent'];
if (userAgent) {
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_USER_AGENT],
+ span.attributes[HttpAttribute.HTTP_USER_AGENT],
userAgent
);
}
}
if (span.kind === SpanKind.CLIENT) {
assert.strictEqual(
- span.attributes[AttributeNames.NET_PEER_NAME],
+ span.attributes[GeneralAttribute.NET_PEER_NAME],
validations.hostname,
'must be consistent (PEER_NAME and hostname)'
);
- assert.ok(span.attributes[AttributeNames.NET_PEER_IP], 'must have PEER_IP');
assert.ok(
- span.attributes[AttributeNames.NET_PEER_PORT],
+ span.attributes[GeneralAttribute.NET_PEER_IP],
+ 'must have PEER_IP'
+ );
+ assert.ok(
+ span.attributes[GeneralAttribute.NET_PEER_PORT],
'must have PEER_PORT'
);
assert.ok(
- (span.attributes[AttributeNames.HTTP_URL] as string).indexOf(
- span.attributes[AttributeNames.NET_PEER_NAME] as string
+ (span.attributes[HttpAttribute.HTTP_URL] as string).indexOf(
+ span.attributes[GeneralAttribute.NET_PEER_NAME] as string
) > -1,
'must be consistent'
);
@@ -108,16 +112,19 @@ export const assertSpan = (
if (span.kind === SpanKind.SERVER) {
if (validations.serverName) {
assert.strictEqual(
- span.attributes[AttributeNames.HTTP_SERVER_NAME],
+ span.attributes[HttpAttribute.HTTP_SERVER_NAME],
validations.serverName,
' must have serverName attribute'
);
}
assert.ok(
- span.attributes[AttributeNames.NET_HOST_PORT],
+ span.attributes[GeneralAttribute.NET_HOST_PORT],
'must have HOST_PORT'
);
- assert.ok(span.attributes[AttributeNames.NET_HOST_IP], 'must have HOST_IP');
+ assert.ok(
+ span.attributes[GeneralAttribute.NET_HOST_IP],
+ 'must have HOST_IP'
+ );
assert.strictEqual(span.parentSpanId, DummyPropagation.SPAN_CONTEXT_KEY);
} else if (validations.reqHeaders) {
assert.ok(validations.reqHeaders[DummyPropagation.TRACE_CONTEXT_KEY]);
diff --git a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts
index 956c1da2e2..f75cf1e566 100644
--- a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts
+++ b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-https/test/utils/utils.ts b/packages/opentelemetry-plugin-https/test/utils/utils.ts
index 57a75516a1..a4e37eabea 100644
--- a/packages/opentelemetry-plugin-https/test/utils/utils.ts
+++ b/packages/opentelemetry-plugin-https/test/utils/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/karma.conf.js b/packages/opentelemetry-plugin-xml-http-request/karma.conf.js
index 7183aab033..3019564a15 100644
--- a/packages/opentelemetry-plugin-xml-http-request/karma.conf.js
+++ b/packages/opentelemetry-plugin-xml-http-request/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/package.json b/packages/opentelemetry-plugin-xml-http-request/package.json
index b0f878bc09..d5f3adc59b 100644
--- a/packages/opentelemetry-plugin-xml-http-request/package.json
+++ b/packages/opentelemetry-plugin-xml-http-request/package.json
@@ -55,7 +55,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
@@ -76,6 +76,7 @@
"dependencies": {
"@opentelemetry/api": "^0.8.3",
"@opentelemetry/core": "^0.8.3",
+ "@opentelemetry/semantic-conventions": "^0.8.3",
"@opentelemetry/web": "^0.8.3",
"shimmer": "^1.2.1"
}
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/enums/EventNames.ts b/packages/opentelemetry-plugin-xml-http-request/src/enums/EventNames.ts
index c3edf96cea..b0e7983fa6 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/enums/EventNames.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/src/enums/EventNames.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/index.ts b/packages/opentelemetry-plugin-xml-http-request/src/index.ts
index 41f752b023..80ed3961b0 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/index.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/types.ts b/packages/opentelemetry-plugin-xml-http-request/src/types.ts
index 0fb63f676a..bc49bcd62b 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/types.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/version.ts b/packages/opentelemetry-plugin-xml-http-request/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/version.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts
index 13e8e03c0f..59b59cc03d 100644
--- a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +21,19 @@ import {
isUrlIgnored,
isWrapped,
otperformance,
- urlMatches,
} from '@opentelemetry/core';
import {
- addSpanNetworkEvent,
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
+import {
+ addSpanNetworkEvents,
getResource,
parseUrl,
PerformanceTimingNames as PTN,
+ shouldPropagateTraceHeaders,
} from '@opentelemetry/web';
import * as shimmer from 'shimmer';
-import { AttributeNames } from './enums/AttributeNames';
import { EventNames } from './enums/EventNames';
import {
OpenFunction,
@@ -83,7 +86,12 @@ export class XMLHttpRequestPlugin extends BasePlugin {
* @private
*/
private _addHeaders(xhr: XMLHttpRequest, spanUrl: string) {
- if (!this._shouldPropagateTraceHeaders(spanUrl)) {
+ if (
+ !shouldPropagateTraceHeaders(
+ spanUrl,
+ this._config.propagateTraceHeaderCorsUrls
+ )
+ ) {
return;
}
const headers: { [key: string]: unknown } = {};
@@ -93,34 +101,6 @@ export class XMLHttpRequestPlugin extends BasePlugin {
});
}
- /**
- * checks if trace headers should be propagated
- * @param spanUrl
- * @private
- */
- _shouldPropagateTraceHeaders(spanUrl: string) {
- let propagateTraceHeaderUrls =
- this._config.propagateTraceHeaderCorsUrls || [];
- if (
- typeof propagateTraceHeaderUrls === 'string' ||
- propagateTraceHeaderUrls instanceof RegExp
- ) {
- propagateTraceHeaderUrls = [propagateTraceHeaderUrls];
- }
- const parsedSpanUrl = parseUrl(spanUrl);
-
- if (parsedSpanUrl.origin === window.location.origin) {
- return true;
- } else {
- for (const propagateTraceHeaderUrl of propagateTraceHeaderUrls) {
- if (urlMatches(spanUrl, propagateTraceHeaderUrl)) {
- return true;
- }
- }
- return false;
- }
- }
-
/**
* Add cors pre flight child span
* @param span
@@ -135,7 +115,7 @@ export class XMLHttpRequestPlugin extends BasePlugin {
const childSpan = this._tracer.startSpan('CORS Preflight', {
startTime: corsPreFlightRequest[PTN.FETCH_START],
});
- this._addSpanNetworkEvents(childSpan, corsPreFlightRequest);
+ addSpanNetworkEvents(childSpan, corsPreFlightRequest);
childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);
});
}
@@ -151,41 +131,20 @@ export class XMLHttpRequestPlugin extends BasePlugin {
if (typeof spanUrl === 'string') {
const parsedUrl = parseUrl(spanUrl);
- span.setAttribute(AttributeNames.HTTP_STATUS_CODE, xhrMem.status);
- span.setAttribute(AttributeNames.HTTP_STATUS_TEXT, xhrMem.statusText);
- span.setAttribute(AttributeNames.HTTP_HOST, parsedUrl.host);
+ span.setAttribute(HttpAttribute.HTTP_STATUS_CODE, xhrMem.status);
+ span.setAttribute(HttpAttribute.HTTP_STATUS_TEXT, xhrMem.statusText);
+ span.setAttribute(HttpAttribute.HTTP_HOST, parsedUrl.host);
span.setAttribute(
- AttributeNames.HTTP_SCHEME,
+ HttpAttribute.HTTP_SCHEME,
parsedUrl.protocol.replace(':', '')
);
// @TODO do we want to collect this or it will be collected earlier once only or
// maybe when parent span is not available ?
- span.setAttribute(AttributeNames.HTTP_USER_AGENT, navigator.userAgent);
+ span.setAttribute(HttpAttribute.HTTP_USER_AGENT, navigator.userAgent);
}
}
- /**
- * Adds Network events to the span
- * @param span
- * @param resource
- * @private
- */
- private _addSpanNetworkEvents(
- span: api.Span,
- resource: PerformanceResourceTiming
- ) {
- addSpanNetworkEvent(span, PTN.FETCH_START, resource);
- addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource);
- addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource);
- addSpanNetworkEvent(span, PTN.CONNECT_START, resource);
- addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource);
- addSpanNetworkEvent(span, PTN.CONNECT_END, resource);
- addSpanNetworkEvent(span, PTN.REQUEST_START, resource);
- addSpanNetworkEvent(span, PTN.RESPONSE_START, resource);
- addSpanNetworkEvent(span, PTN.RESPONSE_END, resource);
- }
-
/**
* will collect information about all resources created
* between "send" and "end" with additional waiting for main resource
@@ -257,6 +216,7 @@ export class XMLHttpRequestPlugin extends BasePlugin {
// information
resources = otperformance.getEntriesByType(
// ts thinks this is the perf_hooks module, but it is the browser performance api
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
'resource' as any
) as PerformanceResourceTiming[];
}
@@ -278,7 +238,7 @@ export class XMLHttpRequestPlugin extends BasePlugin {
this._addChildSpan(span, corsPreFlightRequest);
this._markResourceAsUsed(corsPreFlightRequest);
}
- this._addSpanNetworkEvents(span, mainRequest);
+ addSpanNetworkEvents(span, mainRequest);
}
}
@@ -319,9 +279,9 @@ export class XMLHttpRequestPlugin extends BasePlugin {
const currentSpan = this._tracer.startSpan(url, {
kind: api.SpanKind.CLIENT,
attributes: {
- [AttributeNames.COMPONENT]: this.component,
- [AttributeNames.HTTP_METHOD]: method,
- [AttributeNames.HTTP_URL]: url,
+ [GeneralAttribute.COMPONENT]: this.component,
+ [HttpAttribute.HTTP_METHOD]: method,
+ [HttpAttribute.HTTP_URL]: url,
},
});
diff --git a/packages/opentelemetry-plugin-xml-http-request/test/index-webpack.ts b/packages/opentelemetry-plugin-xml-http-request/test/index-webpack.ts
index 7731f09091..061a48ccfa 100644
--- a/packages/opentelemetry-plugin-xml-http-request/test/index-webpack.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('.', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
index ff2b487941..1a59f5c092 100644
--- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
+++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,13 +24,16 @@ import {
} from '@opentelemetry/core';
import { ZoneContextManager } from '@opentelemetry/context-zone';
import * as tracing from '@opentelemetry/tracing';
+import {
+ HttpAttribute,
+ GeneralAttribute,
+} from '@opentelemetry/semantic-conventions';
import {
PerformanceTimingNames as PTN,
WebTracerProvider,
} from '@opentelemetry/web';
import * as assert from 'assert';
import * as sinon from 'sinon';
-import { AttributeNames } from '../src/enums/AttributeNames';
import { EventNames } from '../src/enums/EventNames';
import { XMLHttpRequestPlugin } from '../src/xhr';
@@ -238,40 +241,40 @@ describe('xhr', () => {
assert.ok(
attributes[keys[0]] !== '',
- `attributes ${AttributeNames.COMPONENT} is not defined`
+ `attributes ${GeneralAttribute.COMPONENT} is not defined`
);
assert.strictEqual(
attributes[keys[1]],
'GET',
- `attributes ${AttributeNames.HTTP_METHOD} is wrong`
+ `attributes ${HttpAttribute.HTTP_METHOD} is wrong`
);
assert.strictEqual(
attributes[keys[2]],
url,
- `attributes ${AttributeNames.HTTP_URL} is wrong`
+ `attributes ${HttpAttribute.HTTP_URL} is wrong`
);
assert.strictEqual(
attributes[keys[3]],
200,
- `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong`
+ `attributes ${HttpAttribute.HTTP_STATUS_CODE} is wrong`
);
assert.strictEqual(
attributes[keys[4]],
'OK',
- `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong`
+ `attributes ${HttpAttribute.HTTP_STATUS_TEXT} is wrong`
);
assert.strictEqual(
attributes[keys[5]],
window.location.host,
- `attributes ${AttributeNames.HTTP_HOST} is wrong`
+ `attributes ${HttpAttribute.HTTP_HOST} is wrong`
);
assert.ok(
attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https',
- `attributes ${AttributeNames.HTTP_SCHEME} is wrong`
+ `attributes ${HttpAttribute.HTTP_SCHEME} is wrong`
);
assert.ok(
attributes[keys[7]] !== '',
- `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined`
+ `attributes ${HttpAttribute.HTTP_USER_AGENT} is not defined`
);
assert.strictEqual(keys.length, 8, 'number of attributes is wrong');
@@ -508,40 +511,40 @@ describe('xhr', () => {
assert.ok(
attributes[keys[0]] !== '',
- `attributes ${AttributeNames.COMPONENT} is not defined`
+ `attributes ${GeneralAttribute.COMPONENT} is not defined`
);
assert.strictEqual(
attributes[keys[1]],
'GET',
- `attributes ${AttributeNames.HTTP_METHOD} is wrong`
+ `attributes ${HttpAttribute.HTTP_METHOD} is wrong`
);
assert.strictEqual(
attributes[keys[2]],
url,
- `attributes ${AttributeNames.HTTP_URL} is wrong`
+ `attributes ${HttpAttribute.HTTP_URL} is wrong`
);
assert.strictEqual(
attributes[keys[3]],
400,
- `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong`
+ `attributes ${HttpAttribute.HTTP_STATUS_CODE} is wrong`
);
assert.strictEqual(
attributes[keys[4]],
'Bad Request',
- `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong`
+ `attributes ${HttpAttribute.HTTP_STATUS_TEXT} is wrong`
);
assert.strictEqual(
attributes[keys[5]],
'raw.githubusercontent.com',
- `attributes ${AttributeNames.HTTP_HOST} is wrong`
+ `attributes ${HttpAttribute.HTTP_HOST} is wrong`
);
assert.ok(
attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https',
- `attributes ${AttributeNames.HTTP_SCHEME} is wrong`
+ `attributes ${HttpAttribute.HTTP_SCHEME} is wrong`
);
assert.ok(
attributes[keys[7]] !== '',
- `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined`
+ `attributes ${HttpAttribute.HTTP_USER_AGENT} is not defined`
);
assert.strictEqual(keys.length, 8, 'number of attributes is wrong');
diff --git a/packages/opentelemetry-resources/src/Resource.ts b/packages/opentelemetry-resources/src/Resource.ts
index bed19ee739..f8dc503c1c 100644
--- a/packages/opentelemetry-resources/src/Resource.ts
+++ b/packages/opentelemetry-resources/src/Resource.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/constants.ts b/packages/opentelemetry-resources/src/constants.ts
index c6423777b3..d60b604522 100644
--- a/packages/opentelemetry-resources/src/constants.ts
+++ b/packages/opentelemetry-resources/src/constants.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,13 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Semantic conventions for Resources
- * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-resource-semantic-conventions.md
- */
-
-/** Attributes defining a running environment (e.g. Cloud, Data Center). */
export const CLOUD_RESOURCE = {
/** Name of the cloud provider. Example values are aws, azure, gcp. */
PROVIDER: 'cloud.provider',
diff --git a/packages/opentelemetry-resources/src/index.ts b/packages/opentelemetry-resources/src/index.ts
index 13673409aa..f5a851015a 100644
--- a/packages/opentelemetry-resources/src/index.ts
+++ b/packages/opentelemetry-resources/src/index.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/browser/detect-resources.ts b/packages/opentelemetry-resources/src/platform/browser/detect-resources.ts
index 43db76639a..7ea78b8d39 100644
--- a/packages/opentelemetry-resources/src/platform/browser/detect-resources.ts
+++ b/packages/opentelemetry-resources/src/platform/browser/detect-resources.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/browser/index.ts b/packages/opentelemetry-resources/src/platform/browser/index.ts
index 560cdcf821..f90eb34a5f 100644
--- a/packages/opentelemetry-resources/src/platform/browser/index.ts
+++ b/packages/opentelemetry-resources/src/platform/browser/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/index.ts b/packages/opentelemetry-resources/src/platform/index.ts
index 6c6d039c91..a12506ffa9 100644
--- a/packages/opentelemetry-resources/src/platform/index.ts
+++ b/packages/opentelemetry-resources/src/platform/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,8 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// Use the node platform by default. The "browser" field of package.json is used
-// to override this file to use `./browser/index.ts` when packaged with
-// webpack, Rollup, etc.
export * from './node';
diff --git a/packages/opentelemetry-resources/src/platform/node/detect-resources.ts b/packages/opentelemetry-resources/src/platform/node/detect-resources.ts
index 2351250582..d226ed4437 100644
--- a/packages/opentelemetry-resources/src/platform/node/detect-resources.ts
+++ b/packages/opentelemetry-resources/src/platform/node/detect-resources.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts
index 7e68016925..e58c214db0 100644
--- a/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts
+++ b/packages/opentelemetry-resources/src/platform/node/detectors/AwsEc2Detector.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts
index a6e4cf31b1..58ba567c36 100644
--- a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts
+++ b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/GcpDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/GcpDetector.ts
index ab1136fe8b..25518ed963 100644
--- a/packages/opentelemetry-resources/src/platform/node/detectors/GcpDetector.ts
+++ b/packages/opentelemetry-resources/src/platform/node/detectors/GcpDetector.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/index.ts b/packages/opentelemetry-resources/src/platform/node/detectors/index.ts
index 79597f3f1c..c0c3c37b2c 100644
--- a/packages/opentelemetry-resources/src/platform/node/detectors/index.ts
+++ b/packages/opentelemetry-resources/src/platform/node/detectors/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/platform/node/index.ts b/packages/opentelemetry-resources/src/platform/node/index.ts
index 560cdcf821..f90eb34a5f 100644
--- a/packages/opentelemetry-resources/src/platform/node/index.ts
+++ b/packages/opentelemetry-resources/src/platform/node/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/types.ts b/packages/opentelemetry-resources/src/types.ts
index a9705350a5..e1aa0d45b0 100644
--- a/packages/opentelemetry-resources/src/types.ts
+++ b/packages/opentelemetry-resources/src/types.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/src/version.ts b/packages/opentelemetry-resources/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-resources/src/version.ts
+++ b/packages/opentelemetry-resources/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/Resource.test.ts b/packages/opentelemetry-resources/test/Resource.test.ts
index 4061932532..0c5d0feb9f 100644
--- a/packages/opentelemetry-resources/test/Resource.test.ts
+++ b/packages/opentelemetry-resources/test/Resource.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/detect-resources.test.ts b/packages/opentelemetry-resources/test/detect-resources.test.ts
index 4bf5a0d7cc..ca609fb3c4 100644
--- a/packages/opentelemetry-resources/test/detect-resources.test.ts
+++ b/packages/opentelemetry-resources/test/detect-resources.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts b/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts
index 4c04897916..b60a6cc7f6 100644
--- a/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts
+++ b/packages/opentelemetry-resources/test/detectors/AwsEc2Detector.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts
index b8dfe508eb..20a63e64d5 100644
--- a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts
+++ b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/detectors/GcpDetector.test.ts b/packages/opentelemetry-resources/test/detectors/GcpDetector.test.ts
index 271f8f9c89..75adb78980 100644
--- a/packages/opentelemetry-resources/test/detectors/GcpDetector.test.ts
+++ b/packages/opentelemetry-resources/test/detectors/GcpDetector.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/resource-assertions.test.ts b/packages/opentelemetry-resources/test/resource-assertions.test.ts
index 2ccff2e1b4..20e626daac 100644
--- a/packages/opentelemetry-resources/test/resource-assertions.test.ts
+++ b/packages/opentelemetry-resources/test/resource-assertions.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-resources/test/util/resource-assertions.ts b/packages/opentelemetry-resources/test/util/resource-assertions.ts
index 01ae1f17c0..a6db54b320 100644
--- a/packages/opentelemetry-resources/test/util/resource-assertions.ts
+++ b/packages/opentelemetry-resources/test/util/resource-assertions.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-semantic-conventions/.eslintignore b/packages/opentelemetry-semantic-conventions/.eslintignore
new file mode 100644
index 0000000000..378eac25d3
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/.eslintignore
@@ -0,0 +1 @@
+build
diff --git a/packages/opentelemetry-semantic-conventions/.eslintrc.js b/packages/opentelemetry-semantic-conventions/.eslintrc.js
new file mode 100644
index 0000000000..9dfe62f9b8
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/.eslintrc.js
@@ -0,0 +1,9 @@
+module.exports = {
+ "env": {
+ "mocha": true,
+ "commonjs": true,
+ "node": true,
+ "browser": true
+ },
+ ...require('../../eslint.config.js')
+}
diff --git a/packages/opentelemetry-semantic-conventions/.npmignore b/packages/opentelemetry-semantic-conventions/.npmignore
new file mode 100644
index 0000000000..9505ba9450
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/.npmignore
@@ -0,0 +1,4 @@
+/bin
+/coverage
+/doc
+/test
diff --git a/packages/opentelemetry-semantic-conventions/LICENSE b/packages/opentelemetry-semantic-conventions/LICENSE
new file mode 100644
index 0000000000..b0e74c7d15
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/LICENSE
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [2020] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/packages/opentelemetry-semantic-conventions/README.md b/packages/opentelemetry-semantic-conventions/README.md
new file mode 100644
index 0000000000..eca85da6fc
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/README.md
@@ -0,0 +1,49 @@
+# OpenTelemetry Semantic Conventions
+
+[![Gitter chat][gitter-image]][gitter-url]
+[![NPM Published Version][npm-img]][npm-url]
+[![dependencies][dependencies-image]][dependencies-url]
+[![devDependencies][devDependencies-image]][devDependencies-url]
+[![Apache License][license-image]][license-image]
+
+Semantic Convention constants for use with the OpenTelemetry SDK/APIs. [This document][trace-semantic_conventions] defines standard attributes for traces.
+
+## Installation
+
+```bash
+npm install --save @opentelemetry/semantic-conventions
+```
+
+## Usage
+
+```ts
+import { GeneralAttribute } from '@opentelemetry/semantic-conventions';
+
+const span = tracer.startSpan().startSpan(spanName, spanOptions)
+ .setAttributes({
+ [GeneralAttribute.NET_PEER_HOSTNAME]: 'localhost',
+ });
+```
+
+## Useful links
+
+- For more information on OpenTelemetry, visit:
+- For more about OpenTelemetry JavaScript:
+- For help or feedback on this project, join us on [gitter][gitter-url]
+
+## License
+
+Apache 2.0 - See [LICENSE][license-url] for more information.
+
+[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg
+[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
+[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE
+[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
+[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-semantic-conventions
+[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-semantic-conventions
+[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-semantic-conventions
+[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-semantic-conventions&type=dev
+[npm-url]: https://www.npmjs.com/package/@opentelemetry/semantic-conventions
+[npm-img]: https://badge.fury.io/js/%40opentelemetry%semantic-conventions.svg
+
+[trace-semantic_conventions]: https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions
diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json
new file mode 100644
index 0000000000..f033eb908b
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/package.json
@@ -0,0 +1,57 @@
+{
+ "name": "@opentelemetry/semantic-conventions",
+ "version": "0.8.3",
+ "description": "OpenTelemetry semantic conventions",
+ "main": "build/src/index.js",
+ "types": "build/src/index.d.ts",
+ "repository": "open-telemetry/opentelemetry-js",
+ "scripts": {
+ "lint": "eslint . --ext .ts",
+ "lint:fix": "eslint . --ext .ts --fix",
+ "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
+ "tdd": "npm run test -- --watch-extensions ts --watch",
+ "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
+ "clean": "rimraf build/*",
+ "precompile": "tsc --version",
+ "version:update": "node ../../scripts/version-update.js",
+ "compile": "npm run version:update && tsc -p .",
+ "prepare": "npm run compile"
+ },
+ "keywords": [
+ "opentelemetry",
+ "nodejs",
+ "tracing",
+ "attributes",
+ "semantic conventions"
+ ],
+ "author": "OpenTelemetry Authors",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8.0.0"
+ },
+ "files": [
+ "build/src/**/*.js",
+ "build/src/**/*.d.ts",
+ "doc",
+ "LICENSE",
+ "README.md"
+ ],
+ "publishConfig": {
+ "access": "public"
+ },
+ "devDependencies": {
+ "@types/mocha": "7.0.2",
+ "@types/node": "14.0.13",
+ "@types/sinon": "9.0.4",
+ "codecov": "3.7.0",
+ "gts": "2.0.2",
+ "mocha": "7.2.0",
+ "nock": "12.0.3",
+ "nyc": "15.1.0",
+ "rimraf": "3.0.2",
+ "sinon": "9.0.2",
+ "ts-mocha": "7.0.0",
+ "ts-node": "8.10.2",
+ "typescript": "3.9.5"
+ }
+}
diff --git a/packages/opentelemetry-semantic-conventions/src/index.ts b/packages/opentelemetry-semantic-conventions/src/index.ts
new file mode 100644
index 0000000000..ae2998a38c
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/index.ts
@@ -0,0 +1,17 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './trace';
diff --git a/packages/opentelemetry-semantic-conventions/src/trace/database.ts b/packages/opentelemetry-semantic-conventions/src/trace/database.ts
new file mode 100644
index 0000000000..86705c746e
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/trace/database.ts
@@ -0,0 +1,30 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Database attribute names defined by the Opetelemetry Semantic Conventions specification
+ * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/database.md
+ */
+export const DatabaseAttribute = {
+ // db (required)
+ DB_TYPE: 'db.type',
+ DB_INSTANCE: 'db.instance',
+ DB_STATEMENT: 'db.statement',
+ DB_URL: 'db.url',
+
+ // db (optional)
+ DB_USER: 'db.user',
+};
diff --git a/packages/opentelemetry-semantic-conventions/src/trace/general.ts b/packages/opentelemetry-semantic-conventions/src/trace/general.ts
new file mode 100644
index 0000000000..d52f4ff449
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/trace/general.ts
@@ -0,0 +1,37 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export const GeneralAttribute = {
+ // Not in spec
+ COMPONENT: 'component',
+
+ NET_PEER_IP: 'net.peer.ip',
+ NET_PEER_ADDRESS: 'net.peer.address',
+ NET_PEER_HOSTNAME: 'net.peer.host',
+ NET_PEER_PORT: 'net.peer.port',
+ NET_PEER_NAME: 'net.peer.name',
+ NET_PEER_IPV4: 'net.peer.ipv4',
+ NET_PEER_IPV6: 'net.peer.ipv6',
+ NET_PEER_SERVICE: 'net.peer.service',
+ NET_HOST_IP: 'net.host.ip',
+ NET_HOST_PORT: 'net.host.port',
+ NET_HOST_NAME: 'net.host.name',
+ NET_TRANSPORT: 'net.transport',
+
+ // These are used as potential values to NET_TRANSPORT
+ IP_TCP: 'IP.TCP',
+ IP_UDP: 'IP.UDP',
+ INPROC: 'inproc',
+};
diff --git a/packages/opentelemetry-semantic-conventions/src/trace/http.ts b/packages/opentelemetry-semantic-conventions/src/trace/http.ts
new file mode 100644
index 0000000000..d194db6a41
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/trace/http.ts
@@ -0,0 +1,33 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export const HttpAttribute = {
+ HTTP_HOST: 'http.host',
+ HTTP_METHOD: 'http.method',
+ HTTP_TARGET: 'http.target',
+ HTTP_ROUTE: 'http.route',
+ HTTP_URL: 'http.url',
+ HTTP_STATUS_CODE: 'http.status_code',
+ HTTP_STATUS_TEXT: 'http.status_text',
+ HTTP_FLAVOR: 'http.flavor',
+ HTTP_SERVER_NAME: 'http.server_name',
+ HTTP_CLIENT_IP: 'http.client_ip',
+ HTTP_SCHEME: 'http.scheme',
+
+ // NOT ON OFFICIAL SPEC
+ HTTP_ERROR_NAME: 'http.error_name',
+ HTTP_ERROR_MESSAGE: 'http.error_message',
+ HTTP_USER_AGENT: 'http.user_agent',
+};
diff --git a/packages/opentelemetry-semantic-conventions/src/trace/index.ts b/packages/opentelemetry-semantic-conventions/src/trace/index.ts
new file mode 100644
index 0000000000..a923ac0a36
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/trace/index.ts
@@ -0,0 +1,20 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+export * from './general';
+export * from './rpc';
+export * from './http';
+export * from './database';
diff --git a/packages/opentelemetry-semantic-conventions/src/trace/rpc.ts b/packages/opentelemetry-semantic-conventions/src/trace/rpc.ts
new file mode 100644
index 0000000000..c2681b3d98
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/trace/rpc.ts
@@ -0,0 +1,25 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+export const RpcAttribute = {
+ RPC_SERVICE: 'rpc.service',
+
+ // GRPC (no spec)
+ GRPC_KIND: 'grpc.kind', // SERVER or CLIENT
+ GRPC_METHOD: 'grpc.method',
+ GRPC_STATUS_CODE: 'grpc.status_code',
+ GRPC_ERROR_NAME: 'grpc.error_name',
+ GRPC_ERROR_MESSAGE: 'grpc.error_message',
+};
diff --git a/packages/opentelemetry-semantic-conventions/src/version.ts b/packages/opentelemetry-semantic-conventions/src/version.ts
new file mode 100644
index 0000000000..9e616149a4
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/src/version.ts
@@ -0,0 +1,18 @@
+/*
+ * Copyright The OpenTelemetry Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// this is autogenerated file, see scripts/version-update.js
+export const VERSION = '0.8.3';
diff --git a/packages/opentelemetry-semantic-conventions/tsconfig.json b/packages/opentelemetry-semantic-conventions/tsconfig.json
new file mode 100644
index 0000000000..e4b3b29e6a
--- /dev/null
+++ b/packages/opentelemetry-semantic-conventions/tsconfig.json
@@ -0,0 +1,8 @@
+{
+ "extends": "../tsconfig.base",
+ "compilerOptions": {
+ "rootDir": ".",
+ "outDir": "build"
+ },
+ "include": ["src/**/*.ts", "test/**/*.ts"]
+}
diff --git a/packages/opentelemetry-shim-opentracing/src/index.ts b/packages/opentelemetry-shim-opentracing/src/index.ts
index 7f4e715ee0..e47e7bbcdf 100644
--- a/packages/opentelemetry-shim-opentracing/src/index.ts
+++ b/packages/opentelemetry-shim-opentracing/src/index.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts
index 0fc561bacb..14a49f411f 100644
--- a/packages/opentelemetry-shim-opentracing/src/shim.ts
+++ b/packages/opentelemetry-shim-opentracing/src/shim.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-shim-opentracing/src/version.ts b/packages/opentelemetry-shim-opentracing/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-shim-opentracing/src/version.ts
+++ b/packages/opentelemetry-shim-opentracing/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts
index f7358c9421..9524045d15 100644
--- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts
+++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts
@@ -1,5 +1,5 @@
-/**
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/karma.conf.js b/packages/opentelemetry-tracing/karma.conf.js
index 7183aab033..3019564a15 100644
--- a/packages/opentelemetry-tracing/karma.conf.js
+++ b/packages/opentelemetry-tracing/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json
index 652e245321..201d18e9b7 100644
--- a/packages/opentelemetry-tracing/package.json
+++ b/packages/opentelemetry-tracing/package.json
@@ -56,7 +56,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-mocha": "2.0.1",
diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts
index f86c950e85..e1b4a54bb0 100644
--- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts
+++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts b/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts
index 92a04dd530..ccd96d51d7 100644
--- a/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts
+++ b/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts b/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts
index c00bcb393a..d9291c0436 100644
--- a/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts
+++ b/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts
index 7a6c97bda7..d602d64dd6 100644
--- a/packages/opentelemetry-tracing/src/Span.ts
+++ b/packages/opentelemetry-tracing/src/Span.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/SpanProcessor.ts b/packages/opentelemetry-tracing/src/SpanProcessor.ts
index 7f8deae0a9..ad415fec83 100644
--- a/packages/opentelemetry-tracing/src/SpanProcessor.ts
+++ b/packages/opentelemetry-tracing/src/SpanProcessor.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts
index dbedb8949c..9bc8004eab 100644
--- a/packages/opentelemetry-tracing/src/Tracer.ts
+++ b/packages/opentelemetry-tracing/src/Tracer.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/config.ts b/packages/opentelemetry-tracing/src/config.ts
index 99eb0d22fd..e06be1c7cc 100644
--- a/packages/opentelemetry-tracing/src/config.ts
+++ b/packages/opentelemetry-tracing/src/config.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts b/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts
index 381ec393f4..9076dfdf21 100644
--- a/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts
+++ b/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/ConsoleSpanExporter.ts b/packages/opentelemetry-tracing/src/export/ConsoleSpanExporter.ts
index 42c5875bd6..dfb12a25bf 100644
--- a/packages/opentelemetry-tracing/src/export/ConsoleSpanExporter.ts
+++ b/packages/opentelemetry-tracing/src/export/ConsoleSpanExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/InMemorySpanExporter.ts b/packages/opentelemetry-tracing/src/export/InMemorySpanExporter.ts
index b3de120411..04eec13318 100644
--- a/packages/opentelemetry-tracing/src/export/InMemorySpanExporter.ts
+++ b/packages/opentelemetry-tracing/src/export/InMemorySpanExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts
index 93bf90ea5d..48436444be 100644
--- a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts
+++ b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts b/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts
index 073ffb3f20..eb35a378f6 100644
--- a/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts
+++ b/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/export/SpanExporter.ts b/packages/opentelemetry-tracing/src/export/SpanExporter.ts
index 72f7ff2572..e83621e594 100644
--- a/packages/opentelemetry-tracing/src/export/SpanExporter.ts
+++ b/packages/opentelemetry-tracing/src/export/SpanExporter.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/index.ts b/packages/opentelemetry-tracing/src/index.ts
index 6fdcfce454..720241a310 100644
--- a/packages/opentelemetry-tracing/src/index.ts
+++ b/packages/opentelemetry-tracing/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/types.ts b/packages/opentelemetry-tracing/src/types.ts
index 7f5dedb031..c6eeae35d0 100644
--- a/packages/opentelemetry-tracing/src/types.ts
+++ b/packages/opentelemetry-tracing/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/utility.ts b/packages/opentelemetry-tracing/src/utility.ts
index a417c6e74b..3143a8b1de 100644
--- a/packages/opentelemetry-tracing/src/utility.ts
+++ b/packages/opentelemetry-tracing/src/utility.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/src/version.ts b/packages/opentelemetry-tracing/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-tracing/src/version.ts
+++ b/packages/opentelemetry-tracing/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts
index 6de7339798..da06751509 100644
--- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts
+++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/MultiSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/MultiSpanProcessor.test.ts
index b83da007a6..ea0a6b8e3e 100644
--- a/packages/opentelemetry-tracing/test/MultiSpanProcessor.test.ts
+++ b/packages/opentelemetry-tracing/test/MultiSpanProcessor.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts
index db73757371..9c070c4189 100644
--- a/packages/opentelemetry-tracing/test/Span.test.ts
+++ b/packages/opentelemetry-tracing/test/Span.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/Tracer.test.ts b/packages/opentelemetry-tracing/test/Tracer.test.ts
index 71b6aa569d..1c4922db84 100644
--- a/packages/opentelemetry-tracing/test/Tracer.test.ts
+++ b/packages/opentelemetry-tracing/test/Tracer.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts
index c4452bb069..05ec6b95ff 100644
--- a/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts
+++ b/packages/opentelemetry-tracing/test/export/BatchSpanProcessor.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/export/ConsoleSpanExporter.test.ts b/packages/opentelemetry-tracing/test/export/ConsoleSpanExporter.test.ts
index 6377874195..4a4829ec3a 100644
--- a/packages/opentelemetry-tracing/test/export/ConsoleSpanExporter.test.ts
+++ b/packages/opentelemetry-tracing/test/export/ConsoleSpanExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/export/InMemorySpanExporter.test.ts b/packages/opentelemetry-tracing/test/export/InMemorySpanExporter.test.ts
index f83f96ce02..47af46580e 100644
--- a/packages/opentelemetry-tracing/test/export/InMemorySpanExporter.test.ts
+++ b/packages/opentelemetry-tracing/test/export/InMemorySpanExporter.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts
index 572883b115..60f5cf0e8b 100644
--- a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts
+++ b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-tracing/test/index-webpack.ts b/packages/opentelemetry-tracing/test/index-webpack.ts
index 7731f09091..061a48ccfa 100644
--- a/packages/opentelemetry-tracing/test/index-webpack.ts
+++ b/packages/opentelemetry-tracing/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('.', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-web/karma.conf.js b/packages/opentelemetry-web/karma.conf.js
index 88c2849684..09cb7c72dd 100644
--- a/packages/opentelemetry-web/karma.conf.js
+++ b/packages/opentelemetry-web/karma.conf.js
@@ -1,5 +1,5 @@
/*!
- * Copyright 2019, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json
index dcf829018d..96f83d1c29 100644
--- a/packages/opentelemetry-web/package.json
+++ b/packages/opentelemetry-web/package.json
@@ -54,7 +54,7 @@
"codecov": "3.7.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
- "karma": "5.0.9",
+ "karma": "5.1.0",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jquery": "0.2.4",
diff --git a/packages/opentelemetry-web/src/StackContextManager.ts b/packages/opentelemetry-web/src/StackContextManager.ts
index e91755fdeb..718ec88035 100644
--- a/packages/opentelemetry-web/src/StackContextManager.ts
+++ b/packages/opentelemetry-web/src/StackContextManager.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ export class StackContextManager implements ContextManager {
context = Context.ROOT_CONTEXT
): T {
const manager = this;
- const contextWrapper = function (this: any, ...args: any[]) {
+ const contextWrapper = function (this: unknown, ...args: unknown[]) {
return manager.with(context, () => target.apply(this, args));
};
Object.defineProperty(contextWrapper, 'length', {
diff --git a/packages/opentelemetry-web/src/WebTracerProvider.ts b/packages/opentelemetry-web/src/WebTracerProvider.ts
index 41200c455d..79d23d938d 100644
--- a/packages/opentelemetry-web/src/WebTracerProvider.ts
+++ b/packages/opentelemetry-web/src/WebTracerProvider.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/src/enums/PerformanceTimingNames.ts b/packages/opentelemetry-web/src/enums/PerformanceTimingNames.ts
index 12d5a44fa8..846a9ba967 100644
--- a/packages/opentelemetry-web/src/enums/PerformanceTimingNames.ts
+++ b/packages/opentelemetry-web/src/enums/PerformanceTimingNames.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/src/index.ts b/packages/opentelemetry-web/src/index.ts
index aafef2114c..a506be00ce 100644
--- a/packages/opentelemetry-web/src/index.ts
+++ b/packages/opentelemetry-web/src/index.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/src/types.ts b/packages/opentelemetry-web/src/types.ts
index be51c8ad62..10ee04f14e 100644
--- a/packages/opentelemetry-web/src/types.ts
+++ b/packages/opentelemetry-web/src/types.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-/**
- * Performance metrics
- */
import { PerformanceTimingNames } from './enums/PerformanceTimingNames';
export type PerformanceEntries = {
@@ -57,3 +53,12 @@ export interface PerformanceResourceTimingInfo {
corsPreFlightRequest?: PerformanceResourceTiming;
mainRequest?: PerformanceResourceTiming;
}
+
+type PropagateTraceHeaderCorsUrl = string | RegExp;
+
+/**
+ * urls which should include trace headers when origin doesn't match
+ */
+export type PropagateTraceHeaderCorsUrls =
+ | PropagateTraceHeaderCorsUrl
+ | PropagateTraceHeaderCorsUrl[];
diff --git a/packages/opentelemetry-web/src/utils.ts b/packages/opentelemetry-web/src/utils.ts
index e5a3cd43fe..aa3dd320b6 100644
--- a/packages/opentelemetry-web/src/utils.ts
+++ b/packages/opentelemetry-web/src/utils.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,16 +14,25 @@
* limitations under the License.
*/
-import { PerformanceEntries, PerformanceResourceTimingInfo } from './types';
+import {
+ PerformanceEntries,
+ PerformanceResourceTimingInfo,
+ PropagateTraceHeaderCorsUrls,
+} from './types';
import { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames';
import * as api from '@opentelemetry/api';
-import { hrTimeToNanoseconds, timeInputToHrTime } from '@opentelemetry/core';
+import {
+ hrTimeToNanoseconds,
+ timeInputToHrTime,
+ urlMatches,
+} from '@opentelemetry/core';
/**
* Helper function to be able to use enum as typed key in type and in interface when using forEach
* @param obj
* @param key
*/
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function hasKey(obj: O, key: keyof any): key is keyof O {
return key in obj;
}
@@ -54,6 +63,26 @@ export function addSpanNetworkEvent(
return undefined;
}
+/**
+ * Helper function for adding network events
+ * @param span
+ * @param resource
+ */
+export function addSpanNetworkEvents(
+ span: api.Span,
+ resource: PerformanceEntries
+): void {
+ addSpanNetworkEvent(span, PTN.FETCH_START, resource);
+ addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_START, resource);
+ addSpanNetworkEvent(span, PTN.DOMAIN_LOOKUP_END, resource);
+ addSpanNetworkEvent(span, PTN.CONNECT_START, resource);
+ addSpanNetworkEvent(span, PTN.SECURE_CONNECTION_START, resource);
+ addSpanNetworkEvent(span, PTN.CONNECT_END, resource);
+ addSpanNetworkEvent(span, PTN.REQUEST_START, resource);
+ addSpanNetworkEvent(span, PTN.RESPONSE_START, resource);
+ addSpanNetworkEvent(span, PTN.RESPONSE_END, resource);
+}
+
/**
* sort resources by startTime
* @param filteredResources
@@ -79,6 +108,7 @@ export function sortResources(filteredResources: PerformanceResourceTiming[]) {
* @param endTimeHR
* @param resources
* @param ignoredResources
+ * @param initiatorType
*/
export function getResource(
spanUrl: string,
@@ -87,14 +117,16 @@ export function getResource(
resources: PerformanceResourceTiming[],
ignoredResources: WeakSet = new WeakSet<
PerformanceResourceTiming
- >()
+ >(),
+ initiatorType?: string
): PerformanceResourceTimingInfo {
const filteredResources = filterResourcesForSpan(
spanUrl,
startTimeHR,
endTimeHR,
resources,
- ignoredResources
+ ignoredResources,
+ initiatorType
);
if (filteredResources.length === 0) {
@@ -192,7 +224,8 @@ function filterResourcesForSpan(
startTimeHR: api.HrTime,
endTimeHR: api.HrTime,
resources: PerformanceResourceTiming[],
- ignoredResources: WeakSet
+ ignoredResources: WeakSet,
+ initiatorType?: string
) {
const startTime = hrTimeToNanoseconds(startTimeHR);
const endTime = hrTimeToNanoseconds(endTimeHR);
@@ -205,7 +238,8 @@ function filterResourcesForSpan(
);
return (
- resource.initiatorType.toLowerCase() === 'xmlhttprequest' &&
+ resource.initiatorType.toLowerCase() ===
+ (initiatorType || 'xmlhttprequest') &&
resource.name === spanUrl &&
resourceStartTime >= startTime &&
resourceEndTime <= endTime
@@ -237,6 +271,7 @@ export function parseUrl(url: string): HTMLAnchorElement {
* @param optimised - when id attribute of element is present the xpath can be
* simplified to contain id
*/
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getElementXPath(target: any, optimised?: boolean) {
if (target.nodeType === Node.DOCUMENT_NODE) {
return '/';
@@ -312,3 +347,30 @@ function getNodeValue(target: HTMLElement, optimised?: boolean): string {
}
return `/${nodeValue}`;
}
+
+/**
+ * Checks if trace headers should be propagated
+ * @param spanUrl
+ * @private
+ */
+export function shouldPropagateTraceHeaders(
+ spanUrl: string,
+ propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls
+) {
+ let propagateTraceHeaderUrls = propagateTraceHeaderCorsUrls || [];
+ if (
+ typeof propagateTraceHeaderUrls === 'string' ||
+ propagateTraceHeaderUrls instanceof RegExp
+ ) {
+ propagateTraceHeaderUrls = [propagateTraceHeaderUrls];
+ }
+ const parsedSpanUrl = parseUrl(spanUrl);
+
+ if (parsedSpanUrl.origin === window.location.origin) {
+ return true;
+ } else {
+ return propagateTraceHeaderUrls.some(propagateTraceHeaderUrl =>
+ urlMatches(spanUrl, propagateTraceHeaderUrl)
+ );
+ }
+}
diff --git a/packages/opentelemetry-web/src/version.ts b/packages/opentelemetry-web/src/version.ts
index 90d0ab01d0..9e616149a4 100644
--- a/packages/opentelemetry-web/src/version.ts
+++ b/packages/opentelemetry-web/src/version.ts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/test/StackContextManager.test.ts b/packages/opentelemetry-web/test/StackContextManager.test.ts
index 5c0fe26b22..daebd27971 100644
--- a/packages/opentelemetry-web/test/StackContextManager.test.ts
+++ b/packages/opentelemetry-web/test/StackContextManager.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/test/WebTracerProvider.test.ts b/packages/opentelemetry-web/test/WebTracerProvider.test.ts
index 92f40ccdf0..01b1590d96 100644
--- a/packages/opentelemetry-web/test/WebTracerProvider.test.ts
+++ b/packages/opentelemetry-web/test/WebTracerProvider.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/test/index-webpack.ts b/packages/opentelemetry-web/test/index-webpack.ts
index 7731f09091..061a48ccfa 100644
--- a/packages/opentelemetry-web/test/index-webpack.ts
+++ b/packages/opentelemetry-web/test/index-webpack.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,9 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// This file is the webpack entry point for the browser Karma tests. It requires
-// all modules ending in "test" from the current folder and all its subfolders.
const testsContext = require.context('.', true, /test$/);
testsContext.keys().forEach(testsContext);
diff --git a/packages/opentelemetry-web/test/registration.test.ts b/packages/opentelemetry-web/test/registration.test.ts
index cc86d1c681..2639072bf4 100644
--- a/packages/opentelemetry-web/test/registration.test.ts
+++ b/packages/opentelemetry-web/test/registration.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2020, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/packages/opentelemetry-web/test/utils.test.ts b/packages/opentelemetry-web/test/utils.test.ts
index 96745f5514..805986de71 100644
--- a/packages/opentelemetry-web/test/utils.test.ts
+++ b/packages/opentelemetry-web/test/utils.test.ts
@@ -1,5 +1,5 @@
-/*!
- * Copyright 2019, OpenTelemetry Authors
+/*
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,9 +26,11 @@ import * as assert from 'assert';
import * as sinon from 'sinon';
import {
addSpanNetworkEvent,
+ addSpanNetworkEvents,
getElementXPath,
getResource,
PerformanceEntries,
+ shouldPropagateTraceHeaders,
} from '../src';
import { PerformanceTimingNames as PTN } from '../src/enums/PerformanceTimingNames';
@@ -132,6 +134,31 @@ describe('utils', () => {
sandbox.restore();
});
+ describe('addSpanNetworkEvents', () => {
+ it('should add all network events to span', () => {
+ const addEventSpy = sinon.spy();
+ const span = ({
+ addEvent: addEventSpy,
+ } as unknown) as tracing.Span;
+ const entries = {
+ [PTN.FETCH_START]: 123,
+ [PTN.DOMAIN_LOOKUP_START]: 123,
+ [PTN.DOMAIN_LOOKUP_END]: 123,
+ [PTN.CONNECT_START]: 123,
+ [PTN.SECURE_CONNECTION_START]: 123,
+ [PTN.CONNECT_END]: 123,
+ [PTN.REQUEST_START]: 123,
+ [PTN.RESPONSE_START]: 123,
+ [PTN.RESPONSE_END]: 123,
+ } as PerformanceEntries;
+
+ assert.strictEqual(addEventSpy.callCount, 0);
+
+ addSpanNetworkEvents(span, entries);
+
+ assert.strictEqual(addEventSpy.callCount, 9);
+ });
+ });
describe('addSpanNetworkEvent', () => {
describe('when entries contain the performance', () => {
it('should add event to span', () => {
@@ -508,6 +535,40 @@ describe('utils', () => {
assert.strictEqual(node, getElementByXpath(element));
});
});
+
+ describe('shouldPropagateTraceHeaders', () => {
+ it('should propagate trace when url is the same as origin', () => {
+ const result = shouldPropagateTraceHeaders(
+ `${window.location.origin}/foo/bar`
+ );
+ assert.strictEqual(result, true);
+ });
+ it('should propagate trace when url match', () => {
+ const result = shouldPropagateTraceHeaders(
+ 'http://foo.com',
+ 'http://foo.com'
+ );
+ assert.strictEqual(result, true);
+ });
+ it('should propagate trace when url match regexp', () => {
+ const result = shouldPropagateTraceHeaders('http://foo.com', /foo.+/);
+ assert.strictEqual(result, true);
+ });
+ it('should propagate trace when url match array of string', () => {
+ const result = shouldPropagateTraceHeaders('http://foo.com', [
+ 'http://foo.com',
+ ]);
+ assert.strictEqual(result, true);
+ });
+ it('should propagate trace when url match array of regexp', () => {
+ const result = shouldPropagateTraceHeaders('http://foo.com', [/foo.+/]);
+ assert.strictEqual(result, true);
+ });
+ it("should NOT propagate trace when url doesn't match", () => {
+ const result = shouldPropagateTraceHeaders('http://foo.com');
+ assert.strictEqual(result, false);
+ });
+ });
});
function getElementByXpath(path: string) {
diff --git a/renovate.json b/renovate.json
index f45d8f110c..a8a6b1bf32 100644
--- a/renovate.json
+++ b/renovate.json
@@ -1,5 +1,10 @@
{
"extends": [
"config:base"
- ]
+ ],
+ "rebaseWhen": "behind-base-branch",
+ "schedule": [
+ "after 9pm and before 5am"
+ ],
+ "labels": ["dependencies"]
}
diff --git a/scripts/version-update.js b/scripts/version-update.js
index 720456fdef..32b05516da 100644
--- a/scripts/version-update.js
+++ b/scripts/version-update.js
@@ -1,5 +1,5 @@
/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ const packageJsonUrl = path.resolve(`${appRoot}/package.json`);
const pjson = require(packageJsonUrl);
const content = `/*
- * Copyright 2020, OpenTelemetry Authors
+ * Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.