diff --git a/README.md b/README.md index 3e29e68cf46..e930094bb05 100644 --- a/README.md +++ b/README.md @@ -89,46 +89,25 @@ Please note that versions of Node.JS v8 prior to `v8.5.0` will NOT work, because Automated browser tests are run in the latest version of Headless Chrome. There is currently no list of officially supported browsers, but OpenTelemetry is developed using standard web technologies with wide support and should work in currently supported versions of major browsers. -## Release Schedule - -OpenTelemetry JS is under active development. -This release isn't guaranteed to conform to a specific version of the specification, and future -releases will not attempt to maintain backwards compatibility with the alpha release. - -| Component | Initial Version | Release Date | -|----------------------------|-----------------|------------------| -| Tracing API | Alpha v0.1.0 | October 14 2019 | -| Tracing SDK (Node and Web) | Alpha v0.1.0 | October 14 2019 | -| Jaeger Trace Exporter | Alpha v0.1.0 | October 14 2019 | -| Trace Context Propagation | Alpha v0.1.0 | October 14 2019 | -| Zipkin Trace Exporter | Alpha v0.1.0 | October 14 2019 | -| OpenTracing Bridge | Alpha v0.1.0 | October 14 2019 | -| Metrics API | Alpha v0.2.0 | November 04 2019 | -| Metrics SDK | Alpha v0.2.0 | November 04 2019 | -| Prometheus Metric Exporter | Alpha v0.3.0 | December 13 2019 | -| Resources | Beta v0.5.0 | March 16 2020 | -| Metrics SDK (Complete) | Beta v0.5.0 | March 16 2020 | -| OpenCensus Bridge | Unknown | Unknown | -| Support for Tags/Baggage | Unknown | Unknown | - ## Feature Status -Last updated March 2020 +As of [`v0.19.0`][feature-status-release]: -| Feature | API Status | Specification Target | SDK Status | -|---------------------|------------|----------------------|-------------| -| Tracing | Beta | v0.3 | Beta | -| Metrics | Beta | v0.3 | Beta | -| Context | Beta | v0.3 | Beta | -| Propagation | Beta | v0.3 | Beta | -| Baggage | Alpha | v0.3 | Development | -| OpenTracing Bridge | N/A | v0.3 | Beta | -| Resources | N/A | v0.3 | Beta | +| Feature | Status | +|---------------------|-------------| +| B3 Propagation | Beta | +| Zipkin Export | Beta | +| Jaeger Propagation | Beta | +| Jaeger Export | Beta | +| OpenTracing Bridge | Beta | +| Resources | Beta | +| Tracing | Beta | +| W3C Baggage | Beta | +| W3C Trace Context | Beta | +| Metrics API | Development | +| Metrics SDK | Development | -See the [project -milestones](https://github.com/open-telemetry/opentelemetry-js/milestones) -for details on upcoming releases. The dates and features described here are -estimates, and subject to change. +For a more detailed breakdown of feature support see the [specification compliance matrix][compliance-matrix]. ## Contributing @@ -245,6 +224,12 @@ To request automatic tracing support for a module not on this list, please [file ## Upgrade guidelines +### 0.19.x to x + +- `HttpBaggage` renamed to `HttpBaggagePropagator` + +- `HttpTraceContext` renamed to `HttpTraceContextPropagator` + ### 0.18.x to 0.19.0 - API is now a peer dependency. This means that users will need to include `@opentelemetry/api` as a dependency of their project in order to use the SDK. NPM version 7+ (Node 15+) should do this automatically. @@ -415,6 +400,8 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [good-first-issues]: https://github.com/open-telemetry/OpenTelemetry-js/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 [docs]: https://open-telemetry.github.io/opentelemetry-js +[feature-status-release]: https://github.com/open-telemetry/opentelemetry-js/releases/tag/v0.19.0 +[compliance-matrix]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/spec-compliance-matrix.md [otel-metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-metrics [otel-node]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-node diff --git a/backwards-compatability/node10/package.json b/backwards-compatability/node10/package.json index d0c34bdcd2a..e16056a20ef 100644 --- a/backwards-compatability/node10/package.json +++ b/backwards-compatability/node10/package.json @@ -12,7 +12,7 @@ "@opentelemetry/tracing": "0.19.0" }, "devDependencies": { - "@types/node": "10.17.58", + "@types/node": "10.17.59", "typescript": "4.2.4" }, "author": "OpenTelemetry Authors", diff --git a/backwards-compatability/node12/package.json b/backwards-compatability/node12/package.json index deaf88309f8..38dab3f3e0a 100644 --- a/backwards-compatability/node12/package.json +++ b/backwards-compatability/node12/package.json @@ -12,7 +12,7 @@ "@opentelemetry/tracing": "0.19.0" }, "devDependencies": { - "@types/node": "12.20.10", + "@types/node": "12.20.11", "typescript": "4.2.4" }, "author": "OpenTelemetry Authors", diff --git a/benchmark/README.md b/benchmark/README.md index 63ad35c4ca5..81ceaab647d 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -59,7 +59,7 @@ Beginning B3Propagator Benchmark... #Inject x 2,018,725 ops/sec ±3.49% (100 runs sampled) #Extract x 2,040,891 ops/sec ±1.75% (100 runs sampled) -Beginning HttpTraceContext Benchmark... +Beginning HttpTraceContextPropagator Benchmark... 2 tests completed. #Inject x 3,987,007 ops/sec ±1.87% (100 runs sampled) @@ -112,7 +112,7 @@ Beginning B3Propagator Benchmark... #Inject x 5,086,366 ops/sec ±3.18% (100 runs sampled) #Extract x 4,859,557 ops/sec ±3.80% (100 runs sampled) -Beginning HttpTraceContext Benchmark... +Beginning HttpTraceContextPropagator Benchmark... 2 tests completed. #Inject x 13,660,710 ops/sec ±1.84% (100 runs sampled) diff --git a/benchmark/propagator.js b/benchmark/propagator.js index e3e5617523b..51a8058e1f8 100644 --- a/benchmark/propagator.js +++ b/benchmark/propagator.js @@ -17,8 +17,8 @@ const setups = [ } }, { - name: 'HttpTraceContext', - propagator: new opentelemetry.HttpTraceContext(), + name: 'HttpTraceContextPropagator', + propagator: new opentelemetry.HttpTraceContextPropagator(), injectCarrier: {}, extractCarrier: { traceparent: '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-00' diff --git a/getting-started/traced-example/package.json b/getting-started/traced-example/package.json index 9b9f9f1086e..5596a60e35f 100644 --- a/getting-started/traced-example/package.json +++ b/getting-started/traced-example/package.json @@ -13,7 +13,7 @@ "@opentelemetry/exporter-zipkin": "0.19.0", "@opentelemetry/node": "0.19.0", "@opentelemetry/instrumentation": "0.19.0", - "@opentelemetry/instrumentation-express": "^0.15.0", + "@opentelemetry/instrumentation-express": "^0.16.0", "@opentelemetry/instrumentation-http": "0.19.0", "@opentelemetry/tracing": "0.19.0", "axios": "^0.21.0", diff --git a/getting-started/ts-example/example/package.json b/getting-started/ts-example/example/package.json index f29e8d0ef2f..4aae845d152 100644 --- a/getting-started/ts-example/example/package.json +++ b/getting-started/ts-example/example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "ts-node": "8.10.2" }, "dependencies": { diff --git a/getting-started/ts-example/monitored-example/package.json b/getting-started/ts-example/monitored-example/package.json index bd042408924..afa9f62e5b4 100644 --- a/getting-started/ts-example/monitored-example/package.json +++ b/getting-started/ts-example/monitored-example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "ts-node": "8.10.2" }, "dependencies": { diff --git a/getting-started/ts-example/traced-example/package.json b/getting-started/ts-example/traced-example/package.json index 177c605593c..c2b56f1f98a 100644 --- a/getting-started/ts-example/traced-example/package.json +++ b/getting-started/ts-example/traced-example/package.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "@types/express": "4.17.11", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "ts-node": "9.1.1" }, "dependencies": { @@ -18,7 +18,7 @@ "@opentelemetry/exporter-zipkin": "0.19.0", "@opentelemetry/instrumentation": "0.19.0", "@opentelemetry/node": "0.19.0", - "@opentelemetry/instrumentation-express": "^0.15.0", + "@opentelemetry/instrumentation-express": "^0.16.0", "@opentelemetry/instrumentation-http": "0.19.0", "@opentelemetry/tracing": "0.19.0", "axios": "^0.21.0", diff --git a/integration-tests/propagation-validation-server/validation-server.js b/integration-tests/propagation-validation-server/validation-server.js index badcddb7693..2c327cacb8b 100644 --- a/integration-tests/propagation-validation-server/validation-server.js +++ b/integration-tests/propagation-validation-server/validation-server.js @@ -1,5 +1,5 @@ const axios = require("axios"); -const { HttpTraceContext } = require("@opentelemetry/core"); +const { HttpTraceContextPropagator } = require("@opentelemetry/core"); const { BasicTracerProvider } = require("@opentelemetry/tracing"); const { context, propagation, setSpan, trace, ROOT_CONTEXT } = require("@opentelemetry/api"); const { @@ -8,7 +8,7 @@ const { const bodyParser = require("body-parser"); // set global propagator -propagation.setGlobalPropagator(new HttpTraceContext()); +propagation.setGlobalPropagator(new HttpTraceContextPropagator()); // set global context manager context.setGlobalContextManager(new AsyncHooksContextManager()); diff --git a/package.json b/package.json index 3b6211ae12f..b71d1f0fd26 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@typescript-eslint/parser": "4.22.0", "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.24.0", + "eslint": "7.25.0", "eslint-config-airbnb-base": "14.2.1", "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.22.1", diff --git a/packages/opentelemetry-api-metrics/package.json b/packages/opentelemetry-api-metrics/package.json index 47e04d8eb0f..19dd39a057a 100644 --- a/packages/opentelemetry-api-metrics/package.json +++ b/packages/opentelemetry-api-metrics/package.json @@ -58,7 +58,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", "gts": "3.1.0", @@ -71,7 +71,7 @@ "karma-webpack": "5.0.0", "mocha": "7.2.0", "nyc": "15.1.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "typescript": "4.2.4", "webpack": "4.46.0" diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 356dc140c5f..790af59ff82 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -42,7 +42,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/shimmer": "1.0.1", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index d43cb8984f3..c5c0e6f68df 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -45,10 +45,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "@types/zone.js": "0.5.12", @@ -66,7 +66,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index c3d8030fa4a..b1f19d0ded4 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -42,9 +42,9 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", @@ -59,7 +59,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-core/README.md b/packages/opentelemetry-core/README.md index c2ea1817505..f3ddb50cacc 100644 --- a/packages/opentelemetry-core/README.md +++ b/packages/opentelemetry-core/README.md @@ -12,7 +12,7 @@ This package provides default implementations of the OpenTelemetry API for trace - [OpenTelemetry Core](#opentelemetry-core) - [Built-in Implementations](#built-in-implementations) - [Built-in Propagators](#built-in-propagators) - - [HttpTraceContext Propagator](#httptracecontext-propagator) + - [HttpTraceContextPropagator Propagator](#httptracecontext-propagator) - [Composite Propagator](#composite-propagator) - [Baggage Propagator](#baggage-propagator) - [Built-in Sampler](#built-in-sampler) @@ -25,16 +25,16 @@ This package provides default implementations of the OpenTelemetry API for trace ### Built-in Propagators -#### HttpTraceContext Propagator +#### HttpTraceContextPropagator Propagator OpenTelemetry provides a text-based approach to propagate context to remote services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/) HTTP headers. ```js const api = require("@opentelemetry/api"); -const { HttpTraceContext } = require("@opentelemetry/core"); +const { HttpTraceContextPropagator } = require("@opentelemetry/core"); /* Set Global Propagator */ -api.propagation.setGlobalPropagator(new HttpTraceContext()); +api.propagation.setGlobalPropagator(new HttpTraceContextPropagator()); ``` #### Composite Propagator @@ -57,10 +57,10 @@ Provides a text-based approach to propagate [baggage](https://w3c.github.io/bagg ```js const api = require("@opentelemetry/api"); -const { HttpBaggage } = require("@opentelemetry/core"); +const { HttpBaggagePropagator } = require("@opentelemetry/core"); /* Set Global Propagator */ -api.propagation.setGlobalPropagator(new HttpBaggage()); +api.propagation.setGlobalPropagator(new HttpBaggagePropagator()); ``` ### Built-in Sampler diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index b253aed77d5..d2399250d6d 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -58,8 +58,8 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/propagator-b3": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", @@ -75,7 +75,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts b/packages/opentelemetry-core/src/baggage/propagation/HttpBaggagePropagator.ts similarity index 98% rename from packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts rename to packages/opentelemetry-core/src/baggage/propagation/HttpBaggagePropagator.ts index 9452623b992..33f636dfdc4 100644 --- a/packages/opentelemetry-core/src/baggage/propagation/HttpBaggage.ts +++ b/packages/opentelemetry-core/src/baggage/propagation/HttpBaggagePropagator.ts @@ -47,7 +47,7 @@ export const MAX_TOTAL_LENGTH = 8192; * Based on the Baggage specification: * https://w3c.github.io/baggage/ */ -export class HttpBaggage implements TextMapPropagator { +export class HttpBaggagePropagator implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: TextMapSetter) { const baggage = getBaggage(context); if (!baggage || isInstrumentationSuppressed(context)) return; diff --git a/packages/opentelemetry-core/src/context/propagation/types.ts b/packages/opentelemetry-core/src/context/propagation/types.ts deleted file mode 100644 index e973c7790b2..00000000000 --- a/packages/opentelemetry-core/src/context/propagation/types.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { TextMapPropagator } from '@opentelemetry/api'; - -/** Configuration object for composite propagator */ -export interface CompositePropagatorConfig { - /** - * List of propagators to run. Propagators run in the - * list order. If a propagator later in the list writes the same context - * key as a propagator earlier in the list, the later on will "win". - */ - propagators?: TextMapPropagator[]; -} diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts index 871f02dc85c..7d0de201c04 100644 --- a/packages/opentelemetry-core/src/index.ts +++ b/packages/opentelemetry-core/src/index.ts @@ -14,24 +14,23 @@ * limitations under the License. */ +export * from './baggage/propagation/HttpBaggagePropagator'; export * from './common/attributes'; export * from './common/global-error-handler'; export * from './common/logging-error-handler'; export * from './common/time'; export * from './common/types'; export * from './ExportResult'; -export * from './version'; -export * from './context/propagation/composite'; -export * from './context/propagation/HttpTraceContext'; -export * from './context/propagation/types'; -export * from './baggage/propagation/HttpBaggage'; export * from './platform'; +export * from './propagation/composite'; +export * from './trace/HttpTraceContextPropagator'; +export * from './trace/IdGenerator'; export * from './trace/sampler/AlwaysOffSampler'; export * from './trace/sampler/AlwaysOnSampler'; export * from './trace/sampler/ParentBasedSampler'; export * from './trace/sampler/TraceIdRatioBasedSampler'; export * from './trace/TraceState'; -export * from './trace/IdGenerator'; +export * from './utils/sampling'; export * from './utils/url'; export * from './utils/wrap'; -export * from './utils/sampling'; +export * from './version'; diff --git a/packages/opentelemetry-core/src/context/propagation/composite.ts b/packages/opentelemetry-core/src/propagation/composite.ts similarity index 89% rename from packages/opentelemetry-core/src/context/propagation/composite.ts rename to packages/opentelemetry-core/src/propagation/composite.ts index 507b407f246..3a02890bed8 100644 --- a/packages/opentelemetry-core/src/context/propagation/composite.ts +++ b/packages/opentelemetry-core/src/propagation/composite.ts @@ -21,7 +21,16 @@ import { diag, TextMapSetter, } from '@opentelemetry/api'; -import { CompositePropagatorConfig } from './types'; + +/** Configuration object for composite propagator */ +export interface CompositePropagatorConfig { + /** + * List of propagators to run. Propagators run in the + * list order. If a propagator later in the list writes the same context + * key as a propagator earlier in the list, the later on will "win". + */ + propagators?: TextMapPropagator[]; +} /** Combines multiple propagators into a single propagator. */ export class CompositePropagator implements TextMapPropagator { diff --git a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts b/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts similarity index 97% rename from packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts rename to packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts index d40b4477981..29888aa1f12 100644 --- a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts +++ b/packages/opentelemetry-core/src/trace/HttpTraceContextPropagator.ts @@ -26,7 +26,7 @@ import { TextMapSetter, TraceFlags, } from '@opentelemetry/api'; -import { TraceState } from '../../trace/TraceState'; +import { TraceState } from './TraceState'; export const TRACE_PARENT_HEADER = 'traceparent'; export const TRACE_STATE_HEADER = 'tracestate'; @@ -72,7 +72,7 @@ export function parseTraceParent(traceParent: string): SpanContext | null { * Based on the Trace Context specification: * https://www.w3.org/TR/trace-context/ */ -export class HttpTraceContext implements TextMapPropagator { +export class HttpTraceContextPropagator implements TextMapPropagator { inject(context: Context, carrier: unknown, setter: TextMapSetter) { const spanContext = getSpanContext(context); if ( diff --git a/packages/opentelemetry-core/src/trace/sampler/ParentBasedSampler.ts b/packages/opentelemetry-core/src/trace/sampler/ParentBasedSampler.ts index 4cd5c4f871e..a20f9ba181f 100644 --- a/packages/opentelemetry-core/src/trace/sampler/ParentBasedSampler.ts +++ b/packages/opentelemetry-core/src/trace/sampler/ParentBasedSampler.ts @@ -18,6 +18,7 @@ import { SpanAttributes, Context, getSpanContext, + isSpanContextValid, Link, Sampler, SamplingResult, @@ -69,7 +70,7 @@ export class ParentBasedSampler implements Sampler { ): SamplingResult { const parentContext = getSpanContext(context); - if (!parentContext) { + if (!parentContext || !isSpanContextValid(parentContext)) { return this._root.shouldSample( context, traceId, diff --git a/packages/opentelemetry-core/test/baggage/HttpBaggage.test.ts b/packages/opentelemetry-core/test/baggage/HttpBaggagePropagator.test.ts similarity index 88% rename from packages/opentelemetry-core/test/baggage/HttpBaggage.test.ts rename to packages/opentelemetry-core/test/baggage/HttpBaggagePropagator.test.ts index 464be7c2c9a..f081693b45d 100644 --- a/packages/opentelemetry-core/test/baggage/HttpBaggage.test.ts +++ b/packages/opentelemetry-core/test/baggage/HttpBaggagePropagator.test.ts @@ -27,11 +27,11 @@ import { ROOT_CONTEXT } from '@opentelemetry/api'; import * as assert from 'assert'; import { BAGGAGE_HEADER, - HttpBaggage, -} from '../../src/baggage/propagation/HttpBaggage'; + HttpBaggagePropagator, +} from '../../src/baggage/propagation/HttpBaggagePropagator'; -describe('HttpBaggage', () => { - const httpTraceContext = new HttpBaggage(); +describe('HttpBaggagePropagator', () => { + const httpBaggagePropagator = new HttpBaggagePropagator(); let carrier: { [key: string]: unknown }; @@ -47,7 +47,7 @@ describe('HttpBaggage', () => { 'with/slash': { value: 'with spaces' }, }); - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -64,7 +64,7 @@ describe('HttpBaggage', () => { key3: { value: 'c88815a7' }, }); - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -85,7 +85,7 @@ describe('HttpBaggage', () => { [shortKey]: { value: value }, }); - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -101,7 +101,7 @@ describe('HttpBaggage', () => { }); carrier = {}; - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -123,7 +123,7 @@ describe('HttpBaggage', () => { aa: { value: Array(88).fill('v').join('') }, }); - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -141,7 +141,7 @@ describe('HttpBaggage', () => { }); carrier = {}; - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -164,7 +164,7 @@ describe('HttpBaggage', () => { const baggage = createBaggage(entries); - httpTraceContext.inject( + httpBaggagePropagator.inject( setBaggage(ROOT_CONTEXT, baggage), carrier, defaultTextMapSetter @@ -181,7 +181,11 @@ describe('HttpBaggage', () => { carrier[BAGGAGE_HEADER] = 'key1=d4cda95b,key3=c88815a7, keyn = valn, keym =valm'; const extractedBaggage = getBaggage( - httpTraceContext.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) + httpBaggagePropagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ) ); const expected = createBaggage({ @@ -196,7 +200,7 @@ describe('HttpBaggage', () => { describe('fields()', () => { it('returns the fields used by the baggage spec', () => { - const propagator = new HttpBaggage(); + const propagator = new HttpBaggagePropagator(); assert.deepStrictEqual(propagator.fields(), [BAGGAGE_HEADER]); }); }); @@ -204,7 +208,11 @@ describe('HttpBaggage', () => { it('returns undefined if header is missing', () => { assert.deepStrictEqual( getBaggage( - httpTraceContext.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) + httpBaggagePropagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ) ), undefined ); @@ -213,7 +221,7 @@ describe('HttpBaggage', () => { it('returns keys with their properties', () => { carrier[BAGGAGE_HEADER] = 'key1=d4cda95b,key3=c88815a7;prop1=value1'; const bag = getBaggage( - httpTraceContext.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) + httpBaggagePropagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) ); assert.ok(bag); @@ -265,7 +273,11 @@ describe('HttpBaggage', () => { carrier[BAGGAGE_HEADER] = testCases[testCase].header; const extractedSpanContext = getBaggage( - httpTraceContext.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) + httpBaggagePropagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ) ); assert.deepStrictEqual( extractedSpanContext, diff --git a/packages/opentelemetry-core/test/context/composite.test.ts b/packages/opentelemetry-core/test/propagation/composite.test.ts similarity index 94% rename from packages/opentelemetry-core/test/context/composite.test.ts rename to packages/opentelemetry-core/test/propagation/composite.test.ts index 6addee1ff2c..f0a75320304 100644 --- a/packages/opentelemetry-core/test/context/composite.test.ts +++ b/packages/opentelemetry-core/test/propagation/composite.test.ts @@ -26,7 +26,7 @@ import { Context, ROOT_CONTEXT } from '@opentelemetry/api'; import * as assert from 'assert'; import { CompositePropagator, - HttpTraceContext, + HttpTraceContextPropagator, RandomIdGenerator, } from '../../src'; import { @@ -39,7 +39,7 @@ import { import { TRACE_PARENT_HEADER, TRACE_STATE_HEADER, -} from '../../src/context/propagation/HttpTraceContext'; +} from '../../src/trace/HttpTraceContextPropagator'; import { TraceState } from '../../src/trace/TraceState'; describe('Composite Propagator', () => { @@ -72,7 +72,7 @@ describe('Composite Propagator', () => { const composite = new CompositePropagator({ propagators: [ new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }), - new HttpTraceContext(), + new HttpTraceContextPropagator(), ], }); composite.inject(ctxWithSpanContext, carrier, defaultTextMapSetter); @@ -89,7 +89,10 @@ describe('Composite Propagator', () => { it('should not throw', () => { const composite = new CompositePropagator({ - propagators: [new ThrowingPropagator(), new HttpTraceContext()], + propagators: [ + new ThrowingPropagator(), + new HttpTraceContextPropagator(), + ], }); composite.inject(ctxWithSpanContext, carrier, defaultTextMapSetter); @@ -117,7 +120,7 @@ describe('Composite Propagator', () => { const composite = new CompositePropagator({ propagators: [ new B3Propagator({ injectEncoding: B3InjectEncoding.MULTI_HEADER }), - new HttpTraceContext(), + new HttpTraceContextPropagator(), ], }); const spanContext = getSpanContext( @@ -137,7 +140,10 @@ describe('Composite Propagator', () => { it('should not throw', () => { const composite = new CompositePropagator({ - propagators: [new ThrowingPropagator(), new HttpTraceContext()], + propagators: [ + new ThrowingPropagator(), + new HttpTraceContextPropagator(), + ], }); const spanContext = getSpanContext( composite.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) diff --git a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts b/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts similarity index 98% rename from packages/opentelemetry-core/test/context/HttpTraceContext.test.ts rename to packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts index ca2bfabb7a4..115dfd87c37 100644 --- a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts +++ b/packages/opentelemetry-core/test/trace/HttpTraceContextPropagator.test.ts @@ -28,14 +28,14 @@ import { } from '@opentelemetry/api'; import * as assert from 'assert'; import { - HttpTraceContext, + HttpTraceContextPropagator, TRACE_PARENT_HEADER, TRACE_STATE_HEADER, -} from '../../src/context/propagation/HttpTraceContext'; +} from '../../src/trace/HttpTraceContextPropagator'; import { TraceState } from '../../src/trace/TraceState'; -describe('HttpTraceContext', () => { - const httpTraceContext = new HttpTraceContext(); +describe('HttpTraceContextPropagator', () => { + const httpTraceContext = new HttpTraceContextPropagator(); let carrier: { [key: string]: unknown }; beforeEach(() => { diff --git a/packages/opentelemetry-core/test/trace/ParentBasedSampler.test.ts b/packages/opentelemetry-core/test/trace/ParentBasedSampler.test.ts index e6c388ebe79..4394227de44 100644 --- a/packages/opentelemetry-core/test/trace/ParentBasedSampler.test.ts +++ b/packages/opentelemetry-core/test/trace/ParentBasedSampler.test.ts @@ -71,6 +71,24 @@ describe('ParentBasedSampler', () => { ); }); + it('should return api.SamplingDecision.RECORD_AND_SAMPLED for invalid parent spanContext while composited with AlwaysOnSampler', () => { + const sampler = new ParentBasedSampler({ root: new AlwaysOnSampler() }); + + assert.deepStrictEqual( + sampler.shouldSample( + setSpanContext(api.ROOT_CONTEXT, api.INVALID_SPAN_CONTEXT), + traceId, + spanName, + SpanKind.CLIENT, + {}, + [] + ), + { + decision: api.SamplingDecision.RECORD_AND_SAMPLED, + } + ); + }); + it('should return api.SamplingDecision.RECORD_AND_SAMPLED while composited with AlwaysOnSampler', () => { const sampler = new ParentBasedSampler({ root: new AlwaysOnSampler() }); @@ -112,6 +130,24 @@ describe('ParentBasedSampler', () => { ); }); + it('should return api.SamplingDecision.NOT_RECORD for invalid parent spanContext while composited with AlwaysOffSampler', () => { + const sampler = new ParentBasedSampler({ root: new AlwaysOffSampler() }); + + assert.deepStrictEqual( + sampler.shouldSample( + setSpanContext(api.ROOT_CONTEXT, api.INVALID_SPAN_CONTEXT), + traceId, + spanName, + SpanKind.CLIENT, + {}, + [] + ), + { + decision: api.SamplingDecision.NOT_RECORD, + } + ); + }); + it('should return api.SamplingDecision.RECORD_AND_SAMPLED while composited with AlwaysOffSampler', () => { const sampler = new ParentBasedSampler({ root: new AlwaysOffSampler() }); diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index 4b551116821..88713dc2a9e 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -45,11 +45,11 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/api-metrics": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", @@ -58,7 +58,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4" diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index 92e90eb64c1..ba9637f6e10 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -45,11 +45,11 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/api-metrics": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "cpx": "1.5.0", @@ -58,7 +58,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4" diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index feff7bbf38f..c35b3374d4f 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -53,10 +53,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", @@ -74,7 +74,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 7fb9e3fb7ed..139dbe447d7 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -43,7 +43,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/resources": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index ce6e9b7c0ae..27e7d6a2d11 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -41,7 +41,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 59e7e60ea11..bb91a3b2248 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -51,10 +51,10 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", @@ -72,7 +72,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-instrumentation-fetch/package.json b/packages/opentelemetry-instrumentation-fetch/package.json index c586b3b1b94..f45017bba8a 100644 --- a/packages/opentelemetry-instrumentation-fetch/package.json +++ b/packages/opentelemetry-instrumentation-fetch/package.json @@ -46,13 +46,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", @@ -70,7 +70,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-instrumentation-grpc/package.json b/packages/opentelemetry-instrumentation-grpc/package.json index 81e3929a6ca..f4aefe3ca30 100644 --- a/packages/opentelemetry-instrumentation-grpc/package.json +++ b/packages/opentelemetry-instrumentation-grpc/package.json @@ -41,7 +41,7 @@ "access": "public" }, "devDependencies": { - "@grpc/grpc-js": "1.2.12", + "@grpc/grpc-js": "1.3.0", "@grpc/proto-loader": "0.6.1", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-async-hooks": "0.19.0", @@ -49,12 +49,12 @@ "@opentelemetry/node": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "codecov": "3.8.1", - "grpc": "1.24.6", + "grpc": "1.24.7", "gts": "3.1.0", "mocha": "7.2.0", "node-pre-gyp": "0.17.0", diff --git a/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 77665b68249..1c71e494303 100644 --- a/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -21,7 +21,7 @@ import { setSpan, getSpan, } from '@opentelemetry/api'; -import { HttpTraceContext } from '@opentelemetry/core'; +import { HttpTraceContextPropagator } from '@opentelemetry/core'; import { NodeTracerProvider } from '@opentelemetry/node'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { ContextManager } from '@opentelemetry/api'; @@ -388,7 +388,7 @@ export const runTests = ( let contextManager: ContextManager; before(() => { - propagation.setGlobalPropagator(new HttpTraceContext()); + propagation.setGlobalPropagator(new HttpTraceContextPropagator()); }); beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-http/package.json b/packages/opentelemetry-instrumentation-http/package.json index fc7f8ed862e..d0bf47045c2 100644 --- a/packages/opentelemetry-instrumentation-http/package.json +++ b/packages/opentelemetry-instrumentation-http/package.json @@ -48,9 +48,9 @@ "@opentelemetry/tracing": "0.19.0", "@types/got": "9.6.11", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/request-promise-native": "1.0.17", - "@types/semver": "7.3.4", + "@types/semver": "7.3.5", "@types/sinon": "9.0.11", "@types/superagent": "4.1.10", "axios": "0.21.1", diff --git a/packages/opentelemetry-instrumentation-xml-http-request/package.json b/packages/opentelemetry-instrumentation-xml-http-request/package.json index a4392d61283..af7cf75d355 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -46,13 +46,13 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/tracing": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", @@ -69,7 +69,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-instrumentation/package.json b/packages/opentelemetry-instrumentation/package.json index 78de724d28d..409397964bc 100644 --- a/packages/opentelemetry-instrumentation/package.json +++ b/packages/opentelemetry-instrumentation/package.json @@ -68,11 +68,11 @@ "@opentelemetry/api": "^1.0.0-rc.0" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", @@ -91,7 +91,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index 8da6d03371b..d00bcba7ddb 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -47,7 +47,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@types/lodash.merge": "4.6.6", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index b92bb88d3df..2149b395219 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -44,8 +44,8 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/resources": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.11", "codecov": "3.8.1", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index 336ca825d4d..1c2535d32bc 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -48,14 +48,14 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "codecov": "3.8.1", "gts": "3.1.0", "istanbul-instrumenter-loader": "3.0.1", "mocha": "7.2.0", "nyc": "15.1.0", "rimraf": "3.0.2", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "typescript": "4.2.4" } diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index e8bcb7bc0e0..353765fef6e 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -49,7 +49,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", @@ -65,7 +65,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json index 4d8da68cd6c..fde533c296b 100644 --- a/packages/opentelemetry-resource-detector-aws/package.json +++ b/packages/opentelemetry-resource-detector-aws/package.json @@ -41,7 +41,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json index d29fbc957d3..218ab630d7f 100644 --- a/packages/opentelemetry-resource-detector-gcp/package.json +++ b/packages/opentelemetry-resource-detector-gcp/package.json @@ -42,8 +42,8 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/core": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "codecov": "3.8.1", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 903a378b18c..a81bdd3bc48 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index bd209ed45ca..6de91cb1f3a 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -58,8 +58,8 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-async-hooks": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", - "@types/semver": "7.3.4", + "@types/node": "14.14.43", + "@types/semver": "7.3.5", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gcp-metadata": "^4.1.4", @@ -69,7 +69,7 @@ "nyc": "15.1.0", "semver": "7.3.5", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "typescript": "4.2.4" } diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index c82d47d9914..a2e90a7450a 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -44,7 +44,7 @@ }, "devDependencies": { "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "codecov": "3.8.1", "gts": "3.1.0", diff --git a/packages/opentelemetry-shim-opentracing/README.md b/packages/opentelemetry-shim-opentracing/README.md index 9e904937b95..7ed08f4f5b7 100644 --- a/packages/opentelemetry-shim-opentracing/README.md +++ b/packages/opentelemetry-shim-opentracing/README.md @@ -7,8 +7,6 @@ OpenTracing shim allows existing OpenTracing instrumentation to report to OpenTelemetry -Note: Baggage is currently not propagated, see [issues/329](https://github.com/open-telemetry/opentelemetry-js/issues/329). - ## Installation ```bash @@ -34,6 +32,18 @@ opentracing.initGlobalTracer(new TracerShim(tracer)); ``` +Optionally, you can specify propagators to be used for the OpenTracing `TextMap` and `HttpHeaders` formats: + +```javascript +var b3Propagator = new B3Propagator(); +new TracerShim(tracer, { + textMapPropagator: b3Propagator, + httpHeadersPropagator: b3Propagator +}) +``` + +If propagators are not specified, OpenTelemetry's global propagator will be used. + See [examples/opentracing-shim](https://github.com/open-telemetry/opentelemetry-js/tree/main/examples/opentracing-shim) for a short example. ## License diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index c0be2b54d17..30ecc063f49 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -40,8 +40,10 @@ "devDependencies": { "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/tracing": "0.19.0", + "@opentelemetry/propagator-b3": "0.19.0", + "@opentelemetry/propagator-jaeger": "0.19.0", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "codecov": "3.8.1", "gts": "3.1.0", "mocha": "7.2.0", diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts index 84d786d70d1..0fedcb5e01e 100644 --- a/packages/opentelemetry-shim-opentracing/src/shim.ts +++ b/packages/opentelemetry-shim-opentracing/src/shim.ts @@ -20,6 +20,7 @@ import { createBaggage, SpanAttributes, SpanAttributeValue, + TextMapPropagator, } from '@opentelemetry/api'; function translateReferences(references: opentracing.Reference[]): api.Link[] { @@ -65,7 +66,7 @@ function getContextWithParent(options: opentracing.SpanOptions) { } /** - * SpanContextShim wraps a {@link types.SpanContext} and implements the + * SpanContextShim wraps a {@link api.SpanContext} and implements the * OpenTracing span context API. */ export class SpanContextShim extends opentracing.SpanContext { @@ -79,7 +80,7 @@ export class SpanContextShim extends opentracing.SpanContext { } /** - * Returns the underlying {@link types.SpanContext} + * Returns the underlying {@link api.SpanContext} */ getSpanContext(): api.SpanContext { return this._spanContext; @@ -116,16 +117,18 @@ export class SpanContextShim extends opentracing.SpanContext { } /** - * TracerShim wraps a {@link types.Tracer} and implements the + * TracerShim wraps a {@link api.Tracer} and implements the * OpenTracing tracer API. */ export class TracerShim extends opentracing.Tracer { private readonly _tracer: api.Tracer; + private readonly _propagators: ShimPropagators | undefined; - constructor(tracer: api.Tracer) { + constructor(tracer: api.Tracer, propagators?: ShimPropagators) { super(); this._tracer = tracer; + this._propagators = propagators; } startSpan( @@ -163,60 +166,62 @@ export class TracerShim extends opentracing.Tracer { const oTelSpanBaggage: api.Baggage = spanContextShim.getBaggage(); if (!carrier || typeof carrier !== 'object') return; - switch (format) { - case opentracing.FORMAT_HTTP_HEADERS: - case opentracing.FORMAT_TEXT_MAP: { - api.propagation.inject( - api.setBaggage( - api.setSpanContext(api.ROOT_CONTEXT, oTelSpanContext), - oTelSpanBaggage - ), - carrier - ); - return; - } - case opentracing.FORMAT_BINARY: { - api.diag.warn( - 'OpentracingShim.inject() does not support FORMAT_BINARY' - ); - // @todo: Implement binary formats - return; - } - default: + + if (format === opentracing.FORMAT_BINARY) { + api.diag.warn('OpentracingShim.inject() does not support FORMAT_BINARY'); + // @todo: Implement binary format + return; + } + + const propagator = this._getPropagator(format); + if (propagator !== undefined) { + const context = api.setBaggage( + api.setSpanContext(api.ROOT_CONTEXT, oTelSpanContext), + oTelSpanBaggage + ); + propagator.inject(context, carrier, api.defaultTextMapSetter); } } _extract(format: string, carrier: unknown): opentracing.SpanContext | null { - switch (format) { - case opentracing.FORMAT_HTTP_HEADERS: - case opentracing.FORMAT_TEXT_MAP: { - const context: api.Context = api.propagation.extract( - api.ROOT_CONTEXT, - carrier - ); - const spanContext = api.getSpanContext(context); - const baggage = api.getBaggage(context); - - if (!spanContext) { - return null; - } - return new SpanContextShim(spanContext, baggage || createBaggage()); - } - case opentracing.FORMAT_BINARY: { - // @todo: Implement binary format - api.diag.warn( - 'OpentracingShim.extract() does not support FORMAT_BINARY' - ); + if (format === opentracing.FORMAT_BINARY) { + api.diag.warn('OpentracingShim.extract() does not support FORMAT_BINARY'); + // @todo: Implement binary format + return null; + } + + const propagator = this._getPropagator(format); + if (propagator !== undefined) { + const context: api.Context = propagator.extract( + api.ROOT_CONTEXT, + carrier, + api.defaultTextMapGetter + ); + const spanContext = api.getSpanContext(context); + const baggage = api.getBaggage(context); + + if (!spanContext) { return null; } - default: + return new SpanContextShim(spanContext, baggage || createBaggage()); } return null; } + + private _getPropagator(format: string): TextMapPropagator | undefined { + switch (format) { + case opentracing.FORMAT_TEXT_MAP: + return this._propagators?.textMapPropagator ?? api.propagation; + case opentracing.FORMAT_HTTP_HEADERS: + return this._propagators?.httpHeadersPropagator ?? api.propagation; + default: + return; + } + } } /** - * SpanShim wraps an {@link types.Span} and implements the OpenTracing Span API + * SpanShim wraps an {@link api.Span} and implements the OpenTracing Span API * around it. * **/ @@ -334,3 +339,11 @@ export class SpanShim extends opentracing.Span { return this._span; } } + +/** + * Propagator configuration for the {@link TracerShim} + */ +export interface ShimPropagators { + textMapPropagator?: TextMapPropagator; + httpHeadersPropagator?: TextMapPropagator; +} diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index b5711500137..9189b3dd42d 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -17,42 +17,54 @@ import * as assert from 'assert'; import * as opentracing from 'opentracing'; import { BasicTracerProvider, Span } from '@opentelemetry/tracing'; -import { TracerShim, SpanShim, SpanContextShim } from '../src/shim'; +import { SpanContextShim, SpanShim, TracerShim } from '../src/shim'; import { - timeInputToHrTime, - HttpTraceContext, CompositePropagator, - HttpBaggage, + HttpBaggagePropagator, + HttpTraceContextPropagator, + timeInputToHrTime, } from '@opentelemetry/core'; import { createBaggage, + defaultTextMapGetter, + defaultTextMapSetter, + getSpanContext, INVALID_SPAN_CONTEXT, propagation, + ROOT_CONTEXT, + setSpanContext, } from '@opentelemetry/api'; import { performance } from 'perf_hooks'; +import { B3Propagator } from '@opentelemetry/propagator-b3'; +import { JaegerHttpTracePropagator } from '@opentelemetry/propagator-jaeger'; describe('OpenTracing Shim', () => { - const provider = new BasicTracerProvider(); - const shimTracer: opentracing.Tracer = new TracerShim( - provider.getTracer('default') - ); - opentracing.initGlobalTracer(shimTracer); const compositePropagator = new CompositePropagator({ - propagators: [new HttpTraceContext(), new HttpBaggage()], + propagators: [ + new HttpTraceContextPropagator(), + new HttpBaggagePropagator(), + ], }); propagation.setGlobalPropagator(compositePropagator); describe('TracerShim', () => { + let shimTracer: opentracing.Tracer; let span: opentracing.Span; let context: opentracing.SpanContext; - beforeEach(() => { - span = shimTracer.startSpan('my-span'); - context = span.context(); - }); + describe('propagation using default propagators', () => { + before(() => { + const provider = new BasicTracerProvider(); + shimTracer = new TracerShim(provider.getTracer('default')); + opentracing.initGlobalTracer(shimTracer); + }); + + beforeEach(() => { + span = shimTracer.startSpan('my-span'); + context = span.context(); + }); - describe('propagation', () => { it('injects/extracts a span object', () => { const carrier: { [key: string]: unknown } = {}; shimTracer.inject(span, opentracing.FORMAT_HTTP_HEADERS, carrier); @@ -116,48 +128,145 @@ describe('OpenTracing Shim', () => { }); }); - it('creates parent/child relationship using a span object', () => { - const childSpan = shimTracer.startSpan('other-span', { - childOf: span, - }) as SpanShim; - assert.strictEqual( - (childSpan.getSpan() as Span).parentSpanId, - context.toSpanId() - ); - assert.strictEqual( - childSpan.context().toTraceId(), - span.context().toTraceId() - ); - }); + describe('propagation using configured propagators', () => { + const jaegerHttpTracePropagator = new JaegerHttpTracePropagator(); + const b3Propagator = new B3Propagator(); + before(() => { + const provider = new BasicTracerProvider(); + shimTracer = new TracerShim(provider.getTracer('default'), { + textMapPropagator: b3Propagator, + httpHeadersPropagator: jaegerHttpTracePropagator, + }); + opentracing.initGlobalTracer(shimTracer); + }); - it('creates parent/child relationship using a context object', () => { - const childSpan = shimTracer.startSpan('other-span', { - childOf: context, - }) as SpanShim; - assert.strictEqual( - (childSpan.getSpan() as Span).parentSpanId, - context.toSpanId() - ); - assert.strictEqual( - childSpan.context().toTraceId(), - span.context().toTraceId() - ); + beforeEach(() => { + span = shimTracer.startSpan('my-span'); + context = span.context(); + }); + + it('injects HTTP carriers', () => { + const carrier: { [key: string]: unknown } = {}; + shimTracer.inject(context, opentracing.FORMAT_HTTP_HEADERS, carrier); + const extractedContext = getSpanContext( + jaegerHttpTracePropagator.extract( + ROOT_CONTEXT, + carrier, + defaultTextMapGetter + ) + ); + assert.ok(extractedContext !== null); + assert.strictEqual(extractedContext?.traceId, context.toTraceId()); + assert.strictEqual(extractedContext?.spanId, context.toSpanId()); + }); + + it('extracts HTTP carriers', () => { + const carrier: { [key: string]: unknown } = {}; + jaegerHttpTracePropagator.inject( + setSpanContext( + ROOT_CONTEXT, + (context as SpanContextShim).getSpanContext() + ), + carrier, + defaultTextMapSetter + ); + + const extractedContext = shimTracer.extract( + opentracing.FORMAT_HTTP_HEADERS, + carrier + ); + assert.ok(extractedContext !== null); + assert.strictEqual(extractedContext!.toTraceId(), context.toTraceId()); + assert.strictEqual(extractedContext!.toSpanId(), context.toSpanId()); + }); + + it('injects TextMap carriers', () => { + const carrier: { [key: string]: unknown } = {}; + shimTracer.inject(context, opentracing.FORMAT_TEXT_MAP, carrier); + const extractedContext = getSpanContext( + b3Propagator.extract(ROOT_CONTEXT, carrier, defaultTextMapGetter) + ); + assert.ok(extractedContext !== null); + assert.strictEqual(extractedContext?.traceId, context.toTraceId()); + assert.strictEqual(extractedContext?.spanId, context.toSpanId()); + }); + + it('extracts TextMap carriers', () => { + const carrier: { [key: string]: unknown } = {}; + b3Propagator.inject( + setSpanContext( + ROOT_CONTEXT, + (context as SpanContextShim).getSpanContext() + ), + carrier, + defaultTextMapSetter + ); + + const extractedContext = shimTracer.extract( + opentracing.FORMAT_TEXT_MAP, + carrier + ); + assert.ok(extractedContext !== null); + assert.strictEqual(extractedContext!.toTraceId(), context.toTraceId()); + assert.strictEqual(extractedContext!.toSpanId(), context.toSpanId()); + }); }); - it('translates span options correctly', () => { - const now = performance.now(); - const opentracingOptions: opentracing.SpanOptions = { - startTime: now, - tags: { key: 'value', count: 1 }, - references: [opentracing.followsFrom(context)], - }; - span = shimTracer.startSpan('my-span', opentracingOptions); - - const otSpan = (span as SpanShim).getSpan() as Span; - - assert.strictEqual(otSpan.links.length, 1); - assert.deepStrictEqual(otSpan.startTime, timeInputToHrTime(now)); - assert.deepStrictEqual(otSpan.attributes, opentracingOptions.tags); + describe('starting spans', () => { + before(() => { + const provider = new BasicTracerProvider(); + shimTracer = new TracerShim(provider.getTracer('default')); + opentracing.initGlobalTracer(shimTracer); + }); + + beforeEach(() => { + span = shimTracer.startSpan('my-span'); + context = span.context(); + }); + + it('creates parent/child relationship using a span object', () => { + const childSpan = shimTracer.startSpan('other-span', { + childOf: span, + }) as SpanShim; + assert.strictEqual( + (childSpan.getSpan() as Span).parentSpanId, + context.toSpanId() + ); + assert.strictEqual( + childSpan.context().toTraceId(), + span.context().toTraceId() + ); + }); + + it('creates parent/child relationship using a context object', () => { + const childSpan = shimTracer.startSpan('other-span', { + childOf: context, + }) as SpanShim; + assert.strictEqual( + (childSpan.getSpan() as Span).parentSpanId, + context.toSpanId() + ); + assert.strictEqual( + childSpan.context().toTraceId(), + span.context().toTraceId() + ); + }); + + it('translates span options correctly', () => { + const now = performance.now(); + const opentracingOptions: opentracing.SpanOptions = { + startTime: now, + tags: { key: 'value', count: 1 }, + references: [opentracing.followsFrom(context)], + }; + span = shimTracer.startSpan('my-span', opentracingOptions); + + const otSpan = (span as SpanShim).getSpan() as Span; + + assert.strictEqual(otSpan.links.length, 1); + assert.deepStrictEqual(otSpan.startTime, timeInputToHrTime(now)); + assert.deepStrictEqual(otSpan.attributes, opentracingOptions.tags); + }); }); }); @@ -171,9 +280,16 @@ describe('OpenTracing Shim', () => { }); describe('span', () => { + let shimTracer: opentracing.Tracer; let span: SpanShim; let otSpan: Span; + before(() => { + const provider = new BasicTracerProvider(); + shimTracer = new TracerShim(provider.getTracer('default')); + opentracing.initGlobalTracer(shimTracer); + }); + beforeEach(() => { span = shimTracer.startSpan('my-span', { startTime: performance.now(), diff --git a/packages/opentelemetry-shim-opentracing/tsconfig.json b/packages/opentelemetry-shim-opentracing/tsconfig.json index ee62966fd1f..343988c19f8 100644 --- a/packages/opentelemetry-shim-opentracing/tsconfig.json +++ b/packages/opentelemetry-shim-opentracing/tsconfig.json @@ -12,6 +12,12 @@ { "path": "../opentelemetry-core" }, + { + "path": "../opentelemetry-propagator-b3" + }, + { + "path": "../opentelemetry-propagator-jaeger" + }, { "path": "../opentelemetry-tracing" } diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index 08a856c02fa..4fe9a038bcc 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -56,7 +56,7 @@ "@opentelemetry/api": "^1.0.0-rc.0", "@types/lodash.merge": "4.6.6", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "codecov": "3.8.1", @@ -72,7 +72,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts index 86d5f4d077f..0a7aea24dad 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts @@ -24,8 +24,8 @@ import { } from '@opentelemetry/api'; import { CompositePropagator, - HttpTraceContext, - HttpBaggage, + HttpBaggagePropagator, + HttpTraceContextPropagator, getEnv, } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; @@ -46,8 +46,8 @@ export class BasicTracerProvider implements TracerProvider { string, PROPAGATOR_FACTORY >([ - ['tracecontext', () => new HttpTraceContext()], - ['baggage', () => new HttpBaggage()], + ['tracecontext', () => new HttpTraceContextPropagator()], + ['baggage', () => new HttpBaggagePropagator()], ]); private readonly _config: TracerConfig; diff --git a/packages/opentelemetry-tracing/src/config.ts b/packages/opentelemetry-tracing/src/config.ts index afc4db73df1..4e770eb5fae 100644 --- a/packages/opentelemetry-tracing/src/config.ts +++ b/packages/opentelemetry-tracing/src/config.ts @@ -26,6 +26,7 @@ import { import { ENVIRONMENT } from '@opentelemetry/core/src/utils/environment'; const env = getEnv(); +const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn; /** * Default configuration. For fields with primitive values, any user-provided @@ -42,8 +43,6 @@ export const DEFAULT_CONFIG = { }, }; -const FALLBACK_OTEL_TRACES_SAMPLER = TracesSamplerValues.AlwaysOn; - /** * Based on environment, builds a sampler, complies with specification. * @param env optional, by default uses getEnv(), but allows passing a value to reuse parsed environment diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index 71af31964f5..e0d73f1716d 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -45,14 +45,14 @@ "access": "public" }, "devDependencies": { - "@babel/core": "7.13.16", + "@babel/core": "7.14.0", "@opentelemetry/api": "^1.0.0-rc.0", "@opentelemetry/context-zone": "0.19.0", "@opentelemetry/propagator-b3": "0.19.0", "@opentelemetry/resources": "0.19.0", "@types/jquery": "3.5.5", "@types/mocha": "8.2.2", - "@types/node": "14.14.41", + "@types/node": "14.14.43", "@types/sinon": "9.0.11", "@types/webpack-env": "1.16.0", "babel-loader": "8.2.2", @@ -70,7 +70,7 @@ "nyc": "15.1.0", "rimraf": "3.0.2", "sinon": "10.0.0", - "ts-loader": "8.1.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", "ts-node": "9.1.1", "typescript": "4.2.4", diff --git a/packages/template/package.json b/packages/template/package.json index 83ea22f40fd..aeefcf09f51 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -65,7 +65,7 @@ "build/esm/**/*.d.ts" ], "devDependencies": { - "@types/node": "14.14.41", + "@types/node": "14.14.43", "typescript": "4.2.4" }, "Add these to devDependencies for testing": {