From 887c3634a287ece99963fdc963a0236373b9e258 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Mon, 4 Jul 2022 21:57:14 +0200 Subject: [PATCH 1/6] feat: add Instana propagator --- .github/component_owners.yml | 3 + .../.eslintignore | 1 + .../.eslintrc.js | 7 + .../.npmignore | 4 + .../CHANGELOG.md | 2 + .../opentelemetry-propagator-instana/LICENSE | 201 +++++++++ .../README.md | 82 ++++ .../karma.conf.js | 43 ++ .../package.json | 75 ++++ .../src/InstanaPropagator.ts | 125 ++++++ .../test/InstanaPropagator.test.ts | 391 ++++++++++++++++++ .../test/index-webpack.ts | 20 + .../tsconfig.esm.json | 11 + .../tsconfig.json | 11 + 14 files changed, 976 insertions(+) create mode 100644 propagators/opentelemetry-propagator-instana/.eslintignore create mode 100644 propagators/opentelemetry-propagator-instana/.eslintrc.js create mode 100644 propagators/opentelemetry-propagator-instana/.npmignore create mode 100644 propagators/opentelemetry-propagator-instana/CHANGELOG.md create mode 100644 propagators/opentelemetry-propagator-instana/LICENSE create mode 100644 propagators/opentelemetry-propagator-instana/README.md create mode 100644 propagators/opentelemetry-propagator-instana/karma.conf.js create mode 100644 propagators/opentelemetry-propagator-instana/package.json create mode 100644 propagators/opentelemetry-propagator-instana/src/InstanaPropagator.ts create mode 100644 propagators/opentelemetry-propagator-instana/test/InstanaPropagator.test.ts create mode 100644 propagators/opentelemetry-propagator-instana/test/index-webpack.ts create mode 100644 propagators/opentelemetry-propagator-instana/tsconfig.esm.json create mode 100644 propagators/opentelemetry-propagator-instana/tsconfig.json diff --git a/.github/component_owners.yml b/.github/component_owners.yml index de29dcab29..abaf53f05b 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -64,6 +64,9 @@ components: propagators/opentelemetry-propagator-aws-xray: - NathanielRN - willarmiros + propagators/opentelemetry-propagator-instana: + - basti1302 + - kirrg001 ignored-authors: - renovate-bot diff --git a/propagators/opentelemetry-propagator-instana/.eslintignore b/propagators/opentelemetry-propagator-instana/.eslintignore new file mode 100644 index 0000000000..378eac25d3 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/.eslintignore @@ -0,0 +1 @@ +build diff --git a/propagators/opentelemetry-propagator-instana/.eslintrc.js b/propagators/opentelemetry-propagator-instana/.eslintrc.js new file mode 100644 index 0000000000..f726f3becb --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + "env": { + "mocha": true, + "node": true + }, + ...require('../../eslint.config.js') +} diff --git a/propagators/opentelemetry-propagator-instana/.npmignore b/propagators/opentelemetry-propagator-instana/.npmignore new file mode 100644 index 0000000000..9505ba9450 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/.npmignore @@ -0,0 +1,4 @@ +/bin +/coverage +/doc +/test diff --git a/propagators/opentelemetry-propagator-instana/CHANGELOG.md b/propagators/opentelemetry-propagator-instana/CHANGELOG.md new file mode 100644 index 0000000000..4dc68c6ff8 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/CHANGELOG.md @@ -0,0 +1,2 @@ +# Changelog + diff --git a/propagators/opentelemetry-propagator-instana/LICENSE b/propagators/opentelemetry-propagator-instana/LICENSE new file mode 100644 index 0000000000..e50e8c80f9 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/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 [2022] 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. diff --git a/propagators/opentelemetry-propagator-instana/README.md b/propagators/opentelemetry-propagator-instana/README.md new file mode 100644 index 0000000000..15b0aa6815 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/README.md @@ -0,0 +1,82 @@ +# OpenTelemetry Instana Propagator + +[![NPM Published Version][npm-img]][npm-url] +[![Apache License][license-image]][license-image] + +[component owners](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/.github/component_owners.yml): @basti1302, @kirrg001 + +The OpenTelemetry Propagator for Instana provides HTTP header propagation for systems that are using IBM Observability by Instana. +This propagator translates the Instana trace correlation headers (`X-INSTANA-T/X-INSTANA-S/X-INSTANA-L`) into the OpenTelemetry `SpanContext`, and vice versa. +It does not handle `TraceState`. + +This package is compatible with the [OpenTelemetry JS API](https://www.npmjs.com/package/@opentelemetry/api) >= `1.0.0`. + +## Installation + +```sh +npm install --save @opentelemetry/propagator-instana +``` + +## Usage + +In the [global tracer configuration file](https://opentelemetry.io/docs/instrumentation/js/getting-started/nodejs/#setup), configure the following: + +```js +const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); +const { InstanaPropagator } = require('@opentelemetry/propagator-instana'); +// ... + +const provider = new NodeTracerProvider(); + +// Set the global trace context propagator to use X-INSTANA-T/-S/-L trace headers. +provider.register({ + propagator: new InstanaPropagator() +}); +``` + +## Propagator Details + +There are three headers that the propagator handles: `X-INSTANA-T` (the trace ID), `X-INSTANA-S` (the parent span ID), and `X-INSTANA-L` (the sampling level). + +Example header triplet: + +* `X-INSTANA-T: 80f198ee56343ba864fe8b2a57d3eff7`, +* `X-INSTANA-S: e457b5a2e4d86bd1`, +* `X-INSTANA-L: 1`. + +A short summary for each of the headers is provided below. More details are available at . + +### X-INSTANA-T -- trace ID + +* A string of either 16 or 32 characters from the alphabet `0-9a-f`, representing either a 64 bit or 128 bit ID. +* This header corresponds to the [OpenTelemetry TraceId](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext). +* If the propagator receives an X-INSTANA-T header value that is shorter than 32 characters when _extracting_ headers into the OpenTelemetry span context, it will left-pad the string with the character "0" to length 32. +* No length transformation is applied when _injecting_ the span context into headers. + +### X-INSTANA-S -- parent span ID + +* Format: A string of 16 characters from the alphabet `0-9a-f`, representing a 64 bit ID. +* This header corresponds to the [OpenTelemetry SpanId](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext). + +### X-INSTANA-L - sampling level + +* The only two valid values are `1` and `0`. +* A level of `1` means that this request is to be sampled, a level of `0` means that the request should not be sampled. +* This header corresponds to the sampling bit of the [OpenTelemetry TraceFlags](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/overview.md#spancontext). + +## Useful links + +* For more information on Instana, visit and [Instana' documentation](https://www.ibm.com/docs/en/obi/current). +* For more information on OpenTelemetry, visit: +* For more about OpenTelemetry JavaScript: +* For help or feedback on this project, join us in [GitHub Discussions][discussions-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions +[license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[npm-url]: https://www.npmjs.com/package/@opentelemetry/propagator-instana +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fpropagator-instana.svg diff --git a/propagators/opentelemetry-propagator-instana/karma.conf.js b/propagators/opentelemetry-propagator-instana/karma.conf.js new file mode 100644 index 0000000000..133e22df63 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/karma.conf.js @@ -0,0 +1,43 @@ +/*! + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const webpack = require('webpack'); + +const karmaWebpackConfig = require('../../karma.webpack'); +const karmaBaseConfig = require('../../karma.base'); + +module.exports = (config) => { + { + const plugins = karmaWebpackConfig.plugins = []; + plugins.push(new webpack.ProvidePlugin({ + process: 'process/browser', + })); + } + + { + const plugins = karmaBaseConfig.plugins = []; + const toAdd = Object.keys(require('./package.json').devDependencies) + .filter((packageName) => packageName.startsWith('karma-')) + .map((packageName) => require(packageName)); + plugins.push( + ...toAdd + ); + } + + config.set(Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig + })) +}; diff --git a/propagators/opentelemetry-propagator-instana/package.json b/propagators/opentelemetry-propagator-instana/package.json new file mode 100644 index 0000000000..5b7bd20502 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/package.json @@ -0,0 +1,75 @@ +{ + "name": "@opentelemetry/propagator-instana", + "version": "1.0.0", + "description": "The OpenTelemetry Instana Propagator implements the propagation format used by IBM Observability by Instana", + "main": "build/src/index.js", + "module": "build/esm/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js-contrib", + "scripts": { + "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/propagator-instana --include-dependencies", + "prewatch": "npm run precompile", + "compile": "tsc --build tsconfig.json tsconfig.esm.json", + "clean": "tsc --build --clean tsconfig.json tsconfig.esm.json", + "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "test:browser": "nyc karma start --single-run", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", + "prepare": "npm run compile" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "tracing", + "profiling", + "monitoring", + "instana", + "propagator" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=8.12.0" + }, + "files": [ + "build/esm/**/*.js", + "build/esm/**/*.js.map", + "build/esm/**/*.d.ts", + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.0.0" + }, + "devDependencies": { + "@jsdevtools/coverage-istanbul-loader": "3.0.5", + "@opentelemetry/api": "^1.0.0", + "@types/mocha": "8.2.3", + "@types/node": "16.11.21", + "@types/webpack-env": "1.16.2", + "assert": "2.0.0", + "gts": "3.1.0", + "karma": "6.3.17", + "karma-chrome-launcher": "3.1.1", + "karma-coverage-istanbul-reporter": "3.0.3", + "karma-mocha": "2.0.1", + "karma-spec-reporter": "0.0.33", + "karma-webpack": "5.0.0", + "mocha": "7.2.0", + "nyc": "15.1.0", + "process": "0.11.10", + "ts-loader": "8.3.0", + "ts-mocha": "8.0.0", + "typescript": "4.3.5", + "webpack": "5.72.0", + "webpack-cli": "4.9.2" + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/propagators/opentelemetry-propagator-instana#readme" +} diff --git a/propagators/opentelemetry-propagator-instana/src/InstanaPropagator.ts b/propagators/opentelemetry-propagator-instana/src/InstanaPropagator.ts new file mode 100644 index 0000000000..bde8af733b --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/src/InstanaPropagator.ts @@ -0,0 +1,125 @@ +/* + * 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, + trace, + isSpanContextValid, + isValidSpanId, + isValidTraceId, + TextMapGetter, + TextMapPropagator, + TextMapSetter, + TraceFlags, + INVALID_TRACEID, + INVALID_SPANID, +} from '@opentelemetry/api'; + +/** Instana header names */ +export const INSTANA_TRACE_ID_HEADER = 'X-INSTANA-T'; +export const INSTANA_SPAN_ID_HEADER = 'X-INSTANA-S'; +export const INSTANA_LEVEL_HEADER = 'X-INSTANA-L'; + +const FIELDS = [ + INSTANA_TRACE_ID_HEADER, + INSTANA_SPAN_ID_HEADER, + INSTANA_LEVEL_HEADER, +]; + +function readHeader( + carrier: unknown, + getter: TextMapGetter, + key: string +): string { + // By convention, X-INSTANA-* headers are sent all-upper-case. For http and http/2, Node.js normalizes all headers to + // all-lower-case, that's why we first read via the lower case variant of the header name. For other protocols, no + // such normalization happens, so we also need to read via the original all-upper-case variant. + let header = + getter.get(carrier, key.toLowerCase()) || getter.get(carrier, key); + if (Array.isArray(header)) [header] = header; + return header || ''; +} + +/** + * Propagator for the Instana HTTP headers. + */ +export class InstanaPropagator implements TextMapPropagator { + /** + * Injects the current span context into Instana's vendor specific trace correlation headers (X-INSTANA-T, X-INSTANA-S + * and X-INSTANA-L). + */ + inject(context: Context, carrier: unknown, setter: TextMapSetter) { + const spanContext = trace.getSpan(context)?.spanContext(); + if (!spanContext || !isSpanContextValid(spanContext)) { + return; + } + + setter.set(carrier, INSTANA_TRACE_ID_HEADER, spanContext.traceId); + setter.set(carrier, INSTANA_SPAN_ID_HEADER, spanContext.spanId); + const sampled = + (spanContext.traceFlags & TraceFlags.SAMPLED) == TraceFlags.SAMPLED; + setter.set(carrier, INSTANA_LEVEL_HEADER, sampled ? '1' : '0'); + } + + /** + * Extracts the span context from Instana's vendor specific trace correlation headers (X-INSTANA-T, X-INSTANA-S + * and X-INSTANA-L). + */ + extract(context: Context, carrier: unknown, getter: TextMapGetter): Context { + let traceId = readHeader(carrier, getter, INSTANA_TRACE_ID_HEADER); + if (traceId && traceId.length < 32) { + traceId = traceId.padStart(32, '0'); + } + let spanId = readHeader(carrier, getter, INSTANA_SPAN_ID_HEADER); + if (spanId && spanId.length < 16) { + spanId = spanId.padStart(16, '0'); + } + const level = readHeader(carrier, getter, INSTANA_LEVEL_HEADER) || '1'; + const sampled = level !== '0'; + const traceFlags = sampled ? TraceFlags.SAMPLED : TraceFlags.NONE; + + if (isValidTraceId(traceId) && isValidSpanId(spanId)) { + context = trace.setSpan( + context, + trace.wrapSpanContext({ + traceId, + spanId, + isRemote: true, + traceFlags, + }) + ); + } else if (!sampled) { + // Even if we do not receive a trace ID/span ID via X-INSTANA-T/X-INSTANA-S, if there is an explicit incoming + // X-INSTANA-L=0, we want to capture that via trace flags. For Instana tracers, it is perfectly valid to send + // X-INSTANA-L=0 without X-INSTANA-T/-S. + context = trace.setSpan( + context, + trace.wrapSpanContext({ + traceId: INVALID_TRACEID, + spanId: INVALID_SPANID, + isRemote: true, + traceFlags, + }) + ); + } + + return context; + } + + fields(): string[] { + return FIELDS.slice(); + } +} diff --git a/propagators/opentelemetry-propagator-instana/test/InstanaPropagator.test.ts b/propagators/opentelemetry-propagator-instana/test/InstanaPropagator.test.ts new file mode 100644 index 0000000000..102cb30a40 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/test/InstanaPropagator.test.ts @@ -0,0 +1,391 @@ +/* + * 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 { + trace, + defaultTextMapGetter, + defaultTextMapSetter, + INVALID_SPANID, + INVALID_TRACEID, + SpanContext, + TraceFlags, + ROOT_CONTEXT, +} from '@opentelemetry/api'; +import * as assert from 'assert'; +import { + InstanaPropagator, + INSTANA_TRACE_ID_HEADER, + INSTANA_SPAN_ID_HEADER, + INSTANA_LEVEL_HEADER, +} from '../src/InstanaPropagator'; + +describe('InstanaPropagator', () => { + const propagator = new InstanaPropagator(); + let carrier: { [key: string]: unknown }; + + beforeEach(() => { + carrier = {}; + }); + + describe('.inject()', () => { + it('injects a valid span context into the X-INSTANA-T/-S/-L headers', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual( + carrier[INSTANA_TRACE_ID_HEADER], + '80f198ee56343ba864fe8b2a57d3eff7' + ); + assert.strictEqual(carrier[INSTANA_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[INSTANA_LEVEL_HEADER], '1'); + }); + + it('translates sampled flag into level header', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.NONE, + }; + + propagator.inject( + trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual( + carrier[INSTANA_TRACE_ID_HEADER], + '80f198ee56343ba864fe8b2a57d3eff7' + ); + assert.strictEqual(carrier[INSTANA_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[INSTANA_LEVEL_HEADER], '0'); + }); + + it('correctly reads sampled flags, even if other flags are set', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + // 81 = 1000 0001, so this sets the sampled flag (rightmost bit) and one other flag (leftmost bit, semantics + // unspecified at the time of writing) + traceFlags: 81, + }; + + propagator.inject( + trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual( + carrier[INSTANA_TRACE_ID_HEADER], + '80f198ee56343ba864fe8b2a57d3eff7' + ); + assert.strictEqual(carrier[INSTANA_SPAN_ID_HEADER], 'e457b5a2e4d86bd1'); + assert.strictEqual(carrier[INSTANA_LEVEL_HEADER], '1'); + }); + + it('does nothing if the trace ID is invalid', () => { + const spanContext: SpanContext = { + traceId: INVALID_TRACEID, + spanId: 'e457b5a2e4d86bd1', + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[INSTANA_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[INSTANA_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[INSTANA_LEVEL_HEADER], undefined); + }); + + it('does nothing if the span ID is invalid', () => { + const spanContext: SpanContext = { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: INVALID_SPANID, + traceFlags: TraceFlags.SAMPLED, + }; + + propagator.inject( + trace.setSpan(ROOT_CONTEXT, trace.wrapSpanContext(spanContext)), + carrier, + defaultTextMapSetter + ); + + assert.strictEqual(carrier[INSTANA_TRACE_ID_HEADER], undefined); + assert.strictEqual(carrier[INSTANA_SPAN_ID_HEADER], undefined); + assert.strictEqual(carrier[INSTANA_LEVEL_HEADER], undefined); + }); + }); + + describe('.extract', () => { + it('extracts context with trace ID, span ID, and sampled=true', () => { + // Header names converted to lower case to emulate the normalization of header names applied by the Node.js http + // module. + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + + assert.deepStrictEqual(extractedSpanContext, { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('extracts context when no header name normalization occurs', () => { + // Not converting header names to lower case to emulate what would happen for non-HTTP protocols where no + // normalization is applied. + carrier = { + [INSTANA_TRACE_ID_HEADER]: '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + + assert.deepStrictEqual(extractedSpanContext, { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('assumes level=1 when level header is missing', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + + assert.deepStrictEqual(extractedSpanContext, { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('extracts context with trace ID, span ID, sampled=false', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '0', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + + assert.deepStrictEqual(extractedSpanContext, { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: 'e457b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('extracts sampled=false from X-INSTANA-L=0, even if trace ID and span ID are missing', () => { + carrier = { + [INSTANA_LEVEL_HEADER.toLowerCase()]: '0', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + + assert.deepStrictEqual(extractedSpanContext, { + traceId: INVALID_TRACEID, + spanId: INVALID_SPANID, + isRemote: true, + traceFlags: TraceFlags.NONE, + }); + }); + + it('left-pads a 64-bit trace ID', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: '4aaba1a52cf8ee09', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(extractedSpanContext, { + traceId: '00000000000000004aaba1a52cf8ee09', + spanId: 'e457b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('left-pads the span ID if necessary', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: '7b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(extractedSpanContext, { + traceId: '80f198ee56343ba864fe8b2a57d3eff7', + spanId: '0007b5a2e4d86bd1', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + + it('handles malformed trace ID', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + 'ghjklmnopqrstuvwxyz0123456789abc', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles malformed span ID', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '0f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'ghjklmnopqrstuv', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles invalid trace ID', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: INVALID_TRACEID, + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: 'e457b5a2e4d86bd1', + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + + it('handles invalid span ID', () => { + carrier = { + [INSTANA_TRACE_ID_HEADER.toLowerCase()]: + '80f198ee56343ba864fe8b2a57d3eff7', + [INSTANA_SPAN_ID_HEADER.toLowerCase()]: INVALID_SPANID, + [INSTANA_LEVEL_HEADER.toLowerCase()]: '1', + }; + + const context = propagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ); + + const extractedSpanContext = trace.getSpan(context)?.spanContext(); + assert.deepStrictEqual(undefined, extractedSpanContext); + }); + }); + + describe('.fields', () => { + it('provides all fields', () => { + assert.deepStrictEqual( + [INSTANA_TRACE_ID_HEADER, INSTANA_SPAN_ID_HEADER, INSTANA_LEVEL_HEADER], + propagator.fields() + ); + }); + }); +}); diff --git a/propagators/opentelemetry-propagator-instana/test/index-webpack.ts b/propagators/opentelemetry-propagator-instana/test/index-webpack.ts new file mode 100644 index 0000000000..061a48ccfa --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/test/index-webpack.ts @@ -0,0 +1,20 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +const testsContext = require.context('.', true, /test$/); +testsContext.keys().forEach(testsContext); + +const srcContext = require.context('.', true, /src$/); +srcContext.keys().forEach(srcContext); diff --git a/propagators/opentelemetry-propagator-instana/tsconfig.esm.json b/propagators/opentelemetry-propagator-instana/tsconfig.esm.json new file mode 100644 index 0000000000..a94adff6aa --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.esm.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build/esm", + "tsBuildInfoFile": "build/esm/tsconfig.esm.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ] +} diff --git a/propagators/opentelemetry-propagator-instana/tsconfig.json b/propagators/opentelemetry-propagator-instana/tsconfig.json new file mode 100644 index 0000000000..4078877ce6 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} From ecdc2d286088d718d6ef566df667d5f202f6d5c6 Mon Sep 17 00:00:00 2001 From: kirrg001 Date: Thu, 21 Jul 2022 14:25:09 +0200 Subject: [PATCH 2/6] chore: added missing index.ts - otherwise the build wil be broken --- .../src/index.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 propagators/opentelemetry-propagator-instana/src/index.ts diff --git a/propagators/opentelemetry-propagator-instana/src/index.ts b/propagators/opentelemetry-propagator-instana/src/index.ts new file mode 100644 index 0000000000..86526b7426 --- /dev/null +++ b/propagators/opentelemetry-propagator-instana/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 "./InstanaPropagator"; From 8d58011e7db2a1cb38676d42e3db6629822ac94e Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 26 Jul 2022 17:57:04 +0200 Subject: [PATCH 3/6] chore: add Instana propagator to release please config files --- .release-please-manifest.json | 2 +- release-please-config.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba71ac5078..d9817df176 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.27.1","detectors/node/opentelemetry-resource-detector-aws":"1.1.1","detectors/node/opentelemetry-resource-detector-gcp":"0.27.1","detectors/node/opentelemetry-resource-detector-github":"0.27.0","metapackages/auto-instrumentations-node":"0.31.1","metapackages/auto-instrumentations-web":"0.29.0","packages/opentelemetry-host-metrics":"0.29.0","packages/opentelemetry-id-generator-aws-xray":"1.1.0","packages/opentelemetry-test-utils":"0.31.0","plugins/node/instrumentation-amqplib":"0.30.0","plugins/node/instrumentation-fs":"0.4.0","plugins/node/instrumentation-tedious":"0.3.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.32.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.8.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.29.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.29.0","plugins/node/opentelemetry-instrumentation-connect":"0.29.0","plugins/node/opentelemetry-instrumentation-dns":"0.29.0","plugins/node/opentelemetry-instrumentation-express":"0.30.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.29.0","plugins/node/opentelemetry-instrumentation-graphql":"0.29.0","plugins/node/opentelemetry-instrumentation-hapi":"0.29.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.31.0","plugins/node/opentelemetry-instrumentation-knex":"0.29.0","plugins/node/opentelemetry-instrumentation-koa":"0.30.0","plugins/node/instrumentation-lru-memoizer":"0.29.0","plugins/node/opentelemetry-instrumentation-memcached":"0.29.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.31.0","plugins/node/opentelemetry-instrumentation-mysql":"0.30.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.31.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.30.0","plugins/node/opentelemetry-instrumentation-net":"0.29.0","plugins/node/opentelemetry-instrumentation-pg":"0.30.0","plugins/node/opentelemetry-instrumentation-pino":"0.30.0","plugins/node/opentelemetry-instrumentation-redis":"0.32.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.31.0","plugins/node/opentelemetry-instrumentation-restify":"0.29.0","plugins/node/opentelemetry-instrumentation-router":"0.29.0","plugins/node/opentelemetry-instrumentation-winston":"0.29.0","plugins/web/opentelemetry-instrumentation-document-load":"0.29.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.30.0","plugins/web/opentelemetry-plugin-react-load":"0.28.0","propagators/opentelemetry-propagator-aws-xray":"1.1.0","propagators/opentelemetry-propagator-grpc-census-binary":"0.26.0","propagators/opentelemetry-propagator-ot-trace":"0.26.0","plugins/node/opentelemetry-instrumentation-fastify":"0.28.0","packages/opentelemetry-propagation-utils":"0.28.0","plugins/web/opentelemetry-instrumentation-long-task":"0.30.0","detectors/node/opentelemetry-resource-detector-docker":"0.1.1","detectors/node/opentelemetry-resource-detector-instana":"0.1.0"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.27.1","detectors/node/opentelemetry-resource-detector-aws":"1.1.1","detectors/node/opentelemetry-resource-detector-gcp":"0.27.1","detectors/node/opentelemetry-resource-detector-github":"0.27.0","metapackages/auto-instrumentations-node":"0.31.1","metapackages/auto-instrumentations-web":"0.29.0","packages/opentelemetry-host-metrics":"0.29.0","packages/opentelemetry-id-generator-aws-xray":"1.1.0","packages/opentelemetry-test-utils":"0.31.0","plugins/node/instrumentation-amqplib":"0.30.0","plugins/node/instrumentation-fs":"0.4.0","plugins/node/instrumentation-tedious":"0.3.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.32.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.8.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.29.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.29.0","plugins/node/opentelemetry-instrumentation-connect":"0.29.0","plugins/node/opentelemetry-instrumentation-dns":"0.29.0","plugins/node/opentelemetry-instrumentation-express":"0.30.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.29.0","plugins/node/opentelemetry-instrumentation-graphql":"0.29.0","plugins/node/opentelemetry-instrumentation-hapi":"0.29.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.31.0","plugins/node/opentelemetry-instrumentation-knex":"0.29.0","plugins/node/opentelemetry-instrumentation-koa":"0.30.0","plugins/node/instrumentation-lru-memoizer":"0.29.0","plugins/node/opentelemetry-instrumentation-memcached":"0.29.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.31.0","plugins/node/opentelemetry-instrumentation-mysql":"0.30.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.31.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.30.0","plugins/node/opentelemetry-instrumentation-net":"0.29.0","plugins/node/opentelemetry-instrumentation-pg":"0.30.0","plugins/node/opentelemetry-instrumentation-pino":"0.30.0","plugins/node/opentelemetry-instrumentation-redis":"0.32.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.31.0","plugins/node/opentelemetry-instrumentation-restify":"0.29.0","plugins/node/opentelemetry-instrumentation-router":"0.29.0","plugins/node/opentelemetry-instrumentation-winston":"0.29.0","plugins/web/opentelemetry-instrumentation-document-load":"0.29.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.30.0","plugins/web/opentelemetry-plugin-react-load":"0.28.0","propagators/opentelemetry-propagator-aws-xray":"1.1.0","propagators/opentelemetry-propagator-grpc-census-binary":"0.26.0","propagators/opentelemetry-propagator-instana":"1.0.0","propagators/opentelemetry-propagator-ot-trace":"0.26.0","plugins/node/opentelemetry-instrumentation-fastify":"0.28.0","packages/opentelemetry-propagation-utils":"0.28.0","plugins/web/opentelemetry-instrumentation-long-task":"0.30.0","detectors/node/opentelemetry-resource-detector-docker":"0.1.1","detectors/node/opentelemetry-resource-detector-instana":"0.1.0"} diff --git a/release-please-config.json b/release-please-config.json index d3688fd76a..b3771cad45 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -55,6 +55,7 @@ "plugins/web/opentelemetry-plugin-react-load": {}, "propagators/opentelemetry-propagator-aws-xray": {}, "propagators/opentelemetry-propagator-grpc-census-binary": {}, + "propagators/opentelemetry-propagator-instana": {}, "propagators/opentelemetry-propagator-ot-trace": {} } } From 676a5bc5b4ff87d5ec69e7686b31479caac9fd26 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 9 Aug 2022 12:12:26 +0200 Subject: [PATCH 4/6] chore: use 0.1.0 as initial package version --- .release-please-manifest.json | 2 +- propagators/opentelemetry-propagator-instana/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d9817df176..24035ddeb3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.27.1","detectors/node/opentelemetry-resource-detector-aws":"1.1.1","detectors/node/opentelemetry-resource-detector-gcp":"0.27.1","detectors/node/opentelemetry-resource-detector-github":"0.27.0","metapackages/auto-instrumentations-node":"0.31.1","metapackages/auto-instrumentations-web":"0.29.0","packages/opentelemetry-host-metrics":"0.29.0","packages/opentelemetry-id-generator-aws-xray":"1.1.0","packages/opentelemetry-test-utils":"0.31.0","plugins/node/instrumentation-amqplib":"0.30.0","plugins/node/instrumentation-fs":"0.4.0","plugins/node/instrumentation-tedious":"0.3.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.32.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.8.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.29.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.29.0","plugins/node/opentelemetry-instrumentation-connect":"0.29.0","plugins/node/opentelemetry-instrumentation-dns":"0.29.0","plugins/node/opentelemetry-instrumentation-express":"0.30.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.29.0","plugins/node/opentelemetry-instrumentation-graphql":"0.29.0","plugins/node/opentelemetry-instrumentation-hapi":"0.29.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.31.0","plugins/node/opentelemetry-instrumentation-knex":"0.29.0","plugins/node/opentelemetry-instrumentation-koa":"0.30.0","plugins/node/instrumentation-lru-memoizer":"0.29.0","plugins/node/opentelemetry-instrumentation-memcached":"0.29.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.31.0","plugins/node/opentelemetry-instrumentation-mysql":"0.30.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.31.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.30.0","plugins/node/opentelemetry-instrumentation-net":"0.29.0","plugins/node/opentelemetry-instrumentation-pg":"0.30.0","plugins/node/opentelemetry-instrumentation-pino":"0.30.0","plugins/node/opentelemetry-instrumentation-redis":"0.32.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.31.0","plugins/node/opentelemetry-instrumentation-restify":"0.29.0","plugins/node/opentelemetry-instrumentation-router":"0.29.0","plugins/node/opentelemetry-instrumentation-winston":"0.29.0","plugins/web/opentelemetry-instrumentation-document-load":"0.29.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.30.0","plugins/web/opentelemetry-plugin-react-load":"0.28.0","propagators/opentelemetry-propagator-aws-xray":"1.1.0","propagators/opentelemetry-propagator-grpc-census-binary":"0.26.0","propagators/opentelemetry-propagator-instana":"1.0.0","propagators/opentelemetry-propagator-ot-trace":"0.26.0","plugins/node/opentelemetry-instrumentation-fastify":"0.28.0","packages/opentelemetry-propagation-utils":"0.28.0","plugins/web/opentelemetry-instrumentation-long-task":"0.30.0","detectors/node/opentelemetry-resource-detector-docker":"0.1.1","detectors/node/opentelemetry-resource-detector-instana":"0.1.0"} +{"detectors/node/opentelemetry-resource-detector-alibaba-cloud":"0.27.1","detectors/node/opentelemetry-resource-detector-aws":"1.1.1","detectors/node/opentelemetry-resource-detector-gcp":"0.27.1","detectors/node/opentelemetry-resource-detector-github":"0.27.0","metapackages/auto-instrumentations-node":"0.31.1","metapackages/auto-instrumentations-web":"0.29.0","packages/opentelemetry-host-metrics":"0.29.0","packages/opentelemetry-id-generator-aws-xray":"1.1.0","packages/opentelemetry-test-utils":"0.31.0","plugins/node/instrumentation-amqplib":"0.30.0","plugins/node/instrumentation-fs":"0.4.0","plugins/node/instrumentation-tedious":"0.3.0","plugins/node/opentelemetry-instrumentation-aws-lambda":"0.32.0","plugins/node/opentelemetry-instrumentation-aws-sdk":"0.8.1","plugins/node/opentelemetry-instrumentation-bunyan":"0.29.0","plugins/node/opentelemetry-instrumentation-cassandra":"0.29.0","plugins/node/opentelemetry-instrumentation-connect":"0.29.0","plugins/node/opentelemetry-instrumentation-dns":"0.29.0","plugins/node/opentelemetry-instrumentation-express":"0.30.0","plugins/node/opentelemetry-instrumentation-generic-pool":"0.29.0","plugins/node/opentelemetry-instrumentation-graphql":"0.29.0","plugins/node/opentelemetry-instrumentation-hapi":"0.29.0","plugins/node/opentelemetry-instrumentation-ioredis":"0.31.0","plugins/node/opentelemetry-instrumentation-knex":"0.29.0","plugins/node/opentelemetry-instrumentation-koa":"0.30.0","plugins/node/instrumentation-lru-memoizer":"0.29.0","plugins/node/opentelemetry-instrumentation-memcached":"0.29.0","plugins/node/opentelemetry-instrumentation-mongodb":"0.31.0","plugins/node/opentelemetry-instrumentation-mysql":"0.30.0","plugins/node/opentelemetry-instrumentation-mysql2":"0.31.0","plugins/node/opentelemetry-instrumentation-nestjs-core":"0.30.0","plugins/node/opentelemetry-instrumentation-net":"0.29.0","plugins/node/opentelemetry-instrumentation-pg":"0.30.0","plugins/node/opentelemetry-instrumentation-pino":"0.30.0","plugins/node/opentelemetry-instrumentation-redis":"0.32.0","plugins/node/opentelemetry-instrumentation-redis-4":"0.31.0","plugins/node/opentelemetry-instrumentation-restify":"0.29.0","plugins/node/opentelemetry-instrumentation-router":"0.29.0","plugins/node/opentelemetry-instrumentation-winston":"0.29.0","plugins/web/opentelemetry-instrumentation-document-load":"0.29.0","plugins/web/opentelemetry-instrumentation-user-interaction":"0.30.0","plugins/web/opentelemetry-plugin-react-load":"0.28.0","propagators/opentelemetry-propagator-aws-xray":"1.1.0","propagators/opentelemetry-propagator-grpc-census-binary":"0.26.0","propagators/opentelemetry-propagator-instana":"0.1.0","propagators/opentelemetry-propagator-ot-trace":"0.26.0","plugins/node/opentelemetry-instrumentation-fastify":"0.28.0","packages/opentelemetry-propagation-utils":"0.28.0","plugins/web/opentelemetry-instrumentation-long-task":"0.30.0","detectors/node/opentelemetry-resource-detector-docker":"0.1.1","detectors/node/opentelemetry-resource-detector-instana":"0.1.0"} diff --git a/propagators/opentelemetry-propagator-instana/package.json b/propagators/opentelemetry-propagator-instana/package.json index 5b7bd20502..fe9e35ef53 100644 --- a/propagators/opentelemetry-propagator-instana/package.json +++ b/propagators/opentelemetry-propagator-instana/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/propagator-instana", - "version": "1.0.0", + "version": "0.1.0", "description": "The OpenTelemetry Instana Propagator implements the propagation format used by IBM Observability by Instana", "main": "build/src/index.js", "module": "build/esm/index.js", From da9eddfbd60718de66f15e9da7d3f2f8e90bc36d Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 9 Aug 2022 12:19:27 +0200 Subject: [PATCH 5/6] chore: fix lint issue --- propagators/opentelemetry-propagator-instana/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-instana/src/index.ts b/propagators/opentelemetry-propagator-instana/src/index.ts index 86526b7426..4e1274e784 100644 --- a/propagators/opentelemetry-propagator-instana/src/index.ts +++ b/propagators/opentelemetry-propagator-instana/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export * from "./InstanaPropagator"; +export * from './InstanaPropagator'; From dcb04c865484981ce94a4bfdf06c81fd78d70fe1 Mon Sep 17 00:00:00 2001 From: Bastian Krol Date: Tue, 9 Aug 2022 14:50:16 +0200 Subject: [PATCH 6/6] refactor: only export InstanaPropagator class --- propagators/opentelemetry-propagator-instana/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/propagators/opentelemetry-propagator-instana/src/index.ts b/propagators/opentelemetry-propagator-instana/src/index.ts index 4e1274e784..30e03f92ce 100644 --- a/propagators/opentelemetry-propagator-instana/src/index.ts +++ b/propagators/opentelemetry-propagator-instana/src/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ -export * from './InstanaPropagator'; +export { InstanaPropagator } from './InstanaPropagator';