From ea4bfce05010a7570f838e872570fdb944856297 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Mon, 26 Apr 2021 10:14:51 +0200 Subject: [PATCH] chore: prefer use of global TracerProvider/MeterProvider Remove setting of TracerProvider in samples where it is actually not needed as the global TracerProvider should be preferred on default. I found it also inconsistent to set a TracerProvider but no MeterProvider. --- .../auto-instrumentations-node/README.md | 1 + .../auto-instrumentations-web/README.md | 1 + .../README.md | 2 +- .../README.md | 8 ++--- .../README.md | 1 - .../README.md | 5 ++-- .../README.md | 1 - .../README.md | 29 ++++++------------- .../README.md | 4 +-- .../README.md | 6 ++-- .../README.md | 4 +-- .../README.md | 4 ++- .../README.md | 8 ++--- .../test/utils.ts | 5 +++- .../README.md | 3 +- .../README.md | 8 ++--- .../README.md | 8 +++-- .../README.md | 10 +++++-- .../README.md | 8 ++--- .../README.md | 3 +- .../README.md | 4 +-- .../test/userInteraction.nozone.test.ts | 3 +- .../test/userInteraction.test.ts | 4 +-- .../README.md | 12 ++++---- 24 files changed, 75 insertions(+), 67 deletions(-) diff --git a/metapackages/auto-instrumentations-node/README.md b/metapackages/auto-instrumentations-node/README.md index 8742db8eed..9625c281c1 100644 --- a/metapackages/auto-instrumentations-node/README.md +++ b/metapackages/auto-instrumentations-node/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Meta Packages for Node + [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] [![devDependencies][devDependencies-image]][devDependencies-url] diff --git a/metapackages/auto-instrumentations-web/README.md b/metapackages/auto-instrumentations-web/README.md index 4535f6c15a..f76cf87c50 100644 --- a/metapackages/auto-instrumentations-web/README.md +++ b/metapackages/auto-instrumentations-web/README.md @@ -1,4 +1,5 @@ # OpenTelemetry Meta Packages for Web + [![NPM Published Version][npm-img]][npm-url] [![dependencies][dependencies-image]][dependencies-url] [![devDependencies][devDependencies-image]][devDependencies-url] diff --git a/plugins/node/opentelemetry-instrumentation-aws-lambda/README.md b/plugins/node/opentelemetry-instrumentation-aws-lambda/README.md index 5f81212ddc..7c793bf7d0 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-lambda/README.md +++ b/plugins/node/opentelemetry-instrumentation-aws-lambda/README.md @@ -18,6 +18,7 @@ npm install --save @opentelemetry/instrumentation-aws-lambda ## Usage Create a file to initialize the instrumentation, such as `lambda-wrapper.js`. + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); const { AwsLambdaInstrumentation } = require('@opentelemetry/instrumentation-aws-lambda'); @@ -30,7 +31,6 @@ registerInstrumentations({ instrumentations: [ new AwsLambdaInstrumentation() ], - tracerProvider: provider, }); ``` diff --git a/plugins/node/opentelemetry-instrumentation-bunyan/README.md b/plugins/node/opentelemetry-instrumentation-bunyan/README.md index 6ed824a4b5..7816780310 100644 --- a/plugins/node/opentelemetry-instrumentation-bunyan/README.md +++ b/plugins/node/opentelemetry-instrumentation-bunyan/README.md @@ -34,7 +34,6 @@ registerInstrumentations({ }), // other instrumentations ], - tracerProvider: provider, }); bunyan.createLogger({ name: 'example' }).info('foo'); @@ -44,6 +43,7 @@ bunyan.createLogger({ name: 'example' }).info('foo'); ### Fields added to bunyan records For the current active span, the following will be added to the bunyan record: + * `trace_id` * `span_id` * `trace_flags` @@ -52,9 +52,9 @@ When no span context is active or the span context is invalid, injection is skip ## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License diff --git a/plugins/node/opentelemetry-instrumentation-dns/README.md b/plugins/node/opentelemetry-instrumentation-dns/README.md index 9096546698..074d086162 100644 --- a/plugins/node/opentelemetry-instrumentation-dns/README.md +++ b/plugins/node/opentelemetry-instrumentation-dns/README.md @@ -32,7 +32,6 @@ registerInstrumentations({ // see under for available configuration }), ], - tracerProvider: provider, }); ``` diff --git a/plugins/node/opentelemetry-instrumentation-express/README.md b/plugins/node/opentelemetry-instrumentation-express/README.md index 6c065ddcd3..ae2d75749b 100644 --- a/plugins/node/opentelemetry-instrumentation-express/README.md +++ b/plugins/node/opentelemetry-instrumentation-express/README.md @@ -19,7 +19,8 @@ npm install --save @opentelemetry/instrumentation-http @opentelemetry/instrument ``` ### Supported Versions - - `^4.0.0` + +- `^4.0.0` ## Usage @@ -42,7 +43,6 @@ registerInstrumentations({ new HttpInstrumentation(), new ExpressInstrumentation(), ], - tracerProvider: provider, }); ``` @@ -74,6 +74,7 @@ Express instrumentation has few options available to choose from. You can set th - `request_handler` is the name for anything that's not a router or a middleware. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-graphql/README.md b/plugins/node/opentelemetry-instrumentation-graphql/README.md index 172fcd21df..64faacb9bb 100644 --- a/plugins/node/opentelemetry-instrumentation-graphql/README.md +++ b/plugins/node/opentelemetry-instrumentation-graphql/README.md @@ -34,7 +34,6 @@ registerInstrumentations({ // mergeItems: true, }), ], - tracerProvider: provider, }); ``` diff --git a/plugins/node/opentelemetry-instrumentation-hapi/README.md b/plugins/node/opentelemetry-instrumentation-hapi/README.md index 2e9d20084e..72b9243804 100644 --- a/plugins/node/opentelemetry-instrumentation-hapi/README.md +++ b/plugins/node/opentelemetry-instrumentation-hapi/README.md @@ -15,8 +15,10 @@ For automatic instrumentation see the ```bash npm install --save @opentelemetry/instrumentation-hapi ``` + ### Supported Versions - - @hapi/hapi `^17.0.0` + +- @hapi/hapi `^17.0.0` ## Usage @@ -27,12 +29,15 @@ To load a specific instrumentation (Hapi in this case), specify it in the regist ```js const { NodeTracerProvider } = require('@opentelemetry/node'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); +const { HapiInstrumentation } = require('@opentelemetry/instrumentation-hapi'); const provider = new NodeTracerProvider(); provider.register(); registerInstrumentations({ - tracerProvider: provider, + instrumentations: [ + new HapiInstrumentation(), + ], }); ``` @@ -48,24 +53,6 @@ const hapiInstrumentation = new HapiInstrumentation(); hapiInstrumentation.setTracerProvider(provider); ``` -You can combine loading default plugins and HapiInstrumentation at the same time: - -```js -const { NodeTracerProvider } = require('@opentelemetry/node'); -const { HapiInstrumentation } = require('@opentelemetry/instrumentation-hapi'); -const { registerInstrumentations } = require('@opentelemetry/instrumentation'); - -const provider = new NodeTracerProvider(); -provider.register(); - -registerInstrumentations({ - instrumentations: [ - new HapiInstrumentation(), - ], - tracerProvider: provider, -}); -``` - See [examples/hapi](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/hapi) for a short example using Hapi ## Hapi Instrumentation Support + This package provides automatic tracing for hapi server routes and [request lifecycle](https://github.com/hapijs/hapi/blob/main/API.md#request-lifecycle) extensions defined either directly or via a Hapi plugin. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-ioredis/README.md b/plugins/node/opentelemetry-instrumentation-ioredis/README.md index 01e9f6dfb1..9b3a538eda 100644 --- a/plugins/node/opentelemetry-instrumentation-ioredis/README.md +++ b/plugins/node/opentelemetry-instrumentation-ioredis/README.md @@ -38,7 +38,6 @@ registerInstrumentations({ // see under for available configuration }) ], - tracerProvider: provider, }) ``` @@ -52,7 +51,8 @@ IORedis instrumentation has few options available to choose from. You can set th | `responseHook` | `RedisResponseCustomAttributeFunction` | Function for adding custom attributes on db response | | `requireParentSpan` | `boolean` | Require parent to create ioredis span, default when unset is true | -#### Custom db.statement Serializer +#### Custom db.statement Serializer + The instrumentation serializes the whole command into a Span attribute called `db.statement`. The standard serialization format is `{cmdName} {cmdArgs.join(',')}`. It is also possible to define a custom serialization function. The function will receive the command name and arguments and must return a string. diff --git a/plugins/node/opentelemetry-instrumentation-koa/README.md b/plugins/node/opentelemetry-instrumentation-koa/README.md index 6aade4369a..2eab43a952 100644 --- a/plugins/node/opentelemetry-instrumentation-koa/README.md +++ b/plugins/node/opentelemetry-instrumentation-koa/README.md @@ -15,8 +15,10 @@ For automatic instrumentation see the ```bash npm install --save @opentelemetry/instrumentation-koa ``` + ### Supported Versions - - Koa `^2.0.0` + +- Koa `^2.0.0` ## Usage @@ -34,7 +36,6 @@ registerInstrumentations({ instrumentations: [ new KoaInstrumentation(), ], - tracerProvider: provider, }); ``` @@ -45,6 +46,7 @@ See [examples/koa](https://github.com/open-telemetry/opentelemetry-js-contrib/tr This package provides automatic tracing for middleware added using either the core [`Koa`](https://github.com/koajs/koa) package or the [`@koa/router`](https://github.com/koajs/router) package. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/README.md b/plugins/node/opentelemetry-instrumentation-mongodb/README.md index 4595786281..9fe1d7d291 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/README.md +++ b/plugins/node/opentelemetry-instrumentation-mongodb/README.md @@ -15,6 +15,7 @@ For automatic instrumentation see the ```bash npm install --save @opentelemetry/instrumentation-mongodb ``` + ### Supported Versions - `'>=3.3 <4` @@ -38,7 +39,6 @@ registerInstrumentations({ // see under for available configuration }), ], - tracerProvider: provider, }); ``` @@ -51,8 +51,8 @@ Mongodb instrumentation has few options available to choose from. You can set th | ------- | ---- | ----------- | | [`enhancedDatabaseReporting`](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-api/src/trace/instrumentation/instrumentation.ts#L91) | `string` | If true, additional information about query parameters and results will be attached (as `attributes`) to spans representing database operations | - ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-mysql/README.md b/plugins/node/opentelemetry-instrumentation-mysql/README.md index fe870aa6f5..97e1d84733 100644 --- a/plugins/node/opentelemetry-instrumentation-mysql/README.md +++ b/plugins/node/opentelemetry-instrumentation-mysql/README.md @@ -17,6 +17,7 @@ npm install --save @opentelemetry/instrumentation-mysql ``` ## Supported Versions + - `2.x` ## Usage @@ -24,6 +25,7 @@ npm install --save @opentelemetry/instrumentation-mysql OpenTelemetry MySQL 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 [mysql](https://www.npmjs.com/package/mysql). To load a specific plugin (**MySQL** in this case), specify it in the registerInstrumentations's configuration + ```js const { NodeTracerProvider } = require('@opentelemetry/node'); const { MySQLInstrumentation } = require('@opentelemetry/instrumentation-mysql'); @@ -36,13 +38,13 @@ registerInstrumentations({ instrumentations: [ new MySQLInstrumentation(), ], - tracerProvider: provider, }) ``` See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/mysql) for a short example. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-net/README.md b/plugins/node/opentelemetry-instrumentation-net/README.md index 815d65147b..3ebd3937ac 100644 --- a/plugins/node/opentelemetry-instrumentation-net/README.md +++ b/plugins/node/opentelemetry-instrumentation-net/README.md @@ -29,7 +29,6 @@ registerInstrumentations({ new NetInstrumentation(), // other instrumentations ], - tracerProvider: provider, }); ``` @@ -39,6 +38,7 @@ registerInstrumentations({ * `net.peer.name`: host name or the IPC file path For TCP: + * `net.peer.ip` * `net.peer.port` * `net.host.ip` @@ -46,9 +46,9 @@ For TCP: ## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License diff --git a/plugins/node/opentelemetry-instrumentation-net/test/utils.ts b/plugins/node/opentelemetry-instrumentation-net/test/utils.ts index 06dc7f34dd..5f4f6d3138 100644 --- a/plugins/node/opentelemetry-instrumentation-net/test/utils.ts +++ b/plugins/node/opentelemetry-instrumentation-net/test/utils.ts @@ -28,7 +28,10 @@ import { IPC_TRANSPORT } from '../src/utils'; export const PORT = 42123; export const HOST = 'localhost'; -export const IPC_PATH = path.join(os.tmpdir(), 'otel-js-net-test-ipc'); +export const IPC_PATH = + os.platform() !== 'win32' + ? path.join(os.tmpdir(), 'otel-js-net-test-ipc') + : '\\\\.\\pipe\\otel-js-net-test-ipc'; export function assertTcpSpan(span: ReadableSpan, socket: Socket) { assertSpanKind(span); diff --git a/plugins/node/opentelemetry-instrumentation-pg/README.md b/plugins/node/opentelemetry-instrumentation-pg/README.md index af0356f79e..ac59f6823c 100644 --- a/plugins/node/opentelemetry-instrumentation-pg/README.md +++ b/plugins/node/opentelemetry-instrumentation-pg/README.md @@ -27,11 +27,11 @@ const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const provider = new NodeTracerProvider(); provider.register(); + registerInstrumentations({ instrumentations: [ new PgInstrumentation(), ], - tracerProvider: provider, }); ``` @@ -53,6 +53,7 @@ PostgreSQL instrumentation has few options available to choose from. You can set - [pg-pool](https://npmjs.com/package/pg-pool): `2.x`, `3.*` (Installed by `pg`) ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-pino/README.md b/plugins/node/opentelemetry-instrumentation-pino/README.md index cb3bdd8148..b4cc272f38 100644 --- a/plugins/node/opentelemetry-instrumentation-pino/README.md +++ b/plugins/node/opentelemetry-instrumentation-pino/README.md @@ -33,7 +33,6 @@ registerInstrumentations({ }), // other instrumentations ], - tracerProvider: provider, }); const pino = require('pino'); @@ -45,6 +44,7 @@ logger.info('foobar'); ### Fields added to pino log objects For the current active span, the following fields are injected: + * `trace_id` * `span_id` * `trace_flags` @@ -57,9 +57,9 @@ When no span context is active or the span context is invalid, injection is skip ## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License diff --git a/plugins/node/opentelemetry-instrumentation-redis/README.md b/plugins/node/opentelemetry-instrumentation-redis/README.md index 5615173885..9a9b5b9ec7 100644 --- a/plugins/node/opentelemetry-instrumentation-redis/README.md +++ b/plugins/node/opentelemetry-instrumentation-redis/README.md @@ -12,18 +12,20 @@ For automatic instrumentation see the ## Installation -``` +```bash npm install --save @opentelemetry/instrumentation-redis ``` ### Supported Versions - - `>=2.6.0` + +- `>=2.6.0` ## Usage OpenTelemetry Redis 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 [redis](https://www.npmjs.com/package/redis). To load a specific instrumentation (**redis** in this case), specify it in the registerInstrumentations' configuration + ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); const { RedisInstrumentation } = require('@opentelemetry/instrumentation-redis'); @@ -36,13 +38,13 @@ registerInstrumentations({ instrumentations: [ new RedisInstrumentation(), ], - tracerProvider: provider, }) ``` See [examples/redis](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/redis) for a short example. ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] diff --git a/plugins/node/opentelemetry-instrumentation-restify/README.md b/plugins/node/opentelemetry-instrumentation-restify/README.md index c4a438a9bc..faf795a54b 100644 --- a/plugins/node/opentelemetry-instrumentation-restify/README.md +++ b/plugins/node/opentelemetry-instrumentation-restify/README.md @@ -15,8 +15,10 @@ For automatic instrumentation see the ```bash npm install --save @opentelemetry/instrumentation-restify ``` + ### Supported Versions - - `>=4.0.0` + +- `>=4.0.0` ## Usage @@ -32,14 +34,16 @@ provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); provider.register(); registerInstrumentations({ - instrumentations: [new RestifyInstrumentation()], - tracerProvider: provider, + instrumentations: [ + new RestifyInstrumentation() + ], }); ``` See [examples/restify](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/examples/restify) 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/plugins/node/opentelemetry-instrumentation-winston/README.md b/plugins/node/opentelemetry-instrumentation-winston/README.md index 32351d3362..35593312c4 100644 --- a/plugins/node/opentelemetry-instrumentation-winston/README.md +++ b/plugins/node/opentelemetry-instrumentation-winston/README.md @@ -34,7 +34,6 @@ registerInstrumentations({ }), // other instrumentations ], - tracerProvider: provider, }); const winston = require('winston'); @@ -48,6 +47,7 @@ logger.info('foobar'); ### Fields added to Winston metadata For the current active span, the following fields are injected: + * `trace_id` * `span_id` * `trace_flags` @@ -60,9 +60,9 @@ When no span context is active or the span context is invalid, injection is skip ## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License diff --git a/plugins/web/opentelemetry-instrumentation-document-load/README.md b/plugins/web/opentelemetry-instrumentation-document-load/README.md index 56f36ae057..bafda79f84 100644 --- a/plugins/web/opentelemetry-instrumentation-document-load/README.md +++ b/plugins/web/opentelemetry-instrumentation-document-load/README.md @@ -47,12 +47,12 @@ registerInstrumentations({ ], }), ], - tracerProvider: provider, }); ``` ## Optional: Send a trace parent from your server + This instrumentation supports connecting the server side spans for the initial HTML load with the client side span for the load from the browser's timing API. This works by having the server send its parent trace context (trace ID, span ID and trace sampling decision) to the client. Because the browser does not send a trace context header for the initial page navigation, the server needs to fake a trace context header in a middleware and then send that trace context header back to the client as a meta tag *traceparent* . The *traceparent* meta tag should be in the [trace context W3C draft format][trace-context-url] . For example: @@ -83,6 +83,7 @@ Because the browser does not send a trace context header for the initial page na See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/main/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 in [GitHub Discussions][discussions-url] diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/README.md b/plugins/web/opentelemetry-instrumentation-user-interaction/README.md index 28804ff957..34c9a05aff 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/README.md +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/README.md @@ -39,7 +39,6 @@ registerInstrumentations({ instrumentations: [ new UserInteractionInstrumentation(), ], - tracerProvider: provider, }); // and some test @@ -83,12 +82,14 @@ function getData(url) { ``` ## Example Screenshots + ![Screenshot of the running example](images/main.jpg) ![Screenshot of the running example](images/click.jpg) ![Screenshot of the running example](images/main-sync.jpg) ![Screenshot of the running example](images/click-sync.jpg) ## Useful links + - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: - For help or feedback on this project, join us in [GitHub Discussions][discussions-url] @@ -108,4 +109,3 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Finstrumentation-user-interaction.svg [zone-js]: https://www.npmjs.com/package/zone.js [@opentelemetry/context-zone]: https://www.npmjs.com/package/@opentelemetry/context-zone - diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.nozone.test.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.nozone.test.ts index cba1879126..657fcf8573 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.nozone.test.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.nozone.test.ts @@ -15,6 +15,7 @@ */ const originalSetTimeout = window.setTimeout; +import { trace } from '@opentelemetry/api'; import { isWrapped } from '@opentelemetry/core'; import { registerInstrumentations } from '@opentelemetry/instrumentation'; import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request'; @@ -77,7 +78,6 @@ describe('UserInteractionInstrumentation', () => { webTracerProvider.register(); registerInstrumentations({ - tracerProvider: webTracerProvider, instrumentations: [ userInteractionInstrumentation, new XMLHttpRequestInstrumentation(), @@ -92,6 +92,7 @@ describe('UserInteractionInstrumentation', () => { requests = []; sandbox.restore(); exportSpy.restore(); + trace.disable(); }); it('should not break removeEventListener', () => { diff --git a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts index 5e3f86df99..88ad5d1260 100644 --- a/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts +++ b/plugins/web/opentelemetry-instrumentation-user-interaction/test/userInteraction.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ const originalSetTimeout = window.setTimeout; -import { context, ROOT_CONTEXT } from '@opentelemetry/api'; +import { context, ROOT_CONTEXT, trace } from '@opentelemetry/api'; import { ZoneContextManager } from '@opentelemetry/context-zone-peer-dep'; import { isWrapped, @@ -79,7 +79,6 @@ describe('UserInteractionInstrumentation', () => { userInteractionInstrumentation = new UserInteractionInstrumentation(); registerInstrumentations({ - tracerProvider: webTracerProvider, instrumentations: [ userInteractionInstrumentation, new XMLHttpRequestInstrumentation(), @@ -95,6 +94,7 @@ describe('UserInteractionInstrumentation', () => { sandbox.restore(); exportSpy.restore(); context.disable(); + trace.disable(); }); it('should handle task without async operation', () => { diff --git a/propagators/opentelemetry-propagator-grpc-census-binary/README.md b/propagators/opentelemetry-propagator-grpc-census-binary/README.md index 2c00845b7e..37d3f81359 100644 --- a/propagators/opentelemetry-propagator-grpc-census-binary/README.md +++ b/propagators/opentelemetry-propagator-grpc-census-binary/README.md @@ -6,13 +6,14 @@ [![Apache License][license-image]][license-image] OpenTelemetry gRPC Census propagator provides gRPC header propagation for systems that use the OpenCensus 'grpc-trace-bin' binary header format. This allows for context propagation when either: + * incoming gRPC calls come from services already instrumented using OpenCensus * outgoing gRPC calls go to services already instrumented using OpenCensus This propagator works in conjunction with the OpenTelemetry [gRPC plugin](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-plugin-grpc). - Example of usage: + ```javascript const { NodeTracerProvider } = require('@opentelemetry/node'); const { GrpcCensusPropagator } = require("@opentelemetry/propagator-grpc-census-binary"); @@ -31,7 +32,6 @@ registerInstrumentations({ instrumentations: [ new GrpcInstrumentation(), ], - tracerProvider: provider, }); ``` @@ -40,12 +40,14 @@ Also, see [examples/grpc-census-prop](../../examples/grpc-census-prop) for a worked example that shows when this propagator can be useful. ## Implementation Details + See [binary-format.ts](https://github.com/census-instrumentation/opencensus-node/blob/master/packages/opencensus-propagation-binaryformat/src/binary-format.ts) for equivalent encoding/decoding of the format in OpenCensus. Note: the author of the OpenCensus binary format, [@mayurkale22](https://github.com/mayurkale22), also created BinaryTraceContext.ts in [opentelemetry-core](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core) but that was subsequently removed as part of PR [#804](https://github.com/open-telemetry/opentelemetry-js/pull/804). The implementation of GrpcCensusPropagator in _this_ module uses a version of BinaryTraceContext.ts inspired by Mayur's previous work (with minor modifications e.g. there is no longer a BinaryFormat interface to implement). ## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] + +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] ## License