diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c78a412a05..6d44130a79 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,7 +5,7 @@ ##################################################### # # Learn about membership in OpenTelemetry community: -# https://github.com/open-telemetry/community/blob/master/community-membership.md +# https://github.com/open-telemetry/community/blob/main/community-membership.md # # # Learn about CODEOWNERS file format: diff --git a/.github/ISSUE_TEMPLATE/plugin_request.md b/.github/ISSUE_TEMPLATE/plugin_request.md index f6ef3905f3..67b61573e2 100644 --- a/.github/ISSUE_TEMPLATE/plugin_request.md +++ b/.github/ISSUE_TEMPLATE/plugin_request.md @@ -7,7 +7,7 @@ labels: plugin-request **Is your plugin request related to a problem? Please describe.** diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1430a81999..8a17e1d13d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,9 +5,9 @@ Before creating a pull request, please make sure: - Your PR is solving one problem - Please provide enough information so that others can review your pull request - You have read the guide for contributing - - See https://github.com/open-telemetry/opentelemetry-js/blob/master/CONTRIBUTING.md + - See https://github.com/open-telemetry/opentelemetry-js/blob/main/CONTRIBUTING.md - You signed all your commits (otherwise we won't be able to merge the PR) - - See https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md#sign-the-cla + - See https://github.com/open-telemetry/community/blob/main/CONTRIBUTING.md#sign-the-cla - You added unit tests for the new functionality - You mention in the PR description which issue it is addressing, e.g. "Fixes #xxx". This will auto-close the issue that your PR fixes (if such) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1299c32578..2c9d60566d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,10 @@ name: Lint -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: jobs: build: diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fee4ab1f..fe52e67c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -216,4 +216,4 @@ Released 2020-04-27 Released 2020-04-08 -For details about this release and all previous releases, see https://github.com/open-telemetry/opentelemetry-js/blob/master/CHANGELOG.md +For details about this release and all previous releases, see https://github.com/open-telemetry/opentelemetry-js/blob/main/CHANGELOG.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d4ecbe1610..59aac5e6d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ Reporting bugs is an important contribution. Please make sure to include: ### Before you start Please read project contribution -[guide](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md) +[guide](https://github.com/open-telemetry/community/blob/main/CONTRIBUTING.md) for general practices for OpenTelemetry project. #### Conventional commit @@ -42,16 +42,16 @@ git remote add upstream https://github.com/open-telemetry/opentelemetry-js-contr git remote -v ``` -To update your fork, fetch the upstream repo's branches and commits, then merge your master with upstream's master: +To update your fork, fetch the upstream repo's branches and commits, then merge your main with upstream's main: ``` git fetch upstream -git checkout master -git merge upstream/master +git checkout main +git merge upstream/main ``` -Remember to always work in a branch of your local copy, as you might otherwise have to contend with conflicts in master. +Remember to always work in a branch of your local copy, as you might otherwise have to contend with conflicts in main. -Please also see [GitHub workflow](https://github.com/open-telemetry/community/blob/master/CONTRIBUTING.md#github-workflow) section of general project contributing guide. +Please also see [GitHub workflow](https://github.com/open-telemetry/community/blob/main/CONTRIBUTING.md#github-workflow) section of general project contributing guide. ### Running the tests diff --git a/README.md b/README.md index b054bec367..4d6244703c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ---

- Getting Started + Getting Started   •   API Documentation   •   @@ -13,10 +13,10 @@ GitHub release (latest by date including pre-releases) - + Codecov Status - + license
@@ -115,25 +115,25 @@ We'd love your help!. Use tags [up-for-grabs][up-for-grabs-issues] and Apache 2.0 - See [LICENSE][license-url] for more information. [node-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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE [up-for-grabs-issues]: https://github.com/open-telemetry/opentelemetry-js-contrib/issues?q=is%3Aissue+is%3Aopen+label%3Aup-for-grabs [good-first-issues]: https://github.com/open-telemetry/openTelemetry-js-contrib/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 -[otel-plugin-grpc]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-grpc -[otel-plugin-http]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-http -[otel-plugin-https]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-https -[otel-plugin-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-dns -[otel-plugin-document-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-plugin-document-load -[otel-plugin-react-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-plugin-react-load -[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 -[otel-plugin-user-interaction]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web/opentelemetry-plugin-user-interaction -[otel-plugin-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-xml-http-request -[otel-plugin-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-plugin-express -[otel-plugins-node-core-and-contrib]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/metapackages/plugins-node-core-and-contrib -[otel-contrib-hapi-instrumentation]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-hapi-instrumentation -[otel-contrib-koa-instrumentation]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-koa-instrumentation -[otel-contrib-instrumentation-graphql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-hapi-instrumentation +[otel-plugin-grpc]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-grpc +[otel-plugin-http]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-http +[otel-plugin-https]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-https +[otel-plugin-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-dns +[otel-plugin-document-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-plugin-document-load +[otel-plugin-react-load]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-plugin-react-load +[otel-plugin-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-ioredis +[otel-plugin-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-mongodb +[otel-plugin-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-mysql +[otel-plugin-pg-pool]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-pg-pool +[otel-plugin-pg]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-pg +[otel-plugin-redis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-redis +[otel-plugin-user-interaction]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/web/opentelemetry-plugin-user-interaction +[otel-plugin-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-xml-http-request +[otel-plugin-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-express +[otel-plugins-node-core-and-contrib]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/plugins-node-core-and-contrib +[otel-contrib-hapi-instrumentation]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-hapi-instrumentation +[otel-contrib-koa-instrumentation]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-koa-instrumentation +[otel-contrib-instrumentation-graphql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-instrumentation-graphql diff --git a/RELEASING.md b/RELEASING.md index 68b2f6c956..e124d0c6fc 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -16,7 +16,7 @@ Release Process: ## Update to latest locally -Use `git fetch` and `git checkout origin/master` to ensure you’re on the latest commit. Make sure you have no unstaged changes. Ideally, also use `git clean -dfx` to remove all ignored and untracked files. +Use `git fetch` and `git checkout origin/main` to ensure you’re on the latest commit. Make sure you have no unstaged changes. Ideally, also use `git clean -dfx` to remove all ignored and untracked files. ## Create a new branch @@ -70,7 +70,7 @@ GITHUB_AUTH=xxxxx lerna-changelog --from=v1.0.0 --to=v2.0.0 From what `lerna-changelog` has generated, starts new Unreleased label. Follow the example set by recent Released label. -On [GitHub Releases](https://github.com/open-telemetry/opentelemetry-js/releases), follow the example set by recent releases to populate a summary of changes, as well as a list of commits that were applied since the last release. Save it as a draft, don’t publish it. Don’t forget the tag -- call it `vx.y.z` and leave it pointing at `master` for now (this can be changed as long as the GitHub release isn’t published). +On [GitHub Releases](https://github.com/open-telemetry/opentelemetry-js/releases), follow the example set by recent releases to populate a summary of changes, as well as a list of commits that were applied since the last release. Save it as a draft, don’t publish it. Don’t forget the tag -- call it `vx.y.z` and leave it pointing at `main` for now (this can be changed as long as the GitHub release isn’t published). ## Create a new PR @@ -101,9 +101,9 @@ Publish the GitHub release, ensuring that the tag points to the newly landed com ## Update CHANGELOG -* After releasing is done, update the [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-js/blob/master/CHANGELOG.md) and start new Unreleased label. +* After releasing is done, update the [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-js/blob/main/CHANGELOG.md) and start new Unreleased label. * Create a new commit with the exact title: `Post Release: update CHANGELOG.md`. -* Go through PR review and merge it to GitHub master branch. +* Go through PR review and merge it to GitHub main branch. ## Known Issues diff --git a/examples/dns/README.md b/examples/dns/README.md index 3d18e2816f..dc9f810edd 100644 --- a/examples/dns/README.md +++ b/examples/dns/README.md @@ -53,7 +53,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/express/README.md b/examples/express/README.md index 317149d638..10fdc78c6c 100644 --- a/examples/express/README.md +++ b/examples/express/README.md @@ -69,7 +69,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/graphql/README.md b/examples/graphql/README.md index 465439fd47..cc25573219 100644 --- a/examples/graphql/README.md +++ b/examples/graphql/README.md @@ -5,11 +5,11 @@ This example shows how to use 2 popular graphql servers - [Apollo GraphQL](https://www.npmjs.com/package/apollo-server) - [GraphQL HTTP Server Middleware](https://www.npmjs.com/package/express-graphql) -and [@opentelemetry/instrumentation-graphql](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-instrumentation-graphql) to instrument a simple Node.js application. +and [@opentelemetry/instrumentation-graphql](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation-graphql) to instrument a simple Node.js application. This instrumentation should work with any graphql server as it instruments graphql directly. -This example will export spans data simultaneously using [Exporter Collector](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-collector). +This example will export spans data simultaneously using [Exporter Collector](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-collector). ## Installation diff --git a/examples/graphql/schema.js b/examples/graphql/schema.js index be98379c40..e4903f76b6 100644 --- a/examples/graphql/schema.js +++ b/examples/graphql/schema.js @@ -3,7 +3,7 @@ const https = require('https'); const graphql = require('graphql'); -const url1 = 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; +const url1 = 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'; function getData(url) { return new Promise((resolve, reject) => { diff --git a/examples/grpc-census-prop/README.md b/examples/grpc-census-prop/README.md index d85f0446ff..ba70d2d1e7 100644 --- a/examples/grpc-census-prop/README.md +++ b/examples/grpc-census-prop/README.md @@ -11,7 +11,7 @@ that is already instrumented using OpenCensus. If both sides of gRPC communication are using OpenTelemetry instrumentation then the `propagator-grpc-census-binary` propagator isn't required. Context will be propagated using the `traceparent` header (thanks to the -[HttpTraceContext](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts) +[HttpTraceContext](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts) propagator from opentelemetry-core). If there is a mix of OpenCensus and OpenTelemetry instrumentation then the `propagator-grpc-census-binary` propagator allows OpenTelemetry to propagate context through the `grpc-trace-bin` binary header. @@ -123,7 +123,7 @@ See [combination4](./combination4.md) for example output ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/grpc_dynamic_codegen/README.md b/examples/grpc_dynamic_codegen/README.md index a28d1c4238..f7f1f38310 100644 --- a/examples/grpc_dynamic_codegen/README.md +++ b/examples/grpc_dynamic_codegen/README.md @@ -53,7 +53,7 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/ ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/hapi/README.md b/examples/hapi/README.md index 38bbf9f1dd..13ed19543b 100644 --- a/examples/hapi/README.md +++ b/examples/hapi/README.md @@ -69,7 +69,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/koa/README.md b/examples/koa/README.md index 194542b9e7..d742289a03 100644 --- a/examples/koa/README.md +++ b/examples/koa/README.md @@ -69,7 +69,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/mongodb/README.md b/examples/mongodb/README.md index 9958995d4d..cef079c078 100644 --- a/examples/mongodb/README.md +++ b/examples/mongodb/README.md @@ -67,7 +67,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/mysql/README.md b/examples/mysql/README.md index ac25b27399..ad91495968 100644 --- a/examples/mysql/README.md +++ b/examples/mysql/README.md @@ -67,7 +67,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/postgres/README.md b/examples/postgres/README.md index f82058f1bd..548938e0bb 100644 --- a/examples/postgres/README.md +++ b/examples/postgres/README.md @@ -98,7 +98,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/examples/react-load/preact/README.md b/examples/react-load/preact/README.md index ef77db47de..7e6d14b303 100644 --- a/examples/react-load/preact/README.md +++ b/examples/react-load/preact/README.md @@ -60,6 +60,6 @@ After a few seconds (when the request is fulfilled): Apache 2.0 - See [LICENSE][license-url] for more information. -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE [otel]: https://opentelemetry.io/ -[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node \ No newline at end of file +[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node \ No newline at end of file diff --git a/examples/react-load/react/README.md b/examples/react-load/react/README.md index 013c5c5656..e2a5696463 100644 --- a/examples/react-load/react/README.md +++ b/examples/react-load/react/README.md @@ -66,6 +66,6 @@ Since the example adds in a delay to the request, we can see that reflected in t Apache 2.0 - See [LICENSE][license-url] for more information. -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE [otel]: https://opentelemetry.io/ -[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node +[otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node diff --git a/examples/redis/README.md b/examples/redis/README.md index c74c033ae7..073a9396cb 100644 --- a/examples/redis/README.md +++ b/examples/redis/README.md @@ -99,7 +99,7 @@ Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() ## Useful links - For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: +- For more information on OpenTelemetry for Node.js, visit: ## LICENSE diff --git a/metapackages/plugins-node-core-and-contrib/README.md b/metapackages/plugins-node-core-and-contrib/README.md index 7526f7e4aa..e7c5d2403c 100644 --- a/metapackages/plugins-node-core-and-contrib/README.md +++ b/metapackages/plugins-node-core-and-contrib/README.md @@ -34,7 +34,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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 @@ -43,11 +43,11 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [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 +[otel-plugin-dns]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-dns +[otel-plugin-express]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-express +[otel-plugin-ioredis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-ioredis +[otel-plugin-mongodb]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-mongodb +[otel-plugin-mysql]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-mysql +[otel-plugin-pg-pool]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-pg-pool +[otel-plugin-pg]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-pg +[otel-plugin-redis]: https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/plugins/node/opentelemetry-plugin-redis diff --git a/packages/opentelemetry-host-metrics/README.md b/packages/opentelemetry-host-metrics/README.md index 681a612446..19f9007553 100644 --- a/packages/opentelemetry-host-metrics/README.md +++ b/packages/opentelemetry-host-metrics/README.md @@ -51,7 +51,7 @@ APACHE 2.0 - See [LICENSE][license-url] for more information. [gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js-contrib.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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/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-contrib.svg?path=packages%2Fopentelemetry-host-metrics [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-host-metrics diff --git a/packages/opentelemetry-test-utils/testUtils.ts b/packages/opentelemetry-test-utils/testUtils.ts index fc97a1bb30..e6d1918d73 100644 --- a/packages/opentelemetry-test-utils/testUtils.ts +++ b/packages/opentelemetry-test-utils/testUtils.ts @@ -15,7 +15,13 @@ */ import * as childProcess from 'child_process'; -import { SpanKind, Attributes, Event, Span, Status } from '@opentelemetry/api'; +import { + SpanKind, + Attributes, + Span, + Status, + TimedEvent, +} from '@opentelemetry/api'; import * as assert from 'assert'; import { ReadableSpan } from '@opentelemetry/tracing'; import { @@ -78,7 +84,7 @@ export const assertSpan = ( span: ReadableSpan, kind: SpanKind, attributes: Attributes, - events: Event[], + events: TimedEvent[], status: Status ) => { assert.strictEqual(span.spanContext.traceId.length, 32); diff --git a/plugins/node/opentelemetry-hapi-instrumentation/README.md b/plugins/node/opentelemetry-hapi-instrumentation/README.md index e8abaf98eb..ed9eb9e62e 100644 --- a/plugins/node/opentelemetry-hapi-instrumentation/README.md +++ b/plugins/node/opentelemetry-hapi-instrumentation/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`Hapi`](https://hapi.dev). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -43,10 +43,10 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/hapi](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/hapi) for a short example using Hapi +See [examples/hapi](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/hapi) for a short example using Hapi ## Hapi Instrumentation Support -This package provides automatic tracing for hapi server routes and [request lifecycle](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) extensions defined either directly or via a Hapi plugin. +This package provides automatic tracing for hapi server routes and [request lifecycle](https://github.com/hapijs/hapi/blob/main/API.md#request-lifecycle) extensions defined either directly or via a Hapi plugin. ## Useful links - For more information on OpenTelemetry, visit: @@ -59,7 +59,7 @@ 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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/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-contrib/status.svg?path=plugins/node/opentelemetry-hapi-instrumentation [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-hapi-instrumentation diff --git a/plugins/node/opentelemetry-hapi-instrumentation/src/hapi.ts b/plugins/node/opentelemetry-hapi-instrumentation/src/hapi.ts index d02c4df80a..38978bc993 100644 --- a/plugins/node/opentelemetry-hapi-instrumentation/src/hapi.ts +++ b/plugins/node/opentelemetry-hapi-instrumentation/src/hapi.ts @@ -68,7 +68,7 @@ export class HapiInstrumentation extends BasePlugin { // type definition for Hapi.Server. Hapi.Server (note the uppercase) can also function // as a factory function, similarly to Hapi.server (lowercase), and so should // also be supported and instrumented. This is an issue with the DefinitelyTyped repo. - // Function is defined at: https://github.com/hapijs/hapi/blob/master/lib/index.js#L9 + // Function is defined at: https://github.com/hapijs/hapi/blob/main/lib/index.js#L9 this._logger.debug('Patching Hapi.Server'); shimmer.wrap( // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/plugins/node/opentelemetry-instrumentation-graphql/README.md b/plugins/node/opentelemetry-instrumentation-graphql/README.md index 2340e81799..835a06e242 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/README.md +++ b/plugins/node/opentelemetry-instrumentation-graphql/README.md @@ -66,7 +66,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-instrumentation-graphql [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-instrumentation-graphql diff --git a/plugins/node/opentelemetry-instrumentation-graphql/test/schema.ts b/plugins/node/opentelemetry-instrumentation-graphql/test/schema.ts index a55982c6c6..f62b21f0d4 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/test/schema.ts +++ b/plugins/node/opentelemetry-instrumentation-graphql/test/schema.ts @@ -18,7 +18,7 @@ import * as https from 'https'; import * as graphql from 'graphql'; const url1 = - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'; function getData(url: string): any { return new Promise((resolve, reject) => { diff --git a/plugins/node/opentelemetry-koa-instrumentation/README.md b/plugins/node/opentelemetry-koa-instrumentation/README.md index e1f17a9acb..64b13fec20 100644 --- a/plugins/node/opentelemetry-koa-instrumentation/README.md +++ b/plugins/node/opentelemetry-koa-instrumentation/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`Koa`](https://github.com/koajs/koa). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -43,7 +43,7 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/koa) for a short example using both Koa and @koa/router +See [examples/koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/koa) for a short example using both Koa and @koa/router ## Koa Packages @@ -60,7 +60,7 @@ 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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/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-contrib/status.svg?path=plugins/node/opentelemetry-koa-instrumentation [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-koa-instrumentation diff --git a/plugins/node/opentelemetry-plugin-dns/README.md b/plugins/node/opentelemetry-plugin-dns/README.md index d4ee247c9b..367885e87e 100644 --- a/plugins/node/opentelemetry-plugin-dns/README.md +++ b/plugins/node/opentelemetry-plugin-dns/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`dns`](http://nodejs.org/dist/latest/docs/api/dns.html). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -55,7 +55,7 @@ Dns plugin has currently one option. You can set the following: | Options | Type | Description | | ------- | ---- | ----------- | -| [`ignoreHostnames`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-dns/src/types.ts#L98) | `IgnoreMatcher[]` | Dns plugin will not trace all requests that match hostnames | +| [`ignoreHostnames`](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-plugin-dns/src/types.ts#L98) | `IgnoreMatcher[]` | Dns plugin will not trace all requests that match hostnames | ## Useful links - For more information on OpenTelemetry, visit: @@ -68,7 +68,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-dns [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-dns diff --git a/plugins/node/opentelemetry-plugin-express/README.md b/plugins/node/opentelemetry-plugin-express/README.md index 0ad825f9b3..f65c96ad88 100644 --- a/plugins/node/opentelemetry-plugin-express/README.md +++ b/plugins/node/opentelemetry-plugin-express/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`express`](https://github.com/expressjs/express). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -43,7 +43,7 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/express) for a short example. +See [examples/express](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/express) for a short example. ### Caveats @@ -74,7 +74,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-express [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-express diff --git a/plugins/node/opentelemetry-plugin-express/src/types.ts b/plugins/node/opentelemetry-plugin-express/src/types.ts index 051eed6431..1c6fac0a2f 100644 --- a/plugins/node/opentelemetry-plugin-express/src/types.ts +++ b/plugins/node/opentelemetry-plugin-express/src/types.ts @@ -43,7 +43,7 @@ export type PatchedRequest = { } & Request; export type PathParams = string | RegExp | Array; -// https://github.com/expressjs/express/blob/master/lib/router/index.js#L53 +// https://github.com/expressjs/express/blob/main/lib/router/index.js#L53 export type ExpressRouter = { params: { [key: string]: string }; _params: string[]; @@ -53,7 +53,7 @@ export type ExpressRouter = { stack: ExpressLayer[]; }; -// https://github.com/expressjs/express/blob/master/lib/router/layer.js#L33 +// https://github.com/expressjs/express/blob/main/lib/router/layer.js#L33 export type ExpressLayer = { handle: Function; [kLayerPatched]?: boolean; @@ -68,7 +68,7 @@ export type LayerMetadata = { name: string; }; -// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md#databases-client-calls +// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/data-semantic-conventions.md#databases-client-calls export enum AttributeNames { COMPONENT = 'component', HTTP_ROUTE = 'http.route', @@ -85,7 +85,7 @@ export enum ExpressLayerType { export type IgnoreMatcher = string | RegExp | ((name: string) => boolean); /** - * Options available for the Express Plugin (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-express#express-plugin-options)) + * Options available for the Express Plugin (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-express#express-plugin-options)) */ export interface ExpressPluginConfig extends PluginConfig { /** Ignore specific based on their name */ diff --git a/plugins/node/opentelemetry-plugin-ioredis/README.md b/plugins/node/opentelemetry-plugin-ioredis/README.md index 188a2f0669..c41c34f068 100644 --- a/plugins/node/opentelemetry-plugin-ioredis/README.md +++ b/plugins/node/opentelemetry-plugin-ioredis/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`ioredis`](https://github.com/luin/ioredis). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -85,7 +85,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-ioredis [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-ioredis diff --git a/plugins/node/opentelemetry-plugin-ioredis/src/types.ts b/plugins/node/opentelemetry-plugin-ioredis/src/types.ts index b8d7aad62c..09246ace00 100644 --- a/plugins/node/opentelemetry-plugin-ioredis/src/types.ts +++ b/plugins/node/opentelemetry-plugin-ioredis/src/types.ts @@ -39,7 +39,7 @@ export type DbStatementSerializer = ( ) => string; /** - * Options available for the IORedis Plugin (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-ioredis#ioredis-plugin-options)) + * Options available for the IORedis Plugin (see [documentation](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-ioredis#ioredis-plugin-options)) */ export interface IoredisPluginConfig extends PluginConfig { /** Custom serializer function for the db.statement tag */ diff --git a/plugins/node/opentelemetry-plugin-ioredis/src/utils.ts b/plugins/node/opentelemetry-plugin-ioredis/src/utils.ts index 58201d5009..bd7ec340a5 100644 --- a/plugins/node/opentelemetry-plugin-ioredis/src/utils.ts +++ b/plugins/node/opentelemetry-plugin-ioredis/src/utils.ts @@ -36,6 +36,7 @@ import { const endSpan = (span: Span, err: NodeJS.ErrnoException | null | undefined) => { if (err) { + span.recordException(err); span.setStatus({ code: StatusCode.ERROR, message: err.message, @@ -116,7 +117,20 @@ export const traceSendCommand = ( try { const result = original.apply(this, arguments); - endSpan(span, null); + + const origResolve = cmd.resolve; + /* eslint-disable @typescript-eslint/no-explicit-any */ + cmd.resolve = function (result: any) { + endSpan(span, null); + origResolve(result); + }; + + const origReject = cmd.reject; + cmd.reject = function (err: Error) { + endSpan(span, err); + origReject(err); + }; + return result; } catch (error) { endSpan(span, error); diff --git a/plugins/node/opentelemetry-plugin-ioredis/test/ioredis.test.ts b/plugins/node/opentelemetry-plugin-ioredis/test/ioredis.test.ts index 5027d992d3..fe570c1e17 100644 --- a/plugins/node/opentelemetry-plugin-ioredis/test/ioredis.test.ts +++ b/plugins/node/opentelemetry-plugin-ioredis/test/ioredis.test.ts @@ -28,6 +28,7 @@ import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import * as testUtils from '@opentelemetry/test-utils'; import { InMemorySpanExporter, + ReadableSpan, SimpleSpanProcessor, } from '@opentelemetry/tracing'; import * as assert from 'assert'; @@ -36,6 +37,7 @@ import { IORedisPlugin, plugin } from '../src'; import { IoredisPluginConfig, DbStatementSerializer } from '../src/types'; import { DatabaseAttribute, + ExceptionAttribute, GeneralAttribute, } from '@opentelemetry/semantic-conventions'; @@ -59,6 +61,20 @@ const unsetStatus: Status = { code: StatusCode.UNSET, }; +const predictableStackTrace = + '-- Stack trace replaced by test to predictable value -- '; +const sanitizeEventForAssertion = (span: ReadableSpan) => { + span.events.forEach(e => { + // stack trace includes data such as /user/{userName}/repos/{projectName} + if (e.attributes?.[ExceptionAttribute.STACKTRACE]) { + e.attributes[ExceptionAttribute.STACKTRACE] = predictableStackTrace; + } + + // since time will change on each test invocation, it is being replaced to predicable value + e.time = [0, 0]; + }); +}; + describe('ioredis', () => { const provider = new NodeTracerProvider(); let ioredis: typeof ioredisTypes; @@ -131,9 +147,11 @@ describe('ioredis', () => { assert.strictEqual(endedSpans.length, 3); assert.strictEqual(endedSpans[2].name, 'test span'); - client.quit(done); - assert.strictEqual(endedSpans.length, 4); - assert.strictEqual(endedSpans[3].name, 'quit'); + client.quit(() => { + assert.strictEqual(endedSpans.length, 4); + assert.strictEqual(endedSpans[3].name, 'quit'); + done(); + }); }; const errorHandler = (err: Error) => { assert.ifError(err); @@ -263,6 +281,38 @@ describe('ioredis', () => { }); }); + it('should set span with error when redis return reject', async () => { + const span = provider.getTracer('ioredis-test').startSpan('test span'); + await context.with(setSpan(context.active(), span), async () => { + await client.set('non-int-key', 'non-int-value'); + try { + // should throw 'ReplyError: ERR value is not an integer or out of range' + // because the value im the key is not numeric and we try to increment it + await client.incr('non-int-key'); + } catch (ex) { + const endedSpans = memoryExporter.getFinishedSpans(); + assert.strictEqual(endedSpans.length, 2); + const ioredisSpan = endedSpans[1]; + // redis 'incr' operation failed with exception, so span should indicate it + assert.strictEqual(ioredisSpan.status.code, StatusCode.ERROR); + const exceptionEvent = ioredisSpan.events[0]; + assert.strictEqual(exceptionEvent.name, 'exception'); + assert.strictEqual( + exceptionEvent.attributes?.[ExceptionAttribute.MESSAGE], + ex.message + ); + assert.strictEqual( + exceptionEvent.attributes?.[ExceptionAttribute.STACKTRACE], + ex.stack + ); + assert.strictEqual( + exceptionEvent.attributes?.[ExceptionAttribute.TYPE], + ex.name + ); + } + }); + }); + it('should create a child span for streamify scanning', done => { const attributes = { ...DEFAULT_ATTRIBUTES, @@ -322,10 +372,10 @@ describe('ioredis', () => { const spanNames = [ 'connect', 'connect', - 'subscribe', 'info', 'info', 'subscribe', + 'subscribe', 'publish', 'publish', 'unsubscribe', @@ -377,24 +427,48 @@ describe('ioredis', () => { span.end(); const endedSpans = memoryExporter.getFinishedSpans(); + const evalshaSpan = endedSpans[0]; // the script may be already cached on server therefore we get either 2 or 3 spans if (endedSpans.length === 3) { assert.strictEqual(endedSpans[2].name, 'test span'); assert.strictEqual(endedSpans[1].name, 'eval'); assert.strictEqual(endedSpans[0].name, 'evalsha'); + // in this case, server returns NOSCRIPT error for evalsha, + // telling the client to use EVAL instead + sanitizeEventForAssertion(evalshaSpan); + testUtils.assertSpan( + evalshaSpan, + SpanKind.CLIENT, + attributes, + [ + { + attributes: { + [ExceptionAttribute.MESSAGE]: + 'NOSCRIPT No matching script. Please use EVAL.', + [ExceptionAttribute.STACKTRACE]: predictableStackTrace, + [ExceptionAttribute.TYPE]: 'ReplyError', + }, + name: 'exception', + time: [0, 0], + }, + ], + { + code: StatusCode.ERROR, + } + ); } else { assert.strictEqual(endedSpans.length, 2); assert.strictEqual(endedSpans[1].name, 'test span'); assert.strictEqual(endedSpans[0].name, 'evalsha'); + testUtils.assertSpan( + evalshaSpan, + SpanKind.CLIENT, + attributes, + [], + unsetStatus + ); } - testUtils.assertSpan( - endedSpans[0], - SpanKind.CLIENT, - attributes, - [], - unsetStatus - ); - testUtils.assertPropagation(endedSpans[0], span); + testUtils.assertPropagation(evalshaSpan, span); done(); }); }); diff --git a/plugins/node/opentelemetry-plugin-mongodb/README.md b/plugins/node/opentelemetry-plugin-mongodb/README.md index 0d6650de6f..78971f6e55 100644 --- a/plugins/node/opentelemetry-plugin-mongodb/README.md +++ b/plugins/node/opentelemetry-plugin-mongodb/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`mongodb`](https://github.com/mongodb/node-mongodb-native). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -43,7 +43,7 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/mongodb](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/mongodb) for a short example. +See [examples/mongodb](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/mongodb) for a short example. ### Mongo Plugin Options @@ -51,7 +51,7 @@ Mongodb plugin has few options available to choose from. You can set the followi | Options | Type | Description | | ------- | ---- | ----------- | -| [`enhancedDatabaseReporting`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts#L91) | `string` | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations | +| [`enhancedDatabaseReporting`](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts#L91) | `string` | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations | @@ -67,7 +67,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-mongodb [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-mongodb diff --git a/plugins/node/opentelemetry-plugin-mongodb/src/types.ts b/plugins/node/opentelemetry-plugin-mongodb/src/types.ts index 928539c606..84393b4c43 100644 --- a/plugins/node/opentelemetry-plugin-mongodb/src/types.ts +++ b/plugins/node/opentelemetry-plugin-mongodb/src/types.ts @@ -25,7 +25,7 @@ export type MongoInternalCommand = { q?: { [key: string]: unknown }; }; -// https://github.com/mongodb/node-mongodb-native/blob/master/lib/topologies/server.js#L179 +// https://github.com/mongodb/node-mongodb-native/blob/main/lib/topologies/server.js#L179 export type MongoInternalTopology = { s?: { // those are for mongodb@3 diff --git a/plugins/node/opentelemetry-plugin-mysql/README.md b/plugins/node/opentelemetry-plugin-mysql/README.md index 1d83611281..2d44d297eb 100644 --- a/plugins/node/opentelemetry-plugin-mysql/README.md +++ b/plugins/node/opentelemetry-plugin-mysql/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`mysql`](https://www.npmjs.com/package/mysql). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -44,7 +44,7 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/mysql) for a short example. +See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/mysql) for a short example. ## Useful links - For more information on OpenTelemetry, visit: @@ -57,7 +57,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-mysql [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-mysql diff --git a/plugins/node/opentelemetry-plugin-pg-pool/README.md b/plugins/node/opentelemetry-plugin-pg-pool/README.md index e2a4cc21fa..c29fb4541e 100644 --- a/plugins/node/opentelemetry-plugin-pg-pool/README.md +++ b/plugins/node/opentelemetry-plugin-pg-pool/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`pg`](https://github.com/brianc/node-postgres). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -47,7 +47,7 @@ const provider = new NodeTracerProvider({ }); ``` -See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/postgres) for a short example. +See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/postgres) for a short example. ## Supported Versions @@ -65,7 +65,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-pg-pool [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-pg-pool diff --git a/plugins/node/opentelemetry-plugin-pg-pool/src/enums.ts b/plugins/node/opentelemetry-plugin-pg-pool/src/enums.ts index 40bb4a0e8d..f2d96a9cd2 100644 --- a/plugins/node/opentelemetry-plugin-pg-pool/src/enums.ts +++ b/plugins/node/opentelemetry-plugin-pg-pool/src/enums.ts @@ -15,7 +15,7 @@ */ export enum AttributeNames { - // required by https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-database.md + // required by https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/data-database.md COMPONENT = 'component', DB_TYPE = 'db.type', DB_INSTANCE = 'db.instance', diff --git a/plugins/node/opentelemetry-plugin-pg/README.md b/plugins/node/opentelemetry-plugin-pg/README.md index 3c58c814bb..270dccf607 100644 --- a/plugins/node/opentelemetry-plugin-pg/README.md +++ b/plugins/node/opentelemetry-plugin-pg/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`pg`](https://github.com/brianc/node-postgres). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -63,7 +63,7 @@ const provider = new NodeTracerProvider({ }); ``` -See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/postgres) for a short example. +See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/postgres) for a short example. ### PostgreSQL Plugin Options @@ -71,7 +71,7 @@ PostgreSQL plugin has few options available to choose from. You can set the foll | Options | Type | Description | | ------- | ---- | ----------- | -| [`enhancedDatabaseReporting`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts#L90) | `boolean` | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations | +| [`enhancedDatabaseReporting`](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts#L90) | `boolean` | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations | ## Supported Versions @@ -89,7 +89,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-pg [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-pg diff --git a/plugins/node/opentelemetry-plugin-pg/src/enums.ts b/plugins/node/opentelemetry-plugin-pg/src/enums.ts index 91aa855c4b..ee9f5d3682 100644 --- a/plugins/node/opentelemetry-plugin-pg/src/enums.ts +++ b/plugins/node/opentelemetry-plugin-pg/src/enums.ts @@ -15,7 +15,7 @@ */ export enum AttributeNames { - // required by https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-database.md + // required by https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/data-database.md COMPONENT = 'component', DB_TYPE = 'db.type', DB_INSTANCE = 'db.instance', diff --git a/plugins/node/opentelemetry-plugin-redis/README.md b/plugins/node/opentelemetry-plugin-redis/README.md index c361fb2d94..af9fd0565b 100644 --- a/plugins/node/opentelemetry-plugin-redis/README.md +++ b/plugins/node/opentelemetry-plugin-redis/README.md @@ -7,7 +7,7 @@ This module provides automatic instrumentation for [`redis@^2.6.0`](https://github.com/NodeRedis/node_redis). For automatic instrumentation see the -[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node) package. +[@opentelemetry/node](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node) package. ## Installation @@ -44,7 +44,7 @@ const { NodeTracerProvider } = require('@opentelemetry/node'); const provider = new NodeTracerProvider(); ``` -See [examples/redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/redis) for a short example. +See [examples/redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/redis) for a short example. ## Useful links - For more information on OpenTelemetry, visit: @@ -57,7 +57,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-redis [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-redis diff --git a/plugins/web/opentelemetry-plugin-document-load/README.md b/plugins/web/opentelemetry-plugin-document-load/README.md index 374afa2ba5..88af4d8341 100644 --- a/plugins/web/opentelemetry-plugin-document-load/README.md +++ b/plugins/web/opentelemetry-plugin-document-load/README.md @@ -57,7 +57,7 @@ Because the browser does not send a trace context header for the initial page na ``` -See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a short example. +See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/tracer-web) for a short example. ## Useful links - For more information on OpenTelemetry, visit: @@ -70,7 +70,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-document-load [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-document-load diff --git a/plugins/web/opentelemetry-plugin-react-load/README.md b/plugins/web/opentelemetry-plugin-react-load/README.md index 7de8ee50bc..1b383688cd 100644 --- a/plugins/web/opentelemetry-plugin-react-load/README.md +++ b/plugins/web/opentelemetry-plugin-react-load/README.md @@ -28,7 +28,7 @@ import { BaseOpenTelemetryComponent } from '@opentelemetry/plugin-react-load'; export class Component1 extends BaseOpenTelemetryComponent { ... } ``` -See [/examples/react-load](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/react-load) for a short example. +See [/examples/react-load](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/react-load) for a short example. ## Useful links - For more information on OpenTelemetry, visit: @@ -41,7 +41,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat [npm-url]: https://www.npmjs.com/package/@opentelemetry/plugin-react-load [npm-img]: TODO:set_img_url diff --git a/plugins/web/opentelemetry-plugin-user-interaction/README.md b/plugins/web/opentelemetry-plugin-user-interaction/README.md index ba8dacf37f..662ce43fd4 100644 --- a/plugins/web/opentelemetry-plugin-user-interaction/README.md +++ b/plugins/web/opentelemetry-plugin-user-interaction/README.md @@ -92,7 +92,7 @@ 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-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/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-user-interaction [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-plugin-user-interaction diff --git a/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.nozone.test.ts b/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.nozone.test.ts index 07ae45eff7..65ced81285 100644 --- a/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.nozone.test.ts +++ b/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.nozone.test.ts @@ -32,7 +32,7 @@ import { } from './helper.test'; const FILE_URL = - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'; describe('UserInteractionPlugin', () => { describe('when zone.js is NOT available', () => { @@ -312,7 +312,7 @@ describe('UserInteractionPlugin', () => { const attributes = spanXhr.attributes; assert.equal( attributes['http.url'], - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json' + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json' ); // all other attributes are checked in xhr anyway diff --git a/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.test.ts b/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.test.ts index 3748df69a1..b0f0f482d7 100644 --- a/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.test.ts +++ b/plugins/web/opentelemetry-plugin-user-interaction/test/userInteraction.test.ts @@ -35,7 +35,7 @@ import { } from './helper.test'; const FILE_URL = - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'; describe('UserInteractionPlugin', () => { describe('when zone.js is available', () => { @@ -186,7 +186,7 @@ describe('UserInteractionPlugin', () => { const attributes = spanXhr.attributes; assert.equal( attributes['http.url'], - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json' + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json' ); // all other attributes are checked in xhr anyway diff --git a/propagators/README.md b/propagators/README.md index 02ebc3fae9..524e37fbc1 100644 --- a/propagators/README.md +++ b/propagators/README.md @@ -9,7 +9,7 @@ OpenTelemetry core package provides many Built-in Propagators such as HttpTraceContext Propagator, B3 Propagator, Composite Propagator etc. -[Click here](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-core#built-in-propagators) to see Built-in Propagators. +[Click here](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core#built-in-propagators) to see Built-in Propagators. ### Jaeger Propagator @@ -50,4 +50,4 @@ api.propagation.setGlobalPropagator(new GrpcCensusPropagator()); Apache 2.0 - See [LICENSE][license-url] for more information. -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/README.md b/propagators/opentelemetry-propagator-grpc-census-binary/README.md index 471975100a..4565008b02 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/README.md +++ b/propagators/opentelemetry-propagator-grpc-census-binary/README.md @@ -9,7 +9,7 @@ OpenTelemetry gRPC Census propagator provides gRPC header propagation for system * incoming gRPC calls come from services already instrumented using OpenCensus * outgoing gRPC calls go to services already instrumented using OpenCensus -This propagator works in conjunction with the OpenTelemetry [gRPC plugin](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-grpc). +This propagator works in conjunction with the OpenTelemetry [gRPC plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-grpc). Example of usage: @@ -37,7 +37,7 @@ Also, see [examples/grpc-census-prop](../../examples/grpc-census-prop) for a worked example that shows when this propagator can be useful. ## Implementation Details -See [binary-format.ts](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-propagation-binaryformat/src/binary-format.ts) for equivalent encoding/decoding of the format in OpenCensus. Note: the author of the OpenCensus binary format, [@mayurkale22](https://github.com/mayurkale22), also created BinaryTraceContext.ts in [opentelemetry-core](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-core) but that was subsequently removed as part of PR [#804](https://github.com/open-telemetry/opentelemetry-js/pull/804). The implementation of GrpcCensusPropagator in _this_ module uses a version of BinaryTraceContext.ts inspired by Mayur's previous work (with minor modifications e.g. there is no longer a BinaryFormat interface to implement). +See [binary-format.ts](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-propagation-binaryformat/src/binary-format.ts) for equivalent encoding/decoding of the format in OpenCensus. Note: the author of the OpenCensus binary format, [@mayurkale22](https://github.com/mayurkale22), also created BinaryTraceContext.ts in [opentelemetry-core](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core) but that was subsequently removed as part of PR [#804](https://github.com/open-telemetry/opentelemetry-js/pull/804). The implementation of GrpcCensusPropagator in _this_ module uses a version of BinaryTraceContext.ts inspired by Mayur's previous work (with minor modifications e.g. there is no longer a BinaryFormat interface to implement). ## Useful links - For more information on OpenTelemetry, visit: @@ -50,7 +50,7 @@ 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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/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-contrib/status.svg?path=propagators/opentelemetry-propagator-grpc-census-binary [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=propagators%2Fopentelemetry-propagator-grpc-census-binary diff --git a/propagators/opentelemetry-propagator-jaeger/README.md b/propagators/opentelemetry-propagator-jaeger/README.md index 6427312339..ba53de8e8e 100644 --- a/propagators/opentelemetry-propagator-jaeger/README.md +++ b/propagators/opentelemetry-propagator-jaeger/README.md @@ -50,7 +50,7 @@ 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-contrib/blob/master/LICENSE +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/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-propagator-jaeger [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-jaeger diff --git a/propagators/opentelemetry-propagator-opentracing/.eslintignore b/propagators/opentelemetry-propagator-opentracing/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.eslintignore @@ -0,0 +1 @@ +build diff --git a/propagators/opentelemetry-propagator-opentracing/.eslintrc.js b/propagators/opentelemetry-propagator-opentracing/.eslintrc.js new file mode 100644 index 0000000000..9dfe62f9b8 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.eslintrc.js @@ -0,0 +1,9 @@ +module.exports = { + "env": { + "mocha": true, + "commonjs": true, + "node": true, + "browser": true + }, + ...require('../../eslint.config.js') +} diff --git a/propagators/opentelemetry-propagator-opentracing/.npmignore b/propagators/opentelemetry-propagator-opentracing/.npmignore new file mode 100644 index 0000000000..9505ba9450 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.npmignore @@ -0,0 +1,4 @@ +/bin +/coverage +/doc +/test diff --git a/propagators/opentelemetry-propagator-opentracing/LICENSE b/propagators/opentelemetry-propagator-opentracing/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/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/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md new file mode 100644 index 0000000000..aad326b39f --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -0,0 +1,70 @@ +# OpenTelemetry Propagator OpenTracing + +[![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] + +## OpenTracing Format + +| Header Name | Description | Required | +| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | +| `ot-tracer-traceid` | uint64 encoded as a string of 16 hex characters | yes | +| `ot-tracer-spanid` | uint64 encoded as a string of 16 hex characters | yes | +| `ot-tracer-sampled` | boolean encoded as a string with the values `'true'` or `'false'` | no | +| `ot-baggage-*` | repeated string to string key-value baggage items; keys are prefixed with `ot-baggage-` and the corresponding value is the raw string. | if baggage is present | + +### Interop and trace ids + +The OpenTracing propagation format expects trace ids to be 64-bits. In order to +interop with OpenTelemetry, trace ids need to be truncated to 64-bits before +sending them on the wire. When truncating, the least significant (right-most) +bits MUST be retained. For example, a trace id of +`3c3039f4d78d5c02ee8e3e41b17ce105` would be truncated to `ee8e3e41b17ce105`. + +### Baggage Notes + +Baggage keys and values are validated according to [rfc7230][rfc7230-url]. Any +keys or values that would result in invalid HTTP headers will be silently +dropped during inject. + +OpenTelemetry Baggage is represented as multiple headers where the +names are carrier dependent. For this reason, they are omitted from the `fields` +method. This behavior should be taken into account if your application relies +on the `fields` functionality. See the [specification][fields-spec-url] for +more details. + +## Example Usage + +```javascript +const api = require('@opentelemetry/api'); +const { + OpenTracingPropagator, +} = require('@opentelemetry/propagator-opentracing'); + +api.propagation.setGlobalPropagator(new OpenTracingPropagator()); +``` + +## 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-contrib.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-contrib/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-contrib/status.svg?path=packages/opentelemetry-propagator-opentracing +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-propagator-opentracing +[devdependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=packages/opentelemetry-propagator-opentracing +[devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-propagator-opentracing&type=dev +[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-opentracing +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-opentracing.svg +[rfc7230-url]: https://tools.ietf.org/html/rfc7230#section-3.2 +[fields-spec-url]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#fields diff --git a/propagators/opentelemetry-propagator-opentracing/karma.conf.js b/propagators/opentelemetry-propagator-opentracing/karma.conf.js new file mode 100644 index 0000000000..f1a1f3a7e8 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/karma.conf.js @@ -0,0 +1,26 @@ +/*! + * Copyright The 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/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json new file mode 100644 index 0000000000..d4ceb14355 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -0,0 +1,67 @@ +{ + "name": "@opentelemetry/propagator-opentracing", + "version": "0.13.0", + "description": "OpenTelemetry propagator OpenTracing provides context propagation for systems that are using the OpenTracing header format", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "scripts": { + "compile": "tsc --build", + "clean": "tsc --build --clean", + "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "test:browser": "nyc karma start --single-run", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "version": "node ../../scripts/version-update.js", + "watch": "tsc --build --watch" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "tracing", + "profiling", + "monitoring", + "opentracing", + "propagator" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + }, + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@opentelemetry/api": "^0.15.0" + }, + "devDependencies": { + "@types/mocha": "8.2.0", + "@types/node": "14.14.12", + "@types/webpack-env": "1.16.0", + "codecov": "3.8.1", + "gts": "2.0.2", + "istanbul-instrumenter-loader": "3.0.1", + "karma": "5.2.3", + "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", + "ts-loader": "8.0.12", + "ts-mocha": "8.0.0", + "typescript": "3.9.7", + "webpack": "4.46.0" + } +} diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts new file mode 100644 index 0000000000..7d8399101d --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -0,0 +1,129 @@ +/* + * Copyright The 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 { + Baggage, + Context, + getBaggage, + getSpanContext, + isSpanContextValid, + isValidSpanId, + isValidTraceId, + setBaggage, + setSpanContext, + TextMapGetter, + TextMapPropagator, + TextMapSetter, + TraceFlags, +} from '@opentelemetry/api'; + +/** OT header keys */ +export const OT_TRACE_ID_HEADER = 'ot-tracer-traceid'; +export const OT_SPAN_ID_HEADER = 'ot-tracer-spanid'; +export const OT_SAMPLED_HEADER = 'ot-tracer-sampled'; +export const OT_BAGGAGE_PREFIX = 'ot-baggage-'; + +const FIELDS = [OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER]; +const PADDING = '0'.repeat(16); + +function readHeader( + carrier: unknown, + getter: TextMapGetter, + key: string +): string { + let header = getter.get(carrier, key); + if (Array.isArray(header)) [header] = header; + return header || ''; +} + +const VALID_HEADER_NAME_CHARS = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; + +function isValidHeaderName(name: string): boolean { + return VALID_HEADER_NAME_CHARS.test(name); +} + +const INVALID_HEADER_VALUE_CHARS = /[^\t\x20-\x7e\x80-\xff]/; + +function isValidHeaderValue(value: string): boolean { + return !INVALID_HEADER_VALUE_CHARS.test(value); +} + +/** + * Propagator for the OpenTracing HTTP format. + */ +export class OpenTracingPropagator implements TextMapPropagator { + inject(context: Context, carrier: unknown, setter: TextMapSetter) { + const spanContext = getSpanContext(context); + if (!spanContext || !isSpanContextValid(spanContext)) return; + + setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId.substr(16)); + setter.set(carrier, OT_SPAN_ID_HEADER, spanContext.spanId); + setter.set( + carrier, + OT_SAMPLED_HEADER, + spanContext.traceFlags === TraceFlags.SAMPLED ? 'true' : 'false' + ); + + const baggage = getBaggage(context); + if (!baggage) return; + + Object.entries(baggage).forEach(([k, v]) => { + if (!isValidHeaderName(k) || !isValidHeaderValue(v.value)) return; + setter.set(carrier, `${OT_BAGGAGE_PREFIX}${k}`, v.value); + }); + } + + extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + let traceId = readHeader(carrier, getter, OT_TRACE_ID_HEADER); + if (traceId.length == 16) traceId = `${PADDING}${traceId}`; + const spanId = readHeader(carrier, getter, OT_SPAN_ID_HEADER); + const sampled = readHeader(carrier, getter, OT_SAMPLED_HEADER); + const traceFlags = + sampled === 'true' ? TraceFlags.SAMPLED : TraceFlags.NONE; + + if (isValidTraceId(traceId) && isValidSpanId(spanId)) { + context = setSpanContext(context, { + traceId, + spanId, + isRemote: true, + traceFlags, + }); + + const baggage: Baggage = getBaggage(context) || {}; + + getter.keys(carrier).forEach(k => { + if (!k.startsWith(OT_BAGGAGE_PREFIX)) return; + const value = readHeader(carrier, getter, k); + baggage[k.substr(OT_BAGGAGE_PREFIX.length)] = { value }; + }); + + if (Object.keys(baggage).length > 0) { + context = setBaggage(context, baggage); + } + } + + return context; + } + + /** + * Note: fields does not include baggage headers as they are dependent on + * carrier instance. Attempting to reuse a carrier by clearing fields could + * result in a memory leak. + */ + fields(): string[] { + return FIELDS.slice(); + } +} diff --git a/propagators/opentelemetry-propagator-opentracing/src/index.ts b/propagators/opentelemetry-propagator-opentracing/src/index.ts new file mode 100644 index 0000000000..849bcd4a5c --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/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 './OpenTracingPropagator'; diff --git a/propagators/opentelemetry-propagator-opentracing/src/version.ts b/propagators/opentelemetry-propagator-opentracing/src/version.ts new file mode 100644 index 0000000000..db447568f3 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/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.13.0'; diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts new file mode 100644 index 0000000000..47338c3b31 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -0,0 +1,346 @@ +/* + * Copyright The 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 { + defaultTextMapGetter, + defaultTextMapSetter, + INVALID_SPANID, + INVALID_TRACEID, + getSpanContext, + setSpanContext, + SpanContext, + TraceFlags, + Baggage, + setBaggage, + getBaggage, + ROOT_CONTEXT, +} from '@opentelemetry/api'; +import * as assert from 'assert'; +import { + OpenTracingPropagator, + OT_TRACE_ID_HEADER, + OT_SPAN_ID_HEADER, + OT_SAMPLED_HEADER, + OT_BAGGAGE_PREFIX, +} from '../src/OpenTracingPropagator'; + +describe('OpenTracingPropagator', () => { + const propagator = new OpenTracingPropagator(); + let carrier: { [key: string]: unknown }; + + beforeEach(() => { + carrier = {}; + }); + + describe('.inject()', () => { + it('truncates trace id to 64bits', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.NONE, + }; + + propagator.inject( + setSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); + }); + + it('injects context with sampled trace flags', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'true'); + }); + + it('injects context with unspecified trace flags', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.NONE, + }; + + propagator.inject( + setSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'false'); + }); + + it('no-ops if traceid invalid', () => { + const spanContext: SpanContext = { + traceId: INVALID_TRACEID, + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], undefined); + }); + + it('no-ops if spanid invalid', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: INVALID_SPANID, + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], undefined); + }); + + it('injects baggage', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + foo: { value: 'bar' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}foo`], 'bar'); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); + + it('omits baggage items with invalid keys', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + fθθ: { value: 'bar' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + assert.ok(!(`${OT_BAGGAGE_PREFIX}fθθ` in carrier)); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); + + it('omits baggage items with invalid values', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + foo: { value: 'bαr' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + assert.ok(!(`${OT_BAGGAGE_PREFIX}foo` in carrier)); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); + }); + + describe('.extract', () => { + it('extracts context with traceid, spanid, sampled true', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'true', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('extracts context with traceid, spanid, sampled false', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('converts 8-byte traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '4aaba1a52cf8ee09', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '00000000000000004aaba1a52cf8ee09', + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('handles malformed traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: 'abc123', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles malformed spanid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '0f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'abc123', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles invalid traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: INVALID_TRACEID, + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('extracts baggage', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + [`${OT_BAGGAGE_PREFIX}foo`]: 'bar', + [`${OT_BAGGAGE_PREFIX}bar`]: 'baz', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const baggage = getBaggage(context); + + assert.ok(baggage); + assert.deepStrictEqual(baggage, { + foo: { value: 'bar' }, + bar: { value: 'baz' }, + }); + }); + }); +}); diff --git a/propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts b/propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts new file mode 100644 index 0000000000..061a48ccfa --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/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/propagators/opentelemetry-propagator-opentracing/tsconfig.json b/propagators/opentelemetry-propagator-opentracing/tsconfig.json new file mode 100644 index 0000000000..4078877ce6 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +}