From 53dda64823755c1bd7da0eef8fe8920638d41362 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Mon, 27 Jan 2020 19:13:07 -0500 Subject: [PATCH 1/7] feat(plugin-http): sync. specs for statuscode (#719) test: fix and add tests closes #642 Signed-off-by: Olivier Albertini --- packages/opentelemetry-plugin-http/README.md | 1 + .../opentelemetry-plugin-http/src/types.ts | 4 ++ .../opentelemetry-plugin-http/src/utils.ts | 71 ++++++++++++------- .../test/functionals/http-enable.test.ts | 14 +++- .../test/functionals/utils.test.ts | 23 +++--- 5 files changed, 79 insertions(+), 34 deletions(-) diff --git a/packages/opentelemetry-plugin-http/README.md b/packages/opentelemetry-plugin-http/README.md index 69d196b5cdd..59c7fa31e52 100644 --- a/packages/opentelemetry-plugin-http/README.md +++ b/packages/opentelemetry-plugin-http/README.md @@ -55,6 +55,7 @@ Http plugin has few options available to choose from. You can set the following: | [`ignoreIncomingPaths`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-http/src/types.ts#L28) | `IgnoreMatcher[]` | Http plugin will not trace all incoming requests that match paths | | [`ignoreOutgoingUrls`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-http/src/types.ts#L28) | `IgnoreMatcher[]` | Http plugin will not trace all outgoing requests that match urls | | [`serverName`](https://github.com/open-telemetry/opentelemetry-js/blob/master/packages/opentelemetry-plugin-http/src/types.ts#L28) | `string` | The primary server name of the matched virtual host. | + ## Useful links - For more information on OpenTelemetry, visit: - For more about OpenTelemetry JavaScript: diff --git a/packages/opentelemetry-plugin-http/src/types.ts b/packages/opentelemetry-plugin-http/src/types.ts index 432235a05a1..bfd75fefd85 100644 --- a/packages/opentelemetry-plugin-http/src/types.ts +++ b/packages/opentelemetry-plugin-http/src/types.ts @@ -78,3 +78,7 @@ export interface Err extends Error { syscall?: string; stack?: string; } + +export interface SpecialHttpStatusCodeMapping { + [custom: number]: number; +} diff --git a/packages/opentelemetry-plugin-http/src/utils.ts b/packages/opentelemetry-plugin-http/src/utils.ts index f49a9978d4b..2f8c02d8b8d 100644 --- a/packages/opentelemetry-plugin-http/src/utils.ts +++ b/packages/opentelemetry-plugin-http/src/utils.ts @@ -23,12 +23,30 @@ import { OutgoingHttpHeaders, ServerResponse, } from 'http'; -import { IgnoreMatcher, Err, ParsedRequestOptions } from './types'; +import { + IgnoreMatcher, + Err, + ParsedRequestOptions, + SpecialHttpStatusCodeMapping, +} from './types'; import { AttributeNames } from './enums/AttributeNames'; import * as url from 'url'; import { Socket } from 'net'; export const OT_REQUEST_HEADER = 'x-opentelemetry-outgoing-request'; + +export const HTTP_STATUS_SPECIAL_CASES: SpecialHttpStatusCodeMapping = { + 401: CanonicalCode.UNAUTHENTICATED, + 403: CanonicalCode.PERMISSION_DENIED, + 404: CanonicalCode.NOT_FOUND, + 429: CanonicalCode.RESOURCE_EXHAUSTED, + 501: CanonicalCode.UNIMPLEMENTED, + 503: CanonicalCode.UNAVAILABLE, + 504: CanonicalCode.DEADLINE_EXCEEDED, + 598: CanonicalCode.INTERNAL, + 599: CanonicalCode.INTERNAL, +}; + /** * Get an absolute url */ @@ -58,37 +76,40 @@ export const getAbsoluteUrl = ( return `${protocol}//${host}${path}`; }; /** - * Parse status code from HTTP response. + * Parse status code from HTTP response. [More details](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md#status) */ export const parseResponseStatus = ( statusCode: number ): Omit => { - if (statusCode < 200 || statusCode > 504) { + // search for special case + const code: number | undefined = HTTP_STATUS_SPECIAL_CASES[statusCode]; + + if (code !== undefined) { + return { code }; + } + + // 0xx are unknown + if (statusCode < 100) { return { code: CanonicalCode.UNKNOWN }; - } else if (statusCode >= 200 && statusCode < 400) { + } + + // 1xx, 2xx, 3xx are OK + if (statusCode < 400) { return { code: CanonicalCode.OK }; - } else { - switch (statusCode) { - case 400: - return { code: CanonicalCode.INVALID_ARGUMENT }; - case 504: - return { code: CanonicalCode.DEADLINE_EXCEEDED }; - case 404: - return { code: CanonicalCode.NOT_FOUND }; - case 403: - return { code: CanonicalCode.PERMISSION_DENIED }; - case 401: - return { code: CanonicalCode.UNAUTHENTICATED }; - case 429: - return { code: CanonicalCode.RESOURCE_EXHAUSTED }; - case 501: - return { code: CanonicalCode.UNIMPLEMENTED }; - case 503: - return { code: CanonicalCode.UNAVAILABLE }; - default: - return { code: CanonicalCode.UNKNOWN }; - } } + + // 4xx are client errors + if (statusCode < 500) { + return { code: CanonicalCode.INVALID_ARGUMENT }; + } + + // 5xx are internal errors + if (statusCode < 512) { + return { code: CanonicalCode.INTERNAL }; + } + + // All other codes are unknown + return { code: CanonicalCode.UNKNOWN }; }; /** 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 4efaa6920d1..75353e2c212 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts @@ -280,7 +280,19 @@ describe('HttpPlugin', () => { assert.strictEqual(spans.length, 0); }); - const httpErrorCodes = [400, 401, 403, 404, 429, 501, 503, 504, 500, 505]; + const httpErrorCodes = [ + 400, + 401, + 403, + 404, + 429, + 501, + 503, + 504, + 500, + 505, + 597, + ]; for (let i = 0; i < httpErrorCodes.length; i++) { it(`should test span for GET requests with http error ${httpErrorCodes[i]}`, async () => { diff --git a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts index 32372c8cbed..c8bcddd957f 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts @@ -14,17 +14,17 @@ * limitations under the License. */ +import { NoopLogger } from '@opentelemetry/core'; +import { NoopScopeManager } from '@opentelemetry/scope-base'; +import { BasicTracerRegistry, Span } from '@opentelemetry/tracing'; +import { CanonicalCode, SpanKind } from '@opentelemetry/types'; import * as assert from 'assert'; +import * as http from 'http'; import * as sinon from 'sinon'; import * as url from 'url'; -import { CanonicalCode, SpanKind } from '@opentelemetry/types'; -import { NoopScopeManager } from '@opentelemetry/scope-base'; +import { AttributeNames } from '../../src'; import { IgnoreMatcher } from '../../src/types'; import * as utils from '../../src/utils'; -import * as http from 'http'; -import { Span, BasicTracerRegistry } from '@opentelemetry/tracing'; -import { AttributeNames } from '../../src'; -import { NoopLogger } from '@opentelemetry/core'; describe('Utility', () => { describe('parseResponseStatus()', () => { @@ -36,18 +36,25 @@ describe('Utility', () => { }); it('should return OK for Success HTTP status code', () => { - for (let index = 200; index < 400; index++) { + for (let index = 100; index < 400; index++) { const status = utils.parseResponseStatus(index); assert.deepStrictEqual(status, { code: CanonicalCode.OK }); } }); it('should not return OK for Bad HTTP status code', () => { - for (let index = 400; index <= 504; index++) { + for (let index = 400; index <= 600; index++) { const status = utils.parseResponseStatus(index); assert.notStrictEqual(status.code, CanonicalCode.OK); } }); + it('should handle special HTTP status codes', () => { + for (const key in utils.HTTP_STATUS_SPECIAL_CASES) { + const status = utils.parseResponseStatus(key as any); + const canonicalCode = utils.HTTP_STATUS_SPECIAL_CASES[key]; + assert.deepStrictEqual(status.code, canonicalCode); + } + }); }); describe('hasExpectHeader()', () => { it('should throw if no option', () => { From 8711f2b7940c216789649a43b1822b1c8e63d005 Mon Sep 17 00:00:00 2001 From: Xiao Date: Tue, 28 Jan 2020 06:15:03 -0800 Subject: [PATCH 2/7] chore: add instruction for pg-pool plugin (#733) * chore: add instruction for pg-pool plugin * chore: update NodeTracer to NodeTracerRegistry * chore: address comments Co-authored-by: Valentin Marchaud Co-authored-by: Daniel Dyla --- packages/opentelemetry-plugin-grpc/README.md | 2 +- packages/opentelemetry-plugin-http/README.md | 2 +- packages/opentelemetry-plugin-https/README.md | 2 +- .../opentelemetry-plugin-ioredis/README.md | 10 +++--- .../opentelemetry-plugin-mongodb/README.md | 2 +- packages/opentelemetry-plugin-mysql/README.md | 10 +++--- .../opentelemetry-plugin-pg-pool/README.md | 33 +++++++++++++++++-- .../opentelemetry-plugin-pg/README.md | 16 ++++----- packages/opentelemetry-plugin-redis/README.md | 2 +- 9 files changed, 53 insertions(+), 26 deletions(-) diff --git a/packages/opentelemetry-plugin-grpc/README.md b/packages/opentelemetry-plugin-grpc/README.md index e728f8e6947..acd3871178b 100644 --- a/packages/opentelemetry-plugin-grpc/README.md +++ b/packages/opentelemetry-plugin-grpc/README.md @@ -35,7 +35,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```javascript const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-http/README.md b/packages/opentelemetry-plugin-http/README.md index 59c7fa31e52..375619266f8 100644 --- a/packages/opentelemetry-plugin-http/README.md +++ b/packages/opentelemetry-plugin-http/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-https/README.md b/packages/opentelemetry-plugin-https/README.md index a47a71a6caa..3271ff2ba81 100644 --- a/packages/opentelemetry-plugin-https/README.md +++ b/packages/opentelemetry-plugin-https/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-ioredis/README.md b/packages/opentelemetry-plugin-ioredis/README.md index 78095ac4e2f..9ccd46aca36 100644 --- a/packages/opentelemetry-plugin-ioredis/README.md +++ b/packages/opentelemetry-plugin-ioredis/README.md @@ -22,9 +22,9 @@ npm install --save @opentelemetry/plugin-ioredis To load a specific plugin (**ioredis** in this case), specify it in the Node Tracer's configuration ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { ioredis: { enabled: true, @@ -35,11 +35,11 @@ const tracer = new NodeTracer({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```javascript -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); +const registry = new NodeTracerRegistry(); ``` ## Useful links diff --git a/packages/opentelemetry-plugin-mongodb/README.md b/packages/opentelemetry-plugin-mongodb/README.md index e9489b07015..ecccac7fc75 100644 --- a/packages/opentelemetry-plugin-mongodb/README.md +++ b/packages/opentelemetry-plugin-mongodb/README.md @@ -36,7 +36,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```js const { NodeTracerRegistry } = require('@opentelemetry/node'); diff --git a/packages/opentelemetry-plugin-mysql/README.md b/packages/opentelemetry-plugin-mysql/README.md index fb2e08e1835..5aba3e68a33 100644 --- a/packages/opentelemetry-plugin-mysql/README.md +++ b/packages/opentelemetry-plugin-mysql/README.md @@ -24,9 +24,9 @@ OpenTelemetry MySQL Instrumentation allows the user to automatically collect tra To load a specific plugin (**MySQL** in this case), specify it in the Node Tracer's configuration ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { mysql: { enabled: true, @@ -37,11 +37,11 @@ const tracer = new NodeTracer({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); +const registry = new NodeTracerRegistry(); ``` See [examples/mysql](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/mysql) for a short example. diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md index 498830104cf..d831db00b08 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg-pool/README.md @@ -12,20 +12,47 @@ For automatic instrumentation see the ## Installation ```bash +npm install --save @opentelemetry/plugin-pg npm install --save @opentelemetry/plugin-pg-pool ``` ## Usage +To load all of the [default supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use the below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. + ```js -const opentelemetry = require('@opentelemetry/plugin-pg-pool'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -// TODO: DEMONSTRATE API +const registry = new NodeTracerRegistry(); // All default plugins will be used ``` +If instead you would just want to load a specific plugin (**pg** and **pg-pool** in this case), specify it in the `NodeTracer` configuration. You'll need to install both plugins for full functionality. + +```js +const { NodeTracerRegistry } = require('@opentelemetry/node'); + +const registry = new NodeTracerRegistry({ + plugins: { + pg: { + enabled: true, + // You may use a package name or absolute path to the module + path: '@opentelemetry/plugin-pg', + }, + 'pg-pool': { + enabled: true, + // You may use a package name or absolute path to the module + path: '@opentelemetry/plugin-pg-pool', + } + } +}); +``` + +See [examples/postgres](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/postgres) for a short example. + ## Supported Versions -- [pg](https://npmjs.com/package/pg-pool): `2.x` +- [pg](https://npmjs.com/package/pg): `7.x` +- [pg-pool](https://npmjs.com/package/pg-pool): `2.x` ## Useful links - For more information on OpenTelemetry, visit: diff --git a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md index ba0627c815a..88cc40c2e77 100644 --- a/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md +++ b/packages/opentelemetry-plugin-postgres/opentelemetry-plugin-pg/README.md @@ -18,20 +18,20 @@ npm install --save @opentelemetry/plugin-pg-pool ## Usage -To load all of the [default supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use the below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugsin for unused modules. +To load all of the [default supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use the below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer(); // All default plugins will be used +const registry = new NodeTracerRegistry(); // All default plugins will be used ``` -If instead you would just load a specific plugin (**pg** in this case), specify it in the `NodeTracer` configuration. +If instead you would just want to load a specific plugin (**pg** in this case), specify it in the `NodeTracer` configuration. ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { pg: { enabled: true, @@ -45,9 +45,9 @@ const tracer = new NodeTracer({ If you are using any of the [`pg.Pool`](https://node-postgres.com/api/pool) APIs, you will also need to include the [`pg-pool` plugin](../opentelemetry-plugin-pg-pool). ```js -const { NodeTracer } = require('@opentelemetry/node'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); -const tracer = new NodeTracer({ +const registry = new NodeTracerRegistry({ plugins: { pg: { enabled: true, diff --git a/packages/opentelemetry-plugin-redis/README.md b/packages/opentelemetry-plugin-redis/README.md index 5751420c8e4..bfb2d1e4783 100644 --- a/packages/opentelemetry-plugin-redis/README.md +++ b/packages/opentelemetry-plugin-redis/README.md @@ -37,7 +37,7 @@ const registry = new NodeTracerRegistry({ }); ``` -To load all the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. ```javascript const { NodeTracerRegistry } = require('@opentelemetry/node'); From 3dd2a68eab7a415a2106d2c0a97f31ca002ca316 Mon Sep 17 00:00:00 2001 From: Naseem Date: Tue, 28 Jan 2020 09:25:08 -0500 Subject: [PATCH 3/7] docs: add ioredis example (#665) * docs: add ioredis example * refactor: simplify example * fix: ioredis example * fix: tracerRegistry not tracer * fix: test only with set command * fix: only use Jaeger as backend Signed-off-by: Naseem Co-authored-by: Daniel Dyla --- examples/ioredis/README.md | 39 ++++++++++++++++++++++++++++++++++ examples/ioredis/index.js | 19 +++++++++++++++++ examples/ioredis/package.json | 40 +++++++++++++++++++++++++++++++++++ examples/ioredis/tracer.js | 17 +++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 examples/ioredis/README.md create mode 100644 examples/ioredis/index.js create mode 100644 examples/ioredis/package.json create mode 100644 examples/ioredis/tracer.js diff --git a/examples/ioredis/README.md b/examples/ioredis/README.md new file mode 100644 index 00000000000..0f486e7faa0 --- /dev/null +++ b/examples/ioredis/README.md @@ -0,0 +1,39 @@ +# Overview + +OpenTelemetry IORedis Instrumentation allows the user to automatically collect trace data and export them to the backend(s) of choice (Jaeger in this example). + +## Tracing backend setup + +### Jaeger + +- Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one) + +## Installation + +```sh +npm install +``` + +## Run the Application + +- Start redis via docker + + ```sh + npm run docker:start + ``` + +- Run the main program + + ```sh + npm run start + ``` + +- Cleanup docker + + ```sh + npm run docker:stop + ``` + +## LICENSE + +Apache License 2.0 diff --git a/examples/ioredis/index.js b/examples/ioredis/index.js new file mode 100644 index 00000000000..027d87e00f8 --- /dev/null +++ b/examples/ioredis/index.js @@ -0,0 +1,19 @@ +'use strict'; + +// Require tracer before any other modules +require('./tracer'); +const Redis = require('ioredis'); + +const redis = new Redis(); + +async function main() { + try { + await redis.set('test', 'data'); + process.exit(0); + } catch (error) { + console.error(error); + process.exit(1); + } +} + +main(); diff --git a/examples/ioredis/package.json b/examples/ioredis/package.json new file mode 100644 index 00000000000..b356bfd0475 --- /dev/null +++ b/examples/ioredis/package.json @@ -0,0 +1,40 @@ +{ + "name": "ioredis-example", + "private": true, + "version": "0.3.3", + "description": "Example of HTTP integration with OpenTelemetry", + "main": "index.js", + "scripts": { + "docker:start": "docker run -d -p 6379:6379 --name otjsredis redis:alpine", + "docker:stop": "docker stop otjsredis && docker rm otjsredis", + "start": "node index.js" + }, + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/open-telemetry/opentelemetry-js.git" + }, + "keywords": [ + "opentelemetry", + "redis", + "ioredis", + "tracing" + ], + "engines": { + "node": ">=8" + }, + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/open-telemetry/opentelemetry-js/issues" + }, + "dependencies": { + "@opentelemetry/core": "^0.3.3", + "@opentelemetry/exporter-jaeger": "^0.3.3", + "@opentelemetry/node": "^0.3.3", + "@opentelemetry/plugin-ioredis": "^0.3.3", + "@opentelemetry/tracing": "^0.3.3", + "ioredis": "^4.14.1" + }, + "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", + "devDependencies": {} +} diff --git a/examples/ioredis/tracer.js b/examples/ioredis/tracer.js new file mode 100644 index 00000000000..f806749c7a8 --- /dev/null +++ b/examples/ioredis/tracer.js @@ -0,0 +1,17 @@ +'use strict'; + +const opentelemetry = require('@opentelemetry/core'); +const { NodeTracerRegistry } = require('@opentelemetry/node'); +const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); +const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); + +const tracerRegistry = new NodeTracerRegistry(); + +const exporter = new JaegerExporter({ serviceName: 'ioredis-example' }); + +tracerRegistry.addSpanProcessor(new SimpleSpanProcessor(exporter)); + +// Initialize the OpenTelemetry APIs to use the BasicTracer bindings +opentelemetry.initGlobalTracerRegistry(tracerRegistry); + +module.exports = opentelemetry.getTracer(); From 7949e3fa272a25c2d71b1794b1514cbe1624f168 Mon Sep 17 00:00:00 2001 From: Naseem Date: Tue, 28 Jan 2020 10:04:47 -0500 Subject: [PATCH 4/7] [ioredis plugin] fix: change supportedVersions to >1 <5 (#671) * fix: change supportedVersions to 4.x.x * fix: supported versions Co-authored-by: Daniel Dyla --- packages/opentelemetry-plugin-ioredis/src/ioredis.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/opentelemetry-plugin-ioredis/src/ioredis.ts b/packages/opentelemetry-plugin-ioredis/src/ioredis.ts index 7d08fd0fed8..978ec8322f6 100644 --- a/packages/opentelemetry-plugin-ioredis/src/ioredis.ts +++ b/packages/opentelemetry-plugin-ioredis/src/ioredis.ts @@ -23,7 +23,7 @@ import { VERSION } from './version'; export class IORedisPlugin extends BasePlugin { static readonly COMPONENT = 'ioredis'; static readonly DB_TYPE = 'redis'; - readonly supportedVersions = ['^2.0.0']; + readonly supportedVersions = ['>1 <5']; constructor(readonly moduleName: string) { super('@opentelemetry/plugin-ioredis', VERSION); From 4e3c44da3707fa431ddab52edd9573943588f7c9 Mon Sep 17 00:00:00 2001 From: Mayur Kale Date: Tue, 28 Jan 2020 12:50:35 -0800 Subject: [PATCH 5/7] Update Stackdriver exporter example (#731) * Update Stackdriver exporter example * fix: example lints --- examples/postgres/package.json | 6 +++--- examples/stackdriver-trace/index.js | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/examples/postgres/package.json b/examples/postgres/package.json index eff66b11611..52b291bff23 100644 --- a/examples/postgres/package.json +++ b/examples/postgres/package.json @@ -39,11 +39,11 @@ "@opentelemetry/plugin-pg-pool": "^0.3.3", "@opentelemetry/tracing": "^0.3.3", "@opentelemetry/types": "^0.3.3", - "express": "^4.17.1" + "express": "^4.17.1", + "pg": "^7.12.1" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { - "cross-env": "^6.0.0", - "pg": "^7.12.1" + "cross-env": "^6.0.0" } } diff --git a/examples/stackdriver-trace/index.js b/examples/stackdriver-trace/index.js index 277ddba4317..7dda540e81c 100644 --- a/examples/stackdriver-trace/index.js +++ b/examples/stackdriver-trace/index.js @@ -1,27 +1,27 @@ 'use strict'; const opentelemetry = require('@opentelemetry/core'); -const { BasicTracer, SimpleSpanProcessor } = require('@opentelemetry/tracing'); +const { BasicTracerRegistry, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CanonicalCode } = require('@opentelemetry/types'); const { StackdriverTraceExporter } = require('@opentelemetry/exporter-stackdriver-trace'); // Initialize an exporter const exporter = new StackdriverTraceExporter({ - serviceName: 'basic-service', - logger: new opentelemetry.ConsoleLogger(), + projectId: '', }); -const tracer = new BasicTracer(); +const registry = new BasicTracerRegistry(); // Configure span processor to send spans to the provided exporter -tracer.addSpanProcessor(new SimpleSpanProcessor(exporter)); +registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); -// Initialize the OpenTelemetry APIs to use the BasicTracer bindings -opentelemetry.initGlobalTracer(tracer); +// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings +opentelemetry.initGlobalTracerRegistry(registry); +const tracer = opentelemetry.getTracer('stackdriver-basic'); // Create a span. A span must be closed. -const root = opentelemetry.getTracer().startSpan('main'); -const related = opentelemetry.getTracer().startSpan('related', { +const root = tracer.startSpan('main'); +const related = tracer.startSpan('related', { links: [{ spanContext: root.context() }], }); @@ -42,9 +42,7 @@ exporter.shutdown(); function doWork(parent) { // Start another span. In this example, the main method already started a // span, so that'll be the parent span, and this will be a child span. - const span = opentelemetry.getTracer().startSpan('doWork', { - parent, - }); + const span = tracer.startSpan('doWork', { parent }); // simulate some random work. const work = Math.floor(Math.random() * 40000000); From 4a83613c5b1e969e240e210e7bb727ad02b7e438 Mon Sep 17 00:00:00 2001 From: Uladzislau Kiva Date: Wed, 29 Jan 2020 16:44:34 +0300 Subject: [PATCH 6/7] feat: decode jaeger header (#735) * feat: decode jaeger header * fix: gts fix * fix: use const instead of variables * fix: use const for headers Co-authored-by: Uladzislau Kiva Co-authored-by: Daniel Dyla --- .../src/JaegerHttpTraceFormat.ts | 2 +- .../test/JaegerHttpTraceFormat.test.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts b/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts index 811c6d9d410..e6d8a4740b9 100644 --- a/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts +++ b/packages/opentelemetry-propagator-jaeger/src/JaegerHttpTraceFormat.ts @@ -86,7 +86,7 @@ export class JaegerHttpTraceFormat implements HttpTextFormat { * @return {SpanContext} - returns a span context represented by the serializedString. **/ function deserializeSpanContext(serializedString: string): SpanContext | null { - let headers = serializedString.split(':'); + const headers = decodeURIComponent(serializedString).split(':'); if (headers.length !== 4) { return null; } diff --git a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts b/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts index a81dc92ffa8..02d50f536d2 100644 --- a/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts +++ b/packages/opentelemetry-propagator-jaeger/test/JaegerHttpTraceFormat.test.ts @@ -88,6 +88,19 @@ describe('JaegerHttpTraceFormat', () => { }); }); + it('should extract context of a sampled span from UTF-8 encoded carrier', () => { + carrier[UBER_TRACE_ID_HEADER] = + 'ac1f3dc3c2c0b06e%3A5ac292c4a11a163e%3Ac086aaa825821068%3A1'; + const extractedSpanContext = jaegerHttpTraceFormat.extract('', carrier); + + assert.deepStrictEqual(extractedSpanContext, { + spanId: '5ac292c4a11a163e', + traceId: 'ac1f3dc3c2c0b06e', + isRemote: true, + traceFlags: TraceFlags.SAMPLED, + }); + }); + it('should use custom header if provided', () => { carrier[customHeader] = 'd4cda95b652f4a1592b449d5929fda1b:6e0c63257de34c92:0:01'; From 5d6c99d126a8197494968ce8430a05decc0afee9 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 29 Jan 2020 16:30:49 -0500 Subject: [PATCH 7/7] 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 49f2fb39df7..4aa0ba01f17 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 b434fd86400..78238cbceda 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 525e3535db2..abcf0681f41 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 e5ce2fbc516..193684da438 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 8f7b383bd11..edbbafbc9b4 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 00000000000..c58af54e751 --- /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 00000000000..7183aab0336 --- /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 8c8ae8bd88c..e270187111b 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 00000000000..80a1bf1c230 --- /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 00000000000..60b1a30c974 --- /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 b1428617e2e..effec6183fc 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 2cc71b971e6..7596dd96b35 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 e8f77714d30..d73844a7159 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 5e63905ae57..c39a664aa57 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 ab2a28e0ec9..81911dd7337 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 a6fb36da30d..cfa3c9c4c08 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 bd569977fa7..27e47a9093c 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 701dd9d3bf8..c28e99af891 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 71f1051ebad..d77b252cf78 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 00000000000..7731f090914 --- /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 1e15fdb6b5b..a8a0a189c5a 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 468c42947d2..0350a9ab531 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 892e0821052..32dd6813ed6 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 a96e8caea4e..d4356dbe87e 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 172dc627fee..3028b9d2b06 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 e0db5863c8e..f0b1edd1d34 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 861c9efc440..13416ca2d79 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 fe8ed5f1cb2..2363edc3c7c 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 6d44ca78946..ebcd0391cd2 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 9e42f991c2f..cf9860014fa 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 582101ab1ee..f1d0611e27b 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 464a8fa1a9a..cf2920ab375 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 50aeee7006d..cb42e83b64d 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 f61180dc8fc..00000000000 --- 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 04ccc60b26c..af3749b58d4 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 3960e8675a3..e76f5cc5b8a 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 a6491b82cbb..1f20afd2347 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 a65af498fc9..54bfa6e09e3 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 b5d2b530d3f..97087e076ab 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 fae99249a8e..0b5c303fd46 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 4d212b2f85c..28cbf335b40 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 28419030099..7a834528312 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 574ce36ea91..f1706f733e4 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 867b3446929..594584162a6 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 7f978bfcb6a..ac2c636c824 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 c7fff44901e..f825c99f1ea 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 f7932a2afb1..ca8b1f9203d 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 aaf024b0251..1d60c442e27 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 1e5cb13b3d2..1960000d33d 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 d1227f04a8c..4eb4213eac8 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 a1285e8b90b..e6a3c71127b 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 4ae500f74eb..50bdb042c01 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 01451b9e961..0ce2338497d 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 ab17951c6c1..f7f060e16f6 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 3cc994294b2..20ef8467c8b 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 bce206264e9..4e81dd724bf 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 b0d657da60e..8be1a400e4f 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 aa8de5ac6f6..bfdc74cc19f 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 9ac12f5e0aa..65553bbee89 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 d914773f510..11e440f63f6 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 7e92251f802..b2e56391ce7 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 a49c6880411..1e5c5f41259 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 ae17b053fd8..e88b6e9b2a1 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 cfacb9dc02a..68e60baf23d 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 1a35b76d8cc..6d9ddf7969f 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 ba53d81b703..1fd210e0c58 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 06c6c06c379..cbf09085261 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 f04d33e28b2..4efd641f897 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 2be9f91fcf0..1939a9eb652 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 641803902fe..70c4ac16959 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 2a09e37230c..b4b0a5177a0 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 6336ad4c9ee..21a5e197086 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 3899c323ef6..a30ed8426ad 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 fb038384bf0..633f113ac59 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 1a29ad5f5f5..97f3ff08472 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 c9eb6836635..d4c5b2b6e5c 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 88404ee5cd9..4f66dcd8aea 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 031682d5b9d..22fd4527fe5 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 5b8cdf6eed3..e65d35a29b9 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 f0269a5b24a..ab26ebff925 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 8e6c195c32b..38487bec66a 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 ab112d2f3a7..1e883fae4c7 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 99d2abf487d..7f4bfc03458 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 9460de4ad8d..062682e3fb7 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 757be773481..d44ff9a3b4e 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 93440eb2942..b493870ef9f 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 453d64d1868..10c26a01510 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 f7c3eb651b3..d305079dc71 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 0f84de4f60a..54ad5af6e75 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 d2d1b2ce840..f34db15c012 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 4be83dbed20..6355cd73e1f 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 088a6ea93d5..27b4f0a1487 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 ec9e49ae515..ad3782613d7 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 dc8df543dd1..e6238651f59 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 d2a4116b979..3e77482872a 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 2d14055cd8b..cb661df6e5b 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 6ae19c38464..b2a0469956a 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 d8340c5fd37..f63e2c46e16 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 901eba22fe6..e01f2aeb3be 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 762d571d47c..f9d5c6dd794 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 3f778496ea5..1a0adf6eff8 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 acfd340eb17..b484a1561e7 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 adeee6a5881..ec909d8e87b 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 f45fb6ac560..ee4c7f44ca0 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 bfd75fefd85..335e0bbc304 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 2f8c02d8b8d..d9b4b94fc05 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 b9b13276b91..33de9db58d6 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 75353e2c212..e623ebce520 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 cf9e68c6197..bf32608c60f 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 c8bcddd957f..8278d6dd25d 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 0793aa99ed8..14520126758 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 2c9cbd238d9..3e4ca727fc9 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 ce9dc855b6f..cc70a654b91 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 d4ef6e79b96..f241d50772e 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 826fc5d72c3..0dbe79d2efb 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 477b2b906ce..4d5b261de82 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 63769e16f8a..23ec98232c1 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 39002c8af61..be0d7ae4ed9 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 2c9cbd238d9..3e4ca727fc9 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 71167b4e6dc..91afcab1708 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 ec16e8cd3c9..d9282fe276d 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 8dbae4478b5..44f9f573eda 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 3f99e22216f..1aad4e2246b 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 a1cfd453f25..cad7a84fc14 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 ebcab736996..93eed568dfd 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 23e3b9d14de..26c90213eba 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 8cf5529cedf..c246fc28efa 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 9fcd6e64b61..f5106d10328 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 e301d14bf61..4e2d0690a56 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 d422981e7b2..394f65a6023 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 03058deffdf..26ab4b9f617 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 0584e29f839..c6ef88ab5a4 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 dce3f8e2b8a..79ded07a711 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 6dcc9caf1eb..8fa8fb9396a 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 eecd8bc925b..e736da8141b 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 02902df2db3..29f77fb2e78 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 2d42ab8f480..373426e79ab 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 03834e2534f..a4ad66d5fa2 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 675b5afdb31..491db5bd756 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 a9f20d3dd62..8cf65426b30 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 7cb7a00a45c..297fe99a586 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 3f7124d3975..68ade47398f 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 92c64f982f4..c8b36457cf4 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 a64a3f93d9c..3796dc4fa7e 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 d21736db087..3fd7d5eb3c9 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 7d77e5a5f2e..63f02b3182e 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 e6d8a4740b9..bcfd9724922 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 02d50f536d2..4e1ae9c9b66 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 c931c3c3767..4d8f0e37878 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 ccf74b98892..778f440c576 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 b79f45943e0..5d13449400a 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 f0eb0aa7020..21478e3f9e3 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 796567fb215..b6aa054bd72 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 179ca5d330a..fb511a335a8 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 64b09843045..4c8bb3e4943 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 3d5773875e4..54e31ac7566 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 a3aa1018a4c..9918d2394f0 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 64a94630e2b..0ae73d8f93a 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 74c3fb078ea..233d9fb6119 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 00debfb8032..5b899e9c373 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 c4ff93fc2aa..80f1b33eab5 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 a0f84b0626c..039752268de 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 bcf5cfc3cc9..c92ae20294b 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 dd2be6b970c..e8ef51c0aee 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 020a5a5ea28..5a612fb04e2 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 60cbbbfc21a..802311122fa 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 c56d43e8708..6254fb5ca4b 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 16a4ce769c8..00000000000 --- 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 968a5e91b75..e0649266f16 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 c1c999cbbc7..6c9dc7e2a86 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 bc33da84a29..9bda58b9efd 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';