From 26002a0a68b2950f42ebe89332a80c38b6e4d541 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Wed, 13 Jan 2021 16:30:58 -0800 Subject: [PATCH 01/19] feat: add OpenTracing trace context propagation --- .../.eslintignore | 1 + .../.eslintrc.js | 9 + .../.npmignore | 4 + .../LICENSE | 201 ++++++++++++++ .../README.md | 46 +++ .../package.json | 58 ++++ .../src/OpenTracingPropagator.ts | 88 ++++++ .../src/index.ts | 17 ++ .../src/version.ts | 18 ++ .../test/OpenTracingPropagator.test.ts | 261 ++++++++++++++++++ .../tsconfig.json | 11 + 11 files changed, 714 insertions(+) create mode 100644 propagators/opentelemetry-propagator-opentracing/.eslintignore create mode 100644 propagators/opentelemetry-propagator-opentracing/.eslintrc.js create mode 100644 propagators/opentelemetry-propagator-opentracing/.npmignore create mode 100644 propagators/opentelemetry-propagator-opentracing/LICENSE create mode 100644 propagators/opentelemetry-propagator-opentracing/README.md create mode 100644 propagators/opentelemetry-propagator-opentracing/package.json create mode 100644 propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts create mode 100644 propagators/opentelemetry-propagator-opentracing/src/index.ts create mode 100644 propagators/opentelemetry-propagator-opentracing/src/version.ts create mode 100644 propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts create mode 100644 propagators/opentelemetry-propagator-opentracing/tsconfig.json diff --git a/propagators/opentelemetry-propagator-opentracing/.eslintignore b/propagators/opentelemetry-propagator-opentracing/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.eslintignore @@ -0,0 +1 @@ +build diff --git a/propagators/opentelemetry-propagator-opentracing/.eslintrc.js b/propagators/opentelemetry-propagator-opentracing/.eslintrc.js new file mode 100644 index 0000000000..9dfe62f9b8 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.eslintrc.js @@ -0,0 +1,9 @@ +module.exports = { + "env": { + "mocha": true, + "commonjs": true, + "node": true, + "browser": true + }, + ...require('../../eslint.config.js') +} diff --git a/propagators/opentelemetry-propagator-opentracing/.npmignore b/propagators/opentelemetry-propagator-opentracing/.npmignore new file mode 100644 index 0000000000..9505ba9450 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/.npmignore @@ -0,0 +1,4 @@ +/bin +/coverage +/doc +/test diff --git a/propagators/opentelemetry-propagator-opentracing/LICENSE b/propagators/opentelemetry-propagator-opentracing/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md new file mode 100644 index 0000000000..6f54641f1e --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -0,0 +1,46 @@ +# OpenTelemetry Propagator OpenTracing + +[![Gitter chat][gitter-image]][gitter-url] +[![NPM Published Version][npm-img]][npm-url] +[![dependencies][dependencies-image]][dependencies-url] +[![devDependencies][devdependencies-image]][devdependencies-url] +[![Apache License][license-image]][license-image] + +## OpenTracing Format + +```bash +ot-tracer-traceid: unsigned uint64 encoded as hex characters +ot-tracer-spanid: unsigned uint 64 encoded as hex characters +ot-tracer-sampled: boolean encoded as a string with the values true or false +ot-baggage-*: repeated string to string key-value baggage items +``` + +## Example Usage + +```javascript +const api = require('@opentelemetry/api'); +const { B3Propagator } = require('@opentelemetry/propagator-opentracing'); + +api.propagation.setGlobalPropagator(new OpenTracingPropagator()); +``` + +## Useful links + +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us on [gitter][gitter-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg +[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-propagator-opentracing +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-opentracing +[devdependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-propagator-opentracing +[devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-opentracing&type=dev +[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-opentracing +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-opentracing.svg diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json new file mode 100644 index 0000000000..9cd320c5fe --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -0,0 +1,58 @@ +{ + "name": "@opentelemetry/propagator-opentracing", + "version": "0.12.0", + "description": "OpenTelemetry propagator OpenTracing provides context propagation for systems that are using the OpenTracing header format", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "scripts": { + "compile": "tsc --build", + "clean": "tsc --build --clean", + "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "version": "node ../../scripts/version-update.js", + "watch": "tsc --build --watch" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "tracing", + "profiling", + "monitoring", + "b3" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + }, + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@opentelemetry/api": "^0.14.0" + }, + "devDependencies": { + "@opentelemetry/context-base": "^0.14.0", + "@types/mocha": "8.2.0", + "@types/node": "14.14.12", + "codecov": "3.8.1", + "gts": "2.0.2", + "istanbul-instrumenter-loader": "3.0.1", + "mocha": "7.2.0", + "nyc": "15.1.0", + "rimraf": "3.0.2", + "ts-loader": "8.0.12", + "ts-mocha": "8.0.0", + "typescript": "3.9.7" + } +} diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts new file mode 100644 index 0000000000..0ececd15e7 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -0,0 +1,88 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + Context, + getParentSpanContext, + isSpanContextValid, + isValidSpanId, + isValidTraceId, + setExtractedSpanContext, + TextMapGetter, + TextMapPropagator, + TextMapSetter, + TraceFlags, +} from '@opentelemetry/api'; + +/** OT header keys */ +export const OT_TRACE_ID_HEADER = 'ot-tracer-traceid'; +export const OT_SPAN_ID_HEADER = 'ot-tracer-spanid'; +export const OT_SAMPLED_HEADER = 'ot-tracer-sampled'; +export const OT_BAGGAGE_PREFIX = 'ot-tracer-baggage-'; + +const PADDING = '0'.repeat(16); + +function readHeader( + carrier: unknown, + getter: TextMapGetter, + key: string +): string { + let header = getter.get(carrier, key); + if (Array.isArray(header)) [header] = header; + return header || ''; +} + +/** + * Propagator for the OpenTracing HTTP format. + */ +export class OpenTracingPropagator implements TextMapPropagator { + inject(context: Context, carrier: unknown, setter: TextMapSetter) { + const spanContext = getParentSpanContext(context); + if (!spanContext || !isSpanContextValid(spanContext)) return; + + setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId); + setter.set(carrier, OT_SPAN_ID_HEADER, spanContext.spanId); + setter.set( + carrier, + OT_SAMPLED_HEADER, + spanContext.traceFlags === TraceFlags.SAMPLED ? 'true' : 'false' + ); + } + + extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + let traceId = readHeader(carrier, getter, OT_TRACE_ID_HEADER); + if (traceId.length == 16) traceId = `${PADDING}${traceId}`; + const spanId = readHeader(carrier, getter, OT_SPAN_ID_HEADER); + const sampled = readHeader(carrier, getter, OT_SAMPLED_HEADER); + const traceFlags = + sampled === 'true' ? TraceFlags.SAMPLED : TraceFlags.NONE; + + if (isValidTraceId(traceId) && isValidSpanId(spanId)) { + return setExtractedSpanContext(context, { + traceId, + spanId, + isRemote: true, + traceFlags, + }); + } + + return context; + } + + fields(): string[] { + return [OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER]; + } +} diff --git a/propagators/opentelemetry-propagator-opentracing/src/index.ts b/propagators/opentelemetry-propagator-opentracing/src/index.ts new file mode 100644 index 0000000000..849bcd4a5c --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/src/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * from './OpenTracingPropagator'; diff --git a/propagators/opentelemetry-propagator-opentracing/src/version.ts b/propagators/opentelemetry-propagator-opentracing/src/version.ts new file mode 100644 index 0000000000..bc552fd543 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/src/version.ts @@ -0,0 +1,18 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// this is autogenerated file, see scripts/version-update.js +export const VERSION = '0.14.0'; diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts new file mode 100644 index 0000000000..5f33921ee8 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -0,0 +1,261 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + defaultTextMapGetter, + defaultTextMapSetter, + INVALID_SPANID, + INVALID_TRACEID, + getParentSpanContext, + setExtractedSpanContext, + SpanContext, + TraceFlags, +} from '@opentelemetry/api'; +import { ROOT_CONTEXT } from '@opentelemetry/context-base'; +import * as assert from 'assert'; +import { + OpenTracingPropagator, + OT_TRACE_ID_HEADER, + OT_SPAN_ID_HEADER, + OT_SAMPLED_HEADER, +} from '../src/OpenTracingPropagator'; + +describe('OpenTracingPropagator', () => { + const propagator = new OpenTracingPropagator(); + let carrier: { [key: string]: unknown }; + + beforeEach(() => { + carrier = {}; + }); + + describe('.inject()', () => { + it('injects context with sampled trace flags', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setExtractedSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual( + carrier[OT_TRACE_ID_HEADER], + '80f198ee56343ba864fe8b2a57d3eff7' + ); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'true'); + }); + + it('injects context with unspecified trace flags', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.NONE, + }; + + propagator.inject( + setExtractedSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual( + carrier[OT_TRACE_ID_HEADER], + '80f198ee56343ba864fe8b2a57d3eff7' + ); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'false'); + }); + + it('no-ops if traceid invalid', () => { + const spanContext: SpanContext = { + traceId: INVALID_TRACEID, + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setExtractedSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], undefined); + }); + + it('no-ops if spanid invalid', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: INVALID_SPANID, + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + setExtractedSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[OT_SAMPLED_HEADER], undefined); + }); + }); + + describe('.extract', () => { + it('extracts context with traceid, spanid, sampled true', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'true', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('extracts context with traceid, spanid, sampled false', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('converts 8-byte traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '4aaba1a52cf8ee09', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + assert.deepStrictEqual(extractedSpanContext, { + spanId: 'e457b5a2e4d86bd1', + traceId: '00000000000000004aaba1a52cf8ee09', + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('handles malformed traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: 'abc123', + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles malformed spanid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '0f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: 'abc123', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles invalid traceid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: INVALID_TRACEID, + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles invalid spanid', () => { + carrier = { + [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [OT_SPAN_ID_HEADER]: INVALID_SPANID, + [OT_SAMPLED_HEADER]: 'false', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = getParentSpanContext(context); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + }); +}); diff --git a/propagators/opentelemetry-propagator-opentracing/tsconfig.json b/propagators/opentelemetry-propagator-opentracing/tsconfig.json new file mode 100644 index 0000000000..4078877ce6 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} From e0f470fa7bb873177c0dc9dd41e442290e9a9c53 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Wed, 13 Jan 2021 18:31:13 -0800 Subject: [PATCH 02/19] feat: propagate baggage --- .../src/OpenTracingPropagator.ts | 24 ++++++++++- .../test/OpenTracingPropagator.test.ts | 41 +++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 0ececd15e7..8b2cfe344c 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -15,11 +15,14 @@ */ import { + Baggage, Context, + getBaggage, getParentSpanContext, isSpanContextValid, isValidSpanId, isValidTraceId, + setBaggage, setExtractedSpanContext, TextMapGetter, TextMapPropagator, @@ -60,6 +63,13 @@ export class OpenTracingPropagator implements TextMapPropagator { OT_SAMPLED_HEADER, spanContext.traceFlags === TraceFlags.SAMPLED ? 'true' : 'false' ); + + const baggage = getBaggage(context); + if (!baggage) return; + + Object.entries(baggage).forEach(([k, v]) => { + setter.set(carrier, `${OT_BAGGAGE_PREFIX}${k}`, v.value); + }); } extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { @@ -71,12 +81,24 @@ export class OpenTracingPropagator implements TextMapPropagator { sampled === 'true' ? TraceFlags.SAMPLED : TraceFlags.NONE; if (isValidTraceId(traceId) && isValidSpanId(spanId)) { - return setExtractedSpanContext(context, { + context = setExtractedSpanContext(context, { traceId, spanId, isRemote: true, traceFlags, }); + + const baggage: Baggage = getBaggage(context) || {}; + + getter.keys(carrier).forEach(k => { + if (!k.startsWith(OT_BAGGAGE_PREFIX)) return; + const value = readHeader(carrier, getter, k); + baggage[k.substr(OT_BAGGAGE_PREFIX.length)] = { value }; + }); + + if (Object.keys(baggage).length > 0) { + context = setBaggage(context, baggage); + } } return context; diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts index 5f33921ee8..dbd69419f2 100644 --- a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -23,6 +23,9 @@ import { setExtractedSpanContext, SpanContext, TraceFlags, + Baggage, + setBaggage, + getBaggage, } from '@opentelemetry/api'; import { ROOT_CONTEXT } from '@opentelemetry/context-base'; import * as assert from 'assert'; @@ -31,6 +34,7 @@ import { OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER, + OT_BAGGAGE_PREFIX, } from '../src/OpenTracingPropagator'; describe('OpenTracingPropagator', () => { @@ -119,6 +123,28 @@ describe('OpenTracingPropagator', () => { assert.strictEqual(carrier[OT_SPAN_ID_HEADER], undefined); assert.strictEqual(carrier[OT_SAMPLED_HEADER], undefined); }); + + it('injects baggage', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setExtractedSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + foo: { value: 'bar' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}foo`], 'bar'); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); }); describe('.extract', () => { @@ -241,11 +267,13 @@ describe('OpenTracingPropagator', () => { assert.deepStrictEqual(undefined, extractedSpanContext); }); - it('handles invalid spanid', () => { + it('extracts baggage', () => { carrier = { [OT_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', - [OT_SPAN_ID_HEADER]: INVALID_SPANID, + [OT_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', [OT_SAMPLED_HEADER]: 'false', + [`${OT_BAGGAGE_PREFIX}foo`]: 'bar', + [`${OT_BAGGAGE_PREFIX}bar`]: 'baz', }; const context = propagator.extract( @@ -254,8 +282,13 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); - assert.deepStrictEqual(undefined, extractedSpanContext); + const baggage = getBaggage(context); + + assert.ok(baggage); + assert.deepStrictEqual(baggage, { + foo: { value: 'bar' }, + bar: { value: 'baz' }, + }); }); }); }); From 7e40a7689b91752e71669547a7474be28ec059cd Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Thu, 14 Jan 2021 15:55:06 -0800 Subject: [PATCH 03/19] chore: truncate traceid to 64bits on inject --- .../src/OpenTracingPropagator.ts | 2 +- .../test/OpenTracingPropagator.test.ts | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 8b2cfe344c..caa956b8ee 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -56,7 +56,7 @@ export class OpenTracingPropagator implements TextMapPropagator { const spanContext = getParentSpanContext(context); if (!spanContext || !isSpanContextValid(spanContext)) return; - setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId); + setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId.substr(16)); setter.set(carrier, OT_SPAN_ID_HEADER, spanContext.spanId); setter.set( carrier, diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts index dbd69419f2..b0178e62b7 100644 --- a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -46,6 +46,22 @@ describe('OpenTracingPropagator', () => { }); describe('.inject()', () => { + it('truncates trace id to 64bits', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.NONE, + }; + + propagator.inject( + setExtractedSpanContext(ROOT_CONTEXT, spanContext), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); + }); + it('injects context with sampled trace flags', () => { const spanContext: SpanContext = { traceId: '80f198ee56343ba864fe8b2a57d3eff7', @@ -59,10 +75,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapSetter ); - assert.strictEqual( - carrier[OT_TRACE_ID_HEADER], - '80f198ee56343ba864fe8b2a57d3eff7' - ); + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'true'); }); @@ -80,10 +93,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapSetter ); - assert.strictEqual( - carrier[OT_TRACE_ID_HEADER], - '80f198ee56343ba864fe8b2a57d3eff7' - ); + assert.strictEqual(carrier[OT_TRACE_ID_HEADER], '64fe8b2a57d3eff7'); assert.strictEqual(carrier[OT_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); assert.strictEqual(carrier[OT_SAMPLED_HEADER], 'false'); }); From fbcef2273fbf07c87890478876c8e1d2c8ce32d8 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Thu, 21 Jan 2021 16:39:51 -0800 Subject: [PATCH 04/19] docs: update readme --- .../README.md | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md index 6f54641f1e..e1d7d4e2a6 100644 --- a/propagators/opentelemetry-propagator-opentracing/README.md +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -8,12 +8,20 @@ ## OpenTracing Format -```bash -ot-tracer-traceid: unsigned uint64 encoded as hex characters -ot-tracer-spanid: unsigned uint 64 encoded as hex characters -ot-tracer-sampled: boolean encoded as a string with the values true or false -ot-baggage-*: repeated string to string key-value baggage items -``` +| Header Name | Description | Required | +| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | +| `ot-tracer-traceid` | uint64 encoded as a string of 16 hex characters | yes | +| `ot-tracer-spanid` | uint64 encoded as a string of 16 hex characters | yes | +| `ot-tracer-sampled` | boolean encoded as a string with the values `'true'` or `'false'` | no | +| `ot-baggage-*` | repeated string to string key-value baggage items; keys are prefixed with `ot-baggage-` and the corresponding value is the raw string. | if baggage is present | + +### Interop and trace ids + +The OpenTracing propagation format expects trace ids to be 64-bits. In order to +interop with OpenTelemetry, trace ids need to be truncated to 64-bits before +sending them on the wire. When truncating, the least significant (right-most) +bits MUST be retained. For example, a trace id of +`3c3039f4d78d5c02ee8e3e41b17ce105` would be truncated to `ee8e3e41b17ce105`. ## Example Usage From 6002caef999c91adb890c7b1ff3d975b0c806e35 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Thu, 21 Jan 2021 16:45:42 -0800 Subject: [PATCH 05/19] refactor: make fields a constant --- .../src/OpenTracingPropagator.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index caa956b8ee..ad1cac597b 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -36,6 +36,7 @@ export const OT_SPAN_ID_HEADER = 'ot-tracer-spanid'; export const OT_SAMPLED_HEADER = 'ot-tracer-sampled'; export const OT_BAGGAGE_PREFIX = 'ot-tracer-baggage-'; +const FIELDS = [OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER]; const PADDING = '0'.repeat(16); function readHeader( @@ -105,6 +106,6 @@ export class OpenTracingPropagator implements TextMapPropagator { } fields(): string[] { - return [OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER]; + return FIELDS; } } From 939949101f5185eff32c11e4691fb8fe02afc18d Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Fri, 22 Jan 2021 13:57:49 -0800 Subject: [PATCH 06/19] chore: update to api v0.15.0 --- .../package.json | 2 +- .../src/OpenTracingPropagator.ts | 8 +++--- .../test/OpenTracingPropagator.test.ts | 28 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json index 9cd320c5fe..61bf82dba4 100644 --- a/propagators/opentelemetry-propagator-opentracing/package.json +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -39,7 +39,7 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "^0.14.0" + "@opentelemetry/api": "^0.15.0" }, "devDependencies": { "@opentelemetry/context-base": "^0.14.0", diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index ad1cac597b..1aab122754 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -18,12 +18,12 @@ import { Baggage, Context, getBaggage, - getParentSpanContext, + getSpanContext, isSpanContextValid, isValidSpanId, isValidTraceId, setBaggage, - setExtractedSpanContext, + setSpanContext, TextMapGetter, TextMapPropagator, TextMapSetter, @@ -54,7 +54,7 @@ function readHeader( */ export class OpenTracingPropagator implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: TextMapSetter) { - const spanContext = getParentSpanContext(context); + const spanContext = getSpanContext(context); if (!spanContext || !isSpanContextValid(spanContext)) return; setter.set(carrier, OT_TRACE_ID_HEADER, spanContext.traceId.substr(16)); @@ -82,7 +82,7 @@ export class OpenTracingPropagator implements TextMapPropagator { sampled === 'true' ? TraceFlags.SAMPLED : TraceFlags.NONE; if (isValidTraceId(traceId) && isValidSpanId(spanId)) { - context = setExtractedSpanContext(context, { + context = setSpanContext(context, { traceId, spanId, isRemote: true, diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts index b0178e62b7..248f357db8 100644 --- a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -19,8 +19,8 @@ import { defaultTextMapSetter, INVALID_SPANID, INVALID_TRACEID, - getParentSpanContext, - setExtractedSpanContext, + getSpanContext, + setSpanContext, SpanContext, TraceFlags, Baggage, @@ -54,7 +54,7 @@ describe('OpenTracingPropagator', () => { }; propagator.inject( - setExtractedSpanContext(ROOT_CONTEXT, spanContext), + setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter ); @@ -70,7 +70,7 @@ describe('OpenTracingPropagator', () => { }; propagator.inject( - setExtractedSpanContext(ROOT_CONTEXT, spanContext), + setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter ); @@ -88,7 +88,7 @@ describe('OpenTracingPropagator', () => { }; propagator.inject( - setExtractedSpanContext(ROOT_CONTEXT, spanContext), + setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter ); @@ -106,7 +106,7 @@ describe('OpenTracingPropagator', () => { }; propagator.inject( - setExtractedSpanContext(ROOT_CONTEXT, spanContext), + setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter ); @@ -124,7 +124,7 @@ describe('OpenTracingPropagator', () => { }; propagator.inject( - setExtractedSpanContext(ROOT_CONTEXT, spanContext), + setSpanContext(ROOT_CONTEXT, spanContext), carrier, defaultTextMapSetter ); @@ -141,7 +141,7 @@ describe('OpenTracingPropagator', () => { traceFlags: TraceFlags.SAMPLED, }; - let context = setExtractedSpanContext(ROOT_CONTEXT, spanContext); + let context = setSpanContext(ROOT_CONTEXT, spanContext); const baggage: Baggage = { foo: { value: 'bar' }, @@ -171,7 +171,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(extractedSpanContext, { spanId: 'e457b5a2e4d86bd1', @@ -194,7 +194,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(extractedSpanContext, { spanId: 'e457b5a2e4d86bd1', @@ -217,7 +217,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(extractedSpanContext, { spanId: 'e457b5a2e4d86bd1', traceId: '00000000000000004aaba1a52cf8ee09', @@ -239,7 +239,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(undefined, extractedSpanContext); }); @@ -256,7 +256,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(undefined, extractedSpanContext); }); @@ -273,7 +273,7 @@ describe('OpenTracingPropagator', () => { defaultTextMapGetter ); - const extractedSpanContext = getParentSpanContext(context); + const extractedSpanContext = getSpanContext(context); assert.deepStrictEqual(undefined, extractedSpanContext); }); From ec1be99f5e6a02650d253666b62946625755ae1a Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Fri, 22 Jan 2021 14:06:37 -0800 Subject: [PATCH 07/19] chore: match contrib repo version --- propagators/opentelemetry-propagator-opentracing/src/version.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/version.ts b/propagators/opentelemetry-propagator-opentracing/src/version.ts index bc552fd543..c032ed99f3 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/version.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.14.0'; +export const VERSION = '0.12.1'; From 7559c75f6e0f6edd31fcdd142334b574157537ed Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Fri, 22 Jan 2021 15:43:01 -0800 Subject: [PATCH 08/19] docs: fix readme --- propagators/opentelemetry-propagator-opentracing/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md index e1d7d4e2a6..08e58fbd60 100644 --- a/propagators/opentelemetry-propagator-opentracing/README.md +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -27,7 +27,9 @@ bits MUST be retained. For example, a trace id of ```javascript const api = require('@opentelemetry/api'); -const { B3Propagator } = require('@opentelemetry/propagator-opentracing'); +const { + OpenTracingPropagator, +} = require('@opentelemetry/propagator-opentracing'); api.propagation.setGlobalPropagator(new OpenTracingPropagator()); ``` From 13d9efd4fd7caa65ab4cc2e998c75e66222e96d6 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Fri, 22 Jan 2021 15:44:52 -0800 Subject: [PATCH 09/19] chore: remove @opentelemetry/context-base dev dep --- propagators/opentelemetry-propagator-opentracing/package.json | 1 - .../test/OpenTracingPropagator.test.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json index 61bf82dba4..d8f78d48de 100644 --- a/propagators/opentelemetry-propagator-opentracing/package.json +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -42,7 +42,6 @@ "@opentelemetry/api": "^0.15.0" }, "devDependencies": { - "@opentelemetry/context-base": "^0.14.0", "@types/mocha": "8.2.0", "@types/node": "14.14.12", "codecov": "3.8.1", diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts index 248f357db8..3a27d91c32 100644 --- a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -26,8 +26,8 @@ import { Baggage, setBaggage, getBaggage, + ROOT_CONTEXT, } from '@opentelemetry/api'; -import { ROOT_CONTEXT } from '@opentelemetry/context-base'; import * as assert from 'assert'; import { OpenTracingPropagator, From bbda92e6c318a93133a3101f1834f997cf6ea988 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Fri, 22 Jan 2021 15:46:05 -0800 Subject: [PATCH 10/19] chore: update version --- propagators/opentelemetry-propagator-opentracing/package.json | 2 +- propagators/opentelemetry-propagator-opentracing/src/version.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json index d8f78d48de..47f05d7866 100644 --- a/propagators/opentelemetry-propagator-opentracing/package.json +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/propagator-opentracing", - "version": "0.12.0", + "version": "0.13.0", "description": "OpenTelemetry propagator OpenTracing provides context propagation for systems that are using the OpenTracing header format", "main": "build/src/index.js", "types": "build/src/index.d.ts", diff --git a/propagators/opentelemetry-propagator-opentracing/src/version.ts b/propagators/opentelemetry-propagator-opentracing/src/version.ts index c032ed99f3..db447568f3 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/version.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.12.1'; +export const VERSION = '0.13.0'; From 43a252e42d36d37815bc64cc075ca1f729c42f59 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Mon, 25 Jan 2021 10:45:41 -0800 Subject: [PATCH 11/19] fix: correct prefix for baggage --- .../src/OpenTracingPropagator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 1aab122754..363a88891c 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -34,7 +34,7 @@ import { export const OT_TRACE_ID_HEADER = 'ot-tracer-traceid'; export const OT_SPAN_ID_HEADER = 'ot-tracer-spanid'; export const OT_SAMPLED_HEADER = 'ot-tracer-sampled'; -export const OT_BAGGAGE_PREFIX = 'ot-tracer-baggage-'; +export const OT_BAGGAGE_PREFIX = 'ot-baggage-'; const FIELDS = [OT_TRACE_ID_HEADER, OT_SPAN_ID_HEADER, OT_SAMPLED_HEADER]; const PADDING = '0'.repeat(16); From c545068946a7666b23452bc9774d9286695cd157 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Mon, 25 Jan 2021 17:12:26 -0800 Subject: [PATCH 12/19] chore: omit invalid header names and values --- .../src/OpenTracingPropagator.ts | 13 ++++++ .../test/OpenTracingPropagator.test.ts | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 363a88891c..0b491174ab 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -49,6 +49,18 @@ function readHeader( return header || ''; } +const VALID_HEADER_NAME_CHARS = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/; + +function isValidHeaderName(name: string): boolean { + return VALID_HEADER_NAME_CHARS.test(name); +} + +const INVALID_HEADER_VALUE_CHARS = /[^\t\x20-\x7e\x80-\xff]/; + +function isValidHeaderValue(value: string): boolean { + return !INVALID_HEADER_VALUE_CHARS.test(value); +} + /** * Propagator for the OpenTracing HTTP format. */ @@ -69,6 +81,7 @@ export class OpenTracingPropagator implements TextMapPropagator { if (!baggage) return; Object.entries(baggage).forEach(([k, v]) => { + if (!isValidHeaderName(k) || !isValidHeaderValue(v.value)) return; setter.set(carrier, `${OT_BAGGAGE_PREFIX}${k}`, v.value); }); } diff --git a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts index 3a27d91c32..47338c3b31 100644 --- a/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts +++ b/propagators/opentelemetry-propagator-opentracing/test/OpenTracingPropagator.test.ts @@ -155,6 +155,48 @@ describe('OpenTracingPropagator', () => { assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}foo`], 'bar'); assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); }); + + it('omits baggage items with invalid keys', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + fθθ: { value: 'bar' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + assert.ok(!(`${OT_BAGGAGE_PREFIX}fθθ` in carrier)); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); + + it('omits baggage items with invalid values', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + let context = setSpanContext(ROOT_CONTEXT, spanContext); + + const baggage: Baggage = { + foo: { value: 'bαr' }, + bar: { value: 'baz' }, + }; + + context = setBaggage(context, baggage); + + propagator.inject(context, carrier, defaultTextMapSetter); + assert.ok(!(`${OT_BAGGAGE_PREFIX}foo` in carrier)); + assert.strictEqual(carrier[`${OT_BAGGAGE_PREFIX}bar`], 'baz'); + }); }); describe('.extract', () => { From 35b93a9d5163454ec31885c794f6325afaccb0b3 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Mon, 25 Jan 2021 17:53:30 -0800 Subject: [PATCH 13/19] chore: add browser testing --- .../karma.conf.js | 26 +++++++++++++++++++ .../package.json | 11 +++++++- .../test/index-webpack.ts | 20 ++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 propagators/opentelemetry-propagator-opentracing/karma.conf.js create mode 100644 propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts diff --git a/propagators/opentelemetry-propagator-opentracing/karma.conf.js b/propagators/opentelemetry-propagator-opentracing/karma.conf.js new file mode 100644 index 0000000000..feb5554b21 --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/karma.conf.js @@ -0,0 +1,26 @@ +/*! + * Copyright 2020, OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const karmaWebpackConfig = require('../../karma.webpack'); +const karmaBaseConfig = require('../../karma.base'); + +module.exports = config => { + config.set( + Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig, + }) + ); +}; diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json index 47f05d7866..453d50393c 100644 --- a/propagators/opentelemetry-propagator-opentracing/package.json +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -9,6 +9,7 @@ "compile": "tsc --build", "clean": "tsc --build --clean", "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "test:browser": "nyc karma start --single-run", "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", @@ -44,14 +45,22 @@ "devDependencies": { "@types/mocha": "8.2.0", "@types/node": "14.14.12", + "@types/webpack-env": "1.16.0", "codecov": "3.8.1", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", + "karma": "5.2.3", + "karma-chrome-launcher": "3.1.0", + "karma-coverage-istanbul-reporter": "3.0.3", + "karma-mocha": "2.0.1", + "karma-spec-reporter": "0.0.32", + "karma-webpack": "4.0.2", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", "ts-loader": "8.0.12", "ts-mocha": "8.0.0", - "typescript": "3.9.7" + "typescript": "3.9.7", + "webpack": "4.46.0" } } diff --git a/propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts b/propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts new file mode 100644 index 0000000000..061a48ccfa --- /dev/null +++ b/propagators/opentelemetry-propagator-opentracing/test/index-webpack.ts @@ -0,0 +1,20 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const testsContext = require.context('.', true, /test$/); +testsContext.keys().forEach(testsContext); + +const srcContext = require.context('.', true, /src$/); +srcContext.keys().forEach(srcContext); From 45ada8298c78537d8b51f0ce4eb2a0068831c699 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Mon, 25 Jan 2021 17:53:52 -0800 Subject: [PATCH 14/19] chore: update keywords --- propagators/opentelemetry-propagator-opentracing/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/package.json b/propagators/opentelemetry-propagator-opentracing/package.json index 453d50393c..d4ceb14355 100644 --- a/propagators/opentelemetry-propagator-opentracing/package.json +++ b/propagators/opentelemetry-propagator-opentracing/package.json @@ -22,7 +22,8 @@ "tracing", "profiling", "monitoring", - "b3" + "opentracing", + "propagator" ], "author": "OpenTelemetry Authors", "license": "Apache-2.0", From 554a8ff595c755d7ee70b4807b7a40c5cfdd6647 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Mon, 25 Jan 2021 17:59:33 -0800 Subject: [PATCH 15/19] docs: document using fields could result in a memory leak --- .../src/OpenTracingPropagator.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 0b491174ab..155ec1227d 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -118,6 +118,11 @@ export class OpenTracingPropagator implements TextMapPropagator { return context; } + /** + * Note: fields does not include baggage headers as they are dependent on + * carrier instance. Attempting to reuse a carrier by clearing fields could + * result in a memory leak. + */ fields(): string[] { return FIELDS; } From e907ae14ff8c2806c05b38e751192ece9e4b7f69 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Tue, 26 Jan 2021 11:49:35 -0800 Subject: [PATCH 16/19] Update propagators/opentelemetry-propagator-opentracing/karma.conf.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gerhard Stöbich --- propagators/opentelemetry-propagator-opentracing/karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/karma.conf.js b/propagators/opentelemetry-propagator-opentracing/karma.conf.js index feb5554b21..f1a1f3a7e8 100644 --- a/propagators/opentelemetry-propagator-opentracing/karma.conf.js +++ b/propagators/opentelemetry-propagator-opentracing/karma.conf.js @@ -1,5 +1,5 @@ /*! - * Copyright 2020, OpenTelemetry Authors + * Copyright The OpenTelemetry Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 48cb6707dc85a26b76125cee2ab91a9893f04a85 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Tue, 26 Jan 2021 11:57:56 -0800 Subject: [PATCH 17/19] docs: update links in readme --- .../opentelemetry-propagator-opentracing/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md index 08e58fbd60..10e2ecf042 100644 --- a/propagators/opentelemetry-propagator-opentracing/README.md +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -44,13 +44,13 @@ api.propagation.setGlobalPropagator(new OpenTracingPropagator()); Apache 2.0 - See [LICENSE][license-url] for more information. -[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg +[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js-contrib.svg [gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge [license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat -[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-propagator-opentracing -[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-opentracing -[devdependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-propagator-opentracing -[devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-propagator-opentracing&type=dev +[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/status.svg?path=packages/opentelemetry-propagator-opentracing +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-propagator-opentracing +[devdependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=packages/opentelemetry-propagator-opentracing +[devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-propagator-opentracing&type=dev [npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-opentracing [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-opentracing.svg From d4e25c3e067e1bef8a6600d919e1445420795415 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Tue, 26 Jan 2021 14:01:29 -0800 Subject: [PATCH 18/19] Update propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts Co-authored-by: Daniel Dyla --- .../src/OpenTracingPropagator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts index 155ec1227d..7d8399101d 100644 --- a/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts +++ b/propagators/opentelemetry-propagator-opentracing/src/OpenTracingPropagator.ts @@ -124,6 +124,6 @@ export class OpenTracingPropagator implements TextMapPropagator { * result in a memory leak. */ fields(): string[] { - return FIELDS; + return FIELDS.slice(); } } From 10c244a979403ed6458f1c680410bb7d50f76cd9 Mon Sep 17 00:00:00 2001 From: Matthew Wear Date: Tue, 26 Jan 2021 14:52:35 -0800 Subject: [PATCH 19/19] docs: add baggage notes to readme --- .../opentelemetry-propagator-opentracing/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/propagators/opentelemetry-propagator-opentracing/README.md b/propagators/opentelemetry-propagator-opentracing/README.md index 10e2ecf042..aad326b39f 100644 --- a/propagators/opentelemetry-propagator-opentracing/README.md +++ b/propagators/opentelemetry-propagator-opentracing/README.md @@ -23,6 +23,18 @@ sending them on the wire. When truncating, the least significant (right-most) bits MUST be retained. For example, a trace id of `3c3039f4d78d5c02ee8e3e41b17ce105` would be truncated to `ee8e3e41b17ce105`. +### Baggage Notes + +Baggage keys and values are validated according to [rfc7230][rfc7230-url]. Any +keys or values that would result in invalid HTTP headers will be silently +dropped during inject. + +OpenTelemetry Baggage is represented as multiple headers where the +names are carrier dependent. For this reason, they are omitted from the `fields` +method. This behavior should be taken into account if your application relies +on the `fields` functionality. See the [specification][fields-spec-url] for +more details. + ## Example Usage ```javascript @@ -54,3 +66,5 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [devdependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=packages%2Fopentelemetry-propagator-opentracing&type=dev [npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-opentracing [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-opentracing.svg +[rfc7230-url]: https://tools.ietf.org/html/rfc7230#section-3.2 +[fields-spec-url]: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/context/api-propagators.md#fields