From 968fcea1bb3cafea9258a9822b7be958ae705960 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Fri, 15 Aug 2025 10:12:28 -0700 Subject: [PATCH] chore: remove last references to removed 'propagator-grpc-census-binary' package This includes an example folder, and a propagators/README.md that really only discussed the removed package. Refs: https://github.com/open-telemetry/opentelemetry-js-contrib/pull/2276 Closes: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2929 --- .github/component-label-map.yml | 4 - examples/grpc-census-prop/.eslintrc.js | 26 ---- examples/grpc-census-prop/.npmrc | 1 - examples/grpc-census-prop/README.md | 131 ------------------ .../grpc-census-prop/capitalize_client.js | 107 -------------- .../grpc-census-prop/capitalize_server.js | 122 ---------------- examples/grpc-census-prop/combination2.md | 95 ------------- examples/grpc-census-prop/combination4.md | 98 ------------- examples/grpc-census-prop/package.json | 52 ------- examples/grpc-census-prop/protos/defs.proto | 19 --- examples/grpc-census-prop/tracer.js | 61 -------- examples/grpc-census-prop/tracer_census.js | 41 ------ propagators/README.md | 32 ----- 13 files changed, 789 deletions(-) delete mode 100644 examples/grpc-census-prop/.eslintrc.js delete mode 100644 examples/grpc-census-prop/.npmrc delete mode 100644 examples/grpc-census-prop/README.md delete mode 100644 examples/grpc-census-prop/capitalize_client.js delete mode 100644 examples/grpc-census-prop/capitalize_server.js delete mode 100644 examples/grpc-census-prop/combination2.md delete mode 100644 examples/grpc-census-prop/combination4.md delete mode 100644 examples/grpc-census-prop/package.json delete mode 100644 examples/grpc-census-prop/protos/defs.proto delete mode 100644 examples/grpc-census-prop/tracer.js delete mode 100644 examples/grpc-census-prop/tracer_census.js delete mode 100644 propagators/README.md diff --git a/.github/component-label-map.yml b/.github/component-label-map.yml index 1cf350f8ec..17e34a8956 100644 --- a/.github/component-label-map.yml +++ b/.github/component-label-map.yml @@ -253,10 +253,6 @@ pkg:propagation-utils: - any-glob-to-any-file: - packages/propagation-utils/** - packages/contrib-test-utils/** -pkg:propagator-grpc-census-binary: - - changed-files: - - any-glob-to-any-file: - - propagators/opentelemetry-propagator-grpc-census-binary/** pkg:propagator-instana: - changed-files: - any-glob-to-any-file: diff --git a/examples/grpc-census-prop/.eslintrc.js b/examples/grpc-census-prop/.eslintrc.js deleted file mode 100644 index 53452072e2..0000000000 --- a/examples/grpc-census-prop/.eslintrc.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const baseConfig = require('../../eslint.config'); - -module.exports = { - ...baseConfig, - env: { - node: true, - }, -}; diff --git a/examples/grpc-census-prop/.npmrc b/examples/grpc-census-prop/.npmrc deleted file mode 100644 index 43c97e719a..0000000000 --- a/examples/grpc-census-prop/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/examples/grpc-census-prop/README.md b/examples/grpc-census-prop/README.md deleted file mode 100644 index 205056471a..0000000000 --- a/examples/grpc-census-prop/README.md +++ /dev/null @@ -1,131 +0,0 @@ -# Introduction - -This example uses the same gRPC [defs.proto](./protos/defs.proto) as the -[grpc_dynamic_codegen](../grpc_dynamic_codegen) -example in which a server takes a payload containing bytes and capitalizes them. -In this case we are demonstrating the use of the -[propagator-grpc-census-binary](../../propagators/opentelemetry-propagator-grpc-census-binary) -propagator. The propagator can be useful when communicating with another service -that is already instrumented using OpenCensus. - -If both sides of gRPC communication are using OpenTelemetry instrumentation then -the `propagator-grpc-census-binary` propagator isn't required. Context will be -propagated using the `traceparent` header (thanks to the -[HttpTraceContextPropagator](https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-core/src/trace/W3CTraceContextPropagator.ts) -propagator from opentelemetry-core). If there is a mix of OpenCensus and OpenTelemetry -instrumentation then the `propagator-grpc-census-binary` propagator allows OpenTelemetry -to propagate context through the `grpc-trace-bin` binary header. - -The same source code is used to run various versions of the client and server. Environment -variables (set up through `scripts` in [package.json](./package.json)) determine the various -combinations. This table shows what to expect: - -| Combination | Client Instrumentation | Server Instrumentation | Propagation Header | -| :---------- | :--------------------- | :--------------------- | :----------------- | -| 1 | OpenTelemetry (default propagator) | OpenTelemetry (default propagator) | `traceparent` | -| 2 | OpenCensus | OpenTelemetry (**binary propagator**) | `grpc-trace-bin` | -| 3 | OpenCensus | OpenCensus | `grpc-trace-bin` | -| 4 | OpenTelemetry (**binary propagator**) | OpenCensus | `grpc-trace-bin` | - -If context propagation is working correctly we should see consistent values -for `traceId` in the output of both the client and server. (Note: the example -uses simple Console Exporters rather than Jaeger or Zipkin). The servers also -output the contents of `grpc.Metadata` which allows us to see the values of -`traceparent` or `grpc-trace-bin` where applicable. - -## Installation - -```sh -# from this directory -npm install -``` - -## Running the Client and Server combinations - -### Combination 1 - -OpenTelemetry (with default propagator) used on both client and server. -Propagation through `traceparent` header. - -- Run the server - - ```sh - # from this directory - npm run server:otel:defprop - ``` - -- Run the client - - ```sh - # from this directory - npm run client:otel:defprop - ``` - -### Combination 2 - -OpenTelemetry (with **binary propagator**) used on server, OpenCensus used -on client. Propagation through `grpc-trace-bin` header. - -- Run the server - - ```sh - # from this directory - npm run server:otel:binprop - ``` - -- Run the client - - ```sh - # from this directory - npm run client:census - ``` - -See [combination2](./combination2.md) for example output - -### Combination 3 - -OpenCensus used on both client and server. Propagation through `grpc-trace-bin` header. - -- Run the server - - ```sh - # from this directory - npm run server:census - ``` - -- Run the client - - ```sh - # from this directory - npm run client:census - ``` - -### Combination 4 - -OpenCensus used on server, OpenTelemetry (with **binary propagator**) used on -client. Propagation through `grpc-trace-bin` header. - -- Run the server - - ```sh - # from this directory - npm run server:census - ``` - -- Run the client - - ```sh - # from this directory - npm run client:otel:binprop - ``` - -See [combination4](./combination4.md) for example output - -## Useful links - -- For more information on OpenTelemetry, visit: -- For more information on OpenTelemetry for Node.js, visit: - -## LICENSE - -Apache License 2.0 diff --git a/examples/grpc-census-prop/capitalize_client.js b/examples/grpc-census-prop/capitalize_client.js deleted file mode 100644 index 1956c7ddad..0000000000 --- a/examples/grpc-census-prop/capitalize_client.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const api = require('@opentelemetry/api'); -const binaryPropagator = process.env.BINARY_PROPAGATOR === 'true'; -const censusTracer = process.env.CENSUS_TRACER === 'true'; -let tracer; -if (censusTracer) { - tracer = require('./tracer_census')(); -} else { - tracer = require('./tracer')( - 'example-grpc-capitalize-client', - binaryPropagator - ); -} - -const path = require('path'); -const grpc = require('grpc'); - -const PROTO_PATH = path.join(__dirname, 'protos/defs.proto'); - -// Even though grpc.load is deprecated in favor of @grpc/proto-loader, it -// appears @opencensus/instrumentation-grpc only gets to set the -// grpc-trace-bin header if we use grpc.load -const { Fetch } = grpc.load(PROTO_PATH).rpc; - -/** - * Creates a gRPC client, makes a gRPC call and waits before shutting down - */ -function main() { - const client = new Fetch( - 'localhost:50051', - grpc.credentials.createInsecure() - ); - const data = process.argv[2] || 'opentelemetry'; - console.log('> ', data); - - if (censusTracer) { - capitalizeWithCensusTracing(client, data); - } else { - capitalizeWithOTelTracing(client, data); - } - - // The process must live for at least the interval past any traces that - // must be exported, or some risk being lost if they are recorded after the - // last export. - console.log( - 'Sleeping 5 seconds before shutdown to ensure all records are flushed.' - ); - setTimeout(() => { - console.log('Completed.'); - }, 5000); -} - -/** - * Makes the gRPC call wrapped in an OpenCensus-style span - */ -function capitalizeWithCensusTracing(client, data) { - tracer.startRootSpan({ name: 'tutorialsClient.capitalize' }, rootSpan => { - client.capitalize({ data: Buffer.from(data) }, (err, response) => { - if (err) { - console.log('could not get grpc response'); - rootSpan.end(); - return; - } - console.log('< ', response.data.toString('utf8')); - - rootSpan.end(); - }); - }); -} - -/** - * Makes the gRPC call wrapped in an OpenTelemetry-style span - */ -function capitalizeWithOTelTracing(client, data) { - const span = tracer.startSpan('tutorialsClient.capitalize'); - api.context.with(api.trace.setSpan(api.ROOT_CONTEXT, span), () => { - client.capitalize({ data: Buffer.from(data) }, (err, response) => { - if (err) { - console.log('could not get grpc response'); - return; - } - console.log('< ', response.data.toString('utf8')); - // display traceid in the terminal - console.log(`traceid: ${span.spanContext().traceId}`); - span.end(); - }); - }); -} - -main(); diff --git a/examples/grpc-census-prop/capitalize_server.js b/examples/grpc-census-prop/capitalize_server.js deleted file mode 100644 index d0857e9ae7..0000000000 --- a/examples/grpc-census-prop/capitalize_server.js +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const binaryPropagator = process.env.BINARY_PROPAGATOR === 'true'; -const censusTracer = process.env.CENSUS_TRACER === 'true'; - -let tracer; -let SpanKind; -if (censusTracer) { - tracer = require('./tracer_census')(); - ({ SpanKind } = require('@opencensus/core')); -} else { - tracer = require('./tracer')( - 'example-grpc-capitalize-server', - binaryPropagator - ); - ({ SpanKind } = require('@opentelemetry/api')); -} - -const path = require('path'); -const grpc = require('grpc'); -const protoLoader = require('@grpc/proto-loader'); - -const PROTO_PATH = path.join(__dirname, 'protos/defs.proto'); -const PROTO_OPTIONS = { - keepCase: true, - enums: String, - defaults: true, - oneofs: true, -}; -const definition = protoLoader.loadSync(PROTO_PATH, PROTO_OPTIONS); -const rpcProto = grpc.loadPackageDefinition(definition).rpc; - -/** - * Implements the Capitalize RPC method. - */ -function capitalize(call, callback) { - if (call.metadata) { - // output the gRPC metadata to see headers e.g. traceparent or grpc-trace-bin - console.dir(call.metadata, { depth: null }); - } - - let capitalized; - if (censusTracer) { - capitalized = capitalizeWithCensusTracing(call); - } else { - capitalized = capitalizeWithOTelTracing(call); - } - - callback(null, { data: Buffer.from(capitalized) }); -} - -/** - * Capitalize wrapped with Census tracing - */ -function capitalizeWithCensusTracing(call) { - const currentSpan = tracer.currentRootSpan; - // display traceid in the terminal - console.log(`traceid: ${currentSpan.traceId}`); - - const span = tracer.startChildSpan({ - name: 'tutorials.FetchImpl.capitalize', - kind: SpanKind.SERVER, - }); - - const data = call.request.data.toString('utf8'); - const capitalized = data.toUpperCase(); - for (let i = 0; i < 100000000; i += 1) { - // empty - } - span.end(); - return capitalized; -} - -/** - * Capitalize wrapped with OpenTelemetry tracing - */ -function capitalizeWithOTelTracing(call) { - const currentSpan = tracer.getCurrentSpan(); - // display traceid in the terminal - console.log(`traceid: ${currentSpan.spanContext().traceId}`); - - const span = tracer.startSpan('tutorials.FetchImpl.capitalize', { - kind: SpanKind.SERVER, - }); - - const data = call.request.data.toString('utf8'); - const capitalized = data.toUpperCase(); - for (let i = 0; i < 100000000; i += 1) { - // empty - } - span.end(); - return capitalized; -} - -/** - * Starts an RPC server that receives requests for the Fetch service at the - * sample server port. - */ -function main() { - const server = new grpc.Server(); - server.addService(rpcProto.Fetch.service, { capitalize }); - server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure()); - server.start(); -} - -main(); diff --git a/examples/grpc-census-prop/combination2.md b/examples/grpc-census-prop/combination2.md deleted file mode 100644 index cd8b11d7a1..0000000000 --- a/examples/grpc-census-prop/combination2.md +++ /dev/null @@ -1,95 +0,0 @@ -# Example Output from Combination 2 - -OpenTelemetry (with **binary propagator**) used on server, OpenCensus used -on client. Propagation through `grpc-trace-bin` header. - -## Client - -Note: traceId **1565fbb4d6f042d8880bedb509bf6f2e** - -```sh -$ npm run client:census - -> grpc-census-prop-example@0.9.0 client:census /opentelemetry-js-contrib/examples/grpc-census-prop -> cross-env CENSUS_TRACER=true node ./capitalize_client.js - -> opentelemetry -Sleeping 5 seconds before shutdown to ensure all records are flushed. -(node:14866) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead -< OPENTELEMETRY -RootSpan: {traceId: 1565fbb4d6f042d8880bedb509bf6f2e, spanId: a5ccb3c920a18ace, name: tutorialsClient.capitalize } - ChildSpans: - {spanId: c92c3b3f955cdce1, name: grpc.rpc.Fetch/Capitalize} -Completed. -``` - -## Server - -Note: traceId **1565fbb4d6f042d8880bedb509bf6f2e** - -```sh -$ npm run server:otel:binprop - -> grpc-census-prop-example@0.9.0 server:otel:binprop /opentelemetry-js-contrib/examples/grpc-census-prop -> cross-env BINARY_PROPAGATOR=true node ./capitalize_server.js - -PluginLoader#load: trying to load grpc@1.24.2 -Metadata { - _internal_repr: - { 'grpc-trace-bin': - [ Buffer [Uint8Array] [ - 0, - 0, - 21, - 101, - 251, - 180, - 214, - 240, - 66, - 216, - 136, - 11, - 237, - 181, - 9, - 191, - 111, - 46, - 1, - 201, - 44, - 59, - 63, - 149, - 92, - 220, - 225, - 2, - 1 ] ], - 'user-agent': [ 'grpc-node/1.24.2 grpc-c/8.0.0 (linux; chttp2; ganges)' ] }, - flags: 0 } -traceid: 1565fbb4d6f042d8880bedb509bf6f2e -{ traceId: '1565fbb4d6f042d8880bedb509bf6f2e', - parentId: '891bd1ebb5e44ec8', - name: 'tutorials.FetchImpl.capitalize', - id: '61a1c3bce0364fe2', - kind: 1, - timestamp: 1591295467649290, - duration: 101304, - attributes: {}, - status: { code: 0 }, - events: [] } -{ traceId: '1565fbb4d6f042d8880bedb509bf6f2e', - parentId: 'c92c3b3f955cdce1', - name: 'grpc.rpc.Fetch/Capitalize', - id: '891bd1ebb5e44ec8', - kind: 1, - timestamp: 1591295467645184, - duration: 106431, - attributes: - { 'grpc.kind': 1, component: 'grpc', 'grpc.status_code': '0' }, - status: { code: 0 }, - events: - [ { name: 'received', attributes: undefined, time: [Array] } ] } -``` diff --git a/examples/grpc-census-prop/combination4.md b/examples/grpc-census-prop/combination4.md deleted file mode 100644 index 7f622dc7bb..0000000000 --- a/examples/grpc-census-prop/combination4.md +++ /dev/null @@ -1,98 +0,0 @@ -# Example Output from Combination 4 - -OpenCensus used on server, OpenTelemetry (with **binary propagator**) used on -client. Propagation through `grpc-trace-bin` header. - -## Client - -Note: traceId **901c68f681e5a85a125b3dad82e51498** - -```sh -$ npm run client:otel:binprop - -> grpc-census-prop-example@0.9.0 client:otel:binprop /opentelemetry-js-contrib/examples/grpc-census-prop -> cross-env BINARY_PROPAGATOR=true node ./capitalize_client.js - -PluginLoader#load: trying to load grpc@1.24.2 -> opentelemetry -Sleeping 5 seconds before shutdown to ensure all records are flushed. -(node:29834) DeprecationWarning: grpc.load: Use the @grpc/proto-loader module with grpc.loadPackageDefinition instead -{ traceId: '901c68f681e5a85a125b3dad82e51498', - parentId: '070c69c837bbbd1e', - name: 'grpc.rpc.Fetch/Capitalize', - id: 'ecdf319bce919fde', - kind: 2, - timestamp: 1591295728961209, - duration: 159530, - attributes: - { component: 'grpc', - 'grpc.method': '/rpc.Fetch/Capitalize', - 'grpc.kind': 2, - 'grpc.status_code': '0' }, - status: { code: 0 }, - events: [ { name: 'sent', attributes: undefined, time: [Array] } ] } -< OPENTELEMETRY -traceid: 901c68f681e5a85a125b3dad82e51498 -{ traceId: '901c68f681e5a85a125b3dad82e51498', - parentId: undefined, - name: 'tutorialsClient.capitalize', - id: '070c69c837bbbd1e', - kind: 0, - timestamp: 1591295728960326, - duration: 163145, - attributes: {}, - status: { code: 0 }, - events: [] } -Completed. -``` - -## Server - -Note: traceId **901c68f681e5a85a125b3dad82e51498** - -```sh -$ npm run server:census - -> grpc-census-prop-example@0.9.0 server:census /opentelemetry-js-contrib/examples/grpc-census-prop -> cross-env CENSUS_TRACER=true node ./capitalize_server.js - -Metadata { - _internal_repr: - { 'grpc-trace-bin': - [ Buffer [Uint8Array] [ - 0, - 0, - 144, - 28, - 104, - 246, - 129, - 229, - 168, - 90, - 18, - 91, - 61, - 173, - 130, - 229, - 20, - 152, - 1, - 236, - 223, - 49, - 155, - 206, - 145, - 159, - 222, - 2, - 1 ] ], - 'user-agent': [ 'grpc-node/1.24.2 grpc-c/8.0.0 (linux; chttp2; ganges)' ] }, - flags: 0 } -traceid: 901c68f681e5a85a125b3dad82e51498 -RootSpan: {traceId: 901c68f681e5a85a125b3dad82e51498, spanId: 63028b5ce96caec6, name: grpc.rpc.Fetch/Capitalize } - ChildSpans: - {spanId: d70a03f18955e762, name: tutorials.FetchImpl.capitalize} -``` diff --git a/examples/grpc-census-prop/package.json b/examples/grpc-census-prop/package.json deleted file mode 100644 index cc5d9dc855..0000000000 --- a/examples/grpc-census-prop/package.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "grpc-census-prop-example", - "version": "0.23.0", - "description": "Example of using propagator-grpc-census-binary", - "main": "index.js", - "scripts": { - "lint": "eslint . --ext=ts,js,mjs", - "lint:fix": "eslint . --ext=ts,js,mjs --fix", - "server:otel:defprop": "cross-env node ./capitalize_server.js", - "server:otel:binprop": "cross-env BINARY_PROPAGATOR=true node ./capitalize_server.js", - "server:census": "cross-env CENSUS_TRACER=true node ./capitalize_server.js", - "client:otel:defprop": "cross-env node ./capitalize_client.js", - "client:otel:binprop": "cross-env BINARY_PROPAGATOR=true node ./capitalize_client.js", - "client:census": "cross-env CENSUS_TRACER=true node ./capitalize_client.js" - }, - "repository": { - "type": "git", - "url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js.git" - }, - "keywords": [ - "opentelemetry", - "grpc", - "tracing" - ], - "engines": { - "node": ">=8" - }, - "author": "OpenTelemetry Authors", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/open-telemetry/opentelemetry-js/issues" - }, - "dependencies": { - "@grpc/proto-loader": "^0.4.0", - "@opencensus/core": "0.0.21", - "@opencensus/instrumentation-grpc": "0.0.21", - "@opencensus/nodejs": "0.0.21", - "@opencensus/propagation-binaryformat": "0.0.21", - "@opentelemetry/api": "^1.0.2", - "@opentelemetry/core": "^0.25.0", - "@opentelemetry/instrumentation": "^0.25.0", - "@opentelemetry/instrumentation-grpc": "^0.25.0", - "@opentelemetry/sdk-trace-node": "^0.25.0", - "@opentelemetry/propagator-grpc-census-binary": "^0.23.0", - "@opentelemetry/sdk-trace-base": "^0.25.0", - "grpc": "^1.24.2" - }, - "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", - "devDependencies": { - "cross-env": "^6.0.0" - } -} diff --git a/examples/grpc-census-prop/protos/defs.proto b/examples/grpc-census-prop/protos/defs.proto deleted file mode 100644 index cc4a40334c..0000000000 --- a/examples/grpc-census-prop/protos/defs.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "io.grpc.examples.helloworld"; -option java_outer_classname = "HelloWorldProto"; -option objc_class_prefix = "HLW"; - -package rpc; - -service Fetch { - // Sends a capitalizes payload - rpc Capitalize(Payload) returns (Payload) {} -} - -// The request and response payload containing the id and data. -message Payload { - int32 id = 1; - bytes data = 2; -} diff --git a/examples/grpc-census-prop/tracer.js b/examples/grpc-census-prop/tracer.js deleted file mode 100644 index e78cf16000..0000000000 --- a/examples/grpc-census-prop/tracer.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const opentelemetry = require('@opentelemetry/api'); -const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); -const { - SimpleSpanProcessor, - ConsoleSpanExporter, -} = require('@opentelemetry/sdk-trace-base'); -const { HttpTraceContextPropagator } = require('@opentelemetry/core'); -const { - GrpcCensusPropagator, -} = require('@opentelemetry/propagator-grpc-census-binary'); -const { registerInstrumentations } = require('@opentelemetry/instrumentation'); -const { GrpcInstrumentation } = require('@opentelemetry/instrumentation-grpc'); - -/** - * Return an OpenTelemetry tracer configured to use the gRPC plugin and with the - * requested propagator - */ -module.exports = (serviceName, binaryPropagator) => { - const provider = new NodeTracerProvider({ - spanProcessors: [ - // It is recommended to use `BatchSpanProcessor` for better performance - // and optimization, especially in production. - new SimpleSpanProcessor(new ConsoleSpanExporter()), - ], - }); - - if (binaryPropagator) { - // Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings - provider.register({ - propagator: new GrpcCensusPropagator(), - }); - } else { - provider.register({ - propagator: new HttpTraceContextPropagator(), - }); - } - - registerInstrumentations({ - instrumentations: [new GrpcInstrumentation()], - }); - - return opentelemetry.trace.getTracer(serviceName); -}; diff --git a/examples/grpc-census-prop/tracer_census.js b/examples/grpc-census-prop/tracer_census.js deleted file mode 100644 index d43f5b4859..0000000000 --- a/examples/grpc-census-prop/tracer_census.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -'use strict'; - -const tracing = require('@opencensus/nodejs'); -const { ConsoleExporter } = require('@opencensus/core'); - -const defaultBufferConfig = { - bufferSize: 1, - bufferTimeout: 2000, -}; - -/** - * Return an OpenCensus tracer configured to use the gRPC plugin - */ -module.exports = () => { - const { tracer } = tracing.start({ - samplingRate: 1, - plugins: { - grpc: '@opencensus/instrumentation-grpc', - }, - }); - - tracer.registerSpanEventListener(new ConsoleExporter(defaultBufferConfig)); - - return tracer; -}; diff --git a/propagators/README.md b/propagators/README.md deleted file mode 100644 index fde754618f..0000000000 --- a/propagators/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# OpenTelemetry Propagators - -## Built-in Propagators - -OpenTelemetry core package provides many Built-in Propagators such as W3CTraceContextPropagator Propagator, B3 Propagator, Composite Propagator etc. - -[Click here](https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-core#built-in-propagators) to see Built-in Propagators. - -## GRPC Census Propagator - -OpenTelemetry gRPC Census propagator provides gRPC header propagation for systems that use the OpenCensus 'grpc-trace-bin' binary header format. - -```js -const api = require("@opentelemetry/api"); -const { GrpcCensusPropagator } = require("@opentelemetry/propagator-grpc-census-binary"); - -/* Set Global Propagator */ -api.propagation.setGlobalPropagator(new GrpcCensusPropagator()); -``` - -[Click here](opentelemetry-propagator-grpc-census-binary/README.md) for more comprehensive examples. - -## Useful links - -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: - -## License - -Apache 2.0 - See [LICENSE][license-url] for more information. - -[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE