diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 39cd43b323..de1c99048d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,31 +7,46 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: restore lerna - uses: actions/cache@master # must use unreleased master to cache multiple paths - id: cache - with: - path: | - node_modules - packages/*/node_modules - metapackages/*/node_modules - key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} - - - name: Bootstrap - if: steps.cache.outputs.cache-hit != 'true' - run: | - npm install --only=dev --ignore-scripts - npx lerna bootstrap --no-ci --ignore-scripts -- --only=dev - - - name: Lint - run: | - npm run lint - npm run lint:examples - - - name: Install and Build API Dependencies - run: npx lerna bootstrap --no-ci --scope @opentelemetry/api --include-filtered-dependencies - - - name: Test Docs - run: npm run docs-test + - uses: actions/checkout@v2 + + - name: Lint changelog file + uses: avto-dev/markdown-lint@v1 + with: + # Commenting due to + # https://github.com/avto-dev/markdown-lint/blob/aab9be9823fcd706f6da3e6ad6c64874c23fbd4c/lint/rules/changelog.js#L51-L71 + # TODO: adhere to, or overwrite above rule and uncomment rules + # rules: "/lint/rules/changelog.js" + config: "/lint/config/changelog.yml" + args: "./CHANGELOG.md" + + - name: Lint markdown files + uses: avto-dev/markdown-lint@v1 + with: + args: "./**/*.md -i ./CHANGELOG.md" + + - name: restore lerna + uses: actions/cache@master # must use unreleased master to cache multiple paths + id: cache + with: + path: | + node_modules + packages/*/node_modules + metapackages/*/node_modules + key: ${{ runner.os }}-${{ hashFiles('**/package.json') }} + + - name: Bootstrap + if: steps.cache.outputs.cache-hit != 'true' + run: | + npm install --only=dev --ignore-scripts + npx lerna bootstrap --no-ci --ignore-scripts -- --only=dev + + - name: Lint + run: | + npm run lint + npm run lint:examples + + - name: Install and Build API Dependencies + run: npx lerna bootstrap --no-ci --scope @opentelemetry/api --include-filtered-dependencies + + - name: Test Docs + run: npm run docs-test diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000000..484d3db4c0 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "MD013": false, + "MD024": false, + "MD033": false, + "MD041": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index ae1b59e09d..9922008036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,58 +6,66 @@ All notable changes to this project will be documented in this file. ## 0.8.3 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-node` * [#980](https://github.com/open-telemetry/opentelemetry-js/pull/980) feat: merge user supplied and default plugin configs ([@naseemkullah](https://github.com/naseemkullah)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-context-async-hooks` * [#1099](https://github.com/open-telemetry/opentelemetry-js/pull/1099) fix(asynchooks-scope): fix context loss using .with() #1101 ([@vmarchaud](https://github.com/vmarchaud)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#1100](https://github.com/open-telemetry/opentelemetry-js/pull/1100) docs(batcher): document how to configure custom aggregators #989 ([@vmarchaud](https://github.com/vmarchaud)) * `opentelemetry-api` * [#1106](https://github.com/open-telemetry/opentelemetry-js/pull/1106) chore: improve API documentation ([@mayurkale22](https://github.com/mayurkale22)) #### Committers: 7 -- Bartlomiej Obecny ([@obecny](https://github.com/obecny)) -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Kanika Shah ([@kanikashah90](https://github.com/kanikashah90)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) -- Naseem ([@naseemkullah](https://github.com/naseemkullah)) -- Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) -- [@shivkanya9146](https://github.com/shivkanya9146) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Kanika Shah ([@kanikashah90](https://github.com/kanikashah90)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) +* [@shivkanya9146](https://github.com/shivkanya9146) ## 0.8.2 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-exporter-collector` * [#1063](https://github.com/open-telemetry/opentelemetry-js/pull/1063) feat: exporter collector TLS option ([@mzahor](https://github.com/mzahor)) * `opentelemetry-core` * [#838](https://github.com/open-telemetry/opentelemetry-js/pull/838) feat: implement W3C Correlation Context propagator ([@rubenvp8510](https://github.com/rubenvp8510)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-api` * [#1067](https://github.com/open-telemetry/opentelemetry-js/pull/1067) fix: missing `global` in browser environments ([@legendecas](https://github.com/legendecas)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#1057](https://github.com/open-telemetry/opentelemetry-js/pull/1057) chore: add examples README.md ([@mayurkale22](https://github.com/mayurkale22)) * `opentelemetry-core` * [#1080](https://github.com/open-telemetry/opentelemetry-js/pull/1080) docs: document CorrelationContext propagator under Built-in Implement… ([@rubenvp8510](https://github.com/rubenvp8510)) #### Committers: 5 -- Marian Zagoruiko ([@mzahor](https://github.com/mzahor)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) -- Olivier Albertini ([@OlivierAlbertini](https://github.com/OlivierAlbertini)) -- Ruben Vargas Palma ([@rubenvp8510](https://github.com/rubenvp8510)) -- legendecas ([@legendecas](https://github.com/legendecas)) + +* Marian Zagoruiko ([@mzahor](https://github.com/mzahor)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Olivier Albertini ([@OlivierAlbertini](https://github.com/OlivierAlbertini)) +* Ruben Vargas Palma ([@rubenvp8510](https://github.com/rubenvp8510)) +* legendecas ([@legendecas](https://github.com/legendecas)) ## 0.8.1 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * Other * [#1050](https://github.com/open-telemetry/opentelemetry-js/pull/1050) feat: add plugin metapackages ([@dyladan](https://github.com/dyladan)) * `opentelemetry-resources` @@ -69,14 +77,15 @@ All notable changes to this project will be documented in this file. * `opentelemetry-api`, `opentelemetry-metrics` * [#1032](https://github.com/open-telemetry/opentelemetry-js/pull/1032) Make Labels Optional for CounterMetric::add ([@astorm](https://github.com/astorm)) +### :bug: (Bug Fix) -#### :bug: (Bug Fix) * `opentelemetry-plugin-http` * [#1060](https://github.com/open-telemetry/opentelemetry-js/pull/1060) fix(http-plugin): don't modify user's headers object in plugin ([@BlumAmir](https://github.com/BlumAmir)) * `opentelemetry-exporter-collector` * [#1053](https://github.com/open-telemetry/opentelemetry-js/pull/1053) fix: include proto files in deployment package ([@dyladan](https://github.com/dyladan)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#1065](https://github.com/open-telemetry/opentelemetry-js/pull/1065) style: format README ([@naseemkullah](https://github.com/naseemkullah)) * [#1064](https://github.com/open-telemetry/opentelemetry-js/pull/1064) chore: update README ([@mayurkale22](https://github.com/mayurkale22)) @@ -85,25 +94,28 @@ All notable changes to this project will be documented in this file. * [#1056](https://github.com/open-telemetry/opentelemetry-js/pull/1056) fix readme: setting labelKeys when creating the counter ([@luebken](https://github.com/luebken)) #### Committers: 9 -- Alan Storm ([@astorm](https://github.com/astorm)) -- Amir Blum ([@BlumAmir](https://github.com/BlumAmir)) -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Justin Walz ([@justinwalz](https://github.com/justinwalz)) -- Matthew Wear ([@mwear](https://github.com/mwear)) -- Matthias Lübken ([@luebken](https://github.com/luebken)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) -- Naseem ([@naseemkullah](https://github.com/naseemkullah)) -- [@shivkanya9146](https://github.com/shivkanya9146) + +* Alan Storm ([@astorm](https://github.com/astorm)) +* Amir Blum ([@BlumAmir](https://github.com/BlumAmir)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Justin Walz ([@justinwalz](https://github.com/justinwalz)) +* Matthew Wear ([@mwear](https://github.com/mwear)) +* Matthias Lübken ([@luebken](https://github.com/luebken)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* [@shivkanya9146](https://github.com/shivkanya9146) ## 0.8.0 Released 2020-05-12 -#### :boom: Breaking Change +### :boom: Breaking Change + * `opentelemetry-api`, `opentelemetry-metrics` * [#1001](https://github.com/open-telemetry/opentelemetry-js/pull/1001) fix: observers should not expose bind/unbind method ([@legendecas](https://github.com/legendecas)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-plugin-http` * [#984](https://github.com/open-telemetry/opentelemetry-js/pull/984) fix(http-plugin): strip otel custom http header #983 ([@vmarchaud](https://github.com/vmarchaud)) * `opentelemetry-core` @@ -115,7 +127,8 @@ Released 2020-05-12 * `opentelemetry-exporter-collector` * [#1008](https://github.com/open-telemetry/opentelemetry-js/pull/1008) fix: permission denied error when cloning submodules ([@sleighzy](https://github.com/sleighzy)) -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-exporter-zipkin`, `opentelemetry-plugin-http`, `opentelemetry-tracing` * [#1037](https://github.com/open-telemetry/opentelemetry-js/pull/1037) fix(tracing): span processor should receive a readable span as parameters ([@legendecas](https://github.com/legendecas)) * `opentelemetry-tracing` @@ -135,105 +148,119 @@ Released 2020-05-12 * `opentelemetry-core` * [#981](https://github.com/open-telemetry/opentelemetry-js/pull/981) chore: splitting BasePlugin into browser and node ([@obecny](https://github.com/obecny)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#1003](https://github.com/open-telemetry/opentelemetry-js/pull/1003) chore: test on node 14 ([@dyladan](https://github.com/dyladan)) * [#990](https://github.com/open-telemetry/opentelemetry-js/pull/990) fix(opentracing-shim): update opentracing shim example ([@sleighzy](https://github.com/sleighzy)) #### Committers: 7 -- legendecas ([@legendecas](https://github.com/legendecas)) -- Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Ivan Senic ([@ivansenic](https://github.com/ivansenic)) -- Mark Wolff ([@markwolff](https://github.com/markwolff)) -- Simon Leigh ([@sleighzy](https://github.com/sleighzy)) -- Bartlomiej Obecny ([@obecny](https://github.com/obecny)) + +* legendecas ([@legendecas](https://github.com/legendecas)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Ivan Senic ([@ivansenic](https://github.com/ivansenic)) +* Mark Wolff ([@markwolff](https://github.com/markwolff)) +* Simon Leigh ([@sleighzy](https://github.com/sleighzy)) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) ## 0.7.0 Released 2020-04-23 -#### :boom: Breaking Change +### :boom: Breaking Change + * `opentelemetry-exporter-collector` * [#901](https://github.com/open-telemetry/opentelemetry-js/pull/901) grpc for node and support for new proto format for node and browser ([@obecny](https://github.com/obecny)) * `opentelemetry-api`, `opentelemetry-metrics` * [#964](https://github.com/open-telemetry/opentelemetry-js/pull/964) chore: adding metric observable to be able to support async update ([@obecny](https://github.com/obecny)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-plugin-http` * [#960](https://github.com/open-telemetry/opentelemetry-js/pull/960) [http] fix: use url.URL ([@naseemkullah](https://github.com/naseemkullah)) * `opentelemetry-core` * [#977](https://github.com/open-telemetry/opentelemetry-js/pull/977) fix(B3Propagator): B3 sampled causing gRPC error ([@mayurkale22](https://github.com/mayurkale22)) -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-resources` * [#899](https://github.com/open-telemetry/opentelemetry-js/pull/899) feat: resource auto-detection ([@mwear](https://github.com/mwear)) * `opentelemetry-metrics` * [#930](https://github.com/open-telemetry/opentelemetry-js/pull/930) feat(aggregators): implement histogram aggregator ([@vmarchaud](https://github.com/vmarchaud)) #### Committers: 5 -- Naseem ([@naseemkullah](https://github.com/naseemkullah)) -- Matthew Wear ([@mwear](https://github.com/mwear)) -- Bartlomiej Obecny ([@obecny](https://github.com/obecny)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) -- Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) + +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* Matthew Wear ([@mwear](https://github.com/mwear)) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) ## 0.6.1 Released 2020-04-08 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-exporter-jaeger` * [#924](https://github.com/open-telemetry/opentelemetry-js/pull/924) [Jaeger-Exporter] host default env var ([@naseemkullah](https://github.com/naseemkullah)) * `opentelemetry-metrics` * [#933](https://github.com/open-telemetry/opentelemetry-js/pull/933) feat(meter): allow custom batcher #932 ([@vmarchaud](https://github.com/vmarchaud)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-plugin-http` * [#946](https://github.com/open-telemetry/opentelemetry-js/pull/946) Remove bad null check ([@dyladan](https://github.com/dyladan)) * `opentelemetry-exporter-prometheus`, `opentelemetry-metrics` * [#941](https://github.com/open-telemetry/opentelemetry-js/pull/941) fix: do not clear other labelsets when updating metrics ([@dyladan](https://github.com/dyladan)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * `opentelemetry-propagator-jaeger` * [#937](https://github.com/open-telemetry/opentelemetry-js/pull/937) fix: Jaeger propagator example of usage" ([@shivkanya9146](https://github.com/shivkanya9146)) #### Committers: 4 -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Naseem ([@naseemkullah](https://github.com/naseemkullah)) -- Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) -- [@shivkanya9146](https://github.com/shivkanya9146) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) +* [@shivkanya9146](https://github.com/shivkanya9146) ## 0.6.0 Released 2020-04-01 -#### :boom: Breaking Change +### :boom: Breaking Change + * `opentelemetry-api`, `opentelemetry-metrics` * [#915](https://github.com/open-telemetry/opentelemetry-js/pull/915) Remove label set from metrics API ([@mayurkale22](https://github.com/mayurkale22)) -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-tracing` * [#913](https://github.com/open-telemetry/opentelemetry-js/pull/913) chore: remove unused default argument in Tracer ([@Flarna](https://github.com/Flarna)) * `opentelemetry-exporter-jaeger` * [#916](https://github.com/open-telemetry/opentelemetry-js/pull/916) chore: removing force flush ([@obecny](https://github.com/obecny)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * `opentelemetry-node` * [#921](https://github.com/open-telemetry/opentelemetry-js/pull/921) chore: fix Require Path in README [@shivkanya9146](https://github.com/shivkanya9146)) #### Committers: 4 -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) -- Bartlomiej Obecny ([@obecny](https://github.com/obecny)) -- Gerhard Stöbich ([@Flarna](https://github.com/Flarna)) -- Shivkanya Andhare ([@shivkanya9146](https://github.com/shivkanya9146)) + +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Gerhard Stöbich ([@Flarna](https://github.com/Flarna)) +* Shivkanya Andhare ([@shivkanya9146](https://github.com/shivkanya9146)) ## 0.5.2 Released 2020-03-27 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-exporter-prometheus`, `opentelemetry-metrics` * [#893](https://github.com/open-telemetry/opentelemetry-js/pull/893) Metrics: Add lastUpdateTimestamp associated with point ([@mayurkale22](https://github.com/mayurkale22)) * `opentelemetry-tracing` @@ -241,7 +268,8 @@ Released 2020-03-27 * `opentelemetry-api`, `opentelemetry-tracing` * [#889](https://github.com/open-telemetry/opentelemetry-js/pull/889) feat: start a root span with spanOptions.parent = null ([@dyladan](https://github.com/dyladan)) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-core`, `opentelemetry-propagator-jaeger` * [#904](https://github.com/open-telemetry/opentelemetry-js/pull/904) fix: add type checking in propagators ([@dyladan](https://github.com/dyladan)) * `opentelemetry-context-base`, `opentelemetry-core`, `opentelemetry-plugin-document-load`, `opentelemetry-plugin-user-interaction`, `opentelemetry-web` @@ -249,22 +277,24 @@ Released 2020-03-27 * Other * [#884](https://github.com/open-telemetry/opentelemetry-js/pull/884) chore: fixing main package.json version ([@obecny](https://github.com/obecny)) -#### :books: (Refine Doc) +### :books: (Refine Doc) + * `opentelemetry-context-base`, `opentelemetry-core`, `opentelemetry-plugin-document-load`, `opentelemetry-plugin-user-interaction`, `opentelemetry-web` * [#906](https://github.com/open-telemetry/opentelemetry-js/pull/906) chore: fixing documentation for web tracer provider, fixing examples … ([@obecny](https://github.com/obecny)) #### Committers: 4 -- Bartlomiej Obecny ([@obecny](https://github.com/obecny)) -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Mark Robert Henderson ([@aphelionz](https://github.com/aphelionz)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Mark Robert Henderson ([@aphelionz](https://github.com/aphelionz)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) ## 0.5.1 Released 2020-03-19 -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-web` * [#873](https://github.com/open-telemetry/opentelemetry-js/pull/873) Remove unnecessary `this` overwrite in stack context manager ([@dyladan](https://github.com/dyladan)) * `opentelemetry-plugin-mysql` @@ -273,20 +303,23 @@ Released 2020-03-19 * [#881](https://github.com/open-telemetry/opentelemetry-js/pull/881) fix: @opentelemetry/metrics fails to run due to bad import ([@mayurkale22](https://github.com/mayurkale22)) #### Committers: 2 -- Daniel Dyla ([@dyladan](https://github.com/dyladan)) -- Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) + +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) ## 0.5.0 Released 2020-03-16 -### This is a first official beta release, which provides almost fully complete metrics, tracing, and context propagation functionality but makes no promises around breaking changes. +### This is a first official beta release, which provides almost fully complete metrics, tracing, and context propagation functionality but makes no promises around breaking changes + +### :boom: Breaking Change -#### :boom: Breaking Change * [#853](https://github.com/open-telemetry/opentelemetry-js/pull/853) Rename scope to context * [#851](https://github.com/open-telemetry/opentelemetry-js/pull/851) Rename formatter to propagator -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * [#828](https://github.com/open-telemetry/opentelemetry-js/pull/828) feat: metric observer * [#858](https://github.com/open-telemetry/opentelemetry-js/pull/858) chore: update out-of-date dependencies * [#856](https://github.com/open-telemetry/opentelemetry-js/pull/856) fix: change loglevel for beta @@ -313,7 +346,8 @@ Released 2020-03-16 * [#719](https://github.com/open-telemetry/opentelemetry-js/pull/719) feat(plugin-http): sync. specs for statuscode * [#701](https://github.com/open-telemetry/opentelemetry-js/pull/701) feat: add jaeger http trace format (#696) -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * [#798](https://github.com/open-telemetry/opentelemetry-js/pull/798) Respect sampled bit in probability sampler * [#743](https://github.com/open-telemetry/opentelemetry-js/pull/743) fix: left pad jaeger trace ids * [#715](https://github.com/open-telemetry/opentelemetry-js/pull/715) fix: unref jaeger socket to prevent process running indefinitely @@ -322,13 +356,14 @@ Released 2020-03-16 Released 2020-02-05 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-api` * [#727](https://github.com/open-telemetry/opentelemetry-js/pull/727) Api separation (deprecate `opentelemetry-types`) * [#749](https://github.com/open-telemetry/opentelemetry-js/pull/749) chore: rename registry to provider +### :sparkles: (Feature) -#### :sparkles: (Feature) * `opentelemetry-plugin-http` * [#719](https://github.com/open-telemetry/opentelemetry-js/pull/719) feat(plugin-http): sync. specs for statuscode * `opentelemetry-exporter-jaeger` @@ -336,24 +371,26 @@ Released 2020-02-05 * `opentelemetry-plugin-user-interaction` * [#658](https://github.com/open-telemetry/opentelemetry-js/pull/658) feat: plugin user interaction for web -#### :books: (Refine Doc) - * [#689](https://github.com/open-telemetry/opentelemetry-js/pull/689) Add benchmark README and latest numbers - * [#733](https://github.com/open-telemetry/opentelemetry-js/pull/733) chore: add instruction for pg-pool plugin - * [#665](https://github.com/open-telemetry/opentelemetry-js/pull/665) docs: add ioredis example - * [#731](https://github.com/open-telemetry/opentelemetry-js/pull/731) Update Stackdriver exporter example +### :books: (Refine Doc) + +* [#689](https://github.com/open-telemetry/opentelemetry-js/pull/689) Add benchmark README and latest numbers +* [#733](https://github.com/open-telemetry/opentelemetry-js/pull/733) chore: add instruction for pg-pool plugin +* [#665](https://github.com/open-telemetry/opentelemetry-js/pull/665) docs: add ioredis example +* [#731](https://github.com/open-telemetry/opentelemetry-js/pull/731) Update Stackdriver exporter example + +### :bug: (Bug Fix) -#### :bug: (Bug Fix) * `opentelemetry-exporter-jaeger` * [#715](https://github.com/open-telemetry/opentelemetry-js/pull/715) fix: unref jaeger socket to prevent process running indefinitely * `opentelemetry-plugin-ioredis` * [#671](https://github.com/open-telemetry/opentelemetry-js/pull/671) [ioredis plugin] fix: change supportedVersions to >1 <5 - ## 0.3.3 Released 2020-01-22 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-core`, `opentelemetry-exporter-collector`, `opentelemetry-exporter-zipkin`, `opentelemetry-node`, `opentelemetry-plugin-dns`, `opentelemetry-plugin-document-load`, `opentelemetry-plugin-grpc`, `opentelemetry-plugin-http`, `opentelemetry-plugin-https`, `opentelemetry-plugin-ioredis`, `opentelemetry-plugin-mongodb`, `opentelemetry-plugin-mysql`, `opentelemetry-plugin-postgres`, `opentelemetry-plugin-redis`, `opentelemetry-plugin-xml-http-request`, `opentelemetry-shim-opentracing`, `opentelemetry-tracing`, `opentelemetry-types`, `opentelemetry-web` * [#582](https://github.com/open-telemetry/opentelemetry-js/pull/582) Named Tracers / Tracer Registry * `opentelemetry-node`, `opentelemetry-plugin-postgres` @@ -362,16 +399,19 @@ Released 2020-01-22 * `opentelemetry-metrics` * [#700](https://github.com/open-telemetry/opentelemetry-js/pull/700) implement named meter -#### :sparkles: (Feature) +### :sparkles: (Feature) + * `opentelemetry-propagator-jaeger` * [#701](https://github.com/open-telemetry/opentelemetry-js/pull/701) add jaeger http trace format * `opentelemetry-exporter-stackdriver-trace` * [#648](https://github.com/open-telemetry/opentelemetry-js/pull/648) Stackdriver Trace exporter -#### :books: (Refine Doc) - * [#673](https://github.com/open-telemetry/opentelemetry-js/pull/673) chore(getting-started): Added a TypeScript version for Getting Started Guide +### :books: (Refine Doc) + +* [#673](https://github.com/open-telemetry/opentelemetry-js/pull/673) chore(getting-started): Added a TypeScript version for Getting Started Guide + +### :bug: (Bug Fix) -#### :bug: (Bug Fix) * `opentelemetry-plugin-ioredis` * [#714](https://github.com/open-telemetry/opentelemetry-js/pull/714) fix: return module exports from ioredis @@ -379,7 +419,8 @@ Released 2020-01-22 Released 2020-01-03 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-plugin-http`, `opentelemetry-plugin-https` * [#643](https://github.com/open-telemetry/opentelemetry-js/pull/643) feat(plugin-http): add/modify attributes * [#651](https://github.com/open-telemetry/opentelemetry-js/pull/651) chore: add version script to all packages @@ -390,11 +431,13 @@ Released 2020-01-03 * `opentelemetry-test-utils` * [#644](https://github.com/open-telemetry/opentelemetry-js/pull/644) feat: test-utils -#### :sparkles: (Feature) +### :sparkles: (Feature) + * `opentelemetry-plugin-ioredis` * [#558](https://github.com/open-telemetry/opentelemetry-js/pull/558) feat(plugin): add ioredis plugin -#### :books: (Refine Doc) +### :books: (Refine Doc) + * `opentelemetry-node`, `opentelemetry-plugin-xml-http-request` * [#646](https://github.com/open-telemetry/opentelemetry-js/pull/646) chore: update default plugins list and fix npm badge * `opentelemetry-plugin-document-load`, `opentelemetry-plugin-mysql`, `opentelemetry-plugin-redis`, `opentelemetry-plugin-xml-http-request`, `opentelemetry-shim-opentracing` @@ -408,20 +451,24 @@ Released 2020-01-03 Released 2019-12-20 -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-plugin-grpc` * [#631](https://github.com/open-telemetry/opentelemetry-js/pull/631) fix(grpc): patch original client methods * [#593](https://github.com/open-telemetry/opentelemetry-js/pull/593) fix: transpile to es2017 as esnext may result in unsupported JS code -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#629](https://github.com/open-telemetry/opentelemetry-js/pull/629) ci: deploy documentation on releases * [#581](https://github.com/open-telemetry/opentelemetry-js/pull/581) feat: add OpenTracing example -#### :rocket: (Enhancement) - * [#633](https://github.com/open-telemetry/opentelemetry-js/pull/633) chore: enable incremental builds +### :rocket: (Enhancement) + +* [#633](https://github.com/open-telemetry/opentelemetry-js/pull/633) chore: enable incremental builds + +### :sparkles: (Feature) -#### :sparkles: (Feature) * `opentelemetry-plugin-xml-http-request` * [#595](https://github.com/open-telemetry/opentelemetry-js/pull/595) feat: implement XMLHttpRequest plugin @@ -429,7 +476,8 @@ Released 2019-12-20 Released 2019-12-13 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-core`, `opentelemetry-node`, `opentelemetry-plugin-dns`, `opentelemetry-plugin-document-load`, `opentelemetry-plugin-grpc`, `opentelemetry-plugin-postgres`, `opentelemetry-plugin-redis`, `opentelemetry-tracing`, `opentelemetry-types` * [#569](https://github.com/open-telemetry/opentelemetry-js/pull/569) chore: allow parent span to be null * `opentelemetry-plugin-document-load` @@ -450,7 +498,8 @@ Released 2019-12-13 * `opentelemetry-core`, `opentelemetry-plugin-document-load`, `opentelemetry-tracing`, `opentelemetry-web` * [#466](https://github.com/open-telemetry/opentelemetry-js/pull/466) chore: fixing coverage for karma using istanbul -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-exporter-jaeger` * [#609](https://github.com/open-telemetry/opentelemetry-js/pull/609) Jaeger no flush interval * `opentelemetry-plugin-dns` @@ -467,7 +516,8 @@ Released 2019-12-13 * `opentelemetry-core` * [#472](https://github.com/open-telemetry/opentelemetry-js/pull/472) fix(core): add missing semver dependency -#### :books: (Refine Doc) +### :books: (Refine Doc) + * Other * [#574](https://github.com/open-telemetry/opentelemetry-js/pull/574) chore: add CHANGELOG.md * [#575](https://github.com/open-telemetry/opentelemetry-js/pull/575) Add exporter guide @@ -488,7 +538,8 @@ Released 2019-12-13 * `opentelemetry-plugin-postgres` * [#473](https://github.com/open-telemetry/opentelemetry-js/pull/473) chore(plugin): postgres-pool plugin skeleton -#### :sparkles: (Feature) +### :sparkles: (Feature) + * `opentelemetry-core`, `opentelemetry-exporter-collector` * [#552](https://github.com/open-telemetry/opentelemetry-js/pull/552) Collector exporter * `opentelemetry-node`, `opentelemetry-plugin-mysql` @@ -515,7 +566,8 @@ Released 2019-12-13 Released 2019-11-04 -#### :rocket: (Enhancement) +### :rocket: (Enhancement) + * `opentelemetry-shim-opentracing`, `opentelemetry-tracing`, `opentelemetry-types` * [#449](https://github.com/open-telemetry/opentelemetry-js/pull/449) fix: allow recording links only at Span creation time * `opentelemetry-core`, `opentelemetry-node`, `opentelemetry-tracing`, `opentelemetry-types` @@ -527,19 +579,22 @@ Released 2019-11-04 * `opentelemetry-core`, `opentelemetry-plugin-document-load`, `opentelemetry-tracing`, `opentelemetry-web` * [#466](https://github.com/open-telemetry/opentelemetry-js/pull/466) chore: fixing coverage for karma using istanbul -#### :bug: (Bug Fix) +### :bug: (Bug Fix) + * `opentelemetry-tracing` * [#444](https://github.com/open-telemetry/opentelemetry-js/pull/444) fix: batchSpanProcessor test failing intermittently * `opentelemetry-core` * [#472](https://github.com/open-telemetry/opentelemetry-js/pull/472) fix(core): add missing semver dependency -#### :books: (Refine Doc) - * [#462](https://github.com/open-telemetry/opentelemetry-js/pull/462) chore: update README - * [#460](https://github.com/open-telemetry/opentelemetry-js/pull/460) chore: move members list out of community repo - * [#445](https://github.com/open-telemetry/opentelemetry-js/pull/445) chore: update CONTRIBUTING.md - * [#459](https://github.com/open-telemetry/opentelemetry-js/pull/459) chore: update API docs +### :books: (Refine Doc) + +* [#462](https://github.com/open-telemetry/opentelemetry-js/pull/462) chore: update README +* [#460](https://github.com/open-telemetry/opentelemetry-js/pull/460) chore: move members list out of community repo +* [#445](https://github.com/open-telemetry/opentelemetry-js/pull/445) chore: update CONTRIBUTING.md +* [#459](https://github.com/open-telemetry/opentelemetry-js/pull/459) chore: update API docs + +### :sparkles: (Feature) -#### :sparkles: (Feature) * `opentelemetry-metrics`, `opentelemetry-types` * [#437](https://github.com/open-telemetry/opentelemetry-js/pull/437) feat(metrics): add registerMetric and getMetrics * `opentelemetry-metrics` @@ -553,14 +608,14 @@ Released 2019-11-04 ## 0.1.1 -- chore: add prepare script and bump the version (#431) -- docs: fix broken links (#428) -- docs(exporter-jaeger): fix jaeger version (#430) -- fix(plugin-http): ensure no leaks (#398) -- Update readme (#421) -- refactor: cal duration once instead of each get duration call (#412) -- chore: add npm version badge (#414) +* chore: add prepare script and bump the version (#431) +* docs: fix broken links (#428) +* docs(exporter-jaeger): fix jaeger version (#430) +* fix(plugin-http): ensure no leaks (#398) +* Update readme (#421) +* refactor: cal duration once instead of each get duration call (#412) +* chore: add npm version badge (#414) ## 0.1.0 -- Initial release +* Initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2d4d8925bd..813986c055 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,9 +25,11 @@ The Conventional Commits specification is a lightweight convention on top of com We use [commitlint](https://github.com/conventional-changelog/commitlint) and [husky](https://github.com/typicode/husky) to prevent bad commit message. For example, you want to submit the following commit message `git commit -s -am "my bad commit"`. You will receive the following error : -``` + +```text ✖ type must be one of [ci, feat, fix, docs, style, refactor, perf, test, revert, chore] [type-enum] ``` + Here an exemple that will pass the verification: `git commit -s -am "chore(opentelemetry-core): update deps"` ### Fork @@ -35,7 +37,8 @@ Here an exemple that will pass the verification: `git commit -s -am "chore(opent In the interest of keeping this repository clean and manageable, you should work from a fork. To create a fork, click the 'Fork' button at the top of the repository, then clone the fork locally using `git clone git@github.com:USERNAME/opentelemetry-js.git`. You should also add this repository as an "upstream" repo to your local copy, in order to keep it up to date. You can add this as a remote like so: -``` + +```sh git remote add upstream https://github.com/open-telemetry/opentelemetry-js.git #verify that the upstream exists @@ -43,7 +46,8 @@ git remote -v ``` To update your fork, fetch the upstream repo's branches and commits, then merge your master with upstream's master: -``` + +```sh git fetch upstream git checkout master git merge upstream/master @@ -90,12 +94,15 @@ The `opentelemetry-js` project is written in TypeScript. - New or changed functionality is documented. ### Generating API documentation + - `npm run docs` to generate API documentation. Generates the documentation in `packages/opentelemetry-api/docs/out` ### Generating CHANGELOG documentation + - `npm run changelog` to generate CHANGELOG documentation in your terminal (see [RELEASING.md](RELEASING.md) for more details). ### Benchmarks + When two or more approaches must be compared, please write a benchmark in the benchmark/index.js module so that we can keep track of the most efficient algorithm. - `npm run bench` to run your benchmark. diff --git a/README.md b/README.md index 2db50aa664..64722444d5 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ --- ## About this project + This is the JavaScript version of [OpenTelemetry](https://opentelemetry.io/), a framework for collecting traces and metrics from applications. ## Quick start @@ -144,7 +145,7 @@ Maintainers ([@open-telemetry/js-maintainers](https://github.com/orgs/open-telem *Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/master/community-membership.md#maintainer).* -### Thanks to all the people who already contributed! +### Thanks to all the people who already contributed @@ -188,7 +189,7 @@ OpenTelemetry can collect tracing data automatically using plugins. Vendors/User ##### Contrib -These plugins are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node +These plugins are hosted at - [@opentelemetry/plugin-mongodb][otel-contrib-plugin-mongodb] - [@opentelemetry/plugin-mysql][otel-contrib-plugin-mysql] @@ -207,7 +208,7 @@ These plugins are hosted at https://github.com/open-telemetry/opentelemetry-js-c ##### Contrib -These plugins are hosted at https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/web +These plugins are hosted at - [@opentelemetry/plugin-document-load][otel-contrib-plugin-document-load] - [@opentelemetry/plugin-user-interaction][otel-contrib-plugin-user-interaction] diff --git a/RELEASING.md b/RELEASING.md index 68b2f6c956..3b66e9465a 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,15 +4,20 @@ This document explains how to publish all OT modules at version x.y.z. Ensure th Release Process: -* [Update to latest locally](#update-to-latest-locally) -* [Create a new branch](#create-a-new-branch) -* [Prepare each package for release](#prepare-each-package-for-release) -* [Use the Changelog to create a GitHub Release](#use-the-changelog-to-create-a-github-release) -* [Create a new PR](#create-a-new-pr) -* [Merge and pull](#merge-and-pull) -* [Publish all packages](#publish-all-packages) -* [Publish the GitHub Release](#publish-the-github-release) -* [Update CHANGELOG](#update-changelog) +- [Releasing OpenTelemetry Packages (for Maintainers Only)](#releasing-opentelemetry-packages-for-maintainers-only) + - [Update to latest locally](#update-to-latest-locally) + - [Create a new branch](#create-a-new-branch) + - [Prepare each package for release](#prepare-each-package-for-release) + - [Use the Changelog to create a GitHub Release](#use-the-changelog-to-create-a-github-release) + - [Generate the changelog with lerna](#generate-the-changelog-with-lerna) + - [How to use](#how-to-use) + - [Update Changelog file](#update-changelog-file) + - [Create a new PR](#create-a-new-pr) + - [Merge and pull](#merge-and-pull) + - [Publish all packages](#publish-all-packages) + - [Publish the GitHub Release](#publish-the-github-release) + - [Update CHANGELOG](#update-changelog) + - [Known Issues](#known-issues) ## Update to latest locally @@ -26,9 +31,9 @@ Create a new branch called `x.y.z-proposal` from the current commit. Decide on the next `major.minor.patch` release number based on [semver](http://semver.org/) guidelines. -* Use `npm install` command to initialize all package directories -* Use `lerna publish --skip-npm --no-git-tag-version --no-push` to bump the version in all `package.json` -* Use `npm run bootstrap` to generate latest `version.ts` files +- Use `npm install` command to initialize all package directories +- Use `lerna publish --skip-npm --no-git-tag-version --no-push` to bump the version in all `package.json` +- Use `npm run bootstrap` to generate latest `version.ts` files ## Use the Changelog to create a GitHub Release @@ -37,13 +42,16 @@ Decide on the next `major.minor.patch` release number based on [semver](http://s Since we use `lerna`, we can use [lerna-changelog](https://github.com/lerna/lerna-changelog#lerna-changelog) #### How to use + Pass your [github token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) to generate the changelog automatically. For security reasons, when you create a Github token, select the permissions: under **repo**, select **Access public repositories**, **commit status**. In your terminal, execute the following command: + ```bash GITHUB_AUTH= lerna-changelog ``` + It will print something like: ```md @@ -59,10 +67,12 @@ It will print something like: - Helpful Hacker ([@helpful-hacker](https://github.com/helpful-hacker)) - [@careful-coder](https://github.com/careful-coder) ``` + By default lerna-changelog will show all pull requests that have been merged since the latest tagged commit in the repository. That is however only true for pull requests **with certain labels applied** (see [lerna.json](lerna.json) for authorized labels). You can also use the `--from` and `--to` options to view a different range of pull requests: -``` + +```sh GITHUB_AUTH=xxxxx lerna-changelog --from=v1.0.0 --to=v2.0.0 ``` @@ -97,15 +107,15 @@ done Check your e-mail and make sure the number of “you’ve published this module” emails matches the number you expect. ## Publish the GitHub Release + Publish the GitHub release, ensuring that the tag points to the newly landed commit corresponding to release proposal `x.y.z`. ## 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. -* Create a new commit with the exact title: `Post Release: update CHANGELOG.md`. -* Go through PR review and merge it to GitHub master branch. - +- After releasing is done, update the [CHANGELOG.md](https://github.com/open-telemetry/opentelemetry-js/blob/master/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. ## Known Issues -* The `examples/` and `getting-started/` folders are not part of lerna packages, we need to manually bump the version in `package.json`. +- The `examples/` and `getting-started/` folders are not part of lerna packages, we need to manually bump the version in `package.json`. diff --git a/benchmark/README.md b/benchmark/README.md index 0cb629d526..63ad35c4ca 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -3,8 +3,9 @@ ## How to run To run your benchmark, just: + ```sh -$ npm run bench +npm run bench ``` The minimum sample size is set to 10 to perform statistical analysis on benchmark, you can re-configure that in `benchmark.js`. @@ -15,7 +16,7 @@ The minimum sample size is set to 10 to perform statistical analysis on benchmar ### `v0.5.0` release -``` +```text Beginning NoopTracerProvider Benchmark... 5 tests completed. @@ -67,7 +68,7 @@ Beginning HttpTraceContext Benchmark... ### `v0.3.3` release -``` +```text Beginning NoopTracerProvider Benchmark... 5 tests completed. diff --git a/doc/batcher-api.md b/doc/batcher-api.md index d627faca1d..7c9092ff15 100644 --- a/doc/batcher-api.md +++ b/doc/batcher-api.md @@ -7,6 +7,7 @@ Sometimes you may want to use a specific aggregator for one of your metric, export an average of the last X values instead of just the last one. Here is what an aggregator that does that would look like: + ```ts import { Aggregator } from '@opentelemetry/metrics'; import { hrTime } from '@opentelemetry/core'; @@ -43,6 +44,7 @@ export class AverageAggregator implements Aggregator { Now we will need to implement our own batcher to configure the sdk to use our new aggregator. To simplify even more, we will just extend the `UngroupedBatcher` (which is the default) to avoid re-implementing the whole `Aggregator` interface. Here the result: + ```ts import { UngroupedBatcher, @@ -140,4 +142,4 @@ const requestsLatency = meter.createMeasure('requests', { monotonic: true, description: 'Average latency' }); -``` \ No newline at end of file +``` diff --git a/doc/development-guide.md b/doc/development-guide.md index ade620efa2..2bdc162a87 100644 --- a/doc/development-guide.md +++ b/doc/development-guide.md @@ -4,7 +4,7 @@ Before contributing to this open source project, read our [CONTRIBUTING](../CONT The code base is a monorepo. We use [Lerna](https://lerna.js.org/) for managing inter-module dependencies, which makes it easier to develop coordinated changes between the modules. Instead of running lerna directly, the commands are wrapped with `npm`; -### Requirements +## Requirements Since this project supports multiple Node versions, using a version manager such as [nvm](https://github.com/creationix/nvm) is recommended. @@ -12,67 +12,70 @@ manager such as [nvm](https://github.com/creationix/nvm) is recommended. To get started once you have Node installed, run: ```sh -$ npm install +npm install ``` This will install all the necessary modules. -### Testing +## Testing -#### Unit Tests +### Unit Tests To run the all unit tests, use: ```sh -$ npm run test +npm run test ``` To run the unit tests continuously in watch mode while developing, use: ```sh -$ npm run tdd +npm run tdd ``` -### Linting +## Linting We use [gts](https://www.npmjs.com/package/gts) to make sure that new code is conform to our coding standards. Before raising a pull request, make sure there are no lint problems. To check the linter, use: + ```sh -$ npm run lint +npm run lint ``` To fix the linter, use: + ```sh -$ npm run lint:fix +npm run lint:fix ``` -### Continuous Integration +## Continuous Integration We rely on CircleCI 2.0 for our tests. If you want to test how the CI behaves locally, you can use the CircleCI Command Line Interface as described here: -https://circleci.com/docs/2.0/local-jobs/ + After installing the `circleci` CLI, simply run one of the following: ```sh -$ circleci build --job lint -$ circleci build --job node8 -$ circleci build --job node10 -$ circleci build --job node11 -$ circleci build --job node12 -$ circleci build --job node12-browsers +circleci build --job lint +circleci build --job node8 +circleci build --job node10 +circleci build --job node11 +circleci build --job node12 +circleci build --job node12-browsers ``` -### Docs +## Docs We use [typedoc](https://www.npmjs.com/package/typedoc) to generate the api documentation. To generate the docs, use: + ```sh -$ npm run docs +npm run docs ``` The document will be available under `packages/opentelemetry-api/docs/out` path. diff --git a/doc/exporter-guide.md b/doc/exporter-guide.md index e98a0185b6..da17608c8e 100644 --- a/doc/exporter-guide.md +++ b/doc/exporter-guide.md @@ -6,7 +6,7 @@ We provide support for several open source backends and vendors out-of-the-box l A typical package layout: -``` +```text opentelemetry-exporter-myexporter ├── src │ └── index.ts diff --git a/doc/plugin-guide.md b/doc/plugin-guide.md index 497fa82fa6..2276641bf5 100644 --- a/doc/plugin-guide.md +++ b/doc/plugin-guide.md @@ -11,14 +11,16 @@ Each plugin must extend the abstract class [BasePlugin][base-plugin] implementin - `unpatch`: A function describing how the module exports for a given file should be unpatched. This should generally mirror the logic in `patch`; for example, if `patch` wraps a method, `unpatch` should unwrap it. The core `PluginLoader` class is responsible for loading the instrumented plugins that use a patch mechanism to enable automatic tracing for specific target modules. In order to load new plugin, it should export `plugin` identifier. + ```typescript export const plugin = new HttpPlugin(...); ``` > Example of simple module plugin created and used in the tests. -https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-node/test/instrumentation/node_modules/%40opentelemetry/plugin-simple-module/simple-module.js + After the plugin is created, it must be added in the [list of default supported plugins][DEFAULT_INSTRUMENTATION_PLUGINS]. + ```typescript export const DEFAULT_INSTRUMENTATION_PLUGINS: Plugins = { http: { @@ -42,7 +44,6 @@ We recommend using [`shimmer`][shimmer] to modify function properties on objects Please refer to the [HTTP instrumentation][http-plugin] or [gRPC instrumentation][grpc-plugin] for more comprehensive examples. - [shimmer]: https://github.com/othiym23/shimmer [builtin-plugins]: https://github.com/open-telemetry/opentelemetry-js#plugins [base-plugin]: https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts#L29 diff --git a/examples/README.md b/examples/README.md index 9c7a2f94e7..d8452bf53c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,7 +3,7 @@ This directory contains a number of examples of how to run real applications with OpenTelemetry JavaScript. -### Maintained Examples +## Maintained Examples Maintained Examples are expected to be updated with every OpenTelemetry JavaScript release, to use the latest and greatest features, and best practices. @@ -20,7 +20,7 @@ use the latest and greatest features, and best practices. |[collector-exporter-node](collector-exporter-node/) | This example shows how to use `@opentelemetry/exporter-collector` to instrument a simple Node.js application | Intermediate | |[opentracing-shim](opentracing-shim/) | This is a simple example that demonstrates how existing OpenTracing instrumentation can be integrated with OpenTelemetry | Intermediate | -### Contributing +## Contributing Please see [CONTRIBUTING.md](https://github.com/open-telemetry/opentelemetry-js/blob/master/CONTRIBUTING.md) for instructions on how to contribute. diff --git a/examples/basic-tracer-node/README.md b/examples/basic-tracer-node/README.md index f67e881723..bfd695106e 100644 --- a/examples/basic-tracer-node/README.md +++ b/examples/basic-tracer-node/README.md @@ -7,21 +7,20 @@ Our example will export spans data simultaneously on `Console` and [Jaeger](http ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` (Optional) Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one): needs to be running on `localhost` port `16686`. - ## Run the Application ```sh -$ # from this directory -$ npm start +# from this directory +npm start ``` -#### Jaeger UI +### Jaeger UI Open the Jaeger UI in your browser [http://localhost:16686](http://localhost:16686) @@ -34,6 +33,7 @@ Click on the trace to view its details.

## Useful links + - For more information on OpenTelemetry, visit: - For more information on tracing, visit: diff --git a/examples/collector-exporter-node/README.md b/examples/collector-exporter-node/README.md index 3b84a51e16..9d61c6b168 100644 --- a/examples/collector-exporter-node/README.md +++ b/examples/collector-exporter-node/README.md @@ -4,33 +4,34 @@ This example shows how to use [@opentelemetry/exporter-collector](https://github This example will export spans data simultaneously using [Exporter Collector](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-collector) and grpc. It will use [proto format](https://github.com/open-telemetry/opentelemetry-proto). - ## Installation ```shell script -$ # from this directory -$ npm install +# from this directory +npm install ``` ## Run the Application 1. Run docker -```shell script -$ # from this directory -$ npm run docker:start -``` + + ```shell script + # from this directory + npm run docker:start + ``` 2. Run app -```shell script -$ # from this directory -$ npm start -``` -3. Open page at http://localhost:9411/zipkin/ - you should be able to see the spans in zipkin -![Screenshot of the running example](images/spans.png) + ```shell script + # from this directory + npm start + ``` +3. Open page at - you should be able to see the spans in zipkin +![Screenshot of the running example](images/spans.png) ## Useful links + - For more information on OpenTelemetry, visit: - For more information on tracing, visit: diff --git a/examples/grpc/README.md b/examples/grpc/README.md index 30c98639e7..00012cbbf5 100644 --- a/examples/grpc/README.md +++ b/examples/grpc/README.md @@ -5,8 +5,8 @@ OpenTelemetry gRPC Instrumentation allows the user to automatically collect trac ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html) @@ -17,49 +17,52 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/ ### Zipkin - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run zipkin:server + # from this directory + npm run zipkin:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run zipkin:client + # from this directory + npm run zipkin:client ``` #### Zipkin UI + `zipkin:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Zipkin with your browser [http://localhost:9411/zipkin/traces/(your-trace-id)]() (e.g http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6) +Go to Zipkin with your browser (e.g

### Jaeger - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run jaeger:server + # from this directory + npm run jaeger:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run jaeger:client + # from this directory + npm run jaeger:client ``` + #### Jaeger UI `jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Jaeger with your browser [http://localhost:50051/trace/(your-trace-id)]() (e.g http://localhost:50051/trace/4815c3d576d930189725f1f1d1bdfcc6) +Go to Jaeger with your browser (e.g

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry for Node.js, visit: diff --git a/examples/http/README.md b/examples/http/README.md index 7c2caeaad5..c450b211f7 100644 --- a/examples/http/README.md +++ b/examples/http/README.md @@ -4,6 +4,7 @@ OpenTelemetry HTTP Instrumentation allows the user to automatically collect trac This is a simple example that demonstrates tracing HTTP request from client to server. The example shows key aspects of tracing such as + - Root Span (on Client) - Child Span (on Client) - Child Span from a Remote Parent (on Server) @@ -14,8 +15,8 @@ shows key aspects of tracing such as ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html) @@ -26,49 +27,52 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/ ### Zipkin - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run zipkin:server + # from this directory + npm run zipkin:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run zipkin:client + # from this directory + npm run zipkin:client ``` #### Zipkin UI + `zipkin:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Zipkin with your browser [http://localhost:9411/zipkin/traces/(your-trace-id)]() (e.g http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6) +Go to Zipkin with your browser (e.g

### Jaeger - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run jaeger:server + # from this directory + npm run jaeger:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run jaeger:client + # from this directory + npm run jaeger:client ``` + #### Jaeger UI `jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() (e.g http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6) +Go to Jaeger with your browser (e.g

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry for Node.js, visit: diff --git a/examples/https/README.md b/examples/https/README.md index c63ae27ce0..215fd6cbc3 100644 --- a/examples/https/README.md +++ b/examples/https/README.md @@ -4,6 +4,7 @@ OpenTelemetry HTTPS Instrumentation allows the user to automatically collect tra This is a simple example that demonstrates tracing HTTPS request from client to server. The example shows key aspects of tracing such as + - Root Span (on Client) - Child Span (on Client) - Child Span from a Remote Parent (on Server) @@ -14,8 +15,8 @@ shows key aspects of tracing such as ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` Setup [Zipkin Tracing](https://zipkin.io/pages/quickstart.html) @@ -26,49 +27,52 @@ Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/ ### Zipkin - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run zipkin:server + # from this directory + npm run zipkin:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run zipkin:client + # from this directory + npm run zipkin:client ``` #### Zipkin UI + `zipkin:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Zipkin with your browser [http://localhost:9411/zipkin/traces/(your-trace-id)]() (e.g http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6) +Go to Zipkin with your browser (e.g

### Jaeger - - Run the server +- Run the server ```sh - $ # from this directory - $ npm run jaeger:server + # from this directory + npm run jaeger:server ``` - - Run the client +- Run the client ```sh - $ # from this directory - $ npm run jaeger:client + # from this directory + npm run jaeger:client ``` + #### Jaeger UI `jaeger:server` script should output the `traceid` in the terminal (e.g `traceid: 4815c3d576d930189725f1f1d1bdfcc6`). -Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() (e.g http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6) +Go to Jaeger with your browser (e.g

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry for Node.js, visit: diff --git a/examples/metrics/README.md b/examples/metrics/README.md index b5b09885f3..63fd8a5858 100644 --- a/examples/metrics/README.md +++ b/examples/metrics/README.md @@ -7,32 +7,38 @@ This is a simple example that demonstrates basic metrics collection and exports ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` How to setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/) please check [Setup Prometheus](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-exporter-prometheus) ## Run the Application + - Run the example ### Observer + ```sh -$ npm run start:observer +npm run start:observer ``` ### Prometheus + 1. In prometheus search for "metric_observer" ### Links -1. Prometheus Scrape Endpoint http://localhost:9464/metrics -2. Prometheus graph http://localhost:9090/graph + +1. Prometheus Scrape Endpoint +2. Prometheus graph ### Example +

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry metrics, visit: diff --git a/examples/metrics/metrics/observer.js b/examples/metrics/metrics/observer.js index 6cced2142c..52c424b11a 100644 --- a/examples/metrics/metrics/observer.js +++ b/examples/metrics/metrics/observer.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); @@ -19,7 +21,6 @@ const meter = new MeterProvider({ const otelCpuUsage = meter.createObserver('metric_observer', { monotonic: false, - labelKeys: ['pid', 'core'], description: 'Example of a observer', }); diff --git a/examples/opentracing-shim/README.md b/examples/opentracing-shim/README.md index c56e0d3ef2..411e421aeb 100644 --- a/examples/opentracing-shim/README.md +++ b/examples/opentracing-shim/README.md @@ -13,6 +13,7 @@ The example shows key aspects of tracing such as - Make a shim between OpenTracing and OpenTelemetry tracers ## Installation + ```sh # from this directory $ npm install @@ -21,15 +22,18 @@ $ npm install ## Run the Application ### Zipkin + - Setup [Zipkin Tracing UI](https://zipkin.io/pages/quickstart.html) - Run the server + ```sh # from this directory $ npm run zipkin:server ``` - Run the client + ```sh # from this directory $ npm run zipkin:client @@ -39,21 +43,23 @@ $ npm run zipkin:client `zipkin:client` should output the `traceId` in the terminal. - Go to Zipkin with your browser [http://localhost:9411/zipkin/traces/(your-trace-id)]() (e.g http://localhost:9411/zipkin/traces/4815c3d576d930189725f1f1d1bdfcc6) - + Go to Zipkin with your browser (e.g

### Jaeger + - Setup [Jaeger Tracing UI](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one) - Run the server + ```sh # from this directory $ npm run jaeger:server ``` - Run the client + ```sh # from this directory $ npm run jaeger:client @@ -63,15 +69,16 @@ $ npm run jaeger:client `jaeger:client` should output the `traceId` in the terminal. - Go to Jaeger with your browser [http://localhost:16686/trace/(your-trace-id)]() (e.g http://localhost:16686/trace/4815c3d576d930189725f1f1d1bdfcc6) + Go to Jaeger with your browser (e.g

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry for Node.js, visit: - For more information on OpenTracing, visit: ## LICENSE -Apache License 2.0 \ No newline at end of file +Apache License 2.0 diff --git a/examples/prometheus/README.md b/examples/prometheus/README.md index 704769b7bc..1a193fe8a0 100644 --- a/examples/prometheus/README.md +++ b/examples/prometheus/README.md @@ -7,18 +7,19 @@ This is a simple example that demonstrates basic metrics collection and exports ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` Setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/) ## Run the Application + - Run the server ```sh -$ # from this directory -$ npm run start +# from this directory +npm run start ``` - Replace the `prometheus.yml` provided by the Prometheus installation with the following: @@ -39,8 +40,8 @@ scrape_configs: - Start Prometheus ```sh -$ # from the directory you downloaded prometheus -$ prometheus --config.file=prometheus.yml +# from the directory you downloaded prometheus +prometheus --config.file=prometheus.yml ``` ### Prometheus UI @@ -50,6 +51,7 @@ If you are using the default configurations, the prometheus client will be avail

## Useful links + - For more information on OpenTelemetry, visit: - For more information on OpenTelemetry metrics, visit: - For more information on OpenTelemetry for Node.js, visit: diff --git a/examples/prometheus/index.js b/examples/prometheus/index.js index 5d9b52c17a..825df25b1d 100644 --- a/examples/prometheus/index.js +++ b/examples/prometheus/index.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); @@ -20,14 +22,12 @@ const meter = new MeterProvider({ // Monotonic counters can only be increased. const monotonicCounter = meter.createCounter('monotonic_counter', { monotonic: true, - labelKeys: ['pid'], description: 'Example of a monotonic counter', }); // Non-monotonic counters can be increased or decreased. const nonMonotonicCounter = meter.createCounter('non_monotonic_counter', { monotonic: false, - labelKeys: ['pid'], description: 'Example of a non-monotonic counter', }); diff --git a/examples/tracer-web/README.md b/examples/tracer-web/README.md index fef2af26b4..78914ef592 100644 --- a/examples/tracer-web/README.md +++ b/examples/tracer-web/README.md @@ -5,15 +5,15 @@ This example shows how to use [@opentelemetry/web](https://github.com/open-telem ## Installation ```sh -$ # from this directory -$ npm install +# from this directory +npm install ``` ## Run the Application ```sh -$ # from this directory -$ npm start +# from this directory +npm start ``` By default, the application will run on port `8090`. @@ -35,7 +35,6 @@ The screen will look as follows: ![Screenshot of the running example](images/xml-http-request.png) - ## Useful links - For more information on OpenTelemetry, visit: diff --git a/getting-started/README.md b/getting-started/README.md index ce7b341dc5..5937dcad71 100644 --- a/getting-started/README.md +++ b/getting-started/README.md @@ -2,18 +2,19 @@ This guide will walk you through the setup and configuration process for a tracing backend (in this case [Zipkin](https://zipkin.io), but [Jaeger](https://www.jaegertracing.io) would be simple to use as well), a metrics backend like [Prometheus](https://prometheus.io), and auto-instrumentation of NodeJS. [You can find the guide for TypeScript here](ts-example/README.md#getting-started-with-opentelemetry-js-typescript). -1. [Tracing Your Application with OpenTelemetry](#tracing-your-application-with-opentelemetry) - 1. [Setting up a Tracing Backend](#setting-up-a-tracing-backend) - 2. [Trace Your NodeJS Application](#trace-your-nodejs-application) - 1. [Install the required OpenTelemetry libraries](#install-the-required-opentelemetry-libraries) - 2. [Initialize a global tracer](#initialize-a-global-tracer) - 3. [Initialize and register a trace exporter](#initialize-and-register-a-trace-exporter) -2. [Collect Metrics Using OpenTelemetry](#collect-metrics-using-opentelemetry) - 1. [Set up a Metrics Backend](#set-up-a-metrics-backend) - 2. [Monitor Your NodeJS Application](#monitor-your-nodejs-application) - 1. [Install the required OpenTelemetry metrics libraries](#install-the-required-opentelemetry-metrics-libraries) - 2. [Initialize a meter and collect metrics](#initialize-a-meter-and-collect-metrics) - 3. [Initialize and register a metrics exporter](#initialize-and-register-a-metrics-exporter) +- [Getting Started with OpenTelemetry JS](#getting-started-with-opentelemetry-js) + - [Tracing Your Application with OpenTelemetry](#tracing-your-application-with-opentelemetry) + - [Setting up a Tracing Backend](#setting-up-a-tracing-backend) + - [Trace Your NodeJS Application](#trace-your-nodejs-application) + - [Install the required OpenTelemetry libraries](#install-the-required-opentelemetry-libraries) + - [Initialize a global tracer](#initialize-a-global-tracer) + - [Initialize and Register a Trace Exporter](#initialize-and-register-a-trace-exporter) + - [Collect Metrics Using OpenTelemetry](#collect-metrics-using-opentelemetry) + - [Set up a Metrics Backend](#set-up-a-metrics-backend) + - [Monitor Your NodeJS Application](#monitor-your-nodejs-application) + - [Install the required OpenTelemetry metrics libraries](#install-the-required-opentelemetry-metrics-libraries) + - [Initialize a meter and collect metrics](#initialize-a-meter-and-collect-metrics) + - [Initialize and register a metrics exporter](#initialize-and-register-a-metrics-exporter) ## Tracing Your Application with OpenTelemetry @@ -32,7 +33,7 @@ The first thing we will need before we can start collecting traces is a tracing In order to set up Zipkin as quickly as possible, run the latest [Docker Zipkin](https://github.com/openzipkin/docker-zipkin) container, exposing port `9411`. If you can’t run Docker containers, you will need to download and run Zipkin by following the Zipkin [quickstart guide](https://zipkin.io/pages/quickstart.html). ```sh -$ docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin +docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin ``` Browse to to ensure that you can see the Zipkin UI. @@ -134,10 +135,10 @@ provider.addSpanProcessor( console.log("tracing initialized"); ``` -Now if you run your application with the `tracing.js` file loaded, and you send requests to your application over HTTP (in the sample application just browse to http://localhost:8080), you will see traces exported to your tracing backend that look like this: +Now if you run your application with the `tracing.js` file loaded, and you send requests to your application over HTTP (in the sample application just browse to you will see traces exported to your tracing backend that look like this: ```sh -$ node -r ./tracing.js app.js +node -r ./tracing.js app.js ```

@@ -253,7 +254,6 @@ const meter = new MeterProvider().getMeter('your-meter-name'); const requestCount = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); @@ -292,7 +292,7 @@ Now, when we make requests to our service our meter will count all requests. Counting metrics is only useful if we can export them somewhere that we can see them. For this, we're going to use prometheus. Creating and registering a metrics exporter is much like the tracing exporter above. First we will need to install the prometheus exporter. ```sh -$ npm install @opentelemetry/exporter-prometheus +npm install @opentelemetry/exporter-prometheus ``` Next, modify your `monitoring.js` file to look like this: @@ -303,12 +303,17 @@ Next, modify your `monitoring.js` file to look like this: const { MeterProvider } = require('@opentelemetry/metrics'); const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); +const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port +const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint + const exporter = new PrometheusExporter( { startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`, + ); }, ); @@ -319,7 +324,6 @@ const meter = new MeterProvider({ const requestCount = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); @@ -353,7 +357,7 @@ Listening for requests on http://localhost:8080 Now, each time you browse to you should see "Hello from the backend" in your browser and your metrics in prometheus should update. You can verify the current metrics by browsing to , which should look like this: -``` +```sh # HELP requests Count all incoming requests # TYPE requests counter requests{route="/"} 1 diff --git a/getting-started/monitored-example/monitoring.js b/getting-started/monitored-example/monitoring.js index 3f34387711..bd9ac75b3c 100644 --- a/getting-started/monitored-example/monitoring.js +++ b/getting-started/monitored-example/monitoring.js @@ -8,7 +8,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); @@ -19,7 +21,6 @@ const meter = new MeterProvider({ const requestCount = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); diff --git a/getting-started/ts-example/README.md b/getting-started/ts-example/README.md index 4414049bf7..3970ad6c89 100644 --- a/getting-started/ts-example/README.md +++ b/getting-started/ts-example/README.md @@ -2,18 +2,19 @@ This TypeScript guide will walk you through the setup and configuration process for a tracing backend (in this case [Zipkin](https://zipkin.io), but [Jaeger](https://www.jaegertracing.io) would be simple to use as well), a metrics backend like [Prometheus](https://prometheus.io), and auto-instrumentation of NodeJS. [You can find the guide for JavaScript here](../README.md#getting-started-with-opentelemetry-js). -1. [Tracing Your Application with OpenTelemetry](#tracing-your-application-with-opentelemetry) - 1. [Setting up a Tracing Backend](#setting-up-a-tracing-backend) - 2. [Trace Your NodeJS Application](#trace-your-nodejs-application) - 1. [Install the required OpenTelemetry libraries](#install-the-required-opentelemetry-libraries) - 2. [Initialize a global tracer](#initialize-a-global-tracer) - 3. [Initialize and register a trace exporter](#initialize-and-register-a-trace-exporter) -2. [Collect Metrics Using OpenTelemetry](#collect-metrics-using-opentelemetry) - 1. [Set up a Metrics Backend](#set-up-a-metrics-backend) - 2. [Monitor Your NodeJS Application](#monitor-your-nodejs-application) - 1. [Install the required OpenTelemetry metrics libraries](#install-the-required-opentelemetry-metrics-libraries) - 2. [Initialize a meter and collect metrics](#initialize-a-meter-and-collect-metrics) - 3. [Initialize and register a metrics exporter](#initialize-and-register-a-metrics-exporter) +- [Getting Started with OpenTelemetry JS (TypeScript)](#getting-started-with-opentelemetry-js-typescript) + - [Tracing Your Application with OpenTelemetry](#tracing-your-application-with-opentelemetry) + - [Setting up a Tracing Backend](#setting-up-a-tracing-backend) + - [Trace Your NodeJS Application](#trace-your-nodejs-application) + - [Install the required OpenTelemetry libraries](#install-the-required-opentelemetry-libraries) + - [Initialize a global tracer](#initialize-a-global-tracer) + - [Initialize and Register a Trace Exporter](#initialize-and-register-a-trace-exporter) + - [Collect Metrics Using OpenTelemetry](#collect-metrics-using-opentelemetry) + - [Set up a Metrics Backend](#set-up-a-metrics-backend) + - [Monitor Your NodeJS Application](#monitor-your-nodejs-application) + - [Install the required OpenTelemetry metrics libraries](#install-the-required-opentelemetry-metrics-libraries) + - [Initialize a meter and collect metrics](#initialize-a-meter-and-collect-metrics) + - [Initialize and register a metrics exporter](#initialize-and-register-a-metrics-exporter) ## Tracing Your Application with OpenTelemetry @@ -32,7 +33,7 @@ The first thing we will need before we can start collecting traces is a tracing In order to set up Zipkin as quickly as possible, run the latest [Docker Zipkin](https://github.com/openzipkin/docker-zipkin) container, exposing port `9411`. If you can’t run Docker containers, you will need to download and run Zipkin by following the Zipkin [quickstart guide](https://zipkin.io/pages/quickstart.html). ```sh -$ docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin +docker run --rm -d -p 9411:9411 --name zipkin openzipkin/zipkin ``` Browse to to ensure that you can see the Zipkin UI. @@ -137,10 +138,10 @@ provider.addSpanProcessor( console.log("tracing initialized"); ``` -Now if you run your application with the `tracing.ts` file loaded, and you send requests to your application over HTTP (in the sample application just browse to http://localhost:8080), you will see traces exported to your tracing backend that look like this: +Now if you run your application with the `tracing.ts` file loaded, and you send requests to your application over HTTP (in the sample application just browse to you will see traces exported to your tracing backend that look like this: ```sh -$ ts-node -r ./tracing.ts app.ts +ts-node -r ./tracing.ts app.ts ```

@@ -225,7 +226,7 @@ An example application which can be used with this guide can be found at in the To create metrics on NodeJS, you will need `@opentelemetry/metrics`. ```sh -$ npm install @opentelemetry/metrics +npm install @opentelemetry/metrics ``` #### Initialize a meter and collect metrics @@ -252,7 +253,6 @@ const meter = new MeterProvider().getMeter('your-meter-name'); const requestCount: Metric = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); @@ -291,7 +291,7 @@ Now, when we make requests to our service our meter will count all requests. Counting metrics is only useful if we can export them somewhere that we can see them. For this, we're going to use prometheus. Creating and registering a metrics exporter is much like the tracing exporter above. First we will need to install the prometheus exporter. ```sh -$ npm install @opentelemetry/exporter-prometheus +npm install @opentelemetry/exporter-prometheus ``` Next, modify your `monitoring.ts` file to look like this: @@ -301,12 +301,17 @@ import { MeterProvider } from '@opentelemetry/metrics'; import { Metric, BoundCounter } from '@opentelemetry/api'; import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'; +const prometheusPort = PrometheusExporter.DEFAULT_OPTIONS.port +const prometheusEndpoint = PrometheusExporter.DEFAULT_OPTIONS.endpoint + const exporter = new PrometheusExporter( { startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${prometheusPort}${Prometheusendpoint}`, + ); }, ); @@ -317,7 +322,6 @@ const meter = new MeterProvider({ const requestCount: Metric = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); @@ -351,7 +355,7 @@ Listening for requests on http://localhost:8080 Now, each time you browse to you should see "Hello from the backend" in your browser and your metrics in prometheus should update. You can verify the current metrics by browsing to , which should look like this: -``` +```sh # HELP requests Count all incoming requests # TYPE requests counter requests{route="/"} 1 diff --git a/getting-started/ts-example/monitoring.ts b/getting-started/ts-example/monitoring.ts index a7e544d762..282066502c 100644 --- a/getting-started/ts-example/monitoring.ts +++ b/getting-started/ts-example/monitoring.ts @@ -7,7 +7,9 @@ const exporter = new PrometheusExporter( startServer: true, }, () => { - console.log('prometheus scrape endpoint: http://localhost:9464/metrics'); + console.log( + `prometheus scrape endpoint: http://localhost:${PrometheusExporter.DEFAULT_OPTIONS.port}${PrometheusExporter.DEFAULT_OPTIONS.endpoint}`, + ); }, ); @@ -18,7 +20,6 @@ const meter = new MeterProvider({ const requestCount: Metric = meter.createCounter("requests", { monotonic: true, - labelKeys: ["route"], description: "Count all incoming requests" }); diff --git a/metapackages/plugins-node-core/README.md b/metapackages/plugins-node-core/README.md index 8d4d103936..768aeb5210 100644 --- a/metapackages/plugins-node-core/README.md +++ b/metapackages/plugins-node-core/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Plugins Node Core + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -13,6 +14,7 @@ This package depends on all core node plugins maintained by OpenTelemetry author - [@opentelemetry/plugin-https][otel-plugin-https] ## 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] diff --git a/metapackages/plugins-web-core/README.md b/metapackages/plugins-web-core/README.md index 97e9f39250..2fa0dcfb79 100644 --- a/metapackages/plugins-web-core/README.md +++ b/metapackages/plugins-web-core/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Plugins Web Core + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -11,6 +12,7 @@ This package depends on all core web plugins maintained by OpenTelemetry authors - [@opentelemetry/plugin-xml-http-request][otel-plugin-xml-http-request] ## 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] @@ -28,4 +30,4 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [npm-url]: https://www.npmjs.com/package/@opentelemetry/plugins-web-core [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fplugins-web-core.svg -[otel-plugin-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-xml-http-request \ No newline at end of file +[otel-plugin-xml-http-request]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-plugin-xml-http-request diff --git a/packages/opentelemetry-api/README.md b/packages/opentelemetry-api/README.md index 2e965c0fd4..b824c4ae36 100644 --- a/packages/opentelemetry-api/README.md +++ b/packages/opentelemetry-api/README.md @@ -1,4 +1,5 @@ # OpenTelemetry API for JavaScript + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -99,6 +100,7 @@ api.metrics.setGlobalMeterProvider(meterProvider); Because the npm installer and node module resolution algorithm could potentially allow two or more copies of any given package to exist within the same `node_modules` structure, the OpenTelemetry API takes advantage of a variable on the `global` object to store the global API. When an API method in the API package is called, it checks if this `global` API exists and proxies calls to it if and only if it is a compatible API version. This means if a package has a dependency on an OpenTelemetry API version which is not compatible with the API used by the end user, the package will receive a no-op implementation of the API. ## Advanced Use + ### API Registration Options If you prefer to choose your own propagator or context manager, you may pass an options object into the `tracerProvider.register()` method. Omitted or `undefined` options will be replaced by a default value and `null` values will be skipped. @@ -176,6 +178,7 @@ async function doSomething() { ``` ## 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] diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json index 386420ec24..249c773d15 100644 --- a/packages/opentelemetry-api/package.json +++ b/packages/opentelemetry-api/package.json @@ -68,7 +68,7 @@ "karma-webpack": "^4.0.2", "linkinator": "^2.0.3", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "ts-loader": "^6.0.4", "ts-mocha": "^7.0.0", "typedoc": "^0.15.0", diff --git a/packages/opentelemetry-api/src/metrics/Metric.ts b/packages/opentelemetry-api/src/metrics/Metric.ts index 00d4ef215e..23118369fa 100644 --- a/packages/opentelemetry-api/src/metrics/Metric.ts +++ b/packages/opentelemetry-api/src/metrics/Metric.ts @@ -38,9 +38,6 @@ export interface MetricOptions { */ unit?: string; - /** The list of label keys for the Metric. */ - labelKeys?: string[]; - /** The map of constant labels for the Metric. */ constantLabels?: Map; diff --git a/packages/opentelemetry-context-async-hooks/README.md b/packages/opentelemetry-context-async-hooks/README.md index 4a8044a919..95ef201f67 100644 --- a/packages/opentelemetry-context-async-hooks/README.md +++ b/packages/opentelemetry-context-async-hooks/README.md @@ -1,4 +1,5 @@ # OpenTelemetry AsyncHooks-based Context Manager + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -7,7 +8,7 @@ This package provides [async-hooks][async-hooks-doc] based context manager which is used internally by OpenTelemetry plugins to propagate specific context between function calls and async operations. It only targets NodeJS since async-hooks is only available there. -## What is a ContextManager ? +## What is a ContextManager The definition and why they exist is available on [the readme of the context-base package][def-context-manager]. @@ -25,13 +26,14 @@ There are known modules that break context propagation ([some of them are listed ### Prior arts Context propagation is a big subject when talking about tracing in NodeJS, if you want more information about that here are some resources: -- https://www.npmjs.com/package/continuation-local-storage (which was the old way of doing context propagation) + +- (which was the old way of doing context propagation) - Datadog's own implementation for their Javascript tracer: [here][dd-js-tracer-scope] - OpenTracing implementation: [here][opentracing-scope] - Discussion about context propagation by the NodeJS diagnostics working group: [here][diag-team-scope-discussion] - ## 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] diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 76a4e5b792..b12278520f 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -47,7 +47,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-context-base/README.md b/packages/opentelemetry-context-base/README.md index efba889845..a0eb48c24b 100644 --- a/packages/opentelemetry-context-base/README.md +++ b/packages/opentelemetry-context-base/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Base Context Manager + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -7,7 +8,7 @@ This package provides the ContextManager interface (which is used by concrete implementations) and a no-op implementation (which is used internally when no context propagation is defined). It's intended for use both on the server and in the browser. -## What is a Context Manager ? +## What is a Context Manager To understand why they exists, we'll need to understand how Javascript works: when you make native function call (networks, setInterval etc) you generally call C++ code that will later callback your own code. @@ -18,6 +19,7 @@ ContextManager's aim to offer exactly that, it's API offer to store an object in This package only include the interface and a Noop implementation, for more information please see the [async-hooks based ContextManager][ah-context-manager] for NodeJS. ## 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] diff --git a/packages/opentelemetry-context-base/package.json b/packages/opentelemetry-context-base/package.json index 9a50b03657..1f432ea41d 100644 --- a/packages/opentelemetry-context-base/package.json +++ b/packages/opentelemetry-context-base/package.json @@ -48,7 +48,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-context-zone-peer-dep/README.md b/packages/opentelemetry-context-zone-peer-dep/README.md index 4a0d2d9bd8..119e054846 100644 --- a/packages/opentelemetry-context-zone-peer-dep/README.md +++ b/packages/opentelemetry-context-zone-peer-dep/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Context Zone Peer Dependency + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -9,7 +10,6 @@ This module provides *Zone Context Manager with a peer dependency for [zone-js]* If you use Angular you already have the [zone-js] and you should use this package. If you don't have your own [zone-js] please use [@opentelemetry/context-zone] - ## Installation ```bash @@ -17,6 +17,7 @@ npm install --save @opentelemetry/context-zone-peer-dep ``` ## Usage + ```js import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing'; import { WebTracer } from '@opentelemetry/web'; @@ -49,6 +50,7 @@ webTracerWithZone.withSpan(span1, () => { ``` ## 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] diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index eae4690edc..6811e47633 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -58,7 +58,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-context-zone/README.md b/packages/opentelemetry-context-zone/README.md index 0b23b884d3..b3c702c425 100644 --- a/packages/opentelemetry-context-zone/README.md +++ b/packages/opentelemetry-context-zone/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Context Zone + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -9,7 +10,6 @@ This module provides *Zone Context Manager with bundled [zone-js]* for Web appli If you have your own [zone-js] please use [@opentelemetry/context-zone-peer-dep] If you use Angular it means you already have the [zone-js] and you should use [@opentelemetry/context-zone-peer-dep] - ## Installation ```bash @@ -17,6 +17,7 @@ npm install --save @opentelemetry/context-zone ``` ## Usage + ```js import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing'; import { WebTracer } from '@opentelemetry/web'; @@ -49,6 +50,7 @@ webTracerWithZone.withSpan(span1, () => { ``` ## 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] diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index 6b09dfc59d..7e1b696ade 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -52,7 +52,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-core/README.md b/packages/opentelemetry-core/README.md index 8aa5f23148..08e639d492 100644 --- a/packages/opentelemetry-core/README.md +++ b/packages/opentelemetry-core/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Core + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -9,19 +10,24 @@ This package provides default implementations of the OpenTelemetry API for trace ## Built-in Implementations -- [Built-in Propagators](#built-in-propagators) - * [HttpTraceContext Propagator](#httptracecontext-propagator) - * [B3 Propagator](#b3-propagator) - * [Composite Propagator](#composite-propagator) - * [Correlation Context Propagator](#correlation-context-propagator) -- [Built-in Sampler](#built-in-sampler) - * [Always Sampler](#always-sampler) - * [Never Sampler](#never-sampler) - * [Probability Sampler](#probability-sampler) +- [OpenTelemetry Core](#opentelemetry-core) + - [Built-in Implementations](#built-in-implementations) + - [Built-in Propagators](#built-in-propagators) + - [HttpTraceContext Propagator](#httptracecontext-propagator) + - [B3 Propagator](#b3-propagator) + - [Composite Propagator](#composite-propagator) + - [Correlation Context Propagator](#correlation-context-propagator) + - [Built-in Sampler](#built-in-sampler) + - [Always Sampler](#always-sampler) + - [Never Sampler](#never-sampler) + - [Probability Sampler](#probability-sampler) + - [Useful links](#useful-links) + - [License](#license) ### Built-in Propagators #### HttpTraceContext Propagator + OpenTelemetry provides a text-based approach to propagate context to remote services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/) HTTP headers. > This is used as a default Propagator @@ -35,7 +41,8 @@ api.propagation.setGlobalPropagator(new HttpTraceContext()); ``` #### B3 Propagator -This is propagator for the B3 HTTP header format, which sends a `SpanContext` on the wire in an HTTP request, allowing other services to create spans with the right context. Based on: https://github.com/openzipkin/b3-propagation + +This is propagator for the B3 HTTP header format, which sends a `SpanContext` on the wire in an HTTP request, allowing other services to create spans with the right context. Based on: ```js const api = require("@opentelemetry/api"); @@ -46,6 +53,7 @@ api.propagation.setGlobalPropagator(new B3Propagator()); ``` #### Composite Propagator + Combines multiple propagators into a single propagator. ```js @@ -57,6 +65,7 @@ api.propagation.setGlobalPropagator(new CompositePropagator()); ``` #### Correlation Context Propagator + Provides a text-based approach to propagate [correlation context](https://w3c.github.io/correlation-context/) to remote services using the [OpenTelemetry CorrelationContext Propagation](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/correlationcontext/api.md#header-name) HTTP headers. ```js @@ -68,9 +77,11 @@ api.propagation.setGlobalPropagator(new HttpCorrelationContext()); ``` ### Built-in Sampler + Sampler is used to make decisions on `Span` sampling. #### Always Sampler + Samples every trace regardless of upstream sampling decisions. > This is used as a default Sampler @@ -85,6 +96,7 @@ const tracerProvider = new NodeTracerProvider({ ``` #### Never Sampler + Doesn't sample any trace, regardless of upstream sampling decisions. ```js @@ -97,6 +109,7 @@ const tracerProvider = new NodeTracerProvider({ ``` #### Probability Sampler + Samples a configurable percentage of traces, and additionally samples any trace that was sampled upstream. ```js @@ -109,6 +122,7 @@ const tracerProvider = new NodeTracerProvider({ ``` ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us on [gitter][gitter-url] diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 25778b9309..f936e6254d 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -66,7 +66,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index 30ed47caa4..e046bbddb3 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Collector Exporter for web and node + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -14,6 +15,7 @@ npm install --save @opentelemetry/exporter-collector ``` ## Usage in Web + ```js import { SimpleSpanProcessor } from '@opentelemetry/tracing'; import { WebTracerProvider } from '@opentelemetry/web'; @@ -32,6 +34,7 @@ provider.register(); ``` ## Usage in Node + ```js const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CollectorExporter } = require('@opentelemetry/exporter-collector'); @@ -50,6 +53,7 @@ provider.register(); ``` By default, plaintext connection is used. In order to use TLS in Node.js, provide `credentials` option like so: + ```js const fs = require('fs'); const grpc = require('grpc'); @@ -78,11 +82,13 @@ To see how to generate credentials, you can refer to the script used to generate Note, that this will only work if TLS is also configured on the server. ## Running opentelemetry-collector locally to see the traces + 1. Go to examples/basic-tracer-node 2. run `npm run collector:docker:ot` 3. Open page at `http://localhost:9411/zipkin/` to observe the traces ## 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] diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index 4cb6bb73a2..d65bbedcb4 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -70,7 +70,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/README.md b/packages/opentelemetry-exporter-collector/src/platform/node/README.md index aee8555b64..edb0ab60a2 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/README.md +++ b/packages/opentelemetry-exporter-collector/src/platform/node/README.md @@ -1,45 +1,46 @@ -### Important! +# Important + **Submodule is always pointing to certain revision number. So updating the master of the submodule repo will not have impact on your code. Knowing this if you want to change the submodule to point to a different version (when for example proto has changed) here is how to do it:** -### Updating submodule to point to certain revision number +## Updating submodule to point to certain revision number 1. Make sure you are in the same folder as this instruction 2. Update your submodules by running this command -```shell script + ```shell script git submodule sync --recursive git submodule update --init --recursive -``` + ``` 3. Find the SHA which you want to update to and copy it (the long one) the latest sha when this guide was written is `e6c3c4a74d57f870a0d781bada02cb2b2c497d14` 4. Enter a submodule directory from this directory -```shell script - cd protos -``` + ```shell script + cd protos + ``` 5. Updates files in the submodule tree to given commit: -```shell script - git checkout -q -``` + ```shell script + git checkout -q + ``` 6. Return to the main directory: -```shell script - cd ../ -``` + ```shell script + cd ../ + ``` 7. Please run `git status` you should see something like `Head detached at`. This is correct, go to next step 8. Now thing which is very important. You have to commit this to apply these changes -```shell script - git commit -am "chore: updating submodule for opentelemetry-proto" -``` + ```shell script + git commit -am "chore: updating submodule for opentelemetry-proto" + ``` 9. If you look now at git log you will notice that the folder `protos` has been changed and it will show what was the previous sha and what is current one diff --git a/packages/opentelemetry-exporter-jaeger/README.md b/packages/opentelemetry-exporter-jaeger/README.md index ad8c0a88e0..a9d8070514 100644 --- a/packages/opentelemetry-exporter-jaeger/README.md +++ b/packages/opentelemetry-exporter-jaeger/README.md @@ -43,7 +43,7 @@ Or run the `jaeger-all-in-one(.exe)` executable from the [binary distribution ar jaeger-all-in-one --collector.zipkin.http-port=9411 ``` -You can then navigate to http://localhost:16686 to access the Jaeger UI. +You can then navigate to to access the Jaeger UI. ## Installation @@ -85,7 +85,7 @@ You can use built-in `SimpleSpanProcessor` or `BatchSpanProcessor` or write your ## Useful links -- To know more about Jaeger, visit: https://www.jaegertracing.io/docs/latest/getting-started/ +- To know more about Jaeger, visit: - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us on [gitter][gitter-url] diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 8723e39d3d..8bd6b4c45e 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -47,8 +47,8 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", "nock": "^12.0.3", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-exporter-prometheus/README.md b/packages/opentelemetry-exporter-prometheus/README.md index dee3d8e227..c4022f46ef 100644 --- a/packages/opentelemetry-exporter-prometheus/README.md +++ b/packages/opentelemetry-exporter-prometheus/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Prometheus Metric Exporter + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -36,7 +37,6 @@ const meter = new MeterProvider({ // Now, start recording data const counter = meter.createCounter('metric_name', { - labelKeys: ['pid'], description: 'Example of a counter' }); counter.add(10, { pid: process.pid }); @@ -51,11 +51,12 @@ boundCounter.add(10); ## Viewing your metrics -With the above you should now be able to navigate to the Prometheus UI at: http://localhost:9464/metrics +With the above you should now be able to navigate to the Prometheus UI at: ## Useful links + - For more information on OpenTelemetry, visit: -- To learn more about Prometheus, visit: https://prometheus.io/ +- To learn more about Prometheus, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us on [gitter][gitter-url] diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index 6bd21df008..25470d4c28 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -45,7 +45,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts index 84c2fed821..fa1bdc3a35 100644 --- a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts +++ b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts @@ -31,7 +31,7 @@ import { } from '@opentelemetry/metrics'; import * as api from '@opentelemetry/api'; import { createServer, IncomingMessage, Server, ServerResponse } from 'http'; -import { Counter, Gauge, labelValues, Metric, Registry } from 'prom-client'; +import { Counter, Gauge, Metric, Registry } from 'prom-client'; import * as url from 'url'; import { ExporterConfig } from './export/types'; @@ -126,19 +126,17 @@ export class PrometheusExporter implements MetricExporter { const metric = this._registerMetric(record); if (!metric) return; - const labelValues = this._getLabelValues( - record.descriptor.labelKeys, - record.labels - ); const point = record.aggregator.toPoint(); + const labels = record.labels; + if (metric instanceof Counter) { // Prometheus counter saves internal state and increments by given value. // MetricRecord value is the current state, not the delta to be incremented by. // Currently, _registerMetric creates a new counter every time the value changes, // so the increment here behaves as a set value (increment from 0) metric.inc( - labelValues, + labels, point.value as Sum, hrTimeToMilliseconds(point.timestamp) ); @@ -146,10 +144,10 @@ export class PrometheusExporter implements MetricExporter { if (metric instanceof Gauge) { if (record.aggregator instanceof CounterSumAggregator) { - metric.set(labelValues, point.value as Sum); + metric.set(labels, point.value as Sum); } else if (record.aggregator instanceof ObserverAggregator) { metric.set( - labelValues, + labels, point.value as LastValue, hrTimeToMilliseconds(point.timestamp) ); @@ -159,16 +157,6 @@ export class PrometheusExporter implements MetricExporter { // TODO: only counter and gauge are implemented in metrics so far } - private _getLabelValues(keys: string[], labels: api.Labels) { - const labelValues: labelValues = {}; - for (let i = 0; i < keys.length; i++) { - if (labels[keys[i]] !== null) { - labelValues[keys[i]] = labels[keys[i]]; - } - } - return labelValues; - } - private _registerMetric(record: MetricRecord): Metric | undefined { const metricName = this._getPrometheusMetricName(record.descriptor); const metric = this._registry.getSingleMetric(metricName); @@ -183,9 +171,7 @@ export class PrometheusExporter implements MetricExporter { * https://prometheus.io/docs/instrumenting/exposition_formats/ */ if (metric instanceof Counter) { - metric.remove( - ...record.descriptor.labelKeys.map(k => record.labels[k].toString()) - ); + metric.remove(...Object.values(record.labels)); } if (metric) return metric; @@ -198,7 +184,7 @@ export class PrometheusExporter implements MetricExporter { name, // prom-client throws with empty description which is our default help: record.descriptor.description || 'description missing', - labelNames: record.descriptor.labelKeys, + labelNames: Object.keys(record.labels), // list of registries to register the newly created metric registers: [this._registry], }; diff --git a/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts b/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts index dd1294ca3a..5e1e426862 100644 --- a/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts +++ b/packages/opentelemetry-exporter-prometheus/test/prometheus.test.ts @@ -200,7 +200,6 @@ describe('PrometheusExporter', () => { it('should export a count aggregation', done => { const counter = meter.createCounter('counter', { description: 'a test description', - labelKeys: ['key1'], }); const boundCounter = counter.bind({ key1: 'labelValue1' }); @@ -245,7 +244,6 @@ describe('PrometheusExporter', () => { const observer = meter.createObserver('metric_observer', { description: 'a test description', - labelKeys: ['pid'], }) as ObserverMetric; observer.setCallback((observerResult: ObserverResult) => { @@ -269,7 +267,10 @@ describe('PrometheusExporter', () => { assert.strictEqual(lines[1], '# TYPE metric_observer gauge'); const line3 = lines[2].split(' '); - assert.strictEqual(line3[0], 'metric_observer{pid="123"}'); + assert.strictEqual( + line3[0], + 'metric_observer{pid="123",core="1"}' + ); assert.ok( parseFloat(line3[1]) >= 0 && parseFloat(line3[1]) <= 1 ); @@ -286,7 +287,6 @@ describe('PrometheusExporter', () => { it('should export multiple labels', done => { const counter = meter.createCounter('counter', { description: 'a test description', - labelKeys: ['counterKey1'], }) as CounterMetric; counter.bind({ counterKey1: 'labelValue1' }).add(10); @@ -347,7 +347,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter description missing', '# TYPE counter counter', - `counter 10 ${mockedTimeMS}`, + `counter{key1="labelValue1"} 10 ${mockedTimeMS}`, '', ]); @@ -373,7 +373,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter_bad_name description missing', '# TYPE counter_bad_name counter', - `counter_bad_name 10 ${mockedTimeMS}`, + `counter_bad_name{key1="labelValue1"} 10 ${mockedTimeMS}`, '', ]); @@ -388,7 +388,6 @@ describe('PrometheusExporter', () => { const counter = meter.createCounter('counter', { description: 'a test description', monotonic: false, - labelKeys: ['key1'], }); counter.bind({ key1: 'labelValue1' }).add(20); @@ -449,7 +448,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP test_prefix_counter description missing', '# TYPE test_prefix_counter counter', - `test_prefix_counter 10 ${mockedTimeMS}`, + `test_prefix_counter{key1="labelValue1"} 10 ${mockedTimeMS}`, '', ]); @@ -478,7 +477,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter description missing', '# TYPE counter counter', - `counter 10 ${mockedTimeMS}`, + `counter{key1="labelValue1"} 10 ${mockedTimeMS}`, '', ]); @@ -507,7 +506,7 @@ describe('PrometheusExporter', () => { assert.deepStrictEqual(lines, [ '# HELP counter description missing', '# TYPE counter counter', - `counter 10 ${mockedTimeMS}`, + `counter{key1="labelValue1"} 10 ${mockedTimeMS}`, '', ]); diff --git a/packages/opentelemetry-exporter-zipkin/README.md b/packages/opentelemetry-exporter-zipkin/README.md index 9367d0e0d6..e38ce286c3 100644 --- a/packages/opentelemetry-exporter-zipkin/README.md +++ b/packages/opentelemetry-exporter-zipkin/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Zipkin Trace Exporter + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -17,7 +18,7 @@ npm install --save @opentelemetry/exporter-zipkin ## Usage -Install the exporter on your application and pass the options, it must contain a service name. +Install the exporter on your application and pass the options. `serviceName` is an optional string. If omitted, the exporter will first try to get the service name from the Resource. If no service name can be detected on the Resource, a fallback name of "OpenTelemetry Service" will be used. ```js const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin'); @@ -44,12 +45,13 @@ You can use built-in `SimpleSpanProcessor` or `BatchSpanProcessor` or write your ## Viewing your traces -Please visit the Zipkin UI endpoint http://localhost:9411 +Please visit the Zipkin UI endpoint ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: -- For Zipkin project at https://zipkin.io/ +- For Zipkin project at - For help or feedback on this project, join us on [gitter][gitter-url] ## License diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 8143c9b94c..5852f41fc1 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -45,7 +45,7 @@ "gts": "^2.0.0", "mocha": "^7.1.2", "nock": "^11.0.0", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-exporter-zipkin/src/types.ts b/packages/opentelemetry-exporter-zipkin/src/types.ts index 051673d582..7667ef1783 100644 --- a/packages/opentelemetry-exporter-zipkin/src/types.ts +++ b/packages/opentelemetry-exporter-zipkin/src/types.ts @@ -21,7 +21,7 @@ import * as api from '@opentelemetry/api'; */ export interface ExporterConfig { logger?: api.Logger; - serviceName: string; + serviceName?: string; url?: string; // Optional mapping overrides for OpenTelemetry status code and description. statusCodeTagName?: string; diff --git a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts index 39906b3d76..5ca0ff7c9d 100644 --- a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts +++ b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts @@ -27,19 +27,21 @@ import { statusDescriptionTagName, } from './transform'; import { OT_REQUEST_HEADER } from './utils'; +import { SERVICE_RESOURCE } from '@opentelemetry/resources'; /** * Zipkin Exporter */ export class ZipkinExporter implements SpanExporter { static readonly DEFAULT_URL = 'http://localhost:9411/api/v2/spans'; + private readonly DEFAULT_SERVICE_NAME = 'OpenTelemetry Service'; private readonly _logger: api.Logger; - private readonly _serviceName: string; private readonly _statusCodeTagName: string; private readonly _statusDescriptionTagName: string; private readonly _reqOpts: http.RequestOptions; + private _serviceName?: string; private _isShutdown: boolean; - constructor(config: zipkinTypes.ExporterConfig) { + constructor(config: zipkinTypes.ExporterConfig = {}) { const urlStr = config.url || ZipkinExporter.DEFAULT_URL; const urlOpts = url.parse(urlStr); @@ -68,12 +70,18 @@ export class ZipkinExporter implements SpanExporter { spans: ReadableSpan[], resultCallback: (result: ExportResult) => void ) { + if (typeof this._serviceName !== 'string') { + this._serviceName = String( + spans[0].resource.labels[SERVICE_RESOURCE.NAME] || + this.DEFAULT_SERVICE_NAME + ); + } this._logger.debug('Zipkin exporter export'); if (this._isShutdown) { setTimeout(() => resultCallback(ExportResult.FAILED_NOT_RETRYABLE)); return; } - return this._sendSpans(spans, resultCallback); + return this._sendSpans(spans, this._serviceName, resultCallback); } /** @@ -87,26 +95,22 @@ export class ZipkinExporter implements SpanExporter { this._isShutdown = true; } - /** - * Transforms an OpenTelemetry span to a Zipkin span. - */ - private _toZipkinSpan(span: ReadableSpan): zipkinTypes.Span { - return toZipkinSpan( - span, - this._serviceName, - this._statusCodeTagName, - this._statusDescriptionTagName - ); - } - /** * Transform spans and sends to Zipkin service. */ private _sendSpans( spans: ReadableSpan[], + serviceName: string, done?: (result: ExportResult) => void ) { - const zipkinSpans = spans.map(span => this._toZipkinSpan(span)); + const zipkinSpans = spans.map(span => + toZipkinSpan( + span, + serviceName, + this._statusCodeTagName, + this._statusDescriptionTagName + ) + ); return this._send(zipkinSpans, (result: ExportResult) => { if (done) { return done(result); diff --git a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts index 35ff329c61..c4a7a24bc9 100644 --- a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts @@ -28,6 +28,7 @@ import { ZipkinExporter } from '../src'; import * as zipkinTypes from '../src/types'; import { OT_REQUEST_HEADER } from '../src/utils'; import { TraceFlags } from '@opentelemetry/api'; +import { SERVICE_RESOURCE } from '@opentelemetry/resources'; const MICROS_PER_SECS = 1e6; @@ -331,6 +332,152 @@ describe('ZipkinExporter', () => { done(); }); }); + + it('should set serviceName to "Opentelemetry Service" by default', () => { + const scope = nock('http://localhost:9411') + .post('/api/v2/spans') + .replyWithError(new Error('My Socket Error')); + + const parentSpanId = '5c1c63257de34c67'; + const startTime = 1566156729709; + const duration = 2000; + + const span1: ReadableSpan = { + name: 'my-span', + kind: api.SpanKind.INTERNAL, + parentSpanId, + spanContext: { + traceId: 'd4cda95b652f4a1592b449d5929fda1b', + spanId: '6e0c63257de34c92', + traceFlags: TraceFlags.NONE, + }, + startTime: [startTime, 0], + endTime: [startTime + duration, 0], + ended: true, + duration: [duration, 0], + status: { + code: api.CanonicalCode.OK, + }, + attributes: { + key1: 'value1', + key2: 'value2', + }, + links: [], + events: [ + { + name: 'my-event', + time: [startTime + 10, 0], + attributes: { key3: 'value3' }, + }, + ], + resource: Resource.empty(), + }; + const span2: ReadableSpan = { + name: 'my-span', + kind: api.SpanKind.SERVER, + spanContext: { + traceId: 'd4cda95b652f4a1592b449d5929fda1b', + spanId: '6e0c63257de34c92', + traceFlags: TraceFlags.NONE, + }, + startTime: [startTime, 0], + endTime: [startTime + duration, 0], + ended: true, + duration: [duration, 0], + status: { + code: api.CanonicalCode.OK, + }, + attributes: {}, + links: [], + events: [], + resource: Resource.empty(), + }; + + const exporter = new ZipkinExporter({}); + + exporter.export([span1, span2], (result: ExportResult) => { + scope.done(); + assert.equal(exporter['_serviceName'], 'OpenTelemetry Service'); + }); + }); + + it('should set serviceName if resource has one', () => { + const resource_service_name = 'resource_service_name'; + + const scope = nock('http://localhost:9411') + .post('/api/v2/spans') + .replyWithError(new Error('My Socket Error')); + + const parentSpanId = '5c1c63257de34c67'; + const startTime = 1566156729709; + const duration = 2000; + + const span1: ReadableSpan = { + name: 'my-span', + kind: api.SpanKind.INTERNAL, + parentSpanId, + spanContext: { + traceId: 'd4cda95b652f4a1592b449d5929fda1b', + spanId: '6e0c63257de34c92', + traceFlags: TraceFlags.NONE, + }, + startTime: [startTime, 0], + endTime: [startTime + duration, 0], + ended: true, + duration: [duration, 0], + status: { + code: api.CanonicalCode.OK, + }, + attributes: { + key1: 'value1', + key2: 'value2', + }, + links: [], + events: [ + { + name: 'my-event', + time: [startTime + 10, 0], + attributes: { key3: 'value3' }, + }, + ], + resource: new Resource({ + [SERVICE_RESOURCE.NAME]: resource_service_name, + }), + }; + const span2: ReadableSpan = { + name: 'my-span', + kind: api.SpanKind.SERVER, + spanContext: { + traceId: 'd4cda95b652f4a1592b449d5929fda1b', + spanId: '6e0c63257de34c92', + traceFlags: TraceFlags.NONE, + }, + startTime: [startTime, 0], + endTime: [startTime + duration, 0], + ended: true, + duration: [duration, 0], + status: { + code: api.CanonicalCode.OK, + }, + attributes: {}, + links: [], + events: [], + resource: Resource.empty(), + }; + + const exporter = new ZipkinExporter({}); + + exporter.export([span1, span2], (result: ExportResult) => { + scope.done(); + assert.equal(exporter['_serviceName'], resource_service_name); + + // checking if service name remains consistent in further exports + exporter.export([span2], (result: ExportResult) => { + scope.done(); + assert.equal(exporter['_serviceName'], resource_service_name); + }); + }); + }); }); describe('shutdown', () => { diff --git a/packages/opentelemetry-metrics/README.md b/packages/opentelemetry-metrics/README.md index 340f3ee657..7506c30085 100644 --- a/packages/opentelemetry-metrics/README.md +++ b/packages/opentelemetry-metrics/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Metrics SDK + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -16,6 +17,7 @@ npm install --save @opentelemetry/metrics ## Usage ### Counter + Choose this kind of metric when the value is a quantity, the sum is of primary interest, and the event count and value distribution are not of primary interest. Counters are defined as `Monotonic = true` by default, meaning that positive values are expected. ```js @@ -25,7 +27,6 @@ const { MeterProvider } = require('@opentelemetry/metrics'); const meter = new MeterProvider().getMeter('your-meter-name'); const counter = meter.createCounter('metric_name', { - labelKeys: ['pid'], description: 'Example of a counter' }); @@ -38,6 +39,7 @@ boundCounter.add(10); ``` ### Observable + Choose this kind of metric when only last value is important without worry about aggregation ```js @@ -47,7 +49,6 @@ const { MeterProvider, MetricObservable } = require('@opentelemetry/metrics'); const meter = new MeterProvider().getMeter('your-meter-name'); const observer = meter.createObserver('metric_name', { - labelKeys: ['pid', 'core'], description: 'Example of a observer' }); @@ -80,6 +81,7 @@ Values captured by `ValueRecorder.record(value)` are treated as individual event `ValueRecorder` should be chosen either when capturing measurements that do not contribute meaningfully to a sum, or when capturing numbers that are additive in nature, but where the distribution of individual increments is considered interesting. ## 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] diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index 65d06c8a51..c0886dab4e 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -47,7 +47,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-mocha": "^7.0.0", diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts index dd52fd9f3c..09aa518028 100644 --- a/packages/opentelemetry-metrics/src/Metric.ts +++ b/packages/opentelemetry-metrics/src/Metric.ts @@ -98,7 +98,6 @@ export abstract class Metric unit: this._options.unit, metricKind: this._kind, valueType: this._valueType, - labelKeys: this._options.labelKeys, monotonic: this._monotonic, }; } diff --git a/packages/opentelemetry-metrics/src/export/Batcher.ts b/packages/opentelemetry-metrics/src/export/Batcher.ts index 2bb6eb9d1a..8b3dfa5392 100644 --- a/packages/opentelemetry-metrics/src/export/Batcher.ts +++ b/packages/opentelemetry-metrics/src/export/Batcher.ts @@ -64,7 +64,7 @@ export class UngroupedBatcher extends Batcher { } process(record: MetricRecord): void { - const labels = record.descriptor.labelKeys + const labels = Object.keys(record.labels) .map(k => `${k}=${record.labels[k]}`) .join(','); this._batchMap.set(record.descriptor.name + labels, record); diff --git a/packages/opentelemetry-metrics/src/export/types.ts b/packages/opentelemetry-metrics/src/export/types.ts index 8a34a34d1b..a07ca8224e 100644 --- a/packages/opentelemetry-metrics/src/export/types.ts +++ b/packages/opentelemetry-metrics/src/export/types.ts @@ -21,8 +21,12 @@ import { Resource } from '@opentelemetry/resources'; /** The kind of metric. */ export enum MetricKind { COUNTER, + UP_DOWN_COUNTER, VALUE_RECORDER, - OBSERVER, + OBSERVER, // @TODO remove later #1146 + SUM_OBSERVER, + UP_DOWN_SUM_OBSERVER, + VALUE_OBSERVER, } /** Sum returns an aggregated sum. */ @@ -78,7 +82,6 @@ export interface MetricDescriptor { readonly unit: string; readonly metricKind: MetricKind; readonly valueType: ValueType; - readonly labelKeys: string[]; readonly monotonic: boolean; } diff --git a/packages/opentelemetry-metrics/src/types.ts b/packages/opentelemetry-metrics/src/types.ts index b5ba841e68..6f0fea05e7 100644 --- a/packages/opentelemetry-metrics/src/types.ts +++ b/packages/opentelemetry-metrics/src/types.ts @@ -31,9 +31,6 @@ export interface MetricOptions { /** The unit of the Metric values. */ unit: string; - /** The list of label keys for the Metric. */ - labelKeys: string[]; - /** The map of constant labels for the Metric. */ constantLabels?: Map; @@ -84,6 +81,5 @@ export const DEFAULT_METRIC_OPTIONS = { disabled: false, description: '', unit: '1', - labelKeys: [], valueType: ValueType.DOUBLE, }; diff --git a/packages/opentelemetry-metrics/test/Batcher.test.ts b/packages/opentelemetry-metrics/test/Batcher.test.ts index 72c68608bb..a295883cc6 100644 --- a/packages/opentelemetry-metrics/test/Batcher.test.ts +++ b/packages/opentelemetry-metrics/test/Batcher.test.ts @@ -30,9 +30,7 @@ describe('Batcher', () => { logger: new NoopLogger(), interval: 10000, }).getMeter('test-meter'); - counter = meter.createCounter('ungrouped-batcher-test', { - labelKeys: ['key'], - }); + counter = meter.createCounter('ungrouped-batcher-test'); fooCounter = counter.bind({ key: 'foo' }); barCounter = counter.bind({ key: 'bar' }); }); diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index 93244aca35..a71c82b41f 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -228,7 +228,6 @@ describe('Meter', () => { assert.strictEqual(record.length, 1); assert.deepStrictEqual(record[0].descriptor, { description: '', - labelKeys: [], metricKind: MetricKind.COUNTER, monotonic: true, name: 'name1', @@ -487,7 +486,6 @@ describe('Meter', () => { it('should set callback and observe value ', () => { const valueRecorder = meter.createObserver('name', { description: 'desc', - labelKeys: ['pid', 'core'], }) as ObserverMetric; function getCpuUsage() { @@ -546,7 +544,6 @@ describe('Meter', () => { const key = 'key'; const counter = meter.createCounter('counter', { description: 'test', - labelKeys: [key], }); const labels = { [key]: 'counter-value' }; const boundCounter = counter.bind(labels); @@ -563,7 +560,6 @@ describe('Meter', () => { monotonic: true, unit: '1', valueType: ValueType.DOUBLE, - labelKeys: ['key'], }); assert.strictEqual(record[0].labels, labels); const value = record[0].aggregator.toPoint().value as Sum; @@ -574,7 +570,6 @@ describe('Meter', () => { const key = 'key'; const counter = meter.createCounter('counter', { description: 'test', - labelKeys: [key], valueType: api.ValueType.INT, }); const labels = { [key]: 'counter-value' }; @@ -592,7 +587,6 @@ describe('Meter', () => { monotonic: true, unit: '1', valueType: ValueType.INT, - labelKeys: ['key'], }); assert.strictEqual(record[0].labels, labels); const value = record[0].aggregator.toPoint().value as Sum; diff --git a/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts b/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts index d9dc83315f..d47bc2981c 100644 --- a/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts +++ b/packages/opentelemetry-metrics/test/export/ConsoleMetricExporter.test.ts @@ -42,7 +42,6 @@ describe('ConsoleMetricExporter', () => { ); const counter = meter.createCounter('counter', { description: 'a test description', - labelKeys: ['key1', 'key2'], }); const boundCounter = counter.bind({ key1: 'labelValue1', @@ -57,7 +56,6 @@ describe('ConsoleMetricExporter', () => { assert.deepStrictEqual(descriptor, [ { description: 'a test description', - labelKeys: ['key1', 'key2'], metricKind: MetricKind.COUNTER, monotonic: true, name: 'counter', diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 8d2db882ff..429336c953 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -50,7 +50,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "shimmer": "^1.2.0", "ts-mocha": "^7.0.0", diff --git a/packages/opentelemetry-plugin-grpc/README.md b/packages/opentelemetry-plugin-grpc/README.md index 7376811dd8..064b5be954 100644 --- a/packages/opentelemetry-plugin-grpc/README.md +++ b/packages/opentelemetry-plugin-grpc/README.md @@ -1,4 +1,5 @@ # OpenTelemetry gRPC Instrumentation for Node.js + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -12,7 +13,7 @@ For automatic instrumentation see the ## Installation -``` +```sh npm install --save @opentelemetry/plugin-grpc ``` @@ -21,6 +22,7 @@ npm install --save @opentelemetry/plugin-grpc OpenTelemetry gRPC Instrumentation allows the user to automatically collect trace data and export them to the backend of choice, to give observability to distributed systems when working with [gRPC](https://www.npmjs.com/package/grpc). To load a specific plugin (**gRPC** in this case), specify it in the Node Tracer's configuration. + ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -36,6 +38,7 @@ const provider = new NodeTracerProvider({ ``` To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. + ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -44,8 +47,8 @@ const provider = new NodeTracerProvider(); See [examples/grpc](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/grpc) for a short example. - ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us on [gitter][gitter-url] diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json index 9f60263ffa..d292150a8a 100644 --- a/packages/opentelemetry-plugin-grpc/package.json +++ b/packages/opentelemetry-plugin-grpc/package.json @@ -55,7 +55,7 @@ "gts": "^2.0.0", "mocha": "^7.1.2", "node-pre-gyp": "^0.12.0", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "semver": "7.3.2", "sinon": "^7.5.0", diff --git a/packages/opentelemetry-plugin-http/README.md b/packages/opentelemetry-plugin-http/README.md index 247b50996a..004dfed716 100644 --- a/packages/opentelemetry-plugin-http/README.md +++ b/packages/opentelemetry-plugin-http/README.md @@ -1,4 +1,5 @@ # OpenTelemetry HTTP Instrumentation for Node.js + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -21,6 +22,7 @@ npm install --save @opentelemetry/plugin-http OpenTelemetry HTTP Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems. To load a specific plugin (HTTP in this case), specify it in the Node Tracer's configuration. + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -37,6 +39,7 @@ const provider = new NodeTracerProvider({ ``` To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -61,6 +64,7 @@ Http plugin has few options available to choose from. You can set the following: | `requireParentforIncomingSpans` | Boolean | Require that is a parent span to create new span for incoming requests. | ## 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] diff --git a/packages/opentelemetry-plugin-http/package.json b/packages/opentelemetry-plugin-http/package.json index 0cb80e7e45..a4687380c7 100644 --- a/packages/opentelemetry-plugin-http/package.json +++ b/packages/opentelemetry-plugin-http/package.json @@ -60,7 +60,7 @@ "gts": "^2.0.0", "mocha": "^7.1.2", "nock": "^11.3.5", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "request": "^2.88.0", "request-promise-native": "^1.0.7", "rimraf": "^3.0.0", diff --git a/packages/opentelemetry-plugin-https/README.md b/packages/opentelemetry-plugin-https/README.md index 63bf5fa101..e1e905b327 100644 --- a/packages/opentelemetry-plugin-https/README.md +++ b/packages/opentelemetry-plugin-https/README.md @@ -1,4 +1,5 @@ # OpenTelemetry HTTPS Instrumentation for Node.js + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -21,6 +22,7 @@ npm install --save @opentelemetry/plugin-https OpenTelemetry HTTPS Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems. To load a specific plugin (HTTPS in this case), specify it in the Node Tracer's configuration. + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -37,6 +39,7 @@ const provider = new NodeTracerProvider({ ``` To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -56,6 +59,7 @@ Https plugin has few options available to choose from. You can set the following | [`ignoreOutgoingUrls`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-http/src/types.ts#L28) | `IgnoreMatcher[]` | Http plugin will not trace all outgoing requests that match urls | ## 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] diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json index b842f52d42..52939766a0 100644 --- a/packages/opentelemetry-plugin-https/package.json +++ b/packages/opentelemetry-plugin-https/package.json @@ -59,7 +59,7 @@ "gts": "^2.0.0", "mocha": "^7.1.2", "nock": "^11.3.5", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "request": "^2.88.0", "request-promise-native": "^1.0.7", "rimraf": "^3.0.0", diff --git a/packages/opentelemetry-plugin-xml-http-request/README.md b/packages/opentelemetry-plugin-xml-http-request/README.md index 122e4c3fce..465c0c8782 100644 --- a/packages/opentelemetry-plugin-xml-http-request/README.md +++ b/packages/opentelemetry-plugin-xml-http-request/README.md @@ -1,4 +1,5 @@ # OpenTelemetry XMLHttpRequest Instrumentation for web + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -39,6 +40,7 @@ req.send(); ``` ## Example Screenshots + ![Screenshot of the running example](images/main.jpg) ![Screenshot of the running example](images/request.jpg) ![Screenshot of the running example](images/cors.jpg) @@ -46,6 +48,7 @@ req.send(); See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a short example. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us on [gitter][gitter-url] diff --git a/packages/opentelemetry-plugin-xml-http-request/package.json b/packages/opentelemetry-plugin-xml-http-request/package.json index 5c0bda5fd3..f6f5253167 100644 --- a/packages/opentelemetry-plugin-xml-http-request/package.json +++ b/packages/opentelemetry-plugin-xml-http-request/package.json @@ -62,7 +62,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts index eb6a55cbfe..13e8e03c0f 100644 --- a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts @@ -358,15 +358,7 @@ export class XMLHttpRequestPlugin extends BasePlugin { return function patchOpen(this: XMLHttpRequest, ...args): void { const method: string = args[0]; const url: string = args[1]; - const async = !!args[2]; - if (async) { - plugin._createSpan(this, url, method); - } else { - plugin._logger.debug( - 'tracing support for synchronous XMLHttpRequest calls is not' + - ' supported' - ); - } + plugin._createSpan(this, url, method); return original.apply(this, args); }; diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts index 5248fd8b6f..ff2b487941 100644 --- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts +++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts @@ -40,12 +40,14 @@ class DummySpanExporter implements tracing.SpanExporter { shutdown() {} } -const getData = (url: string, callbackAfterSend: Function) => { +const getData = (url: string, callbackAfterSend: Function, async?: boolean) => { // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { + if (async === undefined) { + async = true; + } const req = new XMLHttpRequest(); - req.open('GET', url, true); - req.send(); + req.open('GET', url, async); req.onload = function () { resolve(); }; @@ -57,6 +59,7 @@ const getData = (url: string, callbackAfterSend: Function) => { req.ontimeout = function () { resolve(); }; + req.send(); callbackAfterSend(); }); @@ -94,506 +97,524 @@ function createResource(resource = {}): PerformanceResourceTiming { } describe('xhr', () => { - let sandbox: sinon.SinonSandbox; - let requests: any[] = []; - let prepareData: any; - let clearData: any; - let contextManager: ZoneContextManager; - - beforeEach(() => { - contextManager = new ZoneContextManager().enable(); - api.context.setGlobalContextManager(contextManager); - }); + const asyncTests = [{ async: true }, { async: false }]; + asyncTests.forEach(test => { + const testAsync = test.async; + describe(`when async='${testAsync}'`, () => { + let sandbox: sinon.SinonSandbox; + let requests: any[] = []; + let prepareData: any; + let clearData: any; + let contextManager: ZoneContextManager; + + beforeEach(() => { + contextManager = new ZoneContextManager().enable(); + api.context.setGlobalContextManager(contextManager); + }); - afterEach(() => { - api.context.disable(); - }); + afterEach(() => { + api.context.disable(); + }); - before(() => { - api.propagation.setGlobalPropagator(new B3Propagator()); - }); + before(() => { + api.propagation.setGlobalPropagator(new B3Propagator()); + }); - describe('when request is successful', () => { - let webTracerWithZone: api.Tracer; - let webTracerProviderWithZone: WebTracerProvider; - let dummySpanExporter: DummySpanExporter; - let exportSpy: any; - let rootSpan: api.Span; - let spyEntries: any; - const url = `${window.location.origin}/xml-http-request.js`; - let fakeNow = 0; - - clearData = () => { - requests = []; - sandbox.restore(); - spyEntries.restore(); - }; + describe('when request is successful', () => { + let webTracerWithZone: api.Tracer; + let webTracerProviderWithZone: WebTracerProvider; + let dummySpanExporter: DummySpanExporter; + let exportSpy: any; + let rootSpan: api.Span; + let spyEntries: any; + const url = `${window.location.origin}/xml-http-request.js`; + let fakeNow = 0; + + clearData = () => { + requests = []; + sandbox.restore(); + spyEntries.restore(); + }; + + prepareData = ( + done: any, + fileUrl: string, + propagateTraceHeaderCorsUrls?: any + ) => { + sandbox = sinon.createSandbox(); + const fakeXhr = sandbox.useFakeXMLHttpRequest(); + fakeXhr.onCreate = function (xhr: any) { + requests.push(xhr); + }; + sandbox.useFakeTimers(); + + sandbox.stub(performance, 'timeOrigin').value(0); + sandbox.stub(performance, 'now').callsFake(() => fakeNow); + + const resources: PerformanceResourceTiming[] = []; + resources.push( + createResource({ + name: url, + }) + ); - prepareData = ( - done: any, - fileUrl: string, - propagateTraceHeaderCorsUrls?: any - ) => { - sandbox = sinon.createSandbox(); - const fakeXhr = sandbox.useFakeXMLHttpRequest(); - fakeXhr.onCreate = function (xhr: any) { - requests.push(xhr); - }; - sandbox.useFakeTimers(); - - sandbox.stub(performance, 'timeOrigin').value(0); - sandbox.stub(performance, 'now').callsFake(() => fakeNow); - - const resources: PerformanceResourceTiming[] = []; - resources.push( - createResource({ - name: url, - }) - ); - - spyEntries = sandbox.stub(performance, 'getEntriesByType'); - spyEntries.withArgs('resource').returns(resources); - - webTracerProviderWithZone = new WebTracerProvider({ - logLevel: LogLevel.ERROR, - plugins: [ - new XMLHttpRequestPlugin({ - propagateTraceHeaderCorsUrls: propagateTraceHeaderCorsUrls, - }), - ], - }); - webTracerWithZone = webTracerProviderWithZone.getTracer('xhr-test'); - dummySpanExporter = new DummySpanExporter(); - exportSpy = sinon.stub(dummySpanExporter, 'export'); - webTracerProviderWithZone.addSpanProcessor( - new tracing.SimpleSpanProcessor(dummySpanExporter) - ); - - rootSpan = webTracerWithZone.startSpan('root'); - webTracerWithZone.withSpan(rootSpan, () => { - getData(fileUrl, () => { - fakeNow = 100; - }).then(() => { - fakeNow = 0; - sandbox.clock.tick(1000); - done(); + spyEntries = sandbox.stub(performance, 'getEntriesByType'); + spyEntries.withArgs('resource').returns(resources); + + webTracerProviderWithZone = new WebTracerProvider({ + logLevel: LogLevel.ERROR, + plugins: [ + new XMLHttpRequestPlugin({ + propagateTraceHeaderCorsUrls: propagateTraceHeaderCorsUrls, + }), + ], + }); + webTracerWithZone = webTracerProviderWithZone.getTracer('xhr-test'); + dummySpanExporter = new DummySpanExporter(); + exportSpy = sinon.stub(dummySpanExporter, 'export'); + webTracerProviderWithZone.addSpanProcessor( + new tracing.SimpleSpanProcessor(dummySpanExporter) + ); + + rootSpan = webTracerWithZone.startSpan('root'); + webTracerWithZone.withSpan(rootSpan, () => { + getData( + fileUrl, + () => { + fakeNow = 100; + }, + testAsync + ).then(() => { + fakeNow = 0; + sandbox.clock.tick(1000); + done(); + }); + assert.strictEqual(requests.length, 1, 'request not called'); + + requests[0].respond( + 200, + { 'Content-Type': 'application/json' }, + '{"foo":"bar"}' + ); + }); + }; + + beforeEach(done => { + const propagateTraceHeaderCorsUrls = [window.location.origin]; + prepareData(done, url, propagateTraceHeaderCorsUrls); }); - assert.strictEqual(requests.length, 1, 'request not called'); - requests[0].respond( - 200, - { 'Content-Type': 'application/json' }, - '{"foo":"bar"}' - ); - }); - }; + afterEach(() => { + clearData(); + }); - beforeEach(done => { - const propagateTraceHeaderCorsUrls = [window.location.origin]; - prepareData(done, url, propagateTraceHeaderCorsUrls); - }); + it('should create a span with correct root span', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + assert.strictEqual( + span.parentSpanId, + rootSpan.context().spanId, + 'parent span is not root span' + ); + }); - afterEach(() => { - clearData(); - }); + it('span should have correct name', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + assert.strictEqual(span.name, url, 'span has wrong name'); + }); - it('should create a span with correct root span', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - assert.strictEqual( - span.parentSpanId, - rootSpan.context().spanId, - 'parent span is not root span' - ); - }); + it('span should have correct kind', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + assert.strictEqual( + span.kind, + api.SpanKind.CLIENT, + 'span has wrong kind' + ); + }); - it('span should have correct name', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - assert.strictEqual(span.name, url, 'span has wrong name'); - }); + it('span should have correct attributes', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const attributes = span.attributes; + const keys = Object.keys(attributes); - it('span should have correct kind', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - assert.strictEqual(span.kind, api.SpanKind.CLIENT, 'span has wrong kind'); - }); + assert.ok( + attributes[keys[0]] !== '', + `attributes ${AttributeNames.COMPONENT} is not defined` + ); + assert.strictEqual( + attributes[keys[1]], + 'GET', + `attributes ${AttributeNames.HTTP_METHOD} is wrong` + ); + assert.strictEqual( + attributes[keys[2]], + url, + `attributes ${AttributeNames.HTTP_URL} is wrong` + ); + assert.strictEqual( + attributes[keys[3]], + 200, + `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong` + ); + assert.strictEqual( + attributes[keys[4]], + 'OK', + `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong` + ); + assert.strictEqual( + attributes[keys[5]], + window.location.host, + `attributes ${AttributeNames.HTTP_HOST} is wrong` + ); + assert.ok( + attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https', + `attributes ${AttributeNames.HTTP_SCHEME} is wrong` + ); + assert.ok( + attributes[keys[7]] !== '', + `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined` + ); - it('span should have correct attributes', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - const attributes = span.attributes; - const keys = Object.keys(attributes); - - assert.ok( - attributes[keys[0]] !== '', - `attributes ${AttributeNames.COMPONENT} is not defined` - ); - assert.strictEqual( - attributes[keys[1]], - 'GET', - `attributes ${AttributeNames.HTTP_METHOD} is wrong` - ); - assert.strictEqual( - attributes[keys[2]], - url, - `attributes ${AttributeNames.HTTP_URL} is wrong` - ); - assert.strictEqual( - attributes[keys[3]], - 200, - `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong` - ); - assert.strictEqual( - attributes[keys[4]], - 'OK', - `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong` - ); - assert.strictEqual( - attributes[keys[5]], - window.location.host, - `attributes ${AttributeNames.HTTP_HOST} is wrong` - ); - assert.ok( - attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https', - `attributes ${AttributeNames.HTTP_SCHEME} is wrong` - ); - assert.ok( - attributes[keys[7]] !== '', - `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined` - ); - - assert.strictEqual(keys.length, 8, 'number of attributes is wrong'); - }); + assert.strictEqual(keys.length, 8, 'number of attributes is wrong'); + }); - it('span should have correct events', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - const events = span.events; - - assert.strictEqual( - events[0].name, - EventNames.METHOD_OPEN, - `event ${EventNames.METHOD_OPEN} is not defined` - ); - assert.strictEqual( - events[1].name, - EventNames.METHOD_SEND, - `event ${EventNames.METHOD_SEND} is not defined` - ); - assert.strictEqual( - events[2].name, - PTN.FETCH_START, - `event ${PTN.FETCH_START} is not defined` - ); - assert.strictEqual( - events[3].name, - PTN.DOMAIN_LOOKUP_START, - `event ${PTN.DOMAIN_LOOKUP_START} is not defined` - ); - assert.strictEqual( - events[4].name, - PTN.DOMAIN_LOOKUP_END, - `event ${PTN.DOMAIN_LOOKUP_END} is not defined` - ); - assert.strictEqual( - events[5].name, - PTN.CONNECT_START, - `event ${PTN.CONNECT_START} is not defined` - ); - assert.strictEqual( - events[6].name, - PTN.SECURE_CONNECTION_START, - `event ${PTN.SECURE_CONNECTION_START} is not defined` - ); - assert.strictEqual( - events[7].name, - PTN.CONNECT_END, - `event ${PTN.CONNECT_END} is not defined` - ); - assert.strictEqual( - events[8].name, - PTN.REQUEST_START, - `event ${PTN.REQUEST_START} is not defined` - ); - assert.strictEqual( - events[9].name, - PTN.RESPONSE_START, - `event ${PTN.RESPONSE_START} is not defined` - ); - assert.strictEqual( - events[10].name, - PTN.RESPONSE_END, - `event ${PTN.RESPONSE_END} is not defined` - ); - assert.strictEqual( - events[11].name, - EventNames.EVENT_LOAD, - `event ${EventNames.EVENT_LOAD} is not defined` - ); - - assert.strictEqual(events.length, 12, 'number of events is wrong'); - }); + it('span should have correct events', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const events = span.events; - describe('AND origin match with window.location', () => { - it('should set trace headers', () => { - const span: api.Span = exportSpy.args[0][0][0]; - assert.strictEqual( - requests[0].requestHeaders[X_B3_TRACE_ID], - span.context().traceId, - `trace header '${X_B3_TRACE_ID}' not set` - ); - assert.strictEqual( - requests[0].requestHeaders[X_B3_SPAN_ID], - span.context().spanId, - `trace header '${X_B3_SPAN_ID}' not set` + assert.strictEqual( + events[0].name, + EventNames.METHOD_OPEN, + `event ${EventNames.METHOD_OPEN} is not defined` + ); + assert.strictEqual( + events[1].name, + EventNames.METHOD_SEND, + `event ${EventNames.METHOD_SEND} is not defined` + ); + assert.strictEqual( + events[2].name, + PTN.FETCH_START, + `event ${PTN.FETCH_START} is not defined` + ); + assert.strictEqual( + events[3].name, + PTN.DOMAIN_LOOKUP_START, + `event ${PTN.DOMAIN_LOOKUP_START} is not defined` + ); + assert.strictEqual( + events[4].name, + PTN.DOMAIN_LOOKUP_END, + `event ${PTN.DOMAIN_LOOKUP_END} is not defined` + ); + assert.strictEqual( + events[5].name, + PTN.CONNECT_START, + `event ${PTN.CONNECT_START} is not defined` + ); + assert.strictEqual( + events[6].name, + PTN.SECURE_CONNECTION_START, + `event ${PTN.SECURE_CONNECTION_START} is not defined` + ); + assert.strictEqual( + events[7].name, + PTN.CONNECT_END, + `event ${PTN.CONNECT_END} is not defined` + ); + assert.strictEqual( + events[8].name, + PTN.REQUEST_START, + `event ${PTN.REQUEST_START} is not defined` + ); + assert.strictEqual( + events[9].name, + PTN.RESPONSE_START, + `event ${PTN.RESPONSE_START} is not defined` + ); + assert.strictEqual( + events[10].name, + PTN.RESPONSE_END, + `event ${PTN.RESPONSE_END} is not defined` + ); + assert.strictEqual( + events[11].name, + EventNames.EVENT_LOAD, + `event ${EventNames.EVENT_LOAD} is not defined` + ); + + assert.strictEqual(events.length, 12, 'number of events is wrong'); + }); + + describe('AND origin match with window.location', () => { + it('should set trace headers', () => { + const span: api.Span = exportSpy.args[0][0][0]; + assert.strictEqual( + requests[0].requestHeaders[X_B3_TRACE_ID], + span.context().traceId, + `trace header '${X_B3_TRACE_ID}' not set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SPAN_ID], + span.context().spanId, + `trace header '${X_B3_SPAN_ID}' not set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SAMPLED], + String(span.context().traceFlags), + `trace header '${X_B3_SAMPLED}' not set` + ); + }); + }); + + describe( + 'AND origin does NOT match window.location but match with' + + ' propagateTraceHeaderCorsUrls', + () => { + beforeEach(done => { + clearData(); + prepareData( + done, + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json', + /raw\.githubusercontent\.com/ + ); + }); + it('should set trace headers', () => { + const span: api.Span = exportSpy.args[0][0][0]; + assert.strictEqual( + requests[0].requestHeaders[X_B3_TRACE_ID], + span.context().traceId, + `trace header '${X_B3_TRACE_ID}' not set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SPAN_ID], + span.context().spanId, + `trace header '${X_B3_SPAN_ID}' not set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SAMPLED], + String(span.context().traceFlags), + `trace header '${X_B3_SAMPLED}' not set` + ); + }); + } ); - assert.strictEqual( - requests[0].requestHeaders[X_B3_SAMPLED], - String(span.context().traceFlags), - `trace header '${X_B3_SAMPLED}' not set` + describe( + 'AND origin does NOT match window.location And does NOT match' + + ' with propagateTraceHeaderCorsUrls', + () => { + beforeEach(done => { + clearData(); + prepareData( + done, + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json' + ); + }); + it('should NOT set trace headers', () => { + assert.strictEqual( + requests[0].requestHeaders[X_B3_TRACE_ID], + undefined, + `trace header '${X_B3_TRACE_ID}' should not be set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SPAN_ID], + undefined, + `trace header '${X_B3_SPAN_ID}' should not be set` + ); + assert.strictEqual( + requests[0].requestHeaders[X_B3_SAMPLED], + undefined, + `trace header '${X_B3_SAMPLED}' should not be set` + ); + }); + } ); }); - }); - describe( - 'AND origin does NOT match window.location but match with' + - ' propagateTraceHeaderCorsUrls', - () => { + describe('when request is NOT successful', () => { + let webTracerWithZoneProvider: WebTracerProvider; + let webTracerWithZone: api.Tracer; + let dummySpanExporter: DummySpanExporter; + let exportSpy: any; + let rootSpan: api.Span; + let spyEntries: any; + const url = + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; + let fakeNow = 0; + beforeEach(done => { - clearData(); - prepareData( - done, - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json', - /raw\.githubusercontent\.com/ + sandbox = sinon.createSandbox(); + const fakeXhr = sandbox.useFakeXMLHttpRequest(); + fakeXhr.onCreate = function (xhr: any) { + requests.push(xhr); + }; + + sandbox.useFakeTimers(); + + sandbox.stub(performance, 'timeOrigin').value(0); + sandbox.stub(performance, 'now').callsFake(() => fakeNow); + + const resources: PerformanceResourceTiming[] = []; + resources.push( + createResource({ + name: url, + }) + ); + + spyEntries = sandbox.stub(performance, 'getEntriesByType'); + spyEntries.withArgs('resource').returns(resources); + + webTracerWithZoneProvider = new WebTracerProvider({ + logLevel: LogLevel.ERROR, + plugins: [new XMLHttpRequestPlugin()], + }); + dummySpanExporter = new DummySpanExporter(); + exportSpy = sinon.stub(dummySpanExporter, 'export'); + webTracerWithZoneProvider.addSpanProcessor( + new tracing.SimpleSpanProcessor(dummySpanExporter) ); + webTracerWithZone = webTracerWithZoneProvider.getTracer('xhr-test'); + + rootSpan = webTracerWithZone.startSpan('root'); + + webTracerWithZone.withSpan(rootSpan, () => { + getData( + url, + () => { + fakeNow = 100; + }, + testAsync + ).then(() => { + fakeNow = 0; + sandbox.clock.tick(1000); + done(); + }); + assert.strictEqual(requests.length, 1, 'request not called'); + requests[0].respond( + 400, + { 'Content-Type': 'text/plain' }, + 'Bad Request' + ); + }); + }); + + afterEach(() => { + clearData(); }); - it('should set trace headers', () => { - const span: api.Span = exportSpy.args[0][0][0]; + + it('span should have correct attributes', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const attributes = span.attributes; + const keys = Object.keys(attributes); + + assert.ok( + attributes[keys[0]] !== '', + `attributes ${AttributeNames.COMPONENT} is not defined` + ); assert.strictEqual( - requests[0].requestHeaders[X_B3_TRACE_ID], - span.context().traceId, - `trace header '${X_B3_TRACE_ID}' not set` + attributes[keys[1]], + 'GET', + `attributes ${AttributeNames.HTTP_METHOD} is wrong` ); assert.strictEqual( - requests[0].requestHeaders[X_B3_SPAN_ID], - span.context().spanId, - `trace header '${X_B3_SPAN_ID}' not set` + attributes[keys[2]], + url, + `attributes ${AttributeNames.HTTP_URL} is wrong` ); assert.strictEqual( - requests[0].requestHeaders[X_B3_SAMPLED], - String(span.context().traceFlags), - `trace header '${X_B3_SAMPLED}' not set` + attributes[keys[3]], + 400, + `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong` ); - }); - } - ); - describe( - 'AND origin does NOT match window.location And does NOT match' + - ' with propagateTraceHeaderCorsUrls', - () => { - beforeEach(done => { - clearData(); - prepareData( - done, - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json' + assert.strictEqual( + attributes[keys[4]], + 'Bad Request', + `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong` + ); + assert.strictEqual( + attributes[keys[5]], + 'raw.githubusercontent.com', + `attributes ${AttributeNames.HTTP_HOST} is wrong` + ); + assert.ok( + attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https', + `attributes ${AttributeNames.HTTP_SCHEME} is wrong` ); + assert.ok( + attributes[keys[7]] !== '', + `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined` + ); + + assert.strictEqual(keys.length, 8, 'number of attributes is wrong'); }); - it('should NOT set trace headers', () => { + + it('span should have correct events', () => { + const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; + const events = span.events; + assert.strictEqual( - requests[0].requestHeaders[X_B3_TRACE_ID], - undefined, - `trace header '${X_B3_TRACE_ID}' should not be set` + events[0].name, + EventNames.METHOD_OPEN, + `event ${EventNames.METHOD_OPEN} is not defined` ); assert.strictEqual( - requests[0].requestHeaders[X_B3_SPAN_ID], - undefined, - `trace header '${X_B3_SPAN_ID}' should not be set` + events[1].name, + EventNames.METHOD_SEND, + `event ${EventNames.METHOD_SEND} is not defined` ); assert.strictEqual( - requests[0].requestHeaders[X_B3_SAMPLED], - undefined, - `trace header '${X_B3_SAMPLED}' should not be set` + events[2].name, + PTN.FETCH_START, + `event ${PTN.FETCH_START} is not defined` + ); + assert.strictEqual( + events[3].name, + PTN.DOMAIN_LOOKUP_START, + `event ${PTN.DOMAIN_LOOKUP_START} is not defined` + ); + assert.strictEqual( + events[4].name, + PTN.DOMAIN_LOOKUP_END, + `event ${PTN.DOMAIN_LOOKUP_END} is not defined` + ); + assert.strictEqual( + events[5].name, + PTN.CONNECT_START, + `event ${PTN.CONNECT_START} is not defined` + ); + assert.strictEqual( + events[6].name, + PTN.SECURE_CONNECTION_START, + `event ${PTN.SECURE_CONNECTION_START} is not defined` + ); + assert.strictEqual( + events[7].name, + PTN.CONNECT_END, + `event ${PTN.CONNECT_END} is not defined` + ); + assert.strictEqual( + events[8].name, + PTN.REQUEST_START, + `event ${PTN.REQUEST_START} is not defined` + ); + assert.strictEqual( + events[9].name, + PTN.RESPONSE_START, + `event ${PTN.RESPONSE_START} is not defined` + ); + assert.strictEqual( + events[10].name, + PTN.RESPONSE_END, + `event ${PTN.RESPONSE_END} is not defined` + ); + assert.strictEqual( + events[11].name, + EventNames.EVENT_ERROR, + `event ${EventNames.EVENT_ERROR} is not defined` ); - }); - } - ); - }); - describe('when request is NOT successful', () => { - let webTracerWithZoneProvider: WebTracerProvider; - let webTracerWithZone: api.Tracer; - let dummySpanExporter: DummySpanExporter; - let exportSpy: any; - let rootSpan: api.Span; - let spyEntries: any; - const url = - 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/master/package.json'; - let fakeNow = 0; - - beforeEach(done => { - sandbox = sinon.createSandbox(); - const fakeXhr = sandbox.useFakeXMLHttpRequest(); - fakeXhr.onCreate = function (xhr: any) { - requests.push(xhr); - }; - - sandbox.useFakeTimers(); - - sandbox.stub(performance, 'timeOrigin').value(0); - sandbox.stub(performance, 'now').callsFake(() => fakeNow); - - const resources: PerformanceResourceTiming[] = []; - resources.push( - createResource({ - name: url, - }) - ); - - spyEntries = sandbox.stub(performance, 'getEntriesByType'); - spyEntries.withArgs('resource').returns(resources); - - webTracerWithZoneProvider = new WebTracerProvider({ - logLevel: LogLevel.ERROR, - plugins: [new XMLHttpRequestPlugin()], - }); - dummySpanExporter = new DummySpanExporter(); - exportSpy = sinon.stub(dummySpanExporter, 'export'); - webTracerWithZoneProvider.addSpanProcessor( - new tracing.SimpleSpanProcessor(dummySpanExporter) - ); - webTracerWithZone = webTracerWithZoneProvider.getTracer('xhr-test'); - - rootSpan = webTracerWithZone.startSpan('root'); - - webTracerWithZone.withSpan(rootSpan, () => { - getData(url, () => { - fakeNow = 100; - }).then(() => { - fakeNow = 0; - sandbox.clock.tick(1000); - done(); + assert.strictEqual(events.length, 12, 'number of events is wrong'); }); - assert.strictEqual(requests.length, 1, 'request not called'); - requests[0].respond( - 400, - { 'Content-Type': 'text/plain' }, - 'Bad Request' - ); }); }); - - afterEach(() => { - clearData(); - }); - - it('span should have correct attributes', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - const attributes = span.attributes; - const keys = Object.keys(attributes); - - assert.ok( - attributes[keys[0]] !== '', - `attributes ${AttributeNames.COMPONENT} is not defined` - ); - assert.strictEqual( - attributes[keys[1]], - 'GET', - `attributes ${AttributeNames.HTTP_METHOD} is wrong` - ); - assert.strictEqual( - attributes[keys[2]], - url, - `attributes ${AttributeNames.HTTP_URL} is wrong` - ); - assert.strictEqual( - attributes[keys[3]], - 400, - `attributes ${AttributeNames.HTTP_STATUS_CODE} is wrong` - ); - assert.strictEqual( - attributes[keys[4]], - 'Bad Request', - `attributes ${AttributeNames.HTTP_STATUS_TEXT} is wrong` - ); - assert.strictEqual( - attributes[keys[5]], - 'raw.githubusercontent.com', - `attributes ${AttributeNames.HTTP_HOST} is wrong` - ); - assert.ok( - attributes[keys[6]] === 'http' || attributes[keys[6]] === 'https', - `attributes ${AttributeNames.HTTP_SCHEME} is wrong` - ); - assert.ok( - attributes[keys[7]] !== '', - `attributes ${AttributeNames.HTTP_USER_AGENT} is not defined` - ); - - assert.strictEqual(keys.length, 8, 'number of attributes is wrong'); - }); - - it('span should have correct events', () => { - const span: tracing.ReadableSpan = exportSpy.args[0][0][0]; - const events = span.events; - - assert.strictEqual( - events[0].name, - EventNames.METHOD_OPEN, - `event ${EventNames.METHOD_OPEN} is not defined` - ); - assert.strictEqual( - events[1].name, - EventNames.METHOD_SEND, - `event ${EventNames.METHOD_SEND} is not defined` - ); - assert.strictEqual( - events[2].name, - PTN.FETCH_START, - `event ${PTN.FETCH_START} is not defined` - ); - assert.strictEqual( - events[3].name, - PTN.DOMAIN_LOOKUP_START, - `event ${PTN.DOMAIN_LOOKUP_START} is not defined` - ); - assert.strictEqual( - events[4].name, - PTN.DOMAIN_LOOKUP_END, - `event ${PTN.DOMAIN_LOOKUP_END} is not defined` - ); - assert.strictEqual( - events[5].name, - PTN.CONNECT_START, - `event ${PTN.CONNECT_START} is not defined` - ); - assert.strictEqual( - events[6].name, - PTN.SECURE_CONNECTION_START, - `event ${PTN.SECURE_CONNECTION_START} is not defined` - ); - assert.strictEqual( - events[7].name, - PTN.CONNECT_END, - `event ${PTN.CONNECT_END} is not defined` - ); - assert.strictEqual( - events[8].name, - PTN.REQUEST_START, - `event ${PTN.REQUEST_START} is not defined` - ); - assert.strictEqual( - events[9].name, - PTN.RESPONSE_START, - `event ${PTN.RESPONSE_START} is not defined` - ); - assert.strictEqual( - events[10].name, - PTN.RESPONSE_END, - `event ${PTN.RESPONSE_END} is not defined` - ); - assert.strictEqual( - events[11].name, - EventNames.EVENT_ERROR, - `event ${EventNames.EVENT_ERROR} is not defined` - ); - - assert.strictEqual(events.length, 12, 'number of events is wrong'); - }); }); }); diff --git a/packages/opentelemetry-resources/README.md b/packages/opentelemetry-resources/README.md index 1cc1785c2d..748875a539 100644 --- a/packages/opentelemetry-resources/README.md +++ b/packages/opentelemetry-resources/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Resources Util + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -20,6 +21,7 @@ npm install --save @opentelemetry/resources > TODO ## 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] diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 0efe9f8b0e..c55e09a774 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -51,7 +51,7 @@ "gts": "^2.0.0", "mocha": "^7.1.2", "nock": "^12.0.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-mocha": "^7.0.0", diff --git a/packages/opentelemetry-shim-opentracing/README.md b/packages/opentelemetry-shim-opentracing/README.md index c5a3bec21c..afbe75753d 100644 --- a/packages/opentelemetry-shim-opentracing/README.md +++ b/packages/opentelemetry-shim-opentracing/README.md @@ -1,4 +1,5 @@ # OpenTracing shim + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -36,7 +37,6 @@ opentracing.initGlobalTracer(new TracerShim(tracer)); See [examples/opentracing-shim](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/opentracing-shim) for a short example. - ## License Apache 2.0 - See [LICENSE][license-url] for more information. diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 7535f32bd2..4bf20b11c3 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -45,7 +45,7 @@ "codecov": "^3.6.1", "gts": "^2.0.0", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "ts-mocha": "^7.0.0", "ts-node": "^8.6.2", diff --git a/packages/opentelemetry-tracing/README.md b/packages/opentelemetry-tracing/README.md index 272f97c8e9..9daabdfa2a 100644 --- a/packages/opentelemetry-tracing/README.md +++ b/packages/opentelemetry-tracing/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Tracing SDK + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -43,9 +44,11 @@ span.end(); ``` ## Example + See [examples/basic-tracer-node](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/basic-tracer-node) for an end-to-end example, including exporting created spans. ## 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] diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index adac117a98..6a02e277f9 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -63,7 +63,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4", diff --git a/packages/opentelemetry-web/README.md b/packages/opentelemetry-web/README.md index 2d8ceeac67..d7ea41b666 100644 --- a/packages/opentelemetry-web/README.md +++ b/packages/opentelemetry-web/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Web SDK + [![Gitter chat][gitter-image]][gitter-url] [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] @@ -10,7 +11,8 @@ This module provides *automated instrumentation and tracing* for Web application For manual instrumentation see the [@opentelemetry/tracing](https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-tracing) package. -## How does automatic tracing work? +## How does automatic tracing work + This package exposes a class `WebTracerProvider` that will be able to automatically trace things in Browser only. See the example how to use it. @@ -62,6 +64,7 @@ providerWithZone.register({ ``` ## 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] diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index d6dbfb874d..5785bd3b22 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -62,7 +62,7 @@ "karma-spec-reporter": "^0.0.32", "karma-webpack": "^4.0.2", "mocha": "^7.1.2", - "nyc": "^15.0.0", + "nyc": "^15.1.0", "rimraf": "^3.0.0", "sinon": "^7.5.0", "ts-loader": "^6.0.4",