From 5d6c99d126a8197494968ce8430a05decc0afee9 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 29 Jan 2020 16:30:49 -0500 Subject: [PATCH] Api separation (#727) * feat: create an api package * chore: update circle for new api package * chore: bring back getTracer * chore: add wrongly removed dev dependency * chore: review comments * chore: review comments * chore: lint * chore: export all noop implementations * chore: update API README * chore: ignore known working links that are not yet published * chore: add jsdoc for getInstance calls * chore: add jsdoc for private constructors * chore: review comments * chore: fix readme npm url * chore: fix old readmes without registry * chore: update api calling convention --- .circleci/config.yml | 8 +- CONTRIBUTING.md | 2 +- README.md | 6 +- doc/development-guide.md | 2 +- package.json | 2 +- .../LICENSE | 0 packages/opentelemetry-api/README.md | 123 ++++++++++++++++++ packages/opentelemetry-api/karma.conf.js | 24 ++++ .../package.json | 28 +++- packages/opentelemetry-api/src/api/metrics.ts | 61 +++++++++ packages/opentelemetry-api/src/api/trace.ts | 61 +++++++++ .../src/common/Logger.ts | 0 .../src/common/Time.ts | 0 .../src/context/propagation/BinaryFormat.ts | 0 .../src/context/propagation/HttpTextFormat.ts | 0 .../context/propagation/NoopBinaryFormat.ts | 5 +- .../context/propagation/NoopHttpTextFormat.ts | 5 +- .../distributed_context/DistributedContext.ts | 0 .../src/distributed_context/EntryValue.ts | 0 .../src/index.ts | 18 +++ .../src/metrics/BoundInstrument.ts | 0 .../src/metrics/Meter.ts | 0 .../src/metrics/MeterRegistry.ts | 0 .../src/metrics/Metric.ts | 0 .../src/metrics/NoopMeter.ts | 20 +-- .../src/metrics/NoopMeterRegistry.ts | 13 +- .../src/trace/Event.ts | 0 .../src/trace/NoopSpan.ts | 32 +++-- .../src/trace/NoopTracer.ts | 14 +- .../src/trace/NoopTracerRegistry.ts | 13 +- .../src/trace/Sampler.ts | 0 .../src/trace/SpanOptions.ts | 0 .../src/trace/TimedEvent.ts | 0 .../src/trace/attributes.ts | 0 .../src/trace/instrumentation/Plugin.ts | 0 .../src/trace/link.ts | 0 .../src/trace/span.ts | 0 .../src/trace/span_context.ts | 0 .../src/trace/span_kind.ts | 0 .../src/trace/status.ts | 0 .../src/trace/trace_flags.ts | 0 .../src/trace/trace_state.ts | 0 .../src/trace/tracer.ts | 0 .../src/trace/tracer_registry.ts | 0 .../src/version.ts | 0 .../test/api/api.test.ts} | 26 ++-- .../opentelemetry-api/test/index-webpack.ts | 23 ++++ .../noop-implementations/noop-meter.test.ts} | 15 ++- .../noop-implementations/noop-span.test.ts} | 8 +- .../noop-implementations/noop-tracer.test.ts} | 4 +- .../tsconfig.json | 0 .../tslint.json | 0 packages/opentelemetry-core/package.json | 2 +- .../src/common/ConsoleLogger.ts | 2 +- .../src/common/NoopLogger.ts | 2 +- .../opentelemetry-core/src/common/time.ts | 2 +- .../src/context/propagation/B3Format.ts | 2 +- .../context/propagation/BinaryTraceContext.ts | 2 +- .../context/propagation/HttpTraceContext.ts | 2 +- packages/opentelemetry-core/src/index.ts | 5 - .../src/trace/NoRecordingSpan.ts | 3 +- .../src/trace/TraceState.ts | 2 +- .../src/trace/globaltracer-utils.ts | 45 ------- .../src/trace/instrumentation/BasePlugin.ts | 2 +- .../src/trace/sampler/ProbabilitySampler.ts | 2 +- .../src/trace/spancontext-utils.ts | 2 +- .../test/common/time.test.ts | 2 +- .../test/context/B3Format.test.ts | 2 +- .../test/context/BinaryTraceContext.test.ts | 2 +- .../test/context/HttpTraceContext.test.ts | 2 +- .../test/trace/BasePlugin.test.ts | 2 +- .../test/trace/NoRecordingSpan.test.ts | 2 +- .../README.md | 14 +- .../package.json | 2 +- .../src/CollectorExporter.ts | 2 +- .../src/platform/browser/sendSpans.ts | 2 +- .../src/transform.ts | 2 +- .../src/types.ts | 2 +- .../test/common/transform.test.ts | 2 +- .../package.json | 2 +- .../src/jaeger.ts | 4 +- .../src/transform.ts | 2 +- .../src/types.ts | 2 +- .../test/jaeger.test.ts | 2 +- .../test/transform.test.ts | 2 +- .../package.json | 2 +- .../src/export/types.ts | 2 +- .../src/prometheus.ts | 2 +- .../package.json | 2 +- .../src/external-types.ts | 2 +- .../src/trace.ts | 2 +- .../src/transform.ts | 2 +- .../test/exporter.test.ts | 2 +- .../test/transform.test.ts | 2 +- .../package.json | 2 +- .../src/transform.ts | 2 +- .../src/types.ts | 2 +- .../src/zipkin.ts | 2 +- .../test/transform.test.ts | 2 +- .../test/zipkin.test.ts | 2 +- packages/opentelemetry-metrics/package.json | 2 +- .../src/BoundInstrument.ts | 2 +- .../opentelemetry-metrics/src/LabelSet.ts | 2 +- packages/opentelemetry-metrics/src/Meter.ts | 15 +-- .../src/MeterRegistry.ts | 2 +- packages/opentelemetry-metrics/src/Metric.ts | 2 +- .../opentelemetry-metrics/src/export/types.ts | 2 +- packages/opentelemetry-metrics/src/types.ts | 2 +- .../opentelemetry-metrics/test/Meter.test.ts | 33 ++--- packages/opentelemetry-node/README.md | 4 +- packages/opentelemetry-node/package.json | 2 +- .../src/instrumentation/PluginLoader.ts | 2 +- .../src/instrumentation/utils.ts | 2 +- .../test/NodeTracer.test.ts | 2 +- .../test/instrumentation/PluginLoader.test.ts | 3 +- .../opentelemetry-plugin-dns/package.json | 2 +- packages/opentelemetry-plugin-dns/src/dns.ts | 2 +- .../opentelemetry-plugin-dns/src/types.ts | 2 +- .../opentelemetry-plugin-dns/src/utils.ts | 2 +- .../test/functionals/utils.test.ts | 2 +- .../test/integrations/dns-lookup.test.ts | 2 +- .../integrations/dnspromise-lookup.test.ts | 2 +- .../test/utils/assertSpan.ts | 2 +- .../package.json | 2 +- .../src/documentLoad.ts | 2 +- .../test/documentLoad.test.ts | 2 +- .../opentelemetry-plugin-grpc/package.json | 2 +- .../opentelemetry-plugin-grpc/src/grpc.ts | 2 +- .../opentelemetry-plugin-grpc/src/utils.ts | 2 +- .../test/grpc.test.ts | 4 +- .../test/utils/assertionUtils.ts | 2 +- .../opentelemetry-plugin-http/package.json | 2 +- .../opentelemetry-plugin-http/src/http.ts | 2 +- .../opentelemetry-plugin-http/src/types.ts | 2 +- .../opentelemetry-plugin-http/src/utils.ts | 2 +- .../test/functionals/http-disable.test.ts | 18 +-- .../test/functionals/http-enable.test.ts | 2 +- .../test/functionals/http-package.test.ts | 2 +- .../test/functionals/utils.test.ts | 2 +- .../test/integrations/http-enable.test.ts | 2 +- .../test/utils/DummyPropagation.ts | 2 +- .../test/utils/assertSpan.ts | 2 +- .../opentelemetry-plugin-https/package.json | 2 +- .../test/functionals/https-disable.test.ts | 2 +- .../test/functionals/https-enable.test.ts | 2 +- .../test/functionals/https-package.test.ts | 2 +- .../test/integrations/https-enable.test.ts | 2 +- .../test/utils/DummyPropagation.ts | 2 +- .../test/utils/assertSpan.ts | 2 +- .../opentelemetry-plugin-ioredis/package.json | 2 +- .../opentelemetry-plugin-ioredis/src/utils.ts | 2 +- .../test/ioredis.test.ts | 2 +- .../opentelemetry-plugin-mongodb/package.json | 2 +- .../src/mongodb.ts | 2 +- .../test/mongodb.test.ts | 2 +- .../opentelemetry-plugin-mysql/package.json | 2 +- .../opentelemetry-plugin-mysql/src/mysql.ts | 2 +- .../opentelemetry-plugin-mysql/src/utils.ts | 2 +- .../test/mysql.test.ts | 2 +- .../opentelemetry-plugin-pg-pool/package.json | 2 +- .../src/pg-pool.ts | 2 +- .../opentelemetry-plugin-pg-pool/src/utils.ts | 2 +- .../test/pg-pool.test.ts | 2 +- .../opentelemetry-plugin-pg/package.json | 2 +- .../opentelemetry-plugin-pg/src/pg.ts | 2 +- .../opentelemetry-plugin-pg/src/utils.ts | 2 +- .../opentelemetry-plugin-pg/test/pg.test.ts | 2 +- .../opentelemetry-plugin-redis/package.json | 2 +- .../opentelemetry-plugin-redis/src/utils.ts | 2 +- .../test/redis.test.ts | 2 +- .../package.json | 2 +- .../src/types.ts | 2 +- .../src/xhr.ts | 2 +- .../test/xhr.test.ts | 2 +- .../package.json | 2 +- .../src/JaegerHttpTraceFormat.ts | 2 +- .../test/JaegerHttpTraceFormat.test.ts | 2 +- .../package.json | 2 +- .../src/shim.ts | 2 +- .../opentelemetry-test-utils/package.json | 2 +- .../opentelemetry-test-utils/testUtils.ts | 8 +- packages/opentelemetry-tracing/README.md | 4 +- packages/opentelemetry-tracing/package.json | 2 +- .../src/BasicTracerRegistry.ts | 2 +- .../src/MultiSpanProcessor.ts | 2 +- .../src/NoopSpanProcessor.ts | 2 +- packages/opentelemetry-tracing/src/Span.ts | 2 +- .../src/SpanProcessor.ts | 2 +- packages/opentelemetry-tracing/src/Tracer.ts | 2 +- .../src/export/BatchSpanProcessor.ts | 2 +- .../src/export/ReadableSpan.ts | 2 +- .../src/export/SimpleSpanProcessor.ts | 2 +- packages/opentelemetry-tracing/src/types.ts | 2 +- .../test/BasicTracerRegistry.test.ts | 2 +- .../opentelemetry-tracing/test/Span.test.ts | 2 +- .../test/export/SimpleSpanProcessor.test.ts | 2 +- packages/opentelemetry-types/README.md | 29 ----- packages/opentelemetry-web/package.json | 2 +- packages/opentelemetry-web/src/utils.ts | 2 +- packages/opentelemetry-web/test/utils.test.ts | 2 +- 200 files changed, 599 insertions(+), 371 deletions(-) rename packages/{opentelemetry-types => opentelemetry-api}/LICENSE (100%) create mode 100644 packages/opentelemetry-api/README.md create mode 100644 packages/opentelemetry-api/karma.conf.js rename packages/{opentelemetry-types => opentelemetry-api}/package.json (50%) create mode 100644 packages/opentelemetry-api/src/api/metrics.ts create mode 100644 packages/opentelemetry-api/src/api/trace.ts rename packages/{opentelemetry-types => opentelemetry-api}/src/common/Logger.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/common/Time.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/context/propagation/BinaryFormat.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/context/propagation/HttpTextFormat.ts (100%) rename packages/{opentelemetry-core => opentelemetry-api}/src/context/propagation/NoopBinaryFormat.ts (86%) rename packages/{opentelemetry-core => opentelemetry-api}/src/context/propagation/NoopHttpTextFormat.ts (85%) rename packages/{opentelemetry-types => opentelemetry-api}/src/distributed_context/DistributedContext.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/distributed_context/EntryValue.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/index.ts (76%) rename packages/{opentelemetry-types => opentelemetry-api}/src/metrics/BoundInstrument.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/metrics/Meter.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/metrics/MeterRegistry.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/metrics/Metric.ts (100%) rename packages/{opentelemetry-core => opentelemetry-api}/src/metrics/NoopMeter.ts (92%) rename packages/{opentelemetry-core => opentelemetry-api}/src/metrics/NoopMeterRegistry.ts (69%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/Event.ts (100%) rename packages/{opentelemetry-core => opentelemetry-api}/src/trace/NoopSpan.ts (63%) rename packages/{opentelemetry-core => opentelemetry-api}/src/trace/NoopTracer.ts (88%) rename packages/{opentelemetry-core => opentelemetry-api}/src/trace/NoopTracerRegistry.ts (68%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/Sampler.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/SpanOptions.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/TimedEvent.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/attributes.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/instrumentation/Plugin.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/link.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/span.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/span_context.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/span_kind.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/status.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/trace_flags.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/trace_state.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/tracer.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/trace/tracer_registry.ts (100%) rename packages/{opentelemetry-types => opentelemetry-api}/src/version.ts (100%) rename packages/{opentelemetry-core/test/trace/globaltracer-utils.test.ts => opentelemetry-api/test/api/api.test.ts} (74%) create mode 100644 packages/opentelemetry-api/test/index-webpack.ts rename packages/{opentelemetry-core/test/metrics/NoopMeter.test.ts => opentelemetry-api/test/noop-implementations/noop-meter.test.ts} (94%) rename packages/{opentelemetry-core/test/trace/NoopSpan.test.ts => opentelemetry-api/test/noop-implementations/noop-span.test.ts} (87%) rename packages/{opentelemetry-core/test/trace/NoopTracer.test.ts => opentelemetry-api/test/noop-implementations/noop-tracer.test.ts} (92%) rename packages/{opentelemetry-types => opentelemetry-api}/tsconfig.json (100%) rename packages/{opentelemetry-types => opentelemetry-api}/tslint.json (100%) delete mode 100644 packages/opentelemetry-core/src/trace/globaltracer-utils.ts delete mode 100644 packages/opentelemetry-types/README.md diff --git a/.circleci/config.yml b/.circleci/config.yml index 49f2fb39df..4aa0ba01f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,7 +45,7 @@ cache_1: &cache_1 - ./yarn.lock - packages/opentelemetry-base/node_modules - packages/opentelemetry-scope-base/node_modules - - packages/opentelemetry-types/node_modules + - packages/opentelemetry-api/node_modules - packages/opentelemetry-scope-async-hooks/node_modules - packages/opentelemetry-core/node_modules - packages/opentelemetry-exporter-prometheus/node_modules @@ -169,7 +169,7 @@ jobs: name: Docs tests command: yarn docs-test - persist_to_workspace: - root: packages/opentelemetry-types/docs + root: packages/opentelemetry-api/docs paths: - out - run: @@ -184,7 +184,7 @@ jobs: steps: - checkout - attach_workspace: - at: packages/opentelemetry-types/docs + at: packages/opentelemetry-api/docs - run: name: Install and configure dependencies command: | @@ -196,7 +196,7 @@ jobs: - "1d:a3:60:b5:b4:8d:e7:8a:96:ce:6a:0a:e9:58:4c:54" - run: name: Deploy docs to gh-pages branch - command: gh-pages --dist packages/opentelemetry-types/docs/out + command: gh-pages --dist packages/opentelemetry-api/docs/out node8: docker: - image: node:8 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b434fd8640..78238cbced 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ The `opentelemetry-js` project is written in TypeScript. ### Generating API documentation -- `yarn docs` or `npm run docs` to generate API documentation. Generates the documentation in `packages/opentelemetry-types/docs/out` +- `yarn docs` or `npm run docs` to generate API documentation. Generates the documentation in `packages/opentelemetry-api/docs/out` ### Generating CHANGELOG documentation - `yarn changelog` or `npm run changelog` to generate CHANGELOG documentation in your terminal (see [RELEASING.md](RELEASING.md) for more details). diff --git a/README.md b/README.md index 525e3535db..abcf0681f4 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,8 @@ Maintainers ([@open-telemetry/js-maintainers](https://github.com/orgs/open-telem | Package | Description | | ----------------------- | -----------------| -| [@opentelemetry/types][otel-types] | This package provides TypeScript interfaces and enums for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser. | -| [@opentelemetry/core][otel-core] | This package provides default and no-op implementations of the OpenTelemetry types for trace and metrics. It's intended for use both on the server and in the browser. | +| [@opentelemetry/api][otel-api] | This package provides TypeScript interfaces and enums for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser. | +| [@opentelemetry/core][otel-core] | This package provides default and no-op implementations of the OpenTelemetry api for trace and metrics. It's intended for use both on the server and in the browser. | ### Implementation / SDKs @@ -195,5 +195,5 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [otel-shim-opentracing]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-shim-opentracing [otel-tracing]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-tracing [otel-web]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-web -[otel-types]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-types +[otel-api]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-api [otel-core]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-core diff --git a/doc/development-guide.md b/doc/development-guide.md index e5ce2fbc51..193684da43 100644 --- a/doc/development-guide.md +++ b/doc/development-guide.md @@ -77,4 +77,4 @@ To generate the docs, use: $ yarn docs ``` -The document will be available under `packages/opentelemetry-types/docs/out` path. +The document will be available under `packages/opentelemetry-api/docs/out` path. diff --git a/package.json b/package.json index 8f7b383bd1..edbbafbc9b 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "predocs-test": "yarn docs", "docs-test": "lerna run docs-test", "docs": "lerna run docs", - "docs-deploy": "gh-pages --dist packages/opentelemetry-types/docs/out", + "docs-deploy": "gh-pages --dist packages/opentelemetry-api/docs/out", "lint-examples": "eslint ./examples/**/*.js", "fix-examples": "eslint ./examples/**/*.js --fix" }, diff --git a/packages/opentelemetry-types/LICENSE b/packages/opentelemetry-api/LICENSE similarity index 100% rename from packages/opentelemetry-types/LICENSE rename to packages/opentelemetry-api/LICENSE diff --git a/packages/opentelemetry-api/README.md b/packages/opentelemetry-api/README.md new file mode 100644 index 0000000000..c58af54e75 --- /dev/null +++ b/packages/opentelemetry-api/README.md @@ -0,0 +1,123 @@ +# OpenTelemetry API for JavaScript +[![Gitter chat][gitter-image]][gitter-url] +[![NPM Published Version][npm-img]][npm-url] +[![dependencies][dependencies-image]][dependencies-url] +[![devDependencies][devDependencies-image]][devDependencies-url] +[![Apache License][license-image]][license-image] + +This package provides everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser. + +## Basic Use + +### API Entry Point + +API entry points are defined as global singleton objects `trace` and `metrics` which contain methods used to initialize SDK implementations and acquire resources from the API. + +- [Trace API Documentation][trace-api-docs] +- [Metrics API Documentation][metrics-api-docs] + +```javascript +const api = require("@opentelemetry/api") + +/* Initialize TraceRegistry */ +api.trace.initGlobalTracerRegistry(traceRegistry); +/* returns traceRegistry (no-op if a working registry has not been initialized) */ +api.trace.getTracerRegistry(); +/* returns a tracer from the registered global tracer registry (no-op if a working registry has not been initialized); */ +api.trace.getTracer(name, version); + +/* Initialize MeterRegistry */ +api.metrics.initGlobalMeterRegistry(meterRegistry); +/* returns meterRegistry (no-op if a working registry has not been initialized) */ +api.metrics.getMeterRegistry(); +/* returns a meter from the registered global meter registry (no-op if a working registry has not been initialized); */ +api.metrics.getMeter(name, version); +``` + +### Application Owners + +Application owners will also need a working OpenTelemetry SDK implementation. OpenTelemetry provides working SDK implementations for [web] and [node] for both [tracing] and [metrics]. + +#### Simple NodeJS Example + +Before any other module in your application is loaded, you must initialize the global tracer and meter registries. If you fail to initialize a registry, no-op implementations will be provided to any library which acquires them from the API. + +```javascript +const api = require("@opentelemetry/api"); +const sdk = require("@opentelemetry/node"); + +const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); +const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); + +// Initialize an exporter +const exporter = new JaegerExporter({ + serviceName: 'basic-service' +}); + +// Create a registry which we will configure as the global tracer registry +const registry = new sdk.NodeTracerRegistry(); + +// Configure span processor to send spans to the exporter +registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); + +// Initialize the OpenTelemetry APIs to use the NodeTracerRegistry bindings +api.trace.initGlobalTracerRegistry(registry); + +// your application code below this line +``` + +### Library Authors + +Library authors need only to depend on the `@opentelemetry/api` package and trust that the application owners which use their library will initialize an appropriate SDK. + +```javascript +const api = require("@opentelemetry/api"); + +const tracer = api.trace.getTracer("my-library-name", "0.2.3"); + +async function doSomething() { + const span = tracer.startSpan("doSomething", { parent: tracer.getCurrentSpan() }); + try { + const result = await doSomethingElse(); + span.end(); + return result; + } catch (err) { + span.setStatus({ + // use an appropriate status code here + code: api.CanonicalCode.INTERNAL, + message: err.message, + }); + span.end(); + return null; + } +} +``` + + +## Useful links +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us on [gitter][gitter-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg +[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-api +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api +[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-api +[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api&type=dev +[npm-url]: https://www.npmjs.com/package/@opentelemetry/api +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Ftypes.svg + +[trace-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/traceapi.html +[metrics-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/metricsapi.html + +[web]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-web +[tracing]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-tracing +[node]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node +[metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-metrics \ No newline at end of file diff --git a/packages/opentelemetry-api/karma.conf.js b/packages/opentelemetry-api/karma.conf.js new file mode 100644 index 0000000000..7183aab033 --- /dev/null +++ b/packages/opentelemetry-api/karma.conf.js @@ -0,0 +1,24 @@ +/*! + * Copyright 2019, OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const karmaWebpackConfig = require('../../karma.webpack'); +const karmaBaseConfig = require('../../karma.base'); + +module.exports = (config) => { + config.set(Object.assign({}, karmaBaseConfig, { + webpack: karmaWebpackConfig + })) +}; diff --git a/packages/opentelemetry-types/package.json b/packages/opentelemetry-api/package.json similarity index 50% rename from packages/opentelemetry-types/package.json rename to packages/opentelemetry-api/package.json index 8c8ae8bd88..e270187111 100644 --- a/packages/opentelemetry-types/package.json +++ b/packages/opentelemetry-api/package.json @@ -1,18 +1,22 @@ { - "name": "@opentelemetry/types", + "name": "@opentelemetry/api", "version": "0.3.3", - "description": "TypeScript types for OpenTelemetry", + "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", "repository": "open-telemetry/opentelemetry-js", "scripts": { + "test": "nyc ts-mocha -p tsconfig.json test/**/*.ts", + "test:browser": "nyc karma start --single-run", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", + "codecov:browser": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", "build": "npm run compile", "check": "gts check", "precompile": "tsc --version", "version:update": "node ../../scripts/version-update.js", "compile": "npm run version:update && tsc -p .", "fix": "gts fix", - "docs-test": "linkinator docs/out --skip david-dm.org", + "docs-test": "linkinator docs/out --silent --skip david-dm.org --skip https://open-telemetry.github.io/opentelemetry-js/classes/.+api.html", "docs": "typedoc --tsconfig tsconfig.json", "prepare": "npm run compile" }, @@ -42,11 +46,27 @@ "access": "public" }, "devDependencies": { + "@types/mocha": "^5.2.7", + "@types/node": "^12.6.8", + "@types/webpack-env": "1.13.9", + "codecov": "^3.6.1", "gts": "^1.1.0", + "istanbul-instrumenter-loader": "^3.0.1", + "karma-chrome-launcher": "^3.1.0", + "karma-coverage-istanbul-reporter": "^2.1.0", + "karma-mocha": "^1.3.0", + "karma-spec-reporter": "^0.0.32", + "karma-webpack": "^4.0.2", + "karma": "^4.4.1", "linkinator": "^1.5.0", + "mocha": "^6.1.0", + "nyc": "^14.1.1", + "ts-loader": "^6.0.4", + "ts-mocha": "^6.0.0", "tslint-consistent-codestyle": "^1.15.1", "tslint-microsoft-contrib": "^6.2.0", "typedoc": "^0.15.0", - "typescript": "3.7.2" + "typescript": "3.7.2", + "webpack": "^4.35.2" } } diff --git a/packages/opentelemetry-api/src/api/metrics.ts b/packages/opentelemetry-api/src/api/metrics.ts new file mode 100644 index 0000000000..80a1bf1c23 --- /dev/null +++ b/packages/opentelemetry-api/src/api/metrics.ts @@ -0,0 +1,61 @@ +/*! + * Copyright 2020, OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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 { Meter } from '../metrics/Meter'; +import { MeterRegistry } from '../metrics/MeterRegistry'; +import { NOOP_METER_REGISTRY } from '../metrics/NoopMeterRegistry'; + +/** + * Singleton object which represents the entry point to the OpenTelemetry Metrics API + */ +export class MetricsAPI { + private static _instance?: MetricsAPI; + private _meterRegistry: MeterRegistry = NOOP_METER_REGISTRY; + + /** Empty private constructor prevents end users from constructing a new instance of the API */ + private constructor() {} + + /** Get the singleton instance of the Metrics API */ + public static getInstance(): MetricsAPI { + if (!this._instance) { + this._instance = new MetricsAPI(); + } + + return this._instance; + } + + /** + * Set the current global meter. Returns the initialized global meter registry. + */ + public initGlobalMeterRegistry(registry: MeterRegistry): MeterRegistry { + this._meterRegistry = registry; + return registry; + } + + /** + * Returns the global meter registry. + */ + public getMeterRegistry(): MeterRegistry { + return this._meterRegistry; + } + + /** + * Returns a meter from the global meter registry. + */ + public getMeter(name: string, version?: string): Meter { + return this.getMeterRegistry().getMeter(name, version); + } +} diff --git a/packages/opentelemetry-api/src/api/trace.ts b/packages/opentelemetry-api/src/api/trace.ts new file mode 100644 index 0000000000..60b1a30c97 --- /dev/null +++ b/packages/opentelemetry-api/src/api/trace.ts @@ -0,0 +1,61 @@ +/*! + * Copyright 2020, OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * 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 { NOOP_TRACER_REGISTRY } from '../trace/NoopTracerRegistry'; +import { TracerRegistry } from '../trace/tracer_registry'; +import { Tracer } from '../trace/tracer'; + +/** + * Singleton object which represents the entry point to the OpenTelemetry Tracing API + */ +export class TraceAPI { + private static _instance?: TraceAPI; + private _tracerRegistry: TracerRegistry = NOOP_TRACER_REGISTRY; + + /** Empty private constructor prevents end users from constructing a new instance of the API */ + private constructor() {} + + /** Get the singleton instance of the Trace API */ + public static getInstance(): TraceAPI { + if (!this._instance) { + this._instance = new TraceAPI(); + } + + return this._instance; + } + + /** + * Set the current global tracer. Returns the initialized global tracer registry + */ + public initGlobalTracerRegistry(registry: TracerRegistry): TracerRegistry { + this._tracerRegistry = registry; + return registry; + } + + /** + * Returns the global tracer registry. + */ + public getTracerRegistry(): TracerRegistry { + return this._tracerRegistry; + } + + /** + * Returns a tracer from the global tracer registry. + */ + public getTracer(name: string, version?: string): Tracer { + return this.getTracerRegistry().getTracer(name, version); + } +} diff --git a/packages/opentelemetry-types/src/common/Logger.ts b/packages/opentelemetry-api/src/common/Logger.ts similarity index 100% rename from packages/opentelemetry-types/src/common/Logger.ts rename to packages/opentelemetry-api/src/common/Logger.ts diff --git a/packages/opentelemetry-types/src/common/Time.ts b/packages/opentelemetry-api/src/common/Time.ts similarity index 100% rename from packages/opentelemetry-types/src/common/Time.ts rename to packages/opentelemetry-api/src/common/Time.ts diff --git a/packages/opentelemetry-types/src/context/propagation/BinaryFormat.ts b/packages/opentelemetry-api/src/context/propagation/BinaryFormat.ts similarity index 100% rename from packages/opentelemetry-types/src/context/propagation/BinaryFormat.ts rename to packages/opentelemetry-api/src/context/propagation/BinaryFormat.ts diff --git a/packages/opentelemetry-types/src/context/propagation/HttpTextFormat.ts b/packages/opentelemetry-api/src/context/propagation/HttpTextFormat.ts similarity index 100% rename from packages/opentelemetry-types/src/context/propagation/HttpTextFormat.ts rename to packages/opentelemetry-api/src/context/propagation/HttpTextFormat.ts diff --git a/packages/opentelemetry-core/src/context/propagation/NoopBinaryFormat.ts b/packages/opentelemetry-api/src/context/propagation/NoopBinaryFormat.ts similarity index 86% rename from packages/opentelemetry-core/src/context/propagation/NoopBinaryFormat.ts rename to packages/opentelemetry-api/src/context/propagation/NoopBinaryFormat.ts index b1428617e2..effec6183f 100644 --- a/packages/opentelemetry-core/src/context/propagation/NoopBinaryFormat.ts +++ b/packages/opentelemetry-api/src/context/propagation/NoopBinaryFormat.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import { SpanContext, BinaryFormat } from '@opentelemetry/types'; +import { SpanContext } from '../../trace/span_context'; +import { BinaryFormat } from './BinaryFormat'; /** * No-op implementations of {@link BinaryFormat}. */ -class NoopBinaryFormat implements BinaryFormat { +export class NoopBinaryFormat implements BinaryFormat { private readonly _buff = new ArrayBuffer(0); // By default does nothing toBytes(spanContext: SpanContext): ArrayBuffer { diff --git a/packages/opentelemetry-core/src/context/propagation/NoopHttpTextFormat.ts b/packages/opentelemetry-api/src/context/propagation/NoopHttpTextFormat.ts similarity index 85% rename from packages/opentelemetry-core/src/context/propagation/NoopHttpTextFormat.ts rename to packages/opentelemetry-api/src/context/propagation/NoopHttpTextFormat.ts index 2cc71b971e..7596dd96b3 100644 --- a/packages/opentelemetry-core/src/context/propagation/NoopHttpTextFormat.ts +++ b/packages/opentelemetry-api/src/context/propagation/NoopHttpTextFormat.ts @@ -14,12 +14,13 @@ * limitations under the License. */ -import { HttpTextFormat, SpanContext } from '@opentelemetry/types'; +import { SpanContext } from '../../trace/span_context'; +import { HttpTextFormat } from './HttpTextFormat'; /** * No-op implementations of {@link HttpTextFormat}. */ -class NoopHttpTextFormat implements HttpTextFormat { +export class NoopHttpTextFormat implements HttpTextFormat { // By default does nothing inject(spanContext: SpanContext, format: string, carrier: unknown): void {} // By default does nothing diff --git a/packages/opentelemetry-types/src/distributed_context/DistributedContext.ts b/packages/opentelemetry-api/src/distributed_context/DistributedContext.ts similarity index 100% rename from packages/opentelemetry-types/src/distributed_context/DistributedContext.ts rename to packages/opentelemetry-api/src/distributed_context/DistributedContext.ts diff --git a/packages/opentelemetry-types/src/distributed_context/EntryValue.ts b/packages/opentelemetry-api/src/distributed_context/EntryValue.ts similarity index 100% rename from packages/opentelemetry-types/src/distributed_context/EntryValue.ts rename to packages/opentelemetry-api/src/distributed_context/EntryValue.ts diff --git a/packages/opentelemetry-types/src/index.ts b/packages/opentelemetry-api/src/index.ts similarity index 76% rename from packages/opentelemetry-types/src/index.ts rename to packages/opentelemetry-api/src/index.ts index e8f77714d3..d73844a715 100644 --- a/packages/opentelemetry-types/src/index.ts +++ b/packages/opentelemetry-api/src/index.ts @@ -39,3 +39,21 @@ export * from './trace/tracer'; export * from './trace/tracer_registry'; export * from './trace/trace_flags'; export * from './trace/trace_state'; +export * from './trace/NoopSpan'; +export * from './trace/NoopTracer'; +export * from './trace/NoopTracerRegistry'; +export * from './metrics/NoopMeterRegistry'; +export * from './metrics/NoopMeter'; + +import { TraceAPI } from './api/trace'; +/** Entrypoint for trace API */ +export const trace = TraceAPI.getInstance(); + +import { MetricsAPI } from './api/metrics'; +/** Entrypoint for metrics API */ +export const metrics = MetricsAPI.getInstance(); + +export default { + trace, + metrics, +}; diff --git a/packages/opentelemetry-types/src/metrics/BoundInstrument.ts b/packages/opentelemetry-api/src/metrics/BoundInstrument.ts similarity index 100% rename from packages/opentelemetry-types/src/metrics/BoundInstrument.ts rename to packages/opentelemetry-api/src/metrics/BoundInstrument.ts diff --git a/packages/opentelemetry-types/src/metrics/Meter.ts b/packages/opentelemetry-api/src/metrics/Meter.ts similarity index 100% rename from packages/opentelemetry-types/src/metrics/Meter.ts rename to packages/opentelemetry-api/src/metrics/Meter.ts diff --git a/packages/opentelemetry-types/src/metrics/MeterRegistry.ts b/packages/opentelemetry-api/src/metrics/MeterRegistry.ts similarity index 100% rename from packages/opentelemetry-types/src/metrics/MeterRegistry.ts rename to packages/opentelemetry-api/src/metrics/MeterRegistry.ts diff --git a/packages/opentelemetry-types/src/metrics/Metric.ts b/packages/opentelemetry-api/src/metrics/Metric.ts similarity index 100% rename from packages/opentelemetry-types/src/metrics/Metric.ts rename to packages/opentelemetry-api/src/metrics/Metric.ts diff --git a/packages/opentelemetry-core/src/metrics/NoopMeter.ts b/packages/opentelemetry-api/src/metrics/NoopMeter.ts similarity index 92% rename from packages/opentelemetry-core/src/metrics/NoopMeter.ts rename to packages/opentelemetry-api/src/metrics/NoopMeter.ts index 5e63905ae5..c39a664aa5 100644 --- a/packages/opentelemetry-core/src/metrics/NoopMeter.ts +++ b/packages/opentelemetry-api/src/metrics/NoopMeter.ts @@ -14,19 +14,11 @@ * limitations under the License. */ -import { - BoundCounter, - DistributedContext, - BoundGauge, - Meter, - Metric, - MetricOptions, - MetricUtils, - BoundMeasure, - SpanContext, - LabelSet, - Labels, -} from '@opentelemetry/types'; +import { Meter } from './Meter'; +import { MetricOptions, Metric, Labels, LabelSet, MetricUtils } from './Metric'; +import { BoundMeasure, BoundCounter, BoundGauge } from './BoundInstrument'; +import { DistributedContext } from '../distributed_context/DistributedContext'; +import { SpanContext } from '../trace/span_context'; /** * NoopMeter is a noop implementation of the {@link Meter} interface. It reuses constant @@ -165,7 +157,7 @@ export class NoopBoundMeasure implements BoundMeasure { } } -export const noopMeter = new NoopMeter(); +export const NOOP_METER = new NoopMeter(); export const NOOP_BOUND_GAUGE = new NoopBoundGauge(); export const NOOP_GAUGE_METRIC = new NoopGaugeMetric(NOOP_BOUND_GAUGE); diff --git a/packages/opentelemetry-core/src/metrics/NoopMeterRegistry.ts b/packages/opentelemetry-api/src/metrics/NoopMeterRegistry.ts similarity index 69% rename from packages/opentelemetry-core/src/metrics/NoopMeterRegistry.ts rename to packages/opentelemetry-api/src/metrics/NoopMeterRegistry.ts index ab2a28e0ec..81911dd733 100644 --- a/packages/opentelemetry-core/src/metrics/NoopMeterRegistry.ts +++ b/packages/opentelemetry-api/src/metrics/NoopMeterRegistry.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; -import { noopMeter } from './NoopMeter'; +import { Meter } from './Meter'; +import { MeterRegistry } from './MeterRegistry'; +import { NOOP_METER } from './NoopMeter'; /** * An implementation of the {@link MeterRegistry} which returns an impotent Meter * for all calls to `getMeter` */ -export class NoopMeterRegistry implements types.MeterRegistry { - getMeter(_name?: string, _version?: string): types.Meter { - return noopMeter; +export class NoopMeterRegistry implements MeterRegistry { + getMeter(_name?: string, _version?: string): Meter { + return NOOP_METER; } } + +export const NOOP_METER_REGISTRY = new NoopMeterRegistry(); diff --git a/packages/opentelemetry-types/src/trace/Event.ts b/packages/opentelemetry-api/src/trace/Event.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/Event.ts rename to packages/opentelemetry-api/src/trace/Event.ts diff --git a/packages/opentelemetry-core/src/trace/NoopSpan.ts b/packages/opentelemetry-api/src/trace/NoopSpan.ts similarity index 63% rename from packages/opentelemetry-core/src/trace/NoopSpan.ts rename to packages/opentelemetry-api/src/trace/NoopSpan.ts index a6fb36da30..cfa3c9c4c0 100644 --- a/packages/opentelemetry-core/src/trace/NoopSpan.ts +++ b/packages/opentelemetry-api/src/trace/NoopSpan.ts @@ -14,21 +14,33 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; -import { INVALID_SPAN_CONTEXT } from '../trace/spancontext-utils'; +import { TimeInput } from '../common/Time'; +import { Attributes } from './attributes'; +import { Span } from './span'; +import { SpanContext } from './span_context'; +import { Status } from './status'; +import { TraceFlags } from './trace_flags'; + +export const INVALID_TRACE_ID = '0'; +export const INVALID_SPAN_ID = '0'; +const INVALID_SPAN_CONTEXT: SpanContext = { + traceId: INVALID_TRACE_ID, + spanId: INVALID_SPAN_ID, + traceFlags: TraceFlags.UNSAMPLED, +}; /** * The NoopSpan is the default {@link Span} that is used when no Span * implementation is available. All operations are no-op including context * propagation. */ -export class NoopSpan implements types.Span { +export class NoopSpan implements Span { constructor( - private readonly _spanContext: types.SpanContext = INVALID_SPAN_CONTEXT + private readonly _spanContext: SpanContext = INVALID_SPAN_CONTEXT ) {} // Returns a SpanContext. - context(): types.SpanContext { + context(): SpanContext { return this._spanContext; } @@ -38,22 +50,22 @@ export class NoopSpan implements types.Span { } // By default does nothing - setAttributes(attributes: types.Attributes): this { + setAttributes(attributes: Attributes): this { return this; } // By default does nothing - addEvent(name: string, attributes?: types.Attributes): this { + addEvent(name: string, attributes?: Attributes): this { return this; } // By default does nothing - addLink(spanContext: types.SpanContext, attributes?: types.Attributes): this { + addLink(spanContext: SpanContext, attributes?: Attributes): this { return this; } // By default does nothing - setStatus(status: types.Status): this { + setStatus(status: Status): this { return this; } @@ -63,7 +75,7 @@ export class NoopSpan implements types.Span { } // By default does nothing - end(endTime?: types.TimeInput): void {} + end(endTime?: TimeInput): void {} // isRecording always returns false for noopSpan. isRecording(): boolean { diff --git a/packages/opentelemetry-core/src/trace/NoopTracer.ts b/packages/opentelemetry-api/src/trace/NoopTracer.ts similarity index 88% rename from packages/opentelemetry-core/src/trace/NoopTracer.ts rename to packages/opentelemetry-api/src/trace/NoopTracer.ts index bd569977fa..27e47a9093 100644 --- a/packages/opentelemetry-core/src/trace/NoopTracer.ts +++ b/packages/opentelemetry-api/src/trace/NoopTracer.ts @@ -1,5 +1,5 @@ /*! - * Copyright 2019, OpenTelemetry Authors + * Copyright 2020, OpenTelemetry Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,15 +14,9 @@ * limitations under the License. */ -import { - Tracer, - SpanOptions, - Span, - HttpTextFormat, - BinaryFormat, -} from '@opentelemetry/types'; -import { NOOP_HTTP_TEXT_FORMAT } from '../context/propagation/NoopHttpTextFormat'; +import { BinaryFormat, HttpTextFormat, Span, SpanOptions, Tracer } from '..'; import { NOOP_BINARY_FORMAT } from '../context/propagation/NoopBinaryFormat'; +import { NOOP_HTTP_TEXT_FORMAT } from '../context/propagation/NoopHttpTextFormat'; import { NOOP_SPAN } from './NoopSpan'; /** @@ -60,4 +54,4 @@ export class NoopTracer implements Tracer { } } -export const noopTracer = new NoopTracer(); +export const NOOP_TRACER = new NoopTracer(); diff --git a/packages/opentelemetry-core/src/trace/NoopTracerRegistry.ts b/packages/opentelemetry-api/src/trace/NoopTracerRegistry.ts similarity index 68% rename from packages/opentelemetry-core/src/trace/NoopTracerRegistry.ts rename to packages/opentelemetry-api/src/trace/NoopTracerRegistry.ts index 701dd9d3bf..c28e99af89 100644 --- a/packages/opentelemetry-core/src/trace/NoopTracerRegistry.ts +++ b/packages/opentelemetry-api/src/trace/NoopTracerRegistry.ts @@ -14,15 +14,18 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; -import { noopTracer } from './NoopTracer'; +import { NOOP_TRACER } from './NoopTracer'; +import { Tracer } from './tracer'; +import { TracerRegistry } from './tracer_registry'; /** * An implementation of the {@link TracerRegistry} which returns an impotent Tracer * for all calls to `getTracer` */ -export class NoopTracerRegistry implements types.TracerRegistry { - getTracer(_name?: string, _version?: string): types.Tracer { - return noopTracer; +export class NoopTracerRegistry implements TracerRegistry { + getTracer(_name?: string, _version?: string): Tracer { + return NOOP_TRACER; } } + +export const NOOP_TRACER_REGISTRY = new NoopTracerRegistry(); diff --git a/packages/opentelemetry-types/src/trace/Sampler.ts b/packages/opentelemetry-api/src/trace/Sampler.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/Sampler.ts rename to packages/opentelemetry-api/src/trace/Sampler.ts diff --git a/packages/opentelemetry-types/src/trace/SpanOptions.ts b/packages/opentelemetry-api/src/trace/SpanOptions.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/SpanOptions.ts rename to packages/opentelemetry-api/src/trace/SpanOptions.ts diff --git a/packages/opentelemetry-types/src/trace/TimedEvent.ts b/packages/opentelemetry-api/src/trace/TimedEvent.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/TimedEvent.ts rename to packages/opentelemetry-api/src/trace/TimedEvent.ts diff --git a/packages/opentelemetry-types/src/trace/attributes.ts b/packages/opentelemetry-api/src/trace/attributes.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/attributes.ts rename to packages/opentelemetry-api/src/trace/attributes.ts diff --git a/packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts b/packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/instrumentation/Plugin.ts rename to packages/opentelemetry-api/src/trace/instrumentation/Plugin.ts diff --git a/packages/opentelemetry-types/src/trace/link.ts b/packages/opentelemetry-api/src/trace/link.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/link.ts rename to packages/opentelemetry-api/src/trace/link.ts diff --git a/packages/opentelemetry-types/src/trace/span.ts b/packages/opentelemetry-api/src/trace/span.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/span.ts rename to packages/opentelemetry-api/src/trace/span.ts diff --git a/packages/opentelemetry-types/src/trace/span_context.ts b/packages/opentelemetry-api/src/trace/span_context.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/span_context.ts rename to packages/opentelemetry-api/src/trace/span_context.ts diff --git a/packages/opentelemetry-types/src/trace/span_kind.ts b/packages/opentelemetry-api/src/trace/span_kind.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/span_kind.ts rename to packages/opentelemetry-api/src/trace/span_kind.ts diff --git a/packages/opentelemetry-types/src/trace/status.ts b/packages/opentelemetry-api/src/trace/status.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/status.ts rename to packages/opentelemetry-api/src/trace/status.ts diff --git a/packages/opentelemetry-types/src/trace/trace_flags.ts b/packages/opentelemetry-api/src/trace/trace_flags.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/trace_flags.ts rename to packages/opentelemetry-api/src/trace/trace_flags.ts diff --git a/packages/opentelemetry-types/src/trace/trace_state.ts b/packages/opentelemetry-api/src/trace/trace_state.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/trace_state.ts rename to packages/opentelemetry-api/src/trace/trace_state.ts diff --git a/packages/opentelemetry-types/src/trace/tracer.ts b/packages/opentelemetry-api/src/trace/tracer.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/tracer.ts rename to packages/opentelemetry-api/src/trace/tracer.ts diff --git a/packages/opentelemetry-types/src/trace/tracer_registry.ts b/packages/opentelemetry-api/src/trace/tracer_registry.ts similarity index 100% rename from packages/opentelemetry-types/src/trace/tracer_registry.ts rename to packages/opentelemetry-api/src/trace/tracer_registry.ts diff --git a/packages/opentelemetry-types/src/version.ts b/packages/opentelemetry-api/src/version.ts similarity index 100% rename from packages/opentelemetry-types/src/version.ts rename to packages/opentelemetry-api/src/version.ts diff --git a/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts b/packages/opentelemetry-api/test/api/api.test.ts similarity index 74% rename from packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts rename to packages/opentelemetry-api/test/api/api.test.ts index 71f1051eba..d77b252cf7 100644 --- a/packages/opentelemetry-core/test/trace/globaltracer-utils.test.ts +++ b/packages/opentelemetry-api/test/api/api.test.ts @@ -15,15 +15,9 @@ */ import * as assert from 'assert'; -import * as types from '@opentelemetry/types'; -import { - getTracerRegistry, - initGlobalTracerRegistry, -} from '../../src/trace/globaltracer-utils'; -import { NoopTracer, NoopSpan } from '../../src'; -import { NoopTracerRegistry } from '../../src/trace/NoopTracerRegistry'; +import api, { TraceFlags, NoopSpan, NoopTracerRegistry, NoopTracer, SpanOptions, Span } from '../../src'; -describe('globaltracer-utils', () => { +describe('API', () => { const functions = [ 'getCurrentSpan', 'startSpan', @@ -33,7 +27,7 @@ describe('globaltracer-utils', () => { ]; it('should expose a tracer registry via getTracerRegistry', () => { - const tracer = getTracerRegistry(); + const tracer = api.trace.getTracerRegistry(); assert.ok(tracer); assert.strictEqual(typeof tracer, 'object'); }); @@ -42,17 +36,17 @@ describe('globaltracer-utils', () => { const spanContext = { traceId: 'd4cda95b652f4a1592b449d5929fda1b', spanId: '6e0c63257de34c92', - traceFlags: types.TraceFlags.UNSAMPLED, + traceFlags: TraceFlags.UNSAMPLED, }; const dummySpan = new NoopSpan(spanContext); afterEach(() => { - initGlobalTracerRegistry(new NoopTracerRegistry()); + api.trace.initGlobalTracerRegistry(new NoopTracerRegistry()); }); it('should not crash', () => { functions.forEach(fn => { - const tracer = getTracerRegistry(); + const tracer = api.trace.getTracerRegistry(); try { ((tracer as unknown) as { [fn: string]: Function })[fn](); // Try to run the function assert.ok(true, fn); @@ -65,8 +59,8 @@ describe('globaltracer-utils', () => { }); it('should use the global tracer registry', () => { - initGlobalTracerRegistry(new TestTracerRegistry()); - const tracer = getTracerRegistry().getTracer('name'); + api.trace.initGlobalTracerRegistry(new TestTracerRegistry()); + const tracer = api.trace.getTracerRegistry().getTracer('name'); const span = tracer.startSpan('test'); assert.deepStrictEqual(span, dummySpan); }); @@ -74,8 +68,8 @@ describe('globaltracer-utils', () => { class TestTracer extends NoopTracer { startSpan( name: string, - options?: types.SpanOptions | undefined - ): types.Span { + options?: SpanOptions | undefined + ): Span { return dummySpan; } } diff --git a/packages/opentelemetry-api/test/index-webpack.ts b/packages/opentelemetry-api/test/index-webpack.ts new file mode 100644 index 0000000000..7731f09091 --- /dev/null +++ b/packages/opentelemetry-api/test/index-webpack.ts @@ -0,0 +1,23 @@ +/*! + * Copyright 2019, OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// This file is the webpack entry point for the browser Karma tests. It requires +// all modules ending in "test" from the current folder and all its subfolders. +const testsContext = require.context('.', true, /test$/); +testsContext.keys().forEach(testsContext); + +const srcContext = require.context('.', true, /src$/); +srcContext.keys().forEach(srcContext); diff --git a/packages/opentelemetry-core/test/metrics/NoopMeter.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts similarity index 94% rename from packages/opentelemetry-core/test/metrics/NoopMeter.test.ts rename to packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts index 1e15fdb6b5..a8a0a189c5 100644 --- a/packages/opentelemetry-core/test/metrics/NoopMeter.test.ts +++ b/packages/opentelemetry-api/test/noop-implementations/noop-meter.test.ts @@ -16,15 +16,16 @@ import * as assert from 'assert'; import { - NOOP_BOUND_GAUGE, - NOOP_GAUGE_METRIC, + Labels, + NoopMeterRegistry, NOOP_BOUND_COUNTER, - NOOP_COUNTER_METRIC, + NOOP_BOUND_GAUGE, NOOP_BOUND_MEASURE, - NOOP_MEASURE_METRIC, -} from '../../src/metrics/NoopMeter'; -import { Labels } from '@opentelemetry/types'; -import { NoopMeterRegistry } from '../../src/metrics/NoopMeterRegistry'; + NOOP_COUNTER_METRIC, + NOOP_GAUGE_METRIC, + NOOP_MEASURE_METRIC +} from '../../src'; + describe('NoopMeter', () => { it('should not crash', () => { diff --git a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts similarity index 87% rename from packages/opentelemetry-core/test/trace/NoopSpan.test.ts rename to packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts index 468c42947d..0350a9ab53 100644 --- a/packages/opentelemetry-core/test/trace/NoopSpan.test.ts +++ b/packages/opentelemetry-api/test/noop-implementations/noop-span.test.ts @@ -15,9 +15,7 @@ */ import * as assert from 'assert'; -import { NoopSpan } from '../../src/trace/NoopSpan'; -import { CanonicalCode, TraceFlags } from '@opentelemetry/types'; -import { INVALID_TRACEID, INVALID_SPANID } from '../../src'; +import { CanonicalCode, INVALID_SPAN_ID, INVALID_TRACE_ID, NoopSpan, TraceFlags } from '../../src'; describe('NoopSpan', () => { it('do not crash', () => { @@ -53,8 +51,8 @@ describe('NoopSpan', () => { assert.ok(!span.isRecording()); assert.deepStrictEqual(span.context(), { - traceId: INVALID_TRACEID, - spanId: INVALID_SPANID, + traceId: INVALID_TRACE_ID, + spanId: INVALID_SPAN_ID, traceFlags: TraceFlags.UNSAMPLED, }); span.end(); diff --git a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts similarity index 92% rename from packages/opentelemetry-core/test/trace/NoopTracer.test.ts rename to packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts index 892e082105..32dd6813ed 100644 --- a/packages/opentelemetry-core/test/trace/NoopTracer.test.ts +++ b/packages/opentelemetry-api/test/noop-implementations/noop-tracer.test.ts @@ -15,9 +15,7 @@ */ import * as assert from 'assert'; -import { NoopTracer } from '../../src/trace/NoopTracer'; -import { NOOP_SPAN } from '../../src/trace/NoopSpan'; -import { SpanKind } from '@opentelemetry/types'; +import { NoopTracer, NOOP_SPAN, SpanKind } from '../../src'; describe('NoopTracer', () => { it('should not crash', () => { diff --git a/packages/opentelemetry-types/tsconfig.json b/packages/opentelemetry-api/tsconfig.json similarity index 100% rename from packages/opentelemetry-types/tsconfig.json rename to packages/opentelemetry-api/tsconfig.json diff --git a/packages/opentelemetry-types/tslint.json b/packages/opentelemetry-api/tslint.json similarity index 100% rename from packages/opentelemetry-types/tslint.json rename to packages/opentelemetry-api/tslint.json diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index a96e8caea4..d4356dbe87 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -78,7 +78,7 @@ "webpack": "^4.35.2" }, "dependencies": { - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "semver": "^6.3.0" } } diff --git a/packages/opentelemetry-core/src/common/ConsoleLogger.ts b/packages/opentelemetry-core/src/common/ConsoleLogger.ts index 172dc627fe..3028b9d2b0 100644 --- a/packages/opentelemetry-core/src/common/ConsoleLogger.ts +++ b/packages/opentelemetry-core/src/common/ConsoleLogger.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; import { LogLevel } from './types'; export class ConsoleLogger implements Logger { diff --git a/packages/opentelemetry-core/src/common/NoopLogger.ts b/packages/opentelemetry-core/src/common/NoopLogger.ts index e0db5863c8..f0b1edd1d3 100644 --- a/packages/opentelemetry-core/src/common/NoopLogger.ts +++ b/packages/opentelemetry-core/src/common/NoopLogger.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; /** No-op implementation of Logger */ export class NoopLogger implements Logger { diff --git a/packages/opentelemetry-core/src/common/time.ts b/packages/opentelemetry-core/src/common/time.ts index 861c9efc44..13416ca2d7 100644 --- a/packages/opentelemetry-core/src/common/time.ts +++ b/packages/opentelemetry-core/src/common/time.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { otperformance as performance } from '../platform'; import { TimeOriginLegacy } from './types'; diff --git a/packages/opentelemetry-core/src/context/propagation/B3Format.ts b/packages/opentelemetry-core/src/context/propagation/B3Format.ts index fe8ed5f1cb..2363edc3c7 100644 --- a/packages/opentelemetry-core/src/context/propagation/B3Format.ts +++ b/packages/opentelemetry-core/src/context/propagation/B3Format.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanContext, HttpTextFormat, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, HttpTextFormat, TraceFlags } from '@opentelemetry/api'; export const X_B3_TRACE_ID = 'x-b3-traceid'; export const X_B3_SPAN_ID = 'x-b3-spanid'; diff --git a/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts index 6d44ca7894..ebcd0391cd 100644 --- a/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts +++ b/packages/opentelemetry-core/src/context/propagation/BinaryTraceContext.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { BinaryFormat, SpanContext, TraceFlags } from '@opentelemetry/types'; +import { BinaryFormat, SpanContext, TraceFlags } from '@opentelemetry/api'; const VERSION_ID = 0; const TRACE_ID_FIELD_ID = 0; diff --git a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts index 9e42f991c2..cf9860014f 100644 --- a/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts +++ b/packages/opentelemetry-core/src/context/propagation/HttpTraceContext.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HttpTextFormat, SpanContext, TraceFlags } from '@opentelemetry/types'; +import { HttpTextFormat, SpanContext, TraceFlags } from '@opentelemetry/api'; import { TraceState } from '../../trace/TraceState'; export const TRACE_PARENT_HEADER = 'traceparent'; diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts index 582101ab1e..f1d0611e27 100644 --- a/packages/opentelemetry-core/src/index.ts +++ b/packages/opentelemetry-core/src/index.ts @@ -23,15 +23,10 @@ export * from './context/propagation/B3Format'; export * from './context/propagation/BinaryTraceContext'; export * from './context/propagation/HttpTraceContext'; export * from './platform'; -export * from './trace/globaltracer-utils'; export * from './trace/instrumentation/BasePlugin'; -export * from './trace/NoopSpan'; -export * from './trace/NoopTracer'; -export * from './trace/NoopTracerRegistry'; export * from './trace/NoRecordingSpan'; export * from './trace/sampler/ProbabilitySampler'; export * from './trace/spancontext-utils'; export * from './trace/TraceState'; -export * from './metrics/NoopMeter'; export * from './utils/url'; export * from './utils/wrap'; diff --git a/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts b/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts index 464a8fa1a9..cf2920ab37 100644 --- a/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts +++ b/packages/opentelemetry-core/src/trace/NoRecordingSpan.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import { NoopSpan } from './NoopSpan'; -import { SpanContext } from '@opentelemetry/types'; +import { SpanContext, NoopSpan } from '@opentelemetry/api'; import { INVALID_SPAN_CONTEXT } from '../trace/spancontext-utils'; /** diff --git a/packages/opentelemetry-core/src/trace/TraceState.ts b/packages/opentelemetry-core/src/trace/TraceState.ts index 50aeee7006..cb42e83b64 100644 --- a/packages/opentelemetry-core/src/trace/TraceState.ts +++ b/packages/opentelemetry-core/src/trace/TraceState.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { validateKey, validateValue } from '../internal/validators'; const MAX_TRACE_STATE_ITEMS = 32; diff --git a/packages/opentelemetry-core/src/trace/globaltracer-utils.ts b/packages/opentelemetry-core/src/trace/globaltracer-utils.ts deleted file mode 100644 index f61180dc8f..0000000000 --- a/packages/opentelemetry-core/src/trace/globaltracer-utils.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * Copyright 2019, 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 * as types from '@opentelemetry/types'; -import { NoopTracerRegistry } from './NoopTracerRegistry'; - -let globalTracerRegistry: types.TracerRegistry = new NoopTracerRegistry(); - -/** - * Set the current global tracer. Returns the initialized global tracer - */ -export function initGlobalTracerRegistry( - tracerRegistry: types.TracerRegistry -): types.TracerRegistry { - return (globalTracerRegistry = tracerRegistry); -} - -/** - * Returns the global tracer registry. - */ -export function getTracerRegistry(): types.TracerRegistry { - // Return the global tracer registry - return globalTracerRegistry; -} - -/** - * Returns a tracer from the global tracer registry. - */ -export function getTracer(name: string, version?: string): types.Tracer { - // Return the global tracer registry - return globalTracerRegistry.getTracer(name, version); -} diff --git a/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts b/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts index 04ccc60b26..af3749b58d 100644 --- a/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts +++ b/packages/opentelemetry-core/src/trace/instrumentation/BasePlugin.ts @@ -22,7 +22,7 @@ import { PluginInternalFiles, PluginInternalFilesVersion, TracerRegistry, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import * as semver from 'semver'; import * as path from 'path'; diff --git a/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts b/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts index 3960e8675a..e76f5cc5b8 100644 --- a/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts +++ b/packages/opentelemetry-core/src/trace/sampler/ProbabilitySampler.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Sampler, SpanContext } from '@opentelemetry/types'; +import { Sampler, SpanContext } from '@opentelemetry/api'; /** Sampler that samples a given fraction of traces. */ export class ProbabilitySampler implements Sampler { diff --git a/packages/opentelemetry-core/src/trace/spancontext-utils.ts b/packages/opentelemetry-core/src/trace/spancontext-utils.ts index a6491b82cb..1f20afd234 100644 --- a/packages/opentelemetry-core/src/trace/spancontext-utils.ts +++ b/packages/opentelemetry-core/src/trace/spancontext-utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanContext, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, TraceFlags } from '@opentelemetry/api'; export const INVALID_SPANID = '0'; export const INVALID_TRACEID = '0'; diff --git a/packages/opentelemetry-core/test/common/time.test.ts b/packages/opentelemetry-core/test/common/time.test.ts index a65af498fc..54bfa6e09e 100644 --- a/packages/opentelemetry-core/test/common/time.test.ts +++ b/packages/opentelemetry-core/test/common/time.test.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import { otperformance as performance } from '../../src/platform'; import * as sinon from 'sinon'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { hrTime, timeInputToHrTime, diff --git a/packages/opentelemetry-core/test/context/B3Format.test.ts b/packages/opentelemetry-core/test/context/B3Format.test.ts index b5d2b530d3..97087e076a 100644 --- a/packages/opentelemetry-core/test/context/B3Format.test.ts +++ b/packages/opentelemetry-core/test/context/B3Format.test.ts @@ -21,7 +21,7 @@ import { X_B3_SPAN_ID, X_B3_SAMPLED, } from '../../src/context/propagation/B3Format'; -import { SpanContext, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, TraceFlags } from '@opentelemetry/api'; import { TraceState } from '../../src/trace/TraceState'; describe('B3Format', () => { diff --git a/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts b/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts index fae99249a8..0b5c303fd4 100644 --- a/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts +++ b/packages/opentelemetry-core/test/context/BinaryTraceContext.test.ts @@ -16,7 +16,7 @@ import * as assert from 'assert'; import { BinaryTraceContext } from '../../src/context/propagation/BinaryTraceContext'; -import { SpanContext, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, TraceFlags } from '@opentelemetry/api'; describe('BinaryTraceContext', () => { const binaryTraceContext = new BinaryTraceContext(); diff --git a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts index 4d212b2f85..28cbf335b4 100644 --- a/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts +++ b/packages/opentelemetry-core/test/context/HttpTraceContext.test.ts @@ -20,7 +20,7 @@ import { TRACE_PARENT_HEADER, TRACE_STATE_HEADER, } from '../../src/context/propagation/HttpTraceContext'; -import { SpanContext, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, TraceFlags } from '@opentelemetry/api'; import { TraceState } from '../../src/trace/TraceState'; describe('HttpTraceContext', () => { diff --git a/packages/opentelemetry-core/test/trace/BasePlugin.test.ts b/packages/opentelemetry-core/test/trace/BasePlugin.test.ts index 2841903009..7a83452831 100644 --- a/packages/opentelemetry-core/test/trace/BasePlugin.test.ts +++ b/packages/opentelemetry-core/test/trace/BasePlugin.test.ts @@ -14,10 +14,10 @@ * limitations under the License. */ +import { NoopTracerRegistry } from '@opentelemetry/api'; import * as assert from 'assert'; import * as path from 'path'; import { BasePlugin, NoopLogger } from '../../src'; -import { NoopTracerRegistry } from '../../src/trace/NoopTracerRegistry'; import * as types from './fixtures/test-package/foo/bar/internal'; const registry = new NoopTracerRegistry(); diff --git a/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts b/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts index 574ce36ea9..f1706f733e 100644 --- a/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts +++ b/packages/opentelemetry-core/test/trace/NoRecordingSpan.test.ts @@ -16,7 +16,7 @@ import * as assert from 'assert'; import { NoRecordingSpan } from '../../src/trace/NoRecordingSpan'; -import { TraceFlags } from '@opentelemetry/types'; +import { TraceFlags } from '@opentelemetry/api'; describe('NoRecordingSpan', () => { it('propagates span contexts', () => { diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index 867b344692..594584162a 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -15,26 +15,26 @@ npm install --save @opentelemetry/exporter-collector ## Usage in Web ```js -import * as opentelemetry from '@opentelemetry/core'; +import * as opentelemetry from '@opentelemetry/api'; import { SimpleSpanProcessor } from '@opentelemetry/tracing'; -import { WebTracer } from '@opentelemetry/web'; +import { WebTracerRegistry } from '@opentelemetry/web'; import { CollectorExporter } from '@opentelemetry/exporter-collector' const collectorOptions = { url: '' // url is optional and can be omitted - default is http://localhost:55678/v1/trace }; -const tracer = new WebTracer(); +const registry = new WebTracerRegistry(); const exporter = new CollectorExporter(collectorOptions); -tracer.addSpanProcessor(new SimpleSpanProcessor(exporter)); +registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); -opentelemetry.initGlobalTracer(tracer); +opentelemetry.trace.initGlobalTracerRegistry(registry); ``` ## Usage in Node ```js -const opentelemetry = require('@opentelemetry/core'); +const opentelemetry = require('@opentelemetry/api'); const { BasicTracerRegistry, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CollectorExporter } = require('@opentelemetry/exporter-collector'); @@ -46,7 +46,7 @@ const registry = new BasicTracerRegistry(); const exporter = new CollectorExporter(collectorOptions); registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); -opentelemetry.initGlobalTracerRegistry(registry); +opentelemetry.trace.initGlobalTracerRegistry(registry); ``` diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index 7f978bfcb6..ac2c636c82 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -82,6 +82,6 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-exporter-collector/src/CollectorExporter.ts b/packages/opentelemetry-exporter-collector/src/CollectorExporter.ts index c7fff44901..f825c99f1e 100644 --- a/packages/opentelemetry-exporter-collector/src/CollectorExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/CollectorExporter.ts @@ -17,7 +17,7 @@ import { ExportResult } from '@opentelemetry/base'; import { NoopLogger } from '@opentelemetry/core'; import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; -import { Attributes, Logger } from '@opentelemetry/types'; +import { Attributes, Logger } from '@opentelemetry/api'; import * as collectorTypes from './types'; import { toCollectorSpan } from './transform'; import { onInit, onShutdown, sendSpans } from './platform/index'; diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/sendSpans.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/sendSpans.ts index f7932a2afb..ca8b1f9203 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/sendSpans.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/sendSpans.ts @@ -15,7 +15,7 @@ */ import * as core from '@opentelemetry/core'; -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; import { CollectorExporter } from '../../CollectorExporter'; import * as collectorTypes from '../../types'; import { VERSION } from '../../version'; diff --git a/packages/opentelemetry-exporter-collector/src/transform.ts b/packages/opentelemetry-exporter-collector/src/transform.ts index aaf024b025..1d60c442e2 100644 --- a/packages/opentelemetry-exporter-collector/src/transform.ts +++ b/packages/opentelemetry-exporter-collector/src/transform.ts @@ -16,7 +16,7 @@ import { hexToBase64, hrTimeToTimeStamp } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; -import { Attributes, Link, TimedEvent, TraceState } from '@opentelemetry/types'; +import { Attributes, Link, TimedEvent, TraceState } from '@opentelemetry/api'; import * as collectorTypes from './types'; const OT_MAX_STRING_LENGTH = 128; diff --git a/packages/opentelemetry-exporter-collector/src/types.ts b/packages/opentelemetry-exporter-collector/src/types.ts index 1e5cb13b3d..1960000d33 100644 --- a/packages/opentelemetry-exporter-collector/src/types.ts +++ b/packages/opentelemetry-exporter-collector/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind, Status } from '@opentelemetry/types'; +import { SpanKind, Status } from '@opentelemetry/api'; // header to prevent instrumentation on request export const OT_REQUEST_HEADER = 'x-opentelemetry-outgoing-request'; diff --git a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts index d1227f04a8..4eb4213eac 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Attributes, TimedEvent } from '@opentelemetry/types'; +import { Attributes, TimedEvent } from '@opentelemetry/api'; import * as assert from 'assert'; import * as transform from '../../src/transform'; import { ensureSpanIsCorrect, mockedReadableSpan } from '../helper'; diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index a1285e8b90..e6a3c71127 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -57,7 +57,7 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "jaeger-client": "^3.15.0" } } diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index 4ae500f74e..50bdb042c0 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -14,10 +14,10 @@ * limitations under the License. */ +import * as api from '@opentelemetry/api'; import { ExportResult } from '@opentelemetry/base'; import { NoopLogger } from '@opentelemetry/core'; import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; -import * as types from '@opentelemetry/types'; import { Socket } from 'dgram'; import { spanToThrift } from './transform'; import * as jaegerTypes from './types'; @@ -26,7 +26,7 @@ import * as jaegerTypes from './types'; * Format and sends span information to Jaeger Exporter. */ export class JaegerExporter implements SpanExporter { - private readonly _logger: types.Logger; + private readonly _logger: api.Logger; private readonly _process: jaegerTypes.ThriftProcess; private readonly _sender: typeof jaegerTypes.UDPSender; private readonly _forceFlushOnShutdown: boolean = true; diff --git a/packages/opentelemetry-exporter-jaeger/src/transform.ts b/packages/opentelemetry-exporter-jaeger/src/transform.ts index 01451b9e96..0ce2338497 100644 --- a/packages/opentelemetry-exporter-jaeger/src/transform.ts +++ b/packages/opentelemetry-exporter-jaeger/src/transform.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Link, CanonicalCode, SpanKind } from '@opentelemetry/types'; +import { Link, CanonicalCode, SpanKind } from '@opentelemetry/api'; import { ReadableSpan } from '@opentelemetry/tracing'; import { hrTimeToMilliseconds, diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts index ab17951c6c..f7f060e16f 100644 --- a/packages/opentelemetry-exporter-jaeger/src/types.ts +++ b/packages/opentelemetry-exporter-jaeger/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; /** * Options for Jaeger configuration diff --git a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts index 3cc994294b..20ef8467c8 100644 --- a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts +++ b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import { JaegerExporter } from '../src'; import { NoopLogger } from '@opentelemetry/core'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { ThriftProcess } from '../src/types'; import { ReadableSpan } from '@opentelemetry/tracing'; import { ExportResult } from '@opentelemetry/base'; diff --git a/packages/opentelemetry-exporter-jaeger/test/transform.test.ts b/packages/opentelemetry-exporter-jaeger/test/transform.test.ts index bce206264e..4e81dd724b 100644 --- a/packages/opentelemetry-exporter-jaeger/test/transform.test.ts +++ b/packages/opentelemetry-exporter-jaeger/test/transform.test.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import { spanToThrift } from '../src/transform'; import { ReadableSpan } from '@opentelemetry/tracing'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { ThriftUtils, Utils, ThriftReferenceType } from '../src/types'; import { hrTimeToMicroseconds } from '@opentelemetry/core'; diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index b0d657da60..8be1a400e4 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -56,7 +56,7 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/metrics": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "prom-client": "^11.5.3" } } diff --git a/packages/opentelemetry-exporter-prometheus/src/export/types.ts b/packages/opentelemetry-exporter-prometheus/src/export/types.ts index aa8de5ac6f..bfdc74cc19 100644 --- a/packages/opentelemetry-exporter-prometheus/src/export/types.ts +++ b/packages/opentelemetry-exporter-prometheus/src/export/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; /** * Configuration interface for prometheus exporter diff --git a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts index 9ac12f5e0a..65553bbee8 100644 --- a/packages/opentelemetry-exporter-prometheus/src/prometheus.ts +++ b/packages/opentelemetry-exporter-prometheus/src/prometheus.ts @@ -23,7 +23,7 @@ import { MetricExporter, ReadableMetric, } from '@opentelemetry/metrics'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { createServer, IncomingMessage, Server, ServerResponse } from 'http'; import { Counter, Gauge, labelValues, Metric, Registry } from 'prom-client'; import * as url from 'url'; diff --git a/packages/opentelemetry-exporter-stackdriver-trace/package.json b/packages/opentelemetry-exporter-stackdriver-trace/package.json index d914773f51..11e440f63f 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/package.json +++ b/packages/opentelemetry-exporter-stackdriver-trace/package.json @@ -62,7 +62,7 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "google-auth-library": "^5.7.0", "googleapis": "^46.0.0" } diff --git a/packages/opentelemetry-exporter-stackdriver-trace/src/external-types.ts b/packages/opentelemetry-exporter-stackdriver-trace/src/external-types.ts index 7e92251f80..b2e56391ce 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/src/external-types.ts +++ b/packages/opentelemetry-exporter-stackdriver-trace/src/external-types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; export interface StackdriverExporterOptions { /** diff --git a/packages/opentelemetry-exporter-stackdriver-trace/src/trace.ts b/packages/opentelemetry-exporter-stackdriver-trace/src/trace.ts index a49c688041..1e5c5f4125 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/src/trace.ts +++ b/packages/opentelemetry-exporter-stackdriver-trace/src/trace.ts @@ -17,7 +17,7 @@ import { ExportResult } from '@opentelemetry/base'; import { NoopLogger } from '@opentelemetry/core'; import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; import { GoogleAuth } from 'google-auth-library'; import { google } from 'googleapis'; import { StackdriverExporterOptions } from './external-types'; diff --git a/packages/opentelemetry-exporter-stackdriver-trace/src/transform.ts b/packages/opentelemetry-exporter-stackdriver-trace/src/transform.ts index ae17b053fd..e88b6e9b2a 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/src/transform.ts +++ b/packages/opentelemetry-exporter-stackdriver-trace/src/transform.ts @@ -19,7 +19,7 @@ import { VERSION as CORE_VERSION, } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; -import * as ot from '@opentelemetry/types'; +import * as ot from '@opentelemetry/api'; import { AttributeMap, Attributes, diff --git a/packages/opentelemetry-exporter-stackdriver-trace/test/exporter.test.ts b/packages/opentelemetry-exporter-stackdriver-trace/test/exporter.test.ts index cfacb9dc02..68e60baf23 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/test/exporter.test.ts +++ b/packages/opentelemetry-exporter-stackdriver-trace/test/exporter.test.ts @@ -17,7 +17,7 @@ import { ExportResult } from '@opentelemetry/base'; import { ConsoleLogger, LogLevel } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import * as assert from 'assert'; import * as nock from 'nock'; import * as sinon from 'sinon'; diff --git a/packages/opentelemetry-exporter-stackdriver-trace/test/transform.test.ts b/packages/opentelemetry-exporter-stackdriver-trace/test/transform.test.ts index 1a35b76d8c..6d9ddf7969 100644 --- a/packages/opentelemetry-exporter-stackdriver-trace/test/transform.test.ts +++ b/packages/opentelemetry-exporter-stackdriver-trace/test/transform.test.ts @@ -16,7 +16,7 @@ import { VERSION as CORE_VERSION } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import * as assert from 'assert'; import { getReadableSpanTransformer } from '../src/transform'; import { LinkType, Span } from '../src/types'; diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index ba53d81b70..1fd210e0c5 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -58,6 +58,6 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-exporter-zipkin/src/transform.ts b/packages/opentelemetry-exporter-zipkin/src/transform.ts index 06c6c06c37..cbf0908526 100644 --- a/packages/opentelemetry-exporter-zipkin/src/transform.ts +++ b/packages/opentelemetry-exporter-zipkin/src/transform.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { ReadableSpan } from '@opentelemetry/tracing'; import { hrTimeToMicroseconds } from '@opentelemetry/core'; import * as zipkinTypes from './types'; diff --git a/packages/opentelemetry-exporter-zipkin/src/types.ts b/packages/opentelemetry-exporter-zipkin/src/types.ts index f04d33e28b..4efd641f89 100644 --- a/packages/opentelemetry-exporter-zipkin/src/types.ts +++ b/packages/opentelemetry-exporter-zipkin/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; /** * Exporter config diff --git a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts index 2be9f91fcf..1939a9eb65 100644 --- a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts +++ b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import * as http from 'http'; import * as https from 'https'; import * as url from 'url'; diff --git a/packages/opentelemetry-exporter-zipkin/test/transform.test.ts b/packages/opentelemetry-exporter-zipkin/test/transform.test.ts index 641803902f..70c4ac1695 100644 --- a/packages/opentelemetry-exporter-zipkin/test/transform.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/transform.test.ts @@ -15,7 +15,7 @@ */ import * as assert from 'assert'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { Span, BasicTracerRegistry } from '@opentelemetry/tracing'; import { NoopLogger, diff --git a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts index 2a09e37230..b4b0a5177a 100644 --- a/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts @@ -19,7 +19,7 @@ import * as nock from 'nock'; import { ReadableSpan } from '@opentelemetry/tracing'; import { ExportResult } from '@opentelemetry/base'; import { NoopLogger, hrTimeToMicroseconds } from '@opentelemetry/core'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { ZipkinExporter } from '../src'; import * as zipkinTypes from '../src/types'; import { OT_REQUEST_HEADER } from '../src/utils'; diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index 6336ad4c9e..21a5e19708 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -58,6 +58,6 @@ "dependencies": { "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-metrics/src/BoundInstrument.ts b/packages/opentelemetry-metrics/src/BoundInstrument.ts index 3899c323ef..a30ed8426a 100644 --- a/packages/opentelemetry-metrics/src/BoundInstrument.ts +++ b/packages/opentelemetry-metrics/src/BoundInstrument.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { TimeSeries } from './export/types'; /** diff --git a/packages/opentelemetry-metrics/src/LabelSet.ts b/packages/opentelemetry-metrics/src/LabelSet.ts index fb038384bf..633f113ac5 100644 --- a/packages/opentelemetry-metrics/src/LabelSet.ts +++ b/packages/opentelemetry-metrics/src/LabelSet.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; /** * Canonicalized labels with an unique string identifier. diff --git a/packages/opentelemetry-metrics/src/Meter.ts b/packages/opentelemetry-metrics/src/Meter.ts index 1a29ad5f5f..97f3ff0847 100644 --- a/packages/opentelemetry-metrics/src/Meter.ts +++ b/packages/opentelemetry-metrics/src/Meter.ts @@ -14,13 +14,8 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; -import { - ConsoleLogger, - NOOP_COUNTER_METRIC, - NOOP_GAUGE_METRIC, - NOOP_MEASURE_METRIC, -} from '@opentelemetry/core'; +import * as types from '@opentelemetry/api'; +import { ConsoleLogger } from '@opentelemetry/core'; import { BaseBoundInstrument } from './BoundInstrument'; import { Metric, CounterMetric, GaugeMetric } from './Metric'; import { @@ -64,7 +59,7 @@ export class Meter implements types.Meter { this._logger.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); - return NOOP_MEASURE_METRIC; + return types.NOOP_MEASURE_METRIC; } // @todo: implement this method throw new Error('not implemented yet'); @@ -85,7 +80,7 @@ export class Meter implements types.Meter { this._logger.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); - return NOOP_COUNTER_METRIC; + return types.NOOP_COUNTER_METRIC; } const opt: MetricOptions = { // Counters are defined as monotonic by default @@ -117,7 +112,7 @@ export class Meter implements types.Meter { this._logger.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); - return NOOP_GAUGE_METRIC; + return types.NOOP_GAUGE_METRIC; } const opt: MetricOptions = { // Gauges are defined as non-monotonic by default diff --git a/packages/opentelemetry-metrics/src/MeterRegistry.ts b/packages/opentelemetry-metrics/src/MeterRegistry.ts index c9eb683663..d4c5b2b6e5 100644 --- a/packages/opentelemetry-metrics/src/MeterRegistry.ts +++ b/packages/opentelemetry-metrics/src/MeterRegistry.ts @@ -15,7 +15,7 @@ */ import { ConsoleLogger } from '@opentelemetry/core'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { Meter } from '.'; import { DEFAULT_CONFIG, MeterConfig } from './types'; diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts index 88404ee5cd..4f66dcd8ae 100644 --- a/packages/opentelemetry-metrics/src/Metric.ts +++ b/packages/opentelemetry-metrics/src/Metric.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { hrTime } from '@opentelemetry/core'; import { BoundCounter, diff --git a/packages/opentelemetry-metrics/src/export/types.ts b/packages/opentelemetry-metrics/src/export/types.ts index 031682d5b9..22fd4527fe 100644 --- a/packages/opentelemetry-metrics/src/export/types.ts +++ b/packages/opentelemetry-metrics/src/export/types.ts @@ -22,7 +22,7 @@ * opentelemetry-proto/opentelemetry/proto/metrics/v1/metrics.proto */ -import { HrTime } from '@opentelemetry/types'; +import { HrTime } from '@opentelemetry/api'; import { Resource, ExportResult } from '@opentelemetry/base'; export interface ReadableMetric { diff --git a/packages/opentelemetry-metrics/src/types.ts b/packages/opentelemetry-metrics/src/types.ts index 5b8cdf6eed..e65d35a29b 100644 --- a/packages/opentelemetry-metrics/src/types.ts +++ b/packages/opentelemetry-metrics/src/types.ts @@ -15,7 +15,7 @@ */ import { LogLevel } from '@opentelemetry/core'; -import { Logger, ValueType } from '@opentelemetry/types'; +import { Logger, ValueType } from '@opentelemetry/api'; /** Options needed for SDK metric creation. */ export interface MetricOptions { diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index f0269a5b24..ab26ebff92 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -22,14 +22,9 @@ import { GaugeMetric, MetricDescriptorType, } from '../src'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { LabelSet } from '../src/LabelSet'; -import { - NoopLogger, - NoopMetric, - hrTime, - hrTimeToMilliseconds, -} from '@opentelemetry/core'; +import { NoopLogger, hrTime, hrTimeToMilliseconds } from '@opentelemetry/core'; import { NoopExporter } from './mocks/Exporter'; import { MeterRegistry } from '../src/MeterRegistry'; @@ -205,19 +200,19 @@ describe('Meter', () => { it('should return no op metric if name is an empty string', () => { const counter = meter.createCounter(''); - assert.ok(counter instanceof NoopMetric); + assert.ok(counter instanceof types.NoopMetric); }); it('should return no op metric if name does not start with a letter', () => { const counter1 = meter.createCounter('1name'); const counter_ = meter.createCounter('_name'); - assert.ok(counter1 instanceof NoopMetric); - assert.ok(counter_ instanceof NoopMetric); + assert.ok(counter1 instanceof types.NoopMetric); + assert.ok(counter_ instanceof types.NoopMetric); }); it('should return no op metric if name is an empty string contain only letters, numbers, ".", "_", and "-"', () => { const counter = meter.createCounter('name with invalid characters^&*('); - assert.ok(counter instanceof NoopMetric); + assert.ok(counter instanceof types.NoopMetric); }); }); }); @@ -346,19 +341,19 @@ describe('Meter', () => { it('should return no op metric if name is an empty string', () => { const gauge = meter.createGauge(''); - assert.ok(gauge instanceof NoopMetric); + assert.ok(gauge instanceof types.NoopMetric); }); it('should return no op metric if name does not start with a letter', () => { const gauge1 = meter.createGauge('1name'); const gauge_ = meter.createGauge('_name'); - assert.ok(gauge1 instanceof NoopMetric); - assert.ok(gauge_ instanceof NoopMetric); + assert.ok(gauge1 instanceof types.NoopMetric); + assert.ok(gauge_ instanceof types.NoopMetric); }); it('should return no op metric if name is an empty string contain only letters, numbers, ".", "_", and "-"', () => { const gauge = meter.createGauge('name with invalid characters^&*('); - assert.ok(gauge instanceof NoopMetric); + assert.ok(gauge instanceof types.NoopMetric); }); }); }); @@ -367,19 +362,19 @@ describe('Meter', () => { describe('names', () => { it('should return no op metric if name is an empty string', () => { const gauge = meter.createMeasure(''); - assert.ok(gauge instanceof NoopMetric); + assert.ok(gauge instanceof types.NoopMetric); }); it('should return no op metric if name does not start with a letter', () => { const gauge1 = meter.createMeasure('1name'); const gauge_ = meter.createMeasure('_name'); - assert.ok(gauge1 instanceof NoopMetric); - assert.ok(gauge_ instanceof NoopMetric); + assert.ok(gauge1 instanceof types.NoopMetric); + assert.ok(gauge_ instanceof types.NoopMetric); }); it('should return no op metric if name is an empty string contain only letters, numbers, ".", "_", and "-"', () => { const gauge = meter.createMeasure('name with invalid characters^&*('); - assert.ok(gauge instanceof NoopMetric); + assert.ok(gauge instanceof types.NoopMetric); }); }); }); diff --git a/packages/opentelemetry-node/README.md b/packages/opentelemetry-node/README.md index 8e6c195c32..38487bec66 100644 --- a/packages/opentelemetry-node/README.md +++ b/packages/opentelemetry-node/README.md @@ -69,7 +69,7 @@ const registry = new NodeTracerRegistry({ }); // Initialize the registry -opentelemetry.initGlobalTracerRegistry(registry); +opentelemetry.trace.initGlobalTracerRegistry(registry); // Your application code - http will automatically be instrumented if // @opentelemetry/plugin-http is present @@ -86,7 +86,7 @@ const { NodeTracerRegistry } = require('@opentelemetry/node'); const registry = new NodeTracerRegistry(); // Initialize the registry -opentelemetry.initGlobalTracerRegistry(registry); +opentelemetry.trace.initGlobalTracerRegistry(registry); // Your application code // ... diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index ab112d2f3a..1e883fae4c 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -61,7 +61,7 @@ "@opentelemetry/core": "^0.3.3", "@opentelemetry/scope-async-hooks": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "require-in-the-middle": "^5.0.0", "semver": "^6.2.0" } diff --git a/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts b/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts index 99d2abf487..7f4bfc0345 100644 --- a/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts +++ b/packages/opentelemetry-node/src/instrumentation/PluginLoader.ts @@ -19,7 +19,7 @@ import { Plugin, PluginConfig, TracerRegistry, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import * as hook from 'require-in-the-middle'; import * as utils from './utils'; diff --git a/packages/opentelemetry-node/src/instrumentation/utils.ts b/packages/opentelemetry-node/src/instrumentation/utils.ts index 9460de4ad8..062682e3fb 100644 --- a/packages/opentelemetry-node/src/instrumentation/utils.ts +++ b/packages/opentelemetry-node/src/instrumentation/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/types'; +import { Logger } from '@opentelemetry/api'; import * as path from 'path'; import * as semver from 'semver'; diff --git a/packages/opentelemetry-node/test/NodeTracer.test.ts b/packages/opentelemetry-node/test/NodeTracer.test.ts index 757be77348..d44ff9a3b4 100644 --- a/packages/opentelemetry-node/test/NodeTracer.test.ts +++ b/packages/opentelemetry-node/test/NodeTracer.test.ts @@ -24,7 +24,7 @@ import { NoRecordingSpan, } from '@opentelemetry/core'; import { NodeTracerRegistry } from '../src/NodeTracerRegistry'; -import { TraceFlags } from '@opentelemetry/types'; +import { TraceFlags } from '@opentelemetry/api'; import { Span } from '@opentelemetry/tracing'; import * as path from 'path'; diff --git a/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts b/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts index 93440eb294..b493870ef9 100644 --- a/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts +++ b/packages/opentelemetry-node/test/instrumentation/PluginLoader.test.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { NoopLogger, NoopTracerRegistry } from '@opentelemetry/core'; +import { NoopTracerRegistry } from '@opentelemetry/api'; +import { NoopLogger } from '@opentelemetry/core'; import * as assert from 'assert'; import * as path from 'path'; import { diff --git a/packages/opentelemetry-plugin-dns/package.json b/packages/opentelemetry-plugin-dns/package.json index 453d64d186..10c26a0151 100644 --- a/packages/opentelemetry-plugin-dns/package.json +++ b/packages/opentelemetry-plugin-dns/package.json @@ -62,7 +62,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "semver": "^6.3.0", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-dns/src/dns.ts b/packages/opentelemetry-plugin-dns/src/dns.ts index f7c3eb651b..d305079dc7 100644 --- a/packages/opentelemetry-plugin-dns/src/dns.ts +++ b/packages/opentelemetry-plugin-dns/src/dns.ts @@ -15,7 +15,7 @@ */ import { BasePlugin } from '@opentelemetry/core'; -import { Span, SpanKind, SpanOptions } from '@opentelemetry/types'; +import { Span, SpanKind, SpanOptions } from '@opentelemetry/api'; import { LookupAddress } from 'dns'; import * as semver from 'semver'; import * as shimmer from 'shimmer'; diff --git a/packages/opentelemetry-plugin-dns/src/types.ts b/packages/opentelemetry-plugin-dns/src/types.ts index 0f84de4f60..54ad5af6e7 100644 --- a/packages/opentelemetry-plugin-dns/src/types.ts +++ b/packages/opentelemetry-plugin-dns/src/types.ts @@ -15,7 +15,7 @@ */ import * as dns from 'dns'; -import { PluginConfig } from '@opentelemetry/types'; +import { PluginConfig } from '@opentelemetry/api'; export type Dns = typeof dns; diff --git a/packages/opentelemetry-plugin-dns/src/utils.ts b/packages/opentelemetry-plugin-dns/src/utils.ts index d2d1b2ce84..f34db15c01 100644 --- a/packages/opentelemetry-plugin-dns/src/utils.ts +++ b/packages/opentelemetry-plugin-dns/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span, CanonicalCode, Status, Attributes } from '@opentelemetry/types'; +import { Span, CanonicalCode, Status, Attributes } from '@opentelemetry/api'; import { AttributeNames } from './enums/AttributeNames'; import { AddressFamily } from './enums/AddressFamily'; import * as dns from 'dns'; diff --git a/packages/opentelemetry-plugin-dns/test/functionals/utils.test.ts b/packages/opentelemetry-plugin-dns/test/functionals/utils.test.ts index 4be83dbed2..6355cd73e1 100644 --- a/packages/opentelemetry-plugin-dns/test/functionals/utils.test.ts +++ b/packages/opentelemetry-plugin-dns/test/functionals/utils.test.ts @@ -16,7 +16,7 @@ import { NoopLogger } from '@opentelemetry/core'; import { BasicTracerRegistry, Span } from '@opentelemetry/tracing'; -import { CanonicalCode, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import * as sinon from 'sinon'; import { AttributeNames } from '../../src/enums/AttributeNames'; diff --git a/packages/opentelemetry-plugin-dns/test/integrations/dns-lookup.test.ts b/packages/opentelemetry-plugin-dns/test/integrations/dns-lookup.test.ts index 088a6ea93d..27b4f0a148 100644 --- a/packages/opentelemetry-plugin-dns/test/integrations/dns-lookup.test.ts +++ b/packages/opentelemetry-plugin-dns/test/integrations/dns-lookup.test.ts @@ -25,7 +25,7 @@ import { plugin } from '../../src/dns'; import * as dns from 'dns'; import * as utils from '../utils/utils'; import { assertSpan } from '../utils/assertSpan'; -import { CanonicalCode } from '@opentelemetry/types'; +import { CanonicalCode } from '@opentelemetry/api'; const memoryExporter = new InMemorySpanExporter(); const logger = new NoopLogger(); diff --git a/packages/opentelemetry-plugin-dns/test/integrations/dnspromise-lookup.test.ts b/packages/opentelemetry-plugin-dns/test/integrations/dnspromise-lookup.test.ts index ec9e49ae51..ad3782613d 100644 --- a/packages/opentelemetry-plugin-dns/test/integrations/dnspromise-lookup.test.ts +++ b/packages/opentelemetry-plugin-dns/test/integrations/dnspromise-lookup.test.ts @@ -26,7 +26,7 @@ import * as dns from 'dns'; import * as utils from '../utils/utils'; import * as semver from 'semver'; import { assertSpan } from '../utils/assertSpan'; -import { CanonicalCode } from '@opentelemetry/types'; +import { CanonicalCode } from '@opentelemetry/api'; const memoryExporter = new InMemorySpanExporter(); const logger = new NoopLogger(); diff --git a/packages/opentelemetry-plugin-dns/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-dns/test/utils/assertSpan.ts index dc8df543dd..e6238651f5 100644 --- a/packages/opentelemetry-plugin-dns/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-dns/test/utils/assertSpan.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind, Status, CanonicalCode } from '@opentelemetry/types'; +import { SpanKind, Status, CanonicalCode } from '@opentelemetry/api'; import { hrTimeToNanoseconds } from '@opentelemetry/core'; import * as assert from 'assert'; import { AttributeNames } from '../../src/enums/AttributeNames'; diff --git a/packages/opentelemetry-plugin-document-load/package.json b/packages/opentelemetry-plugin-document-load/package.json index d2a4116b97..3e77482872 100644 --- a/packages/opentelemetry-plugin-document-load/package.json +++ b/packages/opentelemetry-plugin-document-load/package.json @@ -74,7 +74,7 @@ "dependencies": { "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "@opentelemetry/web": "^0.3.3" } } diff --git a/packages/opentelemetry-plugin-document-load/src/documentLoad.ts b/packages/opentelemetry-plugin-document-load/src/documentLoad.ts index 2d14055cd8..cb661df6e5 100644 --- a/packages/opentelemetry-plugin-document-load/src/documentLoad.ts +++ b/packages/opentelemetry-plugin-document-load/src/documentLoad.ts @@ -20,7 +20,7 @@ import { parseTraceParent, TRACE_PARENT_HEADER, } from '@opentelemetry/core'; -import { PluginConfig, Span, SpanOptions } from '@opentelemetry/types'; +import { PluginConfig, Span, SpanOptions } from '@opentelemetry/api'; import { addSpanNetworkEvent, hasKey, diff --git a/packages/opentelemetry-plugin-document-load/test/documentLoad.test.ts b/packages/opentelemetry-plugin-document-load/test/documentLoad.test.ts index 6ae19c3846..b2a0469956 100644 --- a/packages/opentelemetry-plugin-document-load/test/documentLoad.test.ts +++ b/packages/opentelemetry-plugin-document-load/test/documentLoad.test.ts @@ -25,7 +25,7 @@ import { SimpleSpanProcessor, SpanExporter, } from '@opentelemetry/tracing'; -import { Logger, PluginConfig, TimedEvent } from '@opentelemetry/types'; +import { Logger, PluginConfig, TimedEvent } from '@opentelemetry/api'; import * as assert from 'assert'; import * as sinon from 'sinon'; import { ExportResult } from '../../opentelemetry-base/build/src'; diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json index d8340c5fd3..f63e2c46e1 100644 --- a/packages/opentelemetry-plugin-grpc/package.json +++ b/packages/opentelemetry-plugin-grpc/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-grpc/src/grpc.ts b/packages/opentelemetry-plugin-grpc/src/grpc.ts index 901eba22fe..e01f2aeb3b 100644 --- a/packages/opentelemetry-plugin-grpc/src/grpc.ts +++ b/packages/opentelemetry-plugin-grpc/src/grpc.ts @@ -22,7 +22,7 @@ import { SpanKind, SpanOptions, Status, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import * as events from 'events'; import * as grpcTypes from 'grpc'; import * as path from 'path'; diff --git a/packages/opentelemetry-plugin-grpc/src/utils.ts b/packages/opentelemetry-plugin-grpc/src/utils.ts index 762d571d47..f9d5c6dd79 100644 --- a/packages/opentelemetry-plugin-grpc/src/utils.ts +++ b/packages/opentelemetry-plugin-grpc/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { CanonicalCode, Status } from '@opentelemetry/types'; +import { CanonicalCode, Status } from '@opentelemetry/api'; import * as grpcTypes from 'grpc'; // For types only // Equivalent to lodash _.findIndex diff --git a/packages/opentelemetry-plugin-grpc/test/grpc.test.ts b/packages/opentelemetry-plugin-grpc/test/grpc.test.ts index 3f778496ea..1a0adf6eff 100644 --- a/packages/opentelemetry-plugin-grpc/test/grpc.test.ts +++ b/packages/opentelemetry-plugin-grpc/test/grpc.test.ts @@ -14,13 +14,13 @@ * limitations under the License. */ -import { NoopLogger, NoopTracerRegistry } from '@opentelemetry/core'; +import { NoopTracerRegistry, SpanKind } from '@opentelemetry/api'; +import { NoopLogger } from '@opentelemetry/core'; import { NodeTracerRegistry } from '@opentelemetry/node'; import { InMemorySpanExporter, SimpleSpanProcessor, } from '@opentelemetry/tracing'; -import { SpanKind } from '@opentelemetry/types'; import * as assert from 'assert'; import * as grpc from 'grpc'; import * as semver from 'semver'; diff --git a/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts b/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts index acfd340eb1..b484a1561e 100644 --- a/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts +++ b/packages/opentelemetry-plugin-grpc/test/utils/assertionUtils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind } from '@opentelemetry/types'; +import { SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import { AttributeNames } from '../../src/enums/AttributeNames'; import { GrpcPlugin } from '../../src/grpc'; diff --git a/packages/opentelemetry-plugin-http/package.json b/packages/opentelemetry-plugin-http/package.json index adeee6a588..ec909d8e87 100644 --- a/packages/opentelemetry-plugin-http/package.json +++ b/packages/opentelemetry-plugin-http/package.json @@ -73,7 +73,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "semver": "^6.3.0", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-http/src/http.ts b/packages/opentelemetry-plugin-http/src/http.ts index f45fb6ac56..ee4c7f44ca 100644 --- a/packages/opentelemetry-plugin-http/src/http.ts +++ b/packages/opentelemetry-plugin-http/src/http.ts @@ -21,7 +21,7 @@ import { SpanKind, SpanOptions, Status, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import { ClientRequest, IncomingMessage, diff --git a/packages/opentelemetry-plugin-http/src/types.ts b/packages/opentelemetry-plugin-http/src/types.ts index bfd75fefd8..335e0bbc30 100644 --- a/packages/opentelemetry-plugin-http/src/types.ts +++ b/packages/opentelemetry-plugin-http/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span, PluginConfig } from '@opentelemetry/types'; +import { Span, PluginConfig } from '@opentelemetry/api'; import * as url from 'url'; import { ClientRequest, diff --git a/packages/opentelemetry-plugin-http/src/utils.ts b/packages/opentelemetry-plugin-http/src/utils.ts index 2f8c02d8b8..d9b4b94fc0 100644 --- a/packages/opentelemetry-plugin-http/src/utils.ts +++ b/packages/opentelemetry-plugin-http/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Status, CanonicalCode, Span, Attributes } from '@opentelemetry/types'; +import { Status, CanonicalCode, Span, Attributes } from '@opentelemetry/api'; import { RequestOptions, IncomingMessage, diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts index b9b13276b9..33de9db58d 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts @@ -14,18 +14,14 @@ * limitations under the License. */ +import { NoopTracerRegistry, NOOP_TRACER } from '@opentelemetry/api'; +import { NoopLogger } from '@opentelemetry/core'; import * as assert from 'assert'; import * as http from 'http'; +import { AddressInfo } from 'net'; import * as nock from 'nock'; import * as sinon from 'sinon'; - import { plugin } from '../../src/http'; -import { - NoopLogger, - NoopTracerRegistry, - noopTracer, -} from '@opentelemetry/core'; -import { AddressInfo } from 'net'; import { httpRequest } from '../utils/httpRequest'; describe('HttpPlugin', () => { @@ -53,8 +49,8 @@ describe('HttpPlugin', () => { }); beforeEach(() => { - noopTracer.startSpan = sinon.spy(); - noopTracer.withSpan = sinon.spy(); + NOOP_TRACER.startSpan = sinon.spy(); + NOOP_TRACER.withSpan = sinon.spy(); }); afterEach(() => { @@ -73,13 +69,13 @@ describe('HttpPlugin', () => { await httpRequest.get(options).then(result => { assert.strictEqual( - (noopTracer.startSpan as sinon.SinonSpy).called, + (NOOP_TRACER.startSpan as sinon.SinonSpy).called, false ); assert.strictEqual(http.Server.prototype.emit.__wrapped, undefined); assert.strictEqual( - (noopTracer.withSpan as sinon.SinonSpy).called, + (NOOP_TRACER.withSpan as sinon.SinonSpy).called, false ); }); diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts index 75353e2c21..e623ebce52 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts @@ -20,7 +20,7 @@ import { } from '@opentelemetry/tracing'; import { NoopLogger } from '@opentelemetry/core'; import { NodeTracerRegistry } from '@opentelemetry/node'; -import { CanonicalCode, Span as ISpan, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, Span as ISpan, SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import * as path from 'path'; diff --git a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts index cf9e68c619..bf32608c60 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -15,7 +15,7 @@ */ import { NoopLogger } from '@opentelemetry/core'; -import { SpanKind } from '@opentelemetry/types'; +import { SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import * as nock from 'nock'; diff --git a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts index c8bcddd957..8278d6dd25 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts @@ -17,7 +17,7 @@ import { NoopLogger } from '@opentelemetry/core'; import { NoopScopeManager } from '@opentelemetry/scope-base'; import { BasicTracerRegistry, Span } from '@opentelemetry/tracing'; -import { CanonicalCode, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import * as sinon from 'sinon'; diff --git a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts index 0793aa99ed..1452012675 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -15,7 +15,7 @@ */ import { NoopLogger } from '@opentelemetry/core'; -import { SpanKind, Span } from '@opentelemetry/types'; +import { SpanKind, Span } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import { plugin } from '../../src/http'; diff --git a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts index 2c9cbd238d..3e4ca727fc 100644 --- a/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts +++ b/packages/opentelemetry-plugin-http/test/utils/DummyPropagation.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SpanContext, HttpTextFormat } from '@opentelemetry/types'; +import { SpanContext, HttpTextFormat } from '@opentelemetry/api'; import * as http from 'http'; export class DummyPropagation implements HttpTextFormat { diff --git a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts index ce9dc855b6..cc70a654b9 100644 --- a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind, Status } from '@opentelemetry/types'; +import { SpanKind, Status } from '@opentelemetry/api'; import { hrTimeToNanoseconds } from '@opentelemetry/core'; import * as assert from 'assert'; import * as http from 'http'; diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json index d4ef6e79b9..f241d50772 100644 --- a/packages/opentelemetry-plugin-https/package.json +++ b/packages/opentelemetry-plugin-https/package.json @@ -74,7 +74,7 @@ "dependencies": { "@opentelemetry/core": "^0.3.3", "@opentelemetry/plugin-http": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "semver": "^6.3.0", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts index 826fc5d72c..0dbe79d2ef 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts @@ -26,7 +26,7 @@ import { plugin } from '../../src/https'; import { DummyPropagation } from '../utils/DummyPropagation'; import { httpsRequest } from '../utils/httpsRequest'; import { NodeTracerRegistry } from '@opentelemetry/node'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; describe('HttpsPlugin', () => { let server: https.Server; diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts index 477b2b906c..4d5b261de8 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts @@ -26,7 +26,7 @@ import { OT_REQUEST_HEADER, AttributeNames, } from '@opentelemetry/plugin-http'; -import { CanonicalCode, Span as ISpan, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, Span as ISpan, SpanKind } from '@opentelemetry/api'; import * as assert from 'assert'; import * as fs from 'fs'; import * as http from 'http'; diff --git a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts index 63769e16f8..23ec98232c 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -15,7 +15,7 @@ */ import { NoopLogger } from '@opentelemetry/core'; -import { SpanKind, Span } from '@opentelemetry/types'; +import { SpanKind, Span } from '@opentelemetry/api'; import * as assert from 'assert'; import * as https from 'https'; import * as http from 'http'; diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index 39002c8af6..be0d7ae4ed 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -20,7 +20,7 @@ import { Http, AttributeNames, } from '@opentelemetry/plugin-http'; -import { SpanKind, Span } from '@opentelemetry/types'; +import { SpanKind, Span } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import * as https from 'https'; diff --git a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts index 2c9cbd238d..3e4ca727fc 100644 --- a/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts +++ b/packages/opentelemetry-plugin-https/test/utils/DummyPropagation.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { SpanContext, HttpTextFormat } from '@opentelemetry/types'; +import { SpanContext, HttpTextFormat } from '@opentelemetry/api'; import * as http from 'http'; export class DummyPropagation implements HttpTextFormat { diff --git a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts index 71167b4e6d..91afcab170 100644 --- a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind } from '@opentelemetry/types'; +import { SpanKind } from '@opentelemetry/api'; import { hrTimeToNanoseconds } from '@opentelemetry/core'; import * as assert from 'assert'; import * as http from 'http'; diff --git a/packages/opentelemetry-plugin-ioredis/package.json b/packages/opentelemetry-plugin-ioredis/package.json index ec16e8cd3c..d9282fe276 100644 --- a/packages/opentelemetry-plugin-ioredis/package.json +++ b/packages/opentelemetry-plugin-ioredis/package.json @@ -66,7 +66,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-ioredis/src/utils.ts b/packages/opentelemetry-plugin-ioredis/src/utils.ts index 8dbae4478b..44f9f573ed 100644 --- a/packages/opentelemetry-plugin-ioredis/src/utils.ts +++ b/packages/opentelemetry-plugin-ioredis/src/utils.ts @@ -15,7 +15,7 @@ */ import * as ioredisTypes from 'ioredis'; -import { Tracer, SpanKind, Span, CanonicalCode } from '@opentelemetry/types'; +import { Tracer, SpanKind, Span, CanonicalCode } from '@opentelemetry/api'; import { IORedisPluginClientTypes, IORedisCommand } from './types'; import { IORedisPlugin } from './ioredis'; import { AttributeNames } from './enums'; diff --git a/packages/opentelemetry-plugin-ioredis/test/ioredis.test.ts b/packages/opentelemetry-plugin-ioredis/test/ioredis.test.ts index 3f99e22216..1aad4e2246 100644 --- a/packages/opentelemetry-plugin-ioredis/test/ioredis.test.ts +++ b/packages/opentelemetry-plugin-ioredis/test/ioredis.test.ts @@ -24,7 +24,7 @@ import { plugin, IORedisPlugin } from '../src'; import * as ioredisTypes from 'ioredis'; import { NoopLogger } from '@opentelemetry/core'; import * as testUtils from '@opentelemetry/test-utils'; -import { SpanKind, Status, CanonicalCode } from '@opentelemetry/types'; +import { SpanKind, Status, CanonicalCode } from '@opentelemetry/api'; import { AttributeNames } from '../src/enums'; const memoryExporter = new InMemorySpanExporter(); diff --git a/packages/opentelemetry-plugin-mongodb/package.json b/packages/opentelemetry-plugin-mongodb/package.json index a1cfd453f2..cad7a84fc1 100644 --- a/packages/opentelemetry-plugin-mongodb/package.json +++ b/packages/opentelemetry-plugin-mongodb/package.json @@ -61,7 +61,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-mongodb/src/mongodb.ts b/packages/opentelemetry-plugin-mongodb/src/mongodb.ts index ebcab73699..93eed568df 100644 --- a/packages/opentelemetry-plugin-mongodb/src/mongodb.ts +++ b/packages/opentelemetry-plugin-mongodb/src/mongodb.ts @@ -18,7 +18,7 @@ /* tslint:disable:deprecation */ import { BasePlugin } from '@opentelemetry/core'; -import { CanonicalCode, Span, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, Span, SpanKind } from '@opentelemetry/api'; import * as mongodb from 'mongodb'; import * as shimmer from 'shimmer'; import { diff --git a/packages/opentelemetry-plugin-mongodb/test/mongodb.test.ts b/packages/opentelemetry-plugin-mongodb/test/mongodb.test.ts index 23e3b9d14d..26c90213eb 100644 --- a/packages/opentelemetry-plugin-mongodb/test/mongodb.test.ts +++ b/packages/opentelemetry-plugin-mongodb/test/mongodb.test.ts @@ -18,7 +18,7 @@ import { NodeTracerRegistry } from '@opentelemetry/node'; import * as assert from 'assert'; import * as mongodb from 'mongodb'; import { plugin } from '../src'; -import { SpanKind, CanonicalCode } from '@opentelemetry/types'; +import { SpanKind, CanonicalCode } from '@opentelemetry/api'; import { NoopLogger } from '@opentelemetry/core'; import { AttributeNames } from '../src/types'; import { diff --git a/packages/opentelemetry-plugin-mysql/package.json b/packages/opentelemetry-plugin-mysql/package.json index 8cf5529ced..c246fc28ef 100644 --- a/packages/opentelemetry-plugin-mysql/package.json +++ b/packages/opentelemetry-plugin-mysql/package.json @@ -62,7 +62,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-mysql/src/mysql.ts b/packages/opentelemetry-plugin-mysql/src/mysql.ts index 9fcd6e64b6..f5106d1032 100644 --- a/packages/opentelemetry-plugin-mysql/src/mysql.ts +++ b/packages/opentelemetry-plugin-mysql/src/mysql.ts @@ -15,7 +15,7 @@ */ import { BasePlugin } from '@opentelemetry/core'; -import { CanonicalCode, Span, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, Span, SpanKind } from '@opentelemetry/api'; import * as mysqlTypes from 'mysql'; import * as shimmer from 'shimmer'; import { AttributeNames } from './enums'; diff --git a/packages/opentelemetry-plugin-mysql/src/utils.ts b/packages/opentelemetry-plugin-mysql/src/utils.ts index e301d14bf6..4e2d0690a5 100644 --- a/packages/opentelemetry-plugin-mysql/src/utils.ts +++ b/packages/opentelemetry-plugin-mysql/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Attributes } from '@opentelemetry/types'; +import { Attributes } from '@opentelemetry/api'; import { AttributeNames } from './enums'; import { ConnectionConfig, Query } from './types'; diff --git a/packages/opentelemetry-plugin-mysql/test/mysql.test.ts b/packages/opentelemetry-plugin-mysql/test/mysql.test.ts index d422981e7b..394f65a602 100644 --- a/packages/opentelemetry-plugin-mysql/test/mysql.test.ts +++ b/packages/opentelemetry-plugin-mysql/test/mysql.test.ts @@ -26,7 +26,7 @@ import * as mysql from 'mysql'; import { MysqlPlugin, plugin } from '../src'; import * as testUtils from '@opentelemetry/test-utils'; import { AttributeNames } from '../src/enums'; -import { CanonicalCode } from '@opentelemetry/types'; +import { CanonicalCode } from '@opentelemetry/api'; const port = parseInt(process.env.MYSQL_PORT || '33306', 10); const database = process.env.MYSQL_DATABASE || 'test_db'; diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/package.json b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/package.json index 03058deffd..26ab4b9f61 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/package.json +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/package.json @@ -71,7 +71,7 @@ "@opentelemetry/core": "^0.3.3", "@opentelemetry/node": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/pg-pool.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/pg-pool.ts index 0584e29f83..c6ef88ab5a 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/pg-pool.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/pg-pool.ts @@ -15,7 +15,7 @@ */ import { BasePlugin } from '@opentelemetry/core'; -import { CanonicalCode, SpanKind } from '@opentelemetry/types'; +import { CanonicalCode, SpanKind } from '@opentelemetry/api'; import { AttributeNames } from './enums'; import * as shimmer from 'shimmer'; import * as pgPoolTypes from 'pg-pool'; diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/utils.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/utils.ts index dce3f8e2b8..79ded07a71 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/utils.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span, CanonicalCode } from '@opentelemetry/types'; +import { Span, CanonicalCode } from '@opentelemetry/api'; import { PgPoolOptionsParams, PgPoolCallback, PgPoolExtended } from './types'; export function getJDBCString(params: PgPoolOptionsParams) { diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/test/pg-pool.test.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/test/pg-pool.test.ts index 6dcc9caf1e..8fa8fb9396 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/test/pg-pool.test.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/test/pg-pool.test.ts @@ -27,7 +27,7 @@ import { Span, CanonicalCode, Status, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import { plugin as pgPlugin, PostgresPlugin } from '@opentelemetry/plugin-pg'; import { plugin, PostgresPoolPlugin } from '../src'; import { AttributeNames } from '../src/enums'; diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/package.json b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/package.json index eecd8bc925..e736da8141 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/package.json +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/package.json @@ -66,7 +66,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/pg.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/pg.ts index 02902df2db..29f77fb2e7 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/pg.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/pg.ts @@ -15,7 +15,7 @@ */ import { BasePlugin } from '@opentelemetry/core'; -import { CanonicalCode, Span } from '@opentelemetry/types'; +import { CanonicalCode, Span } from '@opentelemetry/api'; import * as pgTypes from 'pg'; import * as shimmer from 'shimmer'; import { diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/utils.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/utils.ts index 2d42ab8f48..373426e79a 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/utils.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/src/utils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span, CanonicalCode, Tracer, SpanKind } from '@opentelemetry/types'; +import { Span, CanonicalCode, Tracer, SpanKind } from '@opentelemetry/api'; import { AttributeNames } from './enums'; import { PgClientExtended, diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/test/pg.test.ts b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/test/pg.test.ts index 03834e2534..a4ad66d5fa 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/test/pg.test.ts +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/test/pg.test.ts @@ -27,7 +27,7 @@ import { Span, CanonicalCode, Status, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import { plugin, PostgresPlugin } from '../src'; import { AttributeNames } from '../src/enums'; import * as assert from 'assert'; diff --git a/packages/opentelemetry-plugin-redis/package.json b/packages/opentelemetry-plugin-redis/package.json index 675b5afdb3..491db5bd75 100644 --- a/packages/opentelemetry-plugin-redis/package.json +++ b/packages/opentelemetry-plugin-redis/package.json @@ -65,7 +65,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-redis/src/utils.ts b/packages/opentelemetry-plugin-redis/src/utils.ts index a9f20d3dd6..8cf65426b3 100644 --- a/packages/opentelemetry-plugin-redis/src/utils.ts +++ b/packages/opentelemetry-plugin-redis/src/utils.ts @@ -15,7 +15,7 @@ */ import * as redisTypes from 'redis'; -import { Tracer, SpanKind, Span, CanonicalCode } from '@opentelemetry/types'; +import { Tracer, SpanKind, Span, CanonicalCode } from '@opentelemetry/api'; import { RedisPluginStreamTypes, RedisPluginClientTypes, diff --git a/packages/opentelemetry-plugin-redis/test/redis.test.ts b/packages/opentelemetry-plugin-redis/test/redis.test.ts index 7cb7a00a45..297fe99a58 100644 --- a/packages/opentelemetry-plugin-redis/test/redis.test.ts +++ b/packages/opentelemetry-plugin-redis/test/redis.test.ts @@ -24,7 +24,7 @@ import { plugin, RedisPlugin } from '../src'; import * as redisTypes from 'redis'; import { NoopLogger } from '@opentelemetry/core'; import * as testUtils from '@opentelemetry/test-utils'; -import { SpanKind, Status, CanonicalCode } from '@opentelemetry/types'; +import { SpanKind, Status, CanonicalCode } from '@opentelemetry/api'; import { AttributeNames } from '../src/enums'; const memoryExporter = new InMemorySpanExporter(); diff --git a/packages/opentelemetry-plugin-xml-http-request/package.json b/packages/opentelemetry-plugin-xml-http-request/package.json index 3f7124d397..68ade47398 100644 --- a/packages/opentelemetry-plugin-xml-http-request/package.json +++ b/packages/opentelemetry-plugin-xml-http-request/package.json @@ -78,7 +78,7 @@ "dependencies": { "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "@opentelemetry/web": "^0.3.3", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-xml-http-request/src/types.ts b/packages/opentelemetry-plugin-xml-http-request/src/types.ts index 92c64f982f..c8b36457cf 100644 --- a/packages/opentelemetry-plugin-xml-http-request/src/types.ts +++ b/packages/opentelemetry-plugin-xml-http-request/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; /** * method "open" from XMLHttpRequest diff --git a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts index a64a3f93d9..3796dc4fa7 100644 --- a/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-plugin-xml-http-request/src/xhr.ts @@ -22,7 +22,7 @@ import { otperformance, urlMatches, } from '@opentelemetry/core'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { addSpanNetworkEvent, getResource, diff --git a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts index d21736db08..3fd7d5eb3c 100644 --- a/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts +++ b/packages/opentelemetry-plugin-xml-http-request/test/xhr.test.ts @@ -26,7 +26,7 @@ import { } from '@opentelemetry/core'; import { ZoneScopeManager } from '@opentelemetry/scope-zone'; import * as tracing from '@opentelemetry/tracing'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { PerformanceTimingNames as PTN, WebTracerRegistry, diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index 7d77e5a5f2..63f02b3182 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -70,6 +70,6 @@ "webpack": "^4.35.2" }, "dependencies": { - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts b/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts index e6d8a4740b..bcfd972492 100644 --- a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts +++ b/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanContext, HttpTextFormat, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, HttpTextFormat, TraceFlags } from '@opentelemetry/api'; export const UBER_TRACE_ID_HEADER = 'uber-trace-id'; diff --git a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts b/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts index 02d50f536d..4e1ae9c9b6 100644 --- a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts +++ b/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts @@ -19,7 +19,7 @@ import { JaegerHttpTraceFormat, UBER_TRACE_ID_HEADER, } from '../src/JaegerHttpTraceFormat'; -import { SpanContext, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, TraceFlags } from '@opentelemetry/api'; describe('JaegerHttpTraceFormat', () => { const jaegerHttpTraceFormat = new JaegerHttpTraceFormat(); diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index c931c3c376..4d8f0e3787 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -55,7 +55,7 @@ }, "dependencies": { "@opentelemetry/core": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "opentracing": "^0.14.4" } } diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts index ccf74b9889..778f440c57 100644 --- a/packages/opentelemetry-shim-opentracing/src/shim.ts +++ b/packages/opentelemetry-shim-opentracing/src/shim.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { NoopLogger } from '@opentelemetry/core'; import * as opentracing from 'opentracing'; diff --git a/packages/opentelemetry-test-utils/package.json b/packages/opentelemetry-test-utils/package.json index b79f45943e..5d13449400 100644 --- a/packages/opentelemetry-test-utils/package.json +++ b/packages/opentelemetry-test-utils/package.json @@ -24,7 +24,7 @@ "devDependencies": { "@opentelemetry/core": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3", + "@opentelemetry/api": "^0.3.3", "gts": "^1.1.2", "ts-node": "^8.6.2", "tslint-consistent-codestyle": "^1.16.0", diff --git a/packages/opentelemetry-test-utils/testUtils.ts b/packages/opentelemetry-test-utils/testUtils.ts index f0eb0aa702..21478e3f9e 100644 --- a/packages/opentelemetry-test-utils/testUtils.ts +++ b/packages/opentelemetry-test-utils/testUtils.ts @@ -15,13 +15,7 @@ */ import * as childProcess from 'child_process'; -import { - SpanKind, - Attributes, - Event, - Span, - Status, -} from '@opentelemetry/types'; +import { SpanKind, Attributes, Event, Span, Status } from '@opentelemetry/api'; import * as assert from 'assert'; import { ReadableSpan } from '@opentelemetry/tracing'; import { diff --git a/packages/opentelemetry-tracing/README.md b/packages/opentelemetry-tracing/README.md index 796567fb21..b6aa054bd7 100644 --- a/packages/opentelemetry-tracing/README.md +++ b/packages/opentelemetry-tracing/README.md @@ -24,12 +24,12 @@ npm install --save @opentelemetry/tracing ## Usage ```js -const opentelemetry = require('@opentelemetry/core'); +const opentelemetry = require('@opentelemetry/api'); const { BasicTracerRegistry } = require('@opentelemetry/tracing'); // To start a trace, you first need to initialize the Tracer registry. // NOTE: the default OpenTelemetry tracer registry does not record any tracing information. -opentelemetry.initGlobalTracer(new BasicTracerRegistry()); +opentelemetry.trace.initGlobalTracerRegistry(new BasicTracerRegistry()); // To create a span in a trace, we used the global singleton tracer to start a new span. const span = opentelemetry.getTracer('default').startSpan('foo'); diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index 179ca5d330..fb511a335a 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -76,6 +76,6 @@ "@opentelemetry/base": "^0.3.3", "@opentelemetry/core": "^0.3.3", "@opentelemetry/scope-base": "^0.3.3", - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-tracing/src/BasicTracerRegistry.ts b/packages/opentelemetry-tracing/src/BasicTracerRegistry.ts index 64b0984304..4c8bb3e494 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerRegistry.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerRegistry.ts @@ -15,7 +15,7 @@ */ import { ConsoleLogger } from '@opentelemetry/core'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { SpanProcessor, Tracer } from '.'; import { DEFAULT_CONFIG } from './config'; import { MultiSpanProcessor } from './MultiSpanProcessor'; diff --git a/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts b/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts index 3d5773875e..54e31ac756 100644 --- a/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/MultiSpanProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span } from '@opentelemetry/types'; +import { Span } from '@opentelemetry/api'; import { SpanProcessor } from './SpanProcessor'; /** diff --git a/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts b/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts index a3aa1018a4..9918d2394f 100644 --- a/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/NoopSpanProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span } from '@opentelemetry/types'; +import { Span } from '@opentelemetry/api'; import { SpanProcessor } from './SpanProcessor'; /** No-op implementation of SpanProcessor */ diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index 64a94630e2..0ae73d8f93 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { hrTime, hrTimeDuration, diff --git a/packages/opentelemetry-tracing/src/SpanProcessor.ts b/packages/opentelemetry-tracing/src/SpanProcessor.ts index 74c3fb078e..233d9fb611 100644 --- a/packages/opentelemetry-tracing/src/SpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/SpanProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Span } from '@opentelemetry/types'; +import { Span } from '@opentelemetry/api'; /** * SpanProcessor is the interface Tracer SDK uses to allow synchronous hooks diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts index 00debfb803..5b899e9c37 100644 --- a/packages/opentelemetry-tracing/src/Tracer.ts +++ b/packages/opentelemetry-tracing/src/Tracer.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { randomTraceId, isValid, diff --git a/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts b/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts index c4ff93fc2a..80f1b33eab 100644 --- a/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/export/BatchSpanProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { TraceFlags } from '@opentelemetry/types'; +import { TraceFlags } from '@opentelemetry/api'; import { unrefTimer } from '@opentelemetry/core'; import { SpanProcessor } from '../SpanProcessor'; import { SpanExporter } from './SpanExporter'; diff --git a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts index a0f84b0626..039752268d 100644 --- a/packages/opentelemetry-tracing/src/export/ReadableSpan.ts +++ b/packages/opentelemetry-tracing/src/export/ReadableSpan.ts @@ -22,7 +22,7 @@ import { Link, SpanContext, TimedEvent, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; export interface ReadableSpan { readonly name: string; diff --git a/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts b/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts index bcf5cfc3cc..c92ae20294 100644 --- a/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts +++ b/packages/opentelemetry-tracing/src/export/SimpleSpanProcessor.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { TraceFlags } from '@opentelemetry/types'; +import { TraceFlags } from '@opentelemetry/api'; import { SpanProcessor } from '../SpanProcessor'; import { SpanExporter } from './SpanExporter'; import { Span } from '../Span'; diff --git a/packages/opentelemetry-tracing/src/types.ts b/packages/opentelemetry-tracing/src/types.ts index dd2be6b970..e8ef51c0ae 100644 --- a/packages/opentelemetry-tracing/src/types.ts +++ b/packages/opentelemetry-tracing/src/types.ts @@ -21,7 +21,7 @@ import { HttpTextFormat, Logger, Sampler, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import { LogLevel } from '@opentelemetry/core'; /** diff --git a/packages/opentelemetry-tracing/test/BasicTracerRegistry.test.ts b/packages/opentelemetry-tracing/test/BasicTracerRegistry.test.ts index 020a5a5ea2..5a612fb04e 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerRegistry.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerRegistry.test.ts @@ -24,7 +24,7 @@ import { TraceState, } from '@opentelemetry/core'; import { NoopScopeManager, ScopeManager } from '@opentelemetry/scope-base'; -import { TraceFlags } from '@opentelemetry/types'; +import { TraceFlags } from '@opentelemetry/api'; import * as assert from 'assert'; import { BasicTracerRegistry, Span } from '../src'; diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts index 60cbbbfc21..802311122f 100644 --- a/packages/opentelemetry-tracing/test/Span.test.ts +++ b/packages/opentelemetry-tracing/test/Span.test.ts @@ -20,7 +20,7 @@ import { CanonicalCode, TraceFlags, SpanContext, -} from '@opentelemetry/types'; +} from '@opentelemetry/api'; import { BasicTracerRegistry, Span } from '../src'; import { hrTime, diff --git a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts index c56d43e870..6254fb5ca4 100644 --- a/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts +++ b/packages/opentelemetry-tracing/test/export/SimpleSpanProcessor.test.ts @@ -21,7 +21,7 @@ import { InMemorySpanExporter, SimpleSpanProcessor, } from '../../src'; -import { SpanContext, SpanKind, TraceFlags } from '@opentelemetry/types'; +import { SpanContext, SpanKind, TraceFlags } from '@opentelemetry/api'; describe('SimpleSpanProcessor', () => { const registry = new BasicTracerRegistry(); diff --git a/packages/opentelemetry-types/README.md b/packages/opentelemetry-types/README.md deleted file mode 100644 index 16a4ce769c..0000000000 --- a/packages/opentelemetry-types/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# OpenTelemetry API for JavaScript -[![Gitter chat][gitter-image]][gitter-url] -[![NPM Published Version][npm-img]][npm-url] -[![dependencies][dependencies-image]][dependencies-url] -[![devDependencies][devDependencies-image]][devDependencies-url] -[![Apache License][license-image]][license-image] - -This package provides TypeScript interfaces and enums for the OpenTelemetry core trace and metrics model. It is intended for use both on the server and in the browser. - - -## Useful links -- For more information on OpenTelemetry, visit: -- For more about OpenTelemetry JavaScript: -- For help or feedback on this project, join us on [gitter][gitter-url] - -## License - -Apache 2.0 - See [LICENSE][license-url] for more information. - -[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg -[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge -[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE -[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat -[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-types -[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-types -[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-types -[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-types&type=dev -[npm-url]: https://www.npmjs.com/package/@opentelemetry/types -[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Ftypes.svg diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index 968a5e91b7..e0649266f1 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -76,6 +76,6 @@ "@opentelemetry/core": "^0.3.3", "@opentelemetry/scope-base": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", - "@opentelemetry/types": "^0.3.3" + "@opentelemetry/api": "^0.3.3" } } diff --git a/packages/opentelemetry-web/src/utils.ts b/packages/opentelemetry-web/src/utils.ts index c1c999cbbc..6c9dc7e2a8 100644 --- a/packages/opentelemetry-web/src/utils.ts +++ b/packages/opentelemetry-web/src/utils.ts @@ -16,7 +16,7 @@ import { PerformanceEntries, PerformanceResourceTimingInfo } from './types'; import { PerformanceTimingNames as PTN } from './enums/PerformanceTimingNames'; -import * as types from '@opentelemetry/types'; +import * as types from '@opentelemetry/api'; import { hrTimeToNanoseconds, timeInputToHrTime } from '@opentelemetry/core'; /** diff --git a/packages/opentelemetry-web/test/utils.test.ts b/packages/opentelemetry-web/test/utils.test.ts index bc33da84a2..9bda58b9ef 100644 --- a/packages/opentelemetry-web/test/utils.test.ts +++ b/packages/opentelemetry-web/test/utils.test.ts @@ -20,7 +20,7 @@ import { } from '@opentelemetry/core'; import * as core from '@opentelemetry/core'; import * as tracing from '@opentelemetry/tracing'; -import { HrTime } from '@opentelemetry/types'; +import { HrTime } from '@opentelemetry/api'; import * as assert from 'assert'; import * as sinon from 'sinon';