From e93888228af333ae831d498a32fbd6ce4272e2c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerhard=20St=C3=B6bich?= Date: Thu, 29 Apr 2021 14:13:02 +0200 Subject: [PATCH 01/16] chore: update dev-dependencies (#48) --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 6fff6ef9..bd1ea0d0 100644 --- a/package.json +++ b/package.json @@ -55,14 +55,14 @@ "access": "public" }, "devDependencies": { - "@types/mocha": "8.2.1", - "@types/node": "14.14.28", - "@types/sinon": "9.0.10", + "@types/mocha": "8.2.2", + "@types/node": "14.14.42", + "@types/sinon": "10.0.0", "@types/webpack-env": "1.16.0", - "@typescript-eslint/eslint-plugin": "4.15.1", - "@typescript-eslint/parser": "4.15.1", + "@typescript-eslint/eslint-plugin": "4.22.0", + "@typescript-eslint/parser": "4.22.0", "codecov": "3.8.1", - "eslint": "7.20.0", + "eslint": "7.25.0", "eslint-plugin-header": "3.1.1", "eslint-plugin-import": "2.22.1", "gh-pages": "3.1.0", @@ -74,15 +74,15 @@ "karma-mocha": "2.0.1", "karma-spec-reporter": "0.0.32", "karma-webpack": "4.0.2", - "lerna-changelog": "^1.0.1", - "linkinator": "2.13.5", + "lerna-changelog": "1.0.1", + "linkinator": "2.13.6", "mocha": "7.2.0", "nyc": "15.1.0", - "sinon": "9.2.4", - "ts-loader": "8.0.17", + "sinon": "10.0.0", + "ts-loader": "8.2.0", "ts-mocha": "8.0.0", - "typedoc": "0.20.25", - "typescript": "4.1.5", + "typedoc": "0.20.36", + "typescript": "4.2.4", "webpack": "4.46.0" } } From c595a59770d6dc30110bd9412d613ea20c25c654 Mon Sep 17 00:00:00 2001 From: Valentin Marchaud Date: Sun, 2 May 2021 15:36:41 +0200 Subject: [PATCH 02/16] chore: move span method for context in trace API #40 (#47) --- README.md | 1 + src/api/trace.ts | 14 +++ src/baggage/index.ts | 23 ++++ src/context/context.ts | 108 ------------------ src/trace/NoopTracer.ts | 2 +- src/trace/context-utils.ts | 106 +++++++++++++++++ test/noop-implementations/noop-tracer.test.ts | 4 +- .../context-utils.test.ts} | 5 +- 8 files changed, 149 insertions(+), 114 deletions(-) create mode 100644 src/trace/context-utils.ts rename test/{context/context.test.ts => trace/context-utils.test.ts} (95%) diff --git a/README.md b/README.md index 074a0ec2..dd5e40b3 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ Because the npm installer and node module resolution algorithm could potentially - `HttpBaggage` renamed to `HttpBaggagePropagator` - [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext` +- [#47](https://github.com/open-telemetry/opentelemetry-js-api/pull/47) `getSpan`/`setSpan`/`getSpanContext`/`setSpanContext` moved to `trace` namespace ## Useful links diff --git a/src/api/trace.ts b/src/api/trace.ts index c5195969..f44fe256 100644 --- a/src/api/trace.ts +++ b/src/api/trace.ts @@ -26,6 +26,12 @@ import { } from '../trace/spancontext-utils'; import { Tracer } from '../trace/tracer'; import { TracerProvider } from '../trace/tracer_provider'; +import { + getSpan, + getSpanContext, + setSpan, + setSpanContext, +} from '../trace/context-utils'; const API_NAME = 'trace'; @@ -82,4 +88,12 @@ export class TraceAPI { public wrapSpanContext = wrapSpanContext; public isSpanContextValid = isSpanContextValid; + + public getSpan = getSpan; + + public getSpanContext = getSpanContext; + + public setSpan = setSpan; + + public setSpanContext = setSpanContext; } diff --git a/src/baggage/index.ts b/src/baggage/index.ts index ba0a297c..03eda420 100644 --- a/src/baggage/index.ts +++ b/src/baggage/index.ts @@ -18,10 +18,17 @@ import { Baggage } from './Baggage'; import { BaggageEntry, BaggageEntryMetadata } from './Entry'; import { BaggageImpl } from './internal/baggage'; import { baggageEntryMetadataSymbol } from './internal/symbol'; +import { Context } from '../context/types'; +import { createContextKey } from '../context/context'; export * from './Baggage'; export * from './Entry'; +/** + * Baggage key + */ +const BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key'); + /** * Create a new Baggage with optional entries * @@ -33,6 +40,22 @@ export function createBaggage( return new BaggageImpl(new Map(Object.entries(entries))); } +/** + * @param {Context} Context that manage all context values + * @returns {Baggage} Extracted baggage from the context + */ +export function getBaggage(context: Context): Baggage | undefined { + return (context.getValue(BAGGAGE_KEY) as Baggage) || undefined; +} + +/** + * @param {Context} Context that manage all context values + * @param {Baggage} baggage that will be set in the actual context + */ +export function setBaggage(context: Context, baggage: Baggage): Context { + return context.setValue(BAGGAGE_KEY, baggage); +} + /** * Create a serializable BaggageEntryMetadata object from a string. * diff --git a/src/context/context.ts b/src/context/context.ts index 0be6163e..ab058b85 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -15,114 +15,6 @@ */ import { Context } from './types'; -import { Baggage, Span, SpanContext } from '../'; -import { NonRecordingSpan } from '../trace/NonRecordingSpan'; - -/** - * span key - */ -const SPAN_KEY = createContextKey('OpenTelemetry Context Key SPAN'); - -/** - * Shared key for indicating if instrumentation should be suppressed beyond - * this current scope. - */ -const SUPPRESS_INSTRUMENTATION_KEY = createContextKey( - 'OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION' -); - -/** - * Baggage key - */ -const BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key'); - -/** - * Return the span if one exists - * - * @param context context to get span from - */ -export function getSpan(context: Context): Span | undefined { - return (context.getValue(SPAN_KEY) as Span) || undefined; -} - -/** - * Set the span on a context - * - * @param context context to use as parent - * @param span span to set active - */ -export function setSpan(context: Context, span: Span): Context { - return context.setValue(SPAN_KEY, span); -} - -/** - * Wrap span context in a NonRecordingSpan and set as span in a new - * context - * - * @param context context to set active span on - * @param spanContext span context to be wrapped - */ -export function setSpanContext( - context: Context, - spanContext: SpanContext -): Context { - return setSpan(context, new NonRecordingSpan(spanContext)); -} - -/** - * Get the span context of the span if it exists. - * - * @param context context to get values from - */ -export function getSpanContext(context: Context): SpanContext | undefined { - return getSpan(context)?.spanContext(); -} - -/** - * Sets value on context to indicate that instrumentation should - * be suppressed beyond this current scope. - * - * @param context context to set the suppress instrumentation value on. - */ -export function suppressInstrumentation(context: Context): Context { - return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, true); -} - -/** - * Sets value on context to indicate that instrumentation should - * no-longer be suppressed beyond this current scope. - * - * @param context context to set the suppress instrumentation value on. - */ -export function unsuppressInstrumentation(context: Context): Context { - return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, false); -} - -/** - * Return current suppress instrumentation value for the given context, - * if it exists. - * - * @param context context check for the suppress instrumentation value. - */ -export function isInstrumentationSuppressed(context: Context): boolean { - return Boolean(context.getValue(SUPPRESS_INSTRUMENTATION_KEY)); -} - -/** - * @param {Context} Context that manage all context values - * @returns {Baggage} Extracted baggage from the context - */ -export function getBaggage(context: Context): Baggage | undefined { - return (context.getValue(BAGGAGE_KEY) as Baggage) || undefined; -} - -/** - * @param {Context} Context that manage all context values - * @param {Baggage} baggage that will be set in the actual context - */ -export function setBaggage(context: Context, baggage: Baggage): Context { - return context.setValue(BAGGAGE_KEY, baggage); -} /** Get a key to uniquely identify a context value */ export function createContextKey(description: string) { diff --git a/src/trace/NoopTracer.ts b/src/trace/NoopTracer.ts index 1fbaf869..67eac54f 100644 --- a/src/trace/NoopTracer.ts +++ b/src/trace/NoopTracer.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { getSpanContext } from '../context/context'; +import { getSpanContext } from '../trace/context-utils'; import { Context } from '../context/types'; import { NonRecordingSpan } from './NonRecordingSpan'; import { Span } from './span'; diff --git a/src/trace/context-utils.ts b/src/trace/context-utils.ts new file mode 100644 index 00000000..4d8d2fe8 --- /dev/null +++ b/src/trace/context-utils.ts @@ -0,0 +1,106 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createContextKey } from '../context/context'; +import { Context } from '../context/types'; +import { Span } from './span'; +import { SpanContext } from './span_context'; +import { NonRecordingSpan } from './NonRecordingSpan'; + +/** + * span key + */ +const SPAN_KEY = createContextKey('OpenTelemetry Context Key SPAN'); + +/** + * Shared key for indicating if instrumentation should be suppressed beyond + * this current scope. + */ +const SUPPRESS_INSTRUMENTATION_KEY = createContextKey( + 'OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION' +); + +/** + * Return the span if one exists + * + * @param context context to get span from + */ +export function getSpan(context: Context): Span | undefined { + return (context.getValue(SPAN_KEY) as Span) || undefined; +} + +/** + * Set the span on a context + * + * @param context context to use as parent + * @param span span to set active + */ +export function setSpan(context: Context, span: Span): Context { + return context.setValue(SPAN_KEY, span); +} + +/** + * Wrap span context in a NoopSpan and set as span in a new + * context + * + * @param context context to set active span on + * @param spanContext span context to be wrapped + */ +export function setSpanContext( + context: Context, + spanContext: SpanContext +): Context { + return setSpan(context, new NonRecordingSpan(spanContext)); +} + +/** + * Get the span context of the span if it exists. + * + * @param context context to get values from + */ +export function getSpanContext(context: Context): SpanContext | undefined { + return getSpan(context)?.spanContext(); +} + +/** + * Sets value on context to indicate that instrumentation should + * be suppressed beyond this current scope. + * + * @param context context to set the suppress instrumentation value on. + */ +export function suppressInstrumentation(context: Context): Context { + return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, true); +} + +/** + * Sets value on context to indicate that instrumentation should + * no-longer be suppressed beyond this current scope. + * + * @param context context to set the suppress instrumentation value on. + */ +export function unsuppressInstrumentation(context: Context): Context { + return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, false); +} + +/** + * Return current suppress instrumentation value for the given context, + * if it exists. + * + * @param context context check for the suppress instrumentation value. + */ +export function isInstrumentationSuppressed(context: Context): boolean { + return Boolean(context.getValue(SUPPRESS_INSTRUMENTATION_KEY)); +} diff --git a/test/noop-implementations/noop-tracer.test.ts b/test/noop-implementations/noop-tracer.test.ts index 7527ae7b..292b2fbb 100644 --- a/test/noop-implementations/noop-tracer.test.ts +++ b/test/noop-implementations/noop-tracer.test.ts @@ -21,7 +21,7 @@ import { SpanKind, TraceFlags, context, - setSpanContext, + trace, } from '../../src'; import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan'; @@ -50,7 +50,7 @@ describe('NoopTracer', () => { const span = tracer.startSpan( 'test-1', {}, - setSpanContext(context.active(), parent) + trace.setSpanContext(context.active(), parent) ); assert(span.spanContext().traceId === parent.traceId); assert(span.spanContext().spanId === parent.spanId); diff --git a/test/context/context.test.ts b/test/trace/context-utils.test.ts similarity index 95% rename from test/context/context.test.ts rename to test/trace/context-utils.test.ts index dfea20b9..1f24c34c 100644 --- a/test/context/context.test.ts +++ b/test/trace/context-utils.test.ts @@ -16,12 +16,11 @@ import * as assert from 'assert'; import { - createContextKey, isInstrumentationSuppressed, - ROOT_CONTEXT, suppressInstrumentation, unsuppressInstrumentation, -} from '../../src/context/context'; +} from '../../src/trace/context-utils'; +import { createContextKey, ROOT_CONTEXT } from '../../src/context/context'; const SUPPRESS_INSTRUMENTATION_KEY = createContextKey( 'OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION' From 9b3f9c75a57190841b5f091933932386f63a62ac Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 5 May 2021 13:22:05 -0400 Subject: [PATCH 03/16] chore: use spancontext for link (#58) --- src/index.ts | 1 - src/trace/link.ts | 6 +++--- src/trace/link_context.ts | 22 ---------------------- 3 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 src/trace/link_context.ts diff --git a/src/index.ts b/src/index.ts index b36eaccd..b19b1bb7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,6 @@ export * from './propagation/NoopTextMapPropagator'; export * from './propagation/TextMapPropagator'; export * from './trace/attributes'; export * from './trace/Event'; -export * from './trace/link_context'; export * from './trace/link'; export * from './trace/NoopTracer'; export * from './trace/NoopTracerProvider'; diff --git a/src/trace/link.ts b/src/trace/link.ts index 8bd37478..1d81d38d 100644 --- a/src/trace/link.ts +++ b/src/trace/link.ts @@ -15,7 +15,7 @@ */ import { SpanAttributes } from './attributes'; -import { LinkContext } from './link_context'; +import { SpanContext } from './span_context'; /** * A pointer from the current {@link Span} to another span in the same trace or @@ -33,8 +33,8 @@ import { LinkContext } from './link_context'; * Service Provider) can be correlated. */ export interface Link { - /** The {@link LinkContext} of a linked span. */ - context: LinkContext; + /** The {@link SpanContext} of a linked span. */ + context: SpanContext; /** A set of {@link SpanAttributes} on the link. */ attributes?: SpanAttributes; } diff --git a/src/trace/link_context.ts b/src/trace/link_context.ts deleted file mode 100644 index c5224597..00000000 --- a/src/trace/link_context.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { SpanContext } from './span_context'; - -/** - * A pointer to another span. - */ -export type LinkContext = Pick; From 6dda82246533cc273074a20dad3c1d82743dba6e Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Tue, 11 May 2021 22:31:53 +0200 Subject: [PATCH 04/16] chore: removing timed event (#60) --- README.md | 1 + src/index.ts | 2 -- src/trace/Event.ts | 25 ------------------------- src/trace/TimedEvent.ts | 26 -------------------------- 4 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 src/trace/Event.ts delete mode 100644 src/trace/TimedEvent.ts diff --git a/README.md b/README.md index dd5e40b3..ff7a382b 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ Because the npm installer and node module resolution algorithm could potentially ### 1.0.0-rc.0 to x +- Removing `TimedEvent` which was not part of spec - `HttpBaggage` renamed to `HttpBaggagePropagator` - [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext` - [#47](https://github.com/open-telemetry/opentelemetry-js-api/pull/47) `getSpan`/`setSpan`/`getSpanContext`/`setSpanContext` moved to `trace` namespace diff --git a/src/index.ts b/src/index.ts index b19b1bb7..34931412 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,6 @@ export * from './diag'; export * from './propagation/NoopTextMapPropagator'; export * from './propagation/TextMapPropagator'; export * from './trace/attributes'; -export * from './trace/Event'; export * from './trace/link'; export * from './trace/NoopTracer'; export * from './trace/NoopTracerProvider'; @@ -34,7 +33,6 @@ export * from './trace/span_kind'; export * from './trace/span'; export * from './trace/SpanOptions'; export * from './trace/status'; -export * from './trace/TimedEvent'; export * from './trace/trace_flags'; export * from './trace/trace_state'; export * from './trace/tracer_provider'; diff --git a/src/trace/Event.ts b/src/trace/Event.ts deleted file mode 100644 index 8bc5e274..00000000 --- a/src/trace/Event.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { SpanAttributes } from './attributes'; - -/** A text annotation with a set of attributes. */ -export interface Event { - /** The name of the event. */ - name: string; - /** The attributes of the event. */ - attributes?: SpanAttributes; -} diff --git a/src/trace/TimedEvent.ts b/src/trace/TimedEvent.ts deleted file mode 100644 index 632107b2..00000000 --- a/src/trace/TimedEvent.ts +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Event } from './Event'; -import { HrTime } from '../common/Time'; - -/** - * Represents a timed event. - * A timed event is an event with a timestamp. - */ -export interface TimedEvent extends Event { - time: HrTime; -} From 26ae4c463e3fd660198076e98a3e7000c78db964 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 12 May 2021 11:47:16 -0400 Subject: [PATCH 05/16] chore: document the reason for symbol.for (#64) --- src/context/context.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/context/context.ts b/src/context/context.ts index ab058b85..825726f3 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -18,6 +18,12 @@ import { Context } from './types'; /** Get a key to uniquely identify a context value */ export function createContextKey(description: string) { + // The specification states that for the same input, multiple calls should + // return different keys. Due to the nature of the JS dependency management + // system, this creates problems where multiple versions of some package + // could hold different keys for the same property. + // + // Therefore, we use Symbol.for which returns the same key for the same input. return Symbol.for(description); } From 0a3bee49f487d2138c6ab9a2f6e4994faed314de Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Fri, 14 May 2021 03:22:06 -0400 Subject: [PATCH 06/16] chore: remove suppress instrumentation (#65) --- src/trace/context-utils.ts | 38 --------------- test/trace/context-utils.test.ts | 80 -------------------------------- 2 files changed, 118 deletions(-) delete mode 100644 test/trace/context-utils.test.ts diff --git a/src/trace/context-utils.ts b/src/trace/context-utils.ts index 4d8d2fe8..3714eb96 100644 --- a/src/trace/context-utils.ts +++ b/src/trace/context-utils.ts @@ -25,14 +25,6 @@ import { NonRecordingSpan } from './NonRecordingSpan'; */ const SPAN_KEY = createContextKey('OpenTelemetry Context Key SPAN'); -/** - * Shared key for indicating if instrumentation should be suppressed beyond - * this current scope. - */ -const SUPPRESS_INSTRUMENTATION_KEY = createContextKey( - 'OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION' -); - /** * Return the span if one exists * @@ -74,33 +66,3 @@ export function setSpanContext( export function getSpanContext(context: Context): SpanContext | undefined { return getSpan(context)?.spanContext(); } - -/** - * Sets value on context to indicate that instrumentation should - * be suppressed beyond this current scope. - * - * @param context context to set the suppress instrumentation value on. - */ -export function suppressInstrumentation(context: Context): Context { - return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, true); -} - -/** - * Sets value on context to indicate that instrumentation should - * no-longer be suppressed beyond this current scope. - * - * @param context context to set the suppress instrumentation value on. - */ -export function unsuppressInstrumentation(context: Context): Context { - return context.setValue(SUPPRESS_INSTRUMENTATION_KEY, false); -} - -/** - * Return current suppress instrumentation value for the given context, - * if it exists. - * - * @param context context check for the suppress instrumentation value. - */ -export function isInstrumentationSuppressed(context: Context): boolean { - return Boolean(context.getValue(SUPPRESS_INSTRUMENTATION_KEY)); -} diff --git a/test/trace/context-utils.test.ts b/test/trace/context-utils.test.ts deleted file mode 100644 index 1f24c34c..00000000 --- a/test/trace/context-utils.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import * as assert from 'assert'; -import { - isInstrumentationSuppressed, - suppressInstrumentation, - unsuppressInstrumentation, -} from '../../src/trace/context-utils'; -import { createContextKey, ROOT_CONTEXT } from '../../src/context/context'; - -const SUPPRESS_INSTRUMENTATION_KEY = createContextKey( - 'OpenTelemetry Context Key SUPPRESS_INSTRUMENTATION' -); - -describe('Context Helpers', () => { - describe('suppressInstrumentation', () => { - it('should set suppress to true', () => { - const context = suppressInstrumentation(ROOT_CONTEXT); - assert.deepStrictEqual(isInstrumentationSuppressed(context), true); - }); - }); - - describe('unsuppressInstrumentation', () => { - it('should set suppress to false', () => { - const context = unsuppressInstrumentation(ROOT_CONTEXT); - assert.deepStrictEqual(isInstrumentationSuppressed(context), false); - }); - }); - - describe('isInstrumentationSuppressed', () => { - it('should get value as bool', () => { - const expectedValue = true; - const context = ROOT_CONTEXT.setValue( - SUPPRESS_INSTRUMENTATION_KEY, - expectedValue - ); - - const value = isInstrumentationSuppressed(context); - - assert.equal(value, expectedValue); - }); - - describe('when suppress instrumentation set to null', () => { - const context = ROOT_CONTEXT.setValue(SUPPRESS_INSTRUMENTATION_KEY, null); - - it('should return false', () => { - const value = isInstrumentationSuppressed(context); - - assert.equal(value, false); - }); - }); - - describe('when suppress instrumentation set to undefined', () => { - const context = ROOT_CONTEXT.setValue( - SUPPRESS_INSTRUMENTATION_KEY, - undefined - ); - - it('should return false', () => { - const value = isInstrumentationSuppressed(context); - - assert.equal(value, false); - }); - }); - }); -}); From 8435e0abe47e27b76ff6ad317311d64295816dc4 Mon Sep 17 00:00:00 2001 From: Valentin Marchaud Date: Fri, 14 May 2021 17:46:34 +0200 Subject: [PATCH 07/16] chore: move baggage methods in propagation namespace (#55) * chore: move baggage methods in propagation namespace * chore: add upgrade guidelines --- README.md | 1 + src/api/propagation.ts | 7 +++++++ src/index.ts | 2 +- test/baggage/Baggage.test.ts | 28 ++++++++++++++-------------- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ff7a382b..d75aa41c 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ Because the npm installer and node module resolution algorithm could potentially - `HttpBaggage` renamed to `HttpBaggagePropagator` - [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) `Span#context` renamed to `Span#spanContext` - [#47](https://github.com/open-telemetry/opentelemetry-js-api/pull/47) `getSpan`/`setSpan`/`getSpanContext`/`setSpanContext` moved to `trace` namespace +- [#55](https://github.com/open-telemetry/opentelemetry-js-api/pull/55) `getBaggage`/`setBaggage`/`createBaggage` moved to `propagation` namespace ## Useful links diff --git a/src/api/propagation.ts b/src/api/propagation.ts index d83d4e7d..a554d2be 100644 --- a/src/api/propagation.ts +++ b/src/api/propagation.ts @@ -28,6 +28,7 @@ import { registerGlobal, unregisterGlobal, } from '../internal/global-utils'; +import { getBaggage, createBaggage, setBaggage } from '../baggage/index'; const API_NAME = 'propagation'; @@ -100,6 +101,12 @@ export class PropagationAPI { unregisterGlobal(API_NAME); } + public createBaggage = createBaggage; + + public getBaggage = getBaggage; + + public setBaggage = setBaggage; + private _getGlobalPropagator(): TextMapPropagator { return getGlobal(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR; } diff --git a/src/index.ts b/src/index.ts index 34931412..29e6e7f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -export * from './baggage'; +export { baggageEntryMetadataFromString } from './baggage'; export * from './common/Exception'; export * from './common/Time'; export * from './diag'; diff --git a/test/baggage/Baggage.test.ts b/test/baggage/Baggage.test.ts index 45eb59d7..080b6a41 100644 --- a/test/baggage/Baggage.test.ts +++ b/test/baggage/Baggage.test.ts @@ -16,24 +16,22 @@ import * as assert from 'assert'; import { - createBaggage, - setBaggage, - getBaggage, ROOT_CONTEXT, + propagation, baggageEntryMetadataFromString, } from '../../src'; describe('Baggage', () => { describe('create', () => { it('should create an empty bag', () => { - const bag = createBaggage(); + const bag = propagation.createBaggage(); assert.deepStrictEqual(bag.getAllEntries(), []); }); it('should create a bag with entries', () => { const meta = baggageEntryMetadataFromString('opaque string'); - const bag = createBaggage({ + const bag = propagation.createBaggage({ key1: { value: 'value1' }, key2: { value: 'value2', metadata: meta }, }); @@ -47,7 +45,9 @@ describe('Baggage', () => { describe('get', () => { it('should not allow modification of returned entries', () => { - const bag = createBaggage().setEntry('key', { value: 'value' }); + const bag = propagation + .createBaggage() + .setEntry('key', { value: 'value' }); const entry = bag.getEntry('key'); assert.ok(entry); @@ -59,7 +59,7 @@ describe('Baggage', () => { describe('set', () => { it('should create a new bag when an entry is added', () => { - const bag = createBaggage(); + const bag = propagation.createBaggage(); const bag2 = bag.setEntry('key', { value: 'value' }); @@ -73,7 +73,7 @@ describe('Baggage', () => { describe('remove', () => { it('should create a new bag when an entry is removed', () => { - const bag = createBaggage({ + const bag = propagation.createBaggage({ key: { value: 'value' }, }); @@ -87,7 +87,7 @@ describe('Baggage', () => { }); it('should create an empty bag multiple keys are removed', () => { - const bag = createBaggage({ + const bag = propagation.createBaggage({ key: { value: 'value' }, key1: { value: 'value1' }, key2: { value: 'value2' }, @@ -107,7 +107,7 @@ describe('Baggage', () => { }); it('should create an empty bag when it cleared', () => { - const bag = createBaggage({ + const bag = propagation.createBaggage({ key: { value: 'value' }, key1: { value: 'value1' }, }); @@ -125,11 +125,11 @@ describe('Baggage', () => { describe('context', () => { it('should set and get a baggage from a context', () => { - const bag = createBaggage(); + const bag = propagation.createBaggage(); - const ctx = setBaggage(ROOT_CONTEXT, bag); + const ctx = propagation.setBaggage(ROOT_CONTEXT, bag); - assert.strictEqual(bag, getBaggage(ctx)); + assert.strictEqual(bag, propagation.getBaggage(ctx)); }); }); @@ -148,7 +148,7 @@ describe('Baggage', () => { }); it('should retain metadata', () => { - const bag = createBaggage({ + const bag = propagation.createBaggage({ key: { value: 'value', metadata: baggageEntryMetadataFromString('meta'), From 28fabc4916a1fdbd7d0e4f0dcdc57974d3b98088 Mon Sep 17 00:00:00 2001 From: Naseem Date: Mon, 17 May 2021 13:27:20 -0400 Subject: [PATCH 08/16] feat: add tracer.startActiveSpan() (#54) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gerhard Stöbich Co-authored-by: Daniel Dyla --- src/trace/NoopTracer.ts | 42 ++++++++++++- src/trace/ProxyTracer.ts | 10 ++++ src/trace/tracer.ts | 59 +++++++++++++++++++ test/noop-implementations/noop-tracer.test.ts | 29 ++++++++- .../proxy-tracer.test.ts | 47 ++++++++++++--- 5 files changed, 177 insertions(+), 10 deletions(-) diff --git a/src/trace/NoopTracer.ts b/src/trace/NoopTracer.ts index 67eac54f..7f810522 100644 --- a/src/trace/NoopTracer.ts +++ b/src/trace/NoopTracer.ts @@ -14,8 +14,9 @@ * limitations under the License. */ -import { getSpanContext } from '../trace/context-utils'; +import { context } from '../'; import { Context } from '../context/types'; +import { getSpanContext, setSpan } from '../trace/context-utils'; import { NonRecordingSpan } from './NonRecordingSpan'; import { Span } from './span'; import { isSpanContextValid } from './spancontext-utils'; @@ -45,6 +46,45 @@ export class NoopTracer implements Tracer { return new NonRecordingSpan(); } } + + startActiveSpan ReturnType>( + name: string, + arg2: F | SpanOptions, + arg3?: F | Context, + arg4?: F + ): ReturnType | undefined { + let fn: F | undefined, + options: SpanOptions | undefined, + activeContext: Context | undefined; + if (arguments.length === 2 && typeof arg2 === 'function') { + fn = arg2; + } else if ( + arguments.length === 3 && + typeof arg2 === 'object' && + typeof arg3 === 'function' + ) { + options = arg2; + fn = arg3; + } else if ( + arguments.length === 4 && + typeof arg2 === 'object' && + typeof arg3 === 'object' && + typeof arg4 === 'function' + ) { + options = arg2; + activeContext = arg3; + fn = arg4; + } + + const parentContext = activeContext ?? context.active(); + const span = this.startSpan(name, options, parentContext); + const contextWithSpanSet = setSpan(parentContext, span); + + if (fn) { + return context.with(contextWithSpanSet, fn, undefined, span); + } + return; + } } function isSpanContext(spanContext: any): spanContext is SpanContext { diff --git a/src/trace/ProxyTracer.ts b/src/trace/ProxyTracer.ts index 05e55f2d..9cd399f9 100644 --- a/src/trace/ProxyTracer.ts +++ b/src/trace/ProxyTracer.ts @@ -38,6 +38,16 @@ export class ProxyTracer implements Tracer { return this._getTracer().startSpan(name, options, context); } + startActiveSpan unknown>( + _name: string, + _options: F | SpanOptions, + _context?: F | Context, + _fn?: F + ): ReturnType { + const tracer = this._getTracer(); + return Reflect.apply(tracer.startActiveSpan, tracer, arguments); + } + /** * Try to get a tracer from the proxy tracer provider. * If the proxy tracer provider has no delegate, return a noop tracer. diff --git a/src/trace/tracer.ts b/src/trace/tracer.ts index c5903c12..13c19ecc 100644 --- a/src/trace/tracer.ts +++ b/src/trace/tracer.ts @@ -37,4 +37,63 @@ export interface Tracer { * span.end(); */ startSpan(name: string, options?: SpanOptions, context?: Context): Span; + + /** + * Starts a new {@link Span} and calls the given function passing it the + * created span as first argument. + * Additionally the new span gets set in context and this context is activated + * for the duration of the function call. + * + * @param name The name of the span + * @param [options] SpanOptions used for span creation + * @param [context] Context to use to extract parent + * @param fn function called in the context of the span and receives the newly created span as an argument + * @returns return value of fn + * @example + * const something = tracer.startActiveSpan('op', span => { + * try { + * do some work + * span.setStatus({code: SpanStatusCode.OK}); + * return something; + * } catch (err) { + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: err.message, + * }); + * throw err; + * } finally { + * span.end(); + * } + * }); + * @example + * const span = tracer.startActiveSpan('op', span => { + * try { + * do some work + * return span; + * } catch (err) { + * span.setStatus({ + * code: SpanStatusCode.ERROR, + * message: err.message, + * }); + * throw err; + * } + * }); + * do some more work + * span.end(); + */ + startActiveSpan unknown>( + name: string, + fn: F + ): ReturnType; + startActiveSpan unknown>( + name: string, + options: SpanOptions, + fn: F + ): ReturnType; + startActiveSpan unknown>( + name: string, + options: SpanOptions, + context: Context, + fn: F + ): ReturnType; } diff --git a/test/noop-implementations/noop-tracer.test.ts b/test/noop-implementations/noop-tracer.test.ts index 292b2fbb..0d4ca1a3 100644 --- a/test/noop-implementations/noop-tracer.test.ts +++ b/test/noop-implementations/noop-tracer.test.ts @@ -16,12 +16,13 @@ import * as assert from 'assert'; import { + context, NoopTracer, + Span, SpanContext, SpanKind, - TraceFlags, - context, trace, + TraceFlags, } from '../../src'; import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan'; @@ -56,4 +57,28 @@ describe('NoopTracer', () => { assert(span.spanContext().spanId === parent.spanId); assert(span.spanContext().traceFlags === parent.traceFlags); }); + + it('should accept 2 to 4 args and start an active span', () => { + const tracer = new NoopTracer(); + const name = 'span-name'; + const fn = (span: Span) => { + try { + return 1; + } finally { + span.end(); + } + }; + const opts = { attributes: { foo: 'bar' } }; + const ctx = context.active(); + + const a = tracer.startActiveSpan(name, fn); + assert.strictEqual(a, 1); + + const b = tracer.startActiveSpan(name, opts, fn); + + assert.strictEqual(b, 1); + + const c = tracer.startActiveSpan(name, opts, ctx, fn); + assert.strictEqual(c, 1); + }); }); diff --git a/test/proxy-implementations/proxy-tracer.test.ts b/test/proxy-implementations/proxy-tracer.test.ts index c350913a..57e3e2dc 100644 --- a/test/proxy-implementations/proxy-tracer.test.ts +++ b/test/proxy-implementations/proxy-tracer.test.ts @@ -17,18 +17,18 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import { - ProxyTracerProvider, - SpanKind, - TracerProvider, - ProxyTracer, - Tracer, - Span, + context, NoopTracer, + ProxyTracer, + ProxyTracerProvider, ROOT_CONTEXT, + Span, + SpanKind, SpanOptions, + Tracer, + TracerProvider, } from '../../src'; import { NonRecordingSpan } from '../../src/trace/NonRecordingSpan'; - describe('ProxyTracer', () => { let provider: ProxyTracerProvider; const sandbox = sinon.createSandbox(); @@ -96,6 +96,10 @@ describe('ProxyTracer', () => { startSpan() { return delegateSpan; }, + + startActiveSpan() { + // stubbed + }, }; tracer = provider.getTracer('test'); @@ -114,6 +118,34 @@ describe('ProxyTracer', () => { assert.strictEqual(span, delegateSpan); }); + it('should create active spans using the delegate tracer', () => { + // sinon types are broken with overloads, hence the any + // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/36436 + const startActiveSpanStub = sinon.stub( + delegateTracer, + 'startActiveSpan' + ); + + const name = 'span-name'; + const fn = (span: Span) => { + try { + return 1; + } finally { + span.end(); + } + }; + const opts = { attributes: { foo: 'bar' } }; + const ctx = context.active(); + + startActiveSpanStub.withArgs(name, fn).returns(1); + startActiveSpanStub.withArgs(name, opts, fn).returns(2); + startActiveSpanStub.withArgs(name, opts, ctx, fn).returns(3); + + assert.strictEqual(tracer.startActiveSpan(name, fn), 1); + assert.strictEqual(tracer.startActiveSpan(name, opts, fn), 2); + assert.strictEqual(tracer.startActiveSpan(name, opts, ctx, fn), 3); + }); + it('should pass original arguments to DelegateTracer#startSpan', () => { const startSpanStub = sandbox.stub(delegateTracer, 'startSpan'); @@ -130,6 +162,7 @@ describe('ProxyTracer', () => { assert.deepStrictEqual(Object.getOwnPropertyNames(NoopTracer.prototype), [ 'constructor', 'startSpan', + 'startActiveSpan', ]); sandbox.assert.calledOnceWithExactly(startSpanStub, name, options, ctx); }); From 20f3bfc316280d0e18f1fdcdd7eb2c315192c6a0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Obecny Date: Tue, 18 May 2021 14:48:30 +0200 Subject: [PATCH 09/16] chore: adding component logger (#62) --- src/api/diag.ts | 18 +++++++- src/diag/ComponentLogger.ts | 70 +++++++++++++++++++++++++++++++ src/diag/types.ts | 7 ++++ test/diag/ComponentLogger.test.ts | 63 ++++++++++++++++++++++++++++ 4 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/diag/ComponentLogger.ts create mode 100644 test/diag/ComponentLogger.test.ts diff --git a/src/api/diag.ts b/src/api/diag.ts index b3136c96..768ad74c 100644 --- a/src/api/diag.ts +++ b/src/api/diag.ts @@ -14,8 +14,14 @@ * limitations under the License. */ +import { DiagComponentLogger } from '../diag/ComponentLogger'; import { createLogLevelDiagLogger } from '../diag/internal/logLevelLogger'; -import { DiagLogFunction, DiagLogger, DiagLogLevel } from '../diag/types'; +import { + ComponentLoggerOptions, + DiagLogFunction, + DiagLogger, + DiagLogLevel, +} from '../diag/types'; import { getGlobal, registerGlobal, @@ -90,6 +96,10 @@ export class DiagAPI implements DiagLogger { unregisterGlobal(API_NAME); }; + self.createComponentLogger = (options: ComponentLoggerOptions) => { + return new DiagComponentLogger(options); + }; + self.verbose = _logProxy('verbose'); self.debug = _logProxy('debug'); self.info = _logProxy('info'); @@ -106,6 +116,12 @@ export class DiagAPI implements DiagLogger { * @returns true if the logger was successfully registered, else false */ public setLogger!: (logger: DiagLogger, logLevel?: DiagLogLevel) => boolean; + /** + * + */ + public createComponentLogger!: ( + options: ComponentLoggerOptions + ) => DiagLogger; // DiagLogger implementation public verbose!: DiagLogFunction; diff --git a/src/diag/ComponentLogger.ts b/src/diag/ComponentLogger.ts new file mode 100644 index 00000000..aaddb9de --- /dev/null +++ b/src/diag/ComponentLogger.ts @@ -0,0 +1,70 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { getGlobal } from '../internal/global-utils'; +import { ComponentLoggerOptions, DiagLogger } from './types'; + +/** + * Component Logger which is meant to be used as part of any component which + * will add automatically additional namespace in front of the log message. + * It will then forward all message to global diag logger + * @example + * const cLogger = diag.createComponentLogger({ namespace: '@opentelemetry/instrumentation-http' }); + * cLogger.debug('test'); + * // @opentelemetry/instrumentation-http test + */ +export class DiagComponentLogger implements DiagLogger { + private _namespace: string; + + constructor(props: ComponentLoggerOptions) { + this._namespace = props.namespace || 'DiagComponentLogger'; + } + + public debug(...args: any[]): void { + return logProxy('debug', this._namespace, args); + } + + public error(...args: any[]): void { + return logProxy('error', this._namespace, args); + } + + public info(...args: any[]): void { + return logProxy('info', this._namespace, args); + } + + public warn(...args: any[]): void { + return logProxy('warn', this._namespace, args); + } + + public verbose(...args: any[]): void { + return logProxy('verbose', this._namespace, args); + } +} + +function logProxy( + funcName: keyof DiagLogger, + namespace: string, + args: any +): void { + const logger = getGlobal('diag'); + // shortcut if logger not set + if (!logger) { + return; + } + + args.unshift(namespace); + return logger[funcName].apply(logger, args); +} diff --git a/src/diag/types.ts b/src/diag/types.ts index 3a633a5b..54bf398d 100644 --- a/src/diag/types.ts +++ b/src/diag/types.ts @@ -89,3 +89,10 @@ export enum DiagLogLevel { /** Used to set the logging level to include all logging */ ALL = 9999, } + +/** + * Defines options for ComponentLogger + */ +export interface ComponentLoggerOptions { + namespace: string; +} diff --git a/test/diag/ComponentLogger.test.ts b/test/diag/ComponentLogger.test.ts new file mode 100644 index 00000000..bbc25b1e --- /dev/null +++ b/test/diag/ComponentLogger.test.ts @@ -0,0 +1,63 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import { diag, DiagLogger, DiagLogLevel } from '../../src'; + +class SpyLogger implements DiagLogger { + debug() {} + + error() {} + + info() {} + + warn() {} + + verbose() {} +} + +const loggerFunctions = ['verbose', 'debug', 'info', 'warn', 'error']; + +describe('ComponentLogger', () => { + let logger: DiagLogger; + + const sandbox = sinon.createSandbox(); + + beforeEach(() => { + logger = new SpyLogger(); + sandbox.spy(logger); + diag.setLogger(logger, DiagLogLevel.ALL); + }); + + afterEach(() => { + sandbox.restore(); + }); + + loggerFunctions.forEach(name => { + const fName = name as keyof SpyLogger; + it(`should call global logger function "${name}" with namespace as first param`, () => { + const componentLogger = diag.createComponentLogger({ namespace: 'foo' }); + componentLogger[fName]('test'); + + assert.strictEqual((logger[fName] as sinon.SinonSpy).callCount, 1); + assert.deepStrictEqual((logger[fName] as sinon.SinonSpy).args[0], [ + 'foo', + 'test', + ]); + }); + }); +}); From da597304cb6b0b944514efd3df6b93c9e5043d7e Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Tue, 18 May 2021 15:00:19 -0400 Subject: [PATCH 10/16] 1.0.0-rc.1 proposal (#70) * chore: rc.1 proposal * chore: changelog * Update readme and package for version bump * chore: update changelog --- CHANGELOG.md | 34 ++++++++++++++++++++++++++++++++++ README.md | 4 +++- package.json | 2 +- src/version.ts | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 923626d1..8e7920ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,40 @@ All notable changes to this project will be documented in this file. +## 1.0.0-rc.1 + +### :boom: Breaking Change + +* [#55](https://github.com/open-telemetry/opentelemetry-js-api/pull/55) chore: move baggage methods in propagation namespace ([@vmarchaud](https://github.com/vmarchaud)) +* [#65](https://github.com/open-telemetry/opentelemetry-js-api/pull/65) chore: remove suppress instrumentation ([@dyladan](https://github.com/dyladan)) +* [#60](https://github.com/open-telemetry/opentelemetry-js-api/pull/60) chore: removing timed event ([@obecny](https://github.com/obecny)) +* [#58](https://github.com/open-telemetry/opentelemetry-js-api/pull/58) chore: use spancontext for link ([@dyladan](https://github.com/dyladan)) +* [#47](https://github.com/open-telemetry/opentelemetry-js-api/pull/47) chore: move span method for context in trace API #40 ([@vmarchaud](https://github.com/vmarchaud)) +* [#45](https://github.com/open-telemetry/opentelemetry-js-api/pull/45) chore: rename `span#context()` to `span#spanContext` ([@dyladan](https://github.com/dyladan)) +* [#43](https://github.com/open-telemetry/opentelemetry-js-api/pull/43) chore: renaming noop span to non recording span ([@obecny](https://github.com/obecny)) +* [#32](https://github.com/open-telemetry/opentelemetry-js-api/pull/32) feat!: return boolean success value from setGlobalXXX methods ([@dyladan](https://github.com/dyladan)) + +### :rocket: Enhancement + +* [#62](https://github.com/open-telemetry/opentelemetry-js-api/pull/62) chore: adding component logger ([@obecny](https://github.com/obecny)) +* [#54](https://github.com/open-telemetry/opentelemetry-js-api/pull/54) feat: add tracer.startActiveSpan() ([@naseemkullah](https://github.com/naseemkullah)) +* [#58](https://github.com/open-telemetry/opentelemetry-js-api/pull/58) chore: use spancontext for link ([@dyladan](https://github.com/dyladan)) +* [#51](https://github.com/open-telemetry/opentelemetry-js-api/pull/51) feat: add function to wrap SpanContext in NonRecordingSpan #49 ([@dyladan](https://github.com/dyladan)) + +### :memo: Documentation + +* [#64](https://github.com/open-telemetry/opentelemetry-js-api/pull/64) chore: document the reason for symbol.for ([@dyladan](https://github.com/dyladan)) +* [#44](https://github.com/open-telemetry/opentelemetry-js-api/pull/44) chore: updating readme headline and fixing links ([@obecny](https://github.com/obecny)) + +### Committers: 6 + +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Gerhard Stöbich ([@Flarna](https://github.com/Flarna)) +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) +* t2t2 ([@t2t2](https://github.com/t2t2)) + ## 1.0.0-rc.0 ### :memo: Documentation diff --git a/README.md b/README.md index d75aa41c..e33e501d 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,9 @@ Because the npm installer and node module resolution algorithm could potentially ## Upgrade Guidelines -### 1.0.0-rc.0 to x +### 1.0.0-rc.1 to x + +### 1.0.0-rc.0 to 1.0.0-rc.1 - Removing `TimedEvent` which was not part of spec - `HttpBaggage` renamed to `HttpBaggagePropagator` diff --git a/package.json b/package.json index bd1ea0d0..abe3f43e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api", - "version": "1.0.0-rc.0", + "version": "1.0.0-rc.1", "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "module": "build/esm/index.js", diff --git a/src/version.ts b/src/version.ts index 04dec95c..c8788d33 100644 --- a/src/version.ts +++ b/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '1.0.0-rc.0'; +export const VERSION = '1.0.0-rc.1'; From 8bd1c6e5d2cbff86851016f2c1948a01f02a5105 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 19 May 2021 10:09:00 -0400 Subject: [PATCH 11/16] chore: 0.19.0 proposal (#73) * chore: 0.19.0 proposal * revert global API symbol key --- package.json | 2 +- src/version.ts | 2 +- test/internal/global.test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index abe3f43e..756df6af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api", - "version": "1.0.0-rc.1", + "version": "0.19.0", "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "module": "build/esm/index.js", diff --git a/src/version.ts b/src/version.ts index c8788d33..3fc2009a 100644 --- a/src/version.ts +++ b/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '1.0.0-rc.1'; +export const VERSION = '0.19.0'; diff --git a/test/internal/global.test.ts b/test/internal/global.test.ts index 3932722b..9d8f78f3 100644 --- a/test/internal/global.test.ts +++ b/test/internal/global.test.ts @@ -30,7 +30,7 @@ const api2 = require('../../src') as typeof import('../../src'); // This will need to be changed manually on major version changes. // It is intentionally not autogenerated to ensure the author of the change is aware of what they are doing. -const GLOBAL_API_SYMBOL_KEY = 'io.opentelemetry.js.api.1'; +const GLOBAL_API_SYMBOL_KEY = 'io.opentelemetry.js.api.0'; describe('Global Utils', () => { // prove they are separate instances From 77b8c341e2a72da76b505ded3a86a65374a284a2 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Thu, 20 May 2021 08:15:17 -0400 Subject: [PATCH 12/16] chore: export baggage (#71) * chore: reorganize baggage folder --- src/api/propagation.ts | 3 +- src/baggage/Entry.ts | 35 ---------------- src/baggage/context-helpers.ts | 40 +++++++++++++++++++ .../internal/{baggage.ts => baggage-impl.ts} | 3 +- src/baggage/{Baggage.ts => types.ts} | 36 ++++++++++++++++- src/baggage/{index.ts => utils.ts} | 36 +++-------------- src/index.ts | 3 +- 7 files changed, 86 insertions(+), 70 deletions(-) delete mode 100644 src/baggage/Entry.ts create mode 100644 src/baggage/context-helpers.ts rename src/baggage/internal/{baggage.ts => baggage-impl.ts} (95%) rename src/baggage/{Baggage.ts => types.ts} (60%) rename src/baggage/{index.ts => utils.ts} (59%) diff --git a/src/api/propagation.ts b/src/api/propagation.ts index a554d2be..ab2a8118 100644 --- a/src/api/propagation.ts +++ b/src/api/propagation.ts @@ -28,7 +28,8 @@ import { registerGlobal, unregisterGlobal, } from '../internal/global-utils'; -import { getBaggage, createBaggage, setBaggage } from '../baggage/index'; +import { getBaggage, setBaggage } from '../baggage/context-helpers'; +import { createBaggage } from '../baggage/utils'; const API_NAME = 'propagation'; diff --git a/src/baggage/Entry.ts b/src/baggage/Entry.ts deleted file mode 100644 index d249c85c..00000000 --- a/src/baggage/Entry.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { baggageEntryMetadataSymbol } from './internal/symbol'; - -export interface BaggageEntry { - /** `String` value of the `BaggageEntry`. */ - value: string; - /** - * Metadata is an optional string property defined by the W3C baggage specification. - * It currently has no special meaning defined by the specification. - */ - metadata?: BaggageEntryMetadata; -} - -/** - * Serializable Metadata defined by the W3C baggage specification. - * It currently has no special meaning defined by the OpenTelemetry or W3C. - */ -export type BaggageEntryMetadata = { toString(): string } & { - __TYPE__: typeof baggageEntryMetadataSymbol; -}; diff --git a/src/baggage/context-helpers.ts b/src/baggage/context-helpers.ts new file mode 100644 index 00000000..05b24a82 --- /dev/null +++ b/src/baggage/context-helpers.ts @@ -0,0 +1,40 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createContextKey } from '../context/context'; +import { Context } from '../context/types'; +import { Baggage } from './types'; + +/** + * Baggage key + */ +const BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key'); + +/** + * @param {Context} Context that manage all context values + * @returns {Baggage} Extracted baggage from the context + */ +export function getBaggage(context: Context): Baggage | undefined { + return (context.getValue(BAGGAGE_KEY) as Baggage) || undefined; +} + +/** + * @param {Context} Context that manage all context values + * @param {Baggage} baggage that will be set in the actual context + */ +export function setBaggage(context: Context, baggage: Baggage): Context { + return context.setValue(BAGGAGE_KEY, baggage); +} diff --git a/src/baggage/internal/baggage.ts b/src/baggage/internal/baggage-impl.ts similarity index 95% rename from src/baggage/internal/baggage.ts rename to src/baggage/internal/baggage-impl.ts index f9331f41..8bd45dd4 100644 --- a/src/baggage/internal/baggage.ts +++ b/src/baggage/internal/baggage-impl.ts @@ -14,8 +14,7 @@ * limitations under the License. */ -import type { Baggage } from '../Baggage'; -import type { BaggageEntry } from '../Entry'; +import type { Baggage, BaggageEntry } from '../types'; export class BaggageImpl implements Baggage { private _entries: Map; diff --git a/src/baggage/Baggage.ts b/src/baggage/types.ts similarity index 60% rename from src/baggage/Baggage.ts rename to src/baggage/types.ts index 2876f5bd..ab6d82e6 100644 --- a/src/baggage/Baggage.ts +++ b/src/baggage/types.ts @@ -14,7 +14,41 @@ * limitations under the License. */ -import { BaggageEntry } from './Entry'; +import { baggageEntryMetadataSymbol } from './internal/symbol'; + +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface BaggageEntry { + /** `String` value of the `BaggageEntry`. */ + value: string; + /** + * Metadata is an optional string property defined by the W3C baggage specification. + * It currently has no special meaning defined by the specification. + */ + metadata?: BaggageEntryMetadata; +} + +/** + * Serializable Metadata defined by the W3C baggage specification. + * It currently has no special meaning defined by the OpenTelemetry or W3C. + */ +export type BaggageEntryMetadata = { toString(): string } & { + __TYPE__: typeof baggageEntryMetadataSymbol; +}; /** * Baggage represents collection of key-value pairs with optional metadata. diff --git a/src/baggage/index.ts b/src/baggage/utils.ts similarity index 59% rename from src/baggage/index.ts rename to src/baggage/utils.ts index 03eda420..2b378b7a 100644 --- a/src/baggage/index.ts +++ b/src/baggage/utils.ts @@ -14,20 +14,10 @@ * limitations under the License. */ -import { Baggage } from './Baggage'; -import { BaggageEntry, BaggageEntryMetadata } from './Entry'; -import { BaggageImpl } from './internal/baggage'; +import { diag } from '..'; +import { BaggageImpl } from './internal/baggage-impl'; import { baggageEntryMetadataSymbol } from './internal/symbol'; -import { Context } from '../context/types'; -import { createContextKey } from '../context/context'; - -export * from './Baggage'; -export * from './Entry'; - -/** - * Baggage key - */ -const BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key'); +import { Baggage, BaggageEntry, BaggageEntryMetadata } from './types'; /** * Create a new Baggage with optional entries @@ -40,22 +30,6 @@ export function createBaggage( return new BaggageImpl(new Map(Object.entries(entries))); } -/** - * @param {Context} Context that manage all context values - * @returns {Baggage} Extracted baggage from the context - */ -export function getBaggage(context: Context): Baggage | undefined { - return (context.getValue(BAGGAGE_KEY) as Baggage) || undefined; -} - -/** - * @param {Context} Context that manage all context values - * @param {Baggage} baggage that will be set in the actual context - */ -export function setBaggage(context: Context, baggage: Baggage): Context { - return context.setValue(BAGGAGE_KEY, baggage); -} - /** * Create a serializable BaggageEntryMetadata object from a string. * @@ -66,7 +40,9 @@ export function baggageEntryMetadataFromString( str: string ): BaggageEntryMetadata { if (typeof str !== 'string') { - // @TODO log diagnostic + diag.error( + `Cannot create baggage metadata from unknown type: ${typeof str}` + ); str = ''; } diff --git a/src/index.ts b/src/index.ts index 29e6e7f5..79f1270d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -export { baggageEntryMetadataFromString } from './baggage'; +export * from './baggage/types'; +export { baggageEntryMetadataFromString } from './baggage/utils'; export * from './common/Exception'; export * from './common/Time'; export * from './diag'; From e1745d19b9bdfd1af7d805a6b2c32a5a5dbf4d15 Mon Sep 17 00:00:00 2001 From: Valentin Marchaud Date: Fri, 21 May 2021 14:16:47 +0200 Subject: [PATCH 13/16] feat(context): add utils method to remove keys from context #66 (#69) --- src/api/propagation.ts | 8 +++++++- src/api/trace.ts | 3 +++ src/baggage/context-helpers.ts | 13 +++++++++++++ src/trace/context-utils.ts | 9 +++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/api/propagation.ts b/src/api/propagation.ts index ab2a8118..6ef7e8a9 100644 --- a/src/api/propagation.ts +++ b/src/api/propagation.ts @@ -28,7 +28,11 @@ import { registerGlobal, unregisterGlobal, } from '../internal/global-utils'; -import { getBaggage, setBaggage } from '../baggage/context-helpers'; +import { + getBaggage, + setBaggage, + deleteBaggage, +} from '../baggage/context-helpers'; import { createBaggage } from '../baggage/utils'; const API_NAME = 'propagation'; @@ -108,6 +112,8 @@ export class PropagationAPI { public setBaggage = setBaggage; + public deleteBaggage = deleteBaggage; + private _getGlobalPropagator(): TextMapPropagator { return getGlobal(API_NAME) || NOOP_TEXT_MAP_PROPAGATOR; } diff --git a/src/api/trace.ts b/src/api/trace.ts index f44fe256..726b552a 100644 --- a/src/api/trace.ts +++ b/src/api/trace.ts @@ -27,6 +27,7 @@ import { import { Tracer } from '../trace/tracer'; import { TracerProvider } from '../trace/tracer_provider'; import { + deleteSpan, getSpan, getSpanContext, setSpan, @@ -89,6 +90,8 @@ export class TraceAPI { public isSpanContextValid = isSpanContextValid; + public deleteSpan = deleteSpan; + public getSpan = getSpan; public getSpanContext = getSpanContext; diff --git a/src/baggage/context-helpers.ts b/src/baggage/context-helpers.ts index 05b24a82..ae7b4a78 100644 --- a/src/baggage/context-helpers.ts +++ b/src/baggage/context-helpers.ts @@ -24,6 +24,8 @@ import { Baggage } from './types'; const BAGGAGE_KEY = createContextKey('OpenTelemetry Baggage Key'); /** + * Retrieve the current baggage from the given context + * * @param {Context} Context that manage all context values * @returns {Baggage} Extracted baggage from the context */ @@ -32,9 +34,20 @@ export function getBaggage(context: Context): Baggage | undefined { } /** + * Store a baggage in the given context + * * @param {Context} Context that manage all context values * @param {Baggage} baggage that will be set in the actual context */ export function setBaggage(context: Context, baggage: Baggage): Context { return context.setValue(BAGGAGE_KEY, baggage); } + +/** + * Delete the baggage stored in the given context + * + * @param {Context} Context that manage all context values + */ +export function deleteBaggage(context: Context): Context { + return context.deleteValue(BAGGAGE_KEY); +} diff --git a/src/trace/context-utils.ts b/src/trace/context-utils.ts index 3714eb96..1d24bc2e 100644 --- a/src/trace/context-utils.ts +++ b/src/trace/context-utils.ts @@ -44,6 +44,15 @@ export function setSpan(context: Context, span: Span): Context { return context.setValue(SPAN_KEY, span); } +/** + * Remove current span stored in the context + * + * @param context context to delete span from + */ +export function deleteSpan(context: Context): Context { + return context.deleteValue(SPAN_KEY); +} + /** * Wrap span context in a NoopSpan and set as span in a new * context From f6673258c06ec80f03dbac102c2ebc32a1e05d31 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Fri, 21 May 2021 16:14:01 -0400 Subject: [PATCH 14/16] chore: release proposal 0.20.0 (#80) --- CHANGELOG.md | 14 +++++++++++++- package.json | 2 +- src/version.ts | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7920ec..133ad1d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,19 @@ All notable changes to this project will be documented in this file. -## 1.0.0-rc.1 +## 0.20.0 + +### :rocket: Enhancement + +* [#69](https://github.com/open-telemetry/opentelemetry-js-api/pull/69) feat(context): add utils method to remove keys from context ([@vmarchaud](https://github.com/vmarchaud)) +* [#71](https://github.com/open-telemetry/opentelemetry-js-api/pull/71) chore: export baggage ([@dyladan](https://github.com/dyladan)) + +### Committers: 2 + +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Valentin Marchaud ([@vmarchaud](https://github.com/vmarchaud)) + +## 0.19.0 ### :boom: Breaking Change diff --git a/package.json b/package.json index 756df6af..2e90a854 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api", - "version": "0.19.0", + "version": "0.20.0", "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "module": "build/esm/index.js", diff --git a/src/version.ts b/src/version.ts index 3fc2009a..a14ba6ef 100644 --- a/src/version.ts +++ b/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.19.0'; +export const VERSION = '0.20.0'; From 7f325670abc97e847e217722e0b642a5acf06bcc Mon Sep 17 00:00:00 2001 From: Rauno Viskus Date: Tue, 25 May 2021 10:43:52 +0300 Subject: [PATCH 15/16] chore: fix eslint config (#79) Co-authored-by: Valentin Marchaud --- .eslintrc.js | 8 +++++++- backwards-compatability/node10/index.ts | 19 +++++++++++++++++-- backwards-compatability/node10/tsconfig.json | 10 +--------- backwards-compatability/node12/index.ts | 19 +++++++++++++++++-- backwards-compatability/node12/tsconfig.json | 10 +--------- backwards-compatability/node8/index.ts | 19 +++++++++++++++++-- backwards-compatability/node8/tsconfig.json | 10 +--------- 7 files changed, 61 insertions(+), 34 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index dc6c5b2f..614b74a5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,8 +13,14 @@ module.exports = { ], parser: "@typescript-eslint/parser", parserOptions: { - "project": "./tsconfig.json" + "project": [ + "./tsconfig.json", + "backwards-compatability/*/tsconfig.json" + ] }, + ignorePatterns: [ + 'build', + ], rules: { "@typescript-eslint/no-this-alias": "off", "eqeqeq": [ diff --git a/backwards-compatability/node10/index.ts b/backwards-compatability/node10/index.ts index 985d78f7..949c48a7 100644 --- a/backwards-compatability/node10/index.ts +++ b/backwards-compatability/node10/index.ts @@ -1,5 +1,20 @@ -import {NodeSDK, api} from '@opentelemetry/sdk-node'; -import {ConsoleSpanExporter} from '@opentelemetry/tracing'; +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NodeSDK, api } from '@opentelemetry/sdk-node'; +import { ConsoleSpanExporter } from '@opentelemetry/tracing'; const sdk = new NodeSDK({ traceExporter: new ConsoleSpanExporter(), diff --git a/backwards-compatability/node10/tsconfig.json b/backwards-compatability/node10/tsconfig.json index 0e5977e0..0a0c58df 100644 --- a/backwards-compatability/node10/tsconfig.json +++ b/backwards-compatability/node10/tsconfig.json @@ -1,18 +1,10 @@ { - "extends": "../../tsconfig.es5.json", + "extends": "../../tsconfig.json", "compilerOptions": { "rootDir": ".", "outDir": "build" }, "include": [ "index.ts" - ], - "references": [ - { - "path": "../../packages/opentelemetry-sdk-node" - }, - { - "path": "../../packages/opentelemetry-tracing" - } ] } diff --git a/backwards-compatability/node12/index.ts b/backwards-compatability/node12/index.ts index 985d78f7..949c48a7 100644 --- a/backwards-compatability/node12/index.ts +++ b/backwards-compatability/node12/index.ts @@ -1,5 +1,20 @@ -import {NodeSDK, api} from '@opentelemetry/sdk-node'; -import {ConsoleSpanExporter} from '@opentelemetry/tracing'; +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NodeSDK, api } from '@opentelemetry/sdk-node'; +import { ConsoleSpanExporter } from '@opentelemetry/tracing'; const sdk = new NodeSDK({ traceExporter: new ConsoleSpanExporter(), diff --git a/backwards-compatability/node12/tsconfig.json b/backwards-compatability/node12/tsconfig.json index 0e5977e0..0a0c58df 100644 --- a/backwards-compatability/node12/tsconfig.json +++ b/backwards-compatability/node12/tsconfig.json @@ -1,18 +1,10 @@ { - "extends": "../../tsconfig.es5.json", + "extends": "../../tsconfig.json", "compilerOptions": { "rootDir": ".", "outDir": "build" }, "include": [ "index.ts" - ], - "references": [ - { - "path": "../../packages/opentelemetry-sdk-node" - }, - { - "path": "../../packages/opentelemetry-tracing" - } ] } diff --git a/backwards-compatability/node8/index.ts b/backwards-compatability/node8/index.ts index 985d78f7..949c48a7 100644 --- a/backwards-compatability/node8/index.ts +++ b/backwards-compatability/node8/index.ts @@ -1,5 +1,20 @@ -import {NodeSDK, api} from '@opentelemetry/sdk-node'; -import {ConsoleSpanExporter} from '@opentelemetry/tracing'; +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { NodeSDK, api } from '@opentelemetry/sdk-node'; +import { ConsoleSpanExporter } from '@opentelemetry/tracing'; const sdk = new NodeSDK({ traceExporter: new ConsoleSpanExporter(), diff --git a/backwards-compatability/node8/tsconfig.json b/backwards-compatability/node8/tsconfig.json index 0e5977e0..0a0c58df 100644 --- a/backwards-compatability/node8/tsconfig.json +++ b/backwards-compatability/node8/tsconfig.json @@ -1,18 +1,10 @@ { - "extends": "../../tsconfig.es5.json", + "extends": "../../tsconfig.json", "compilerOptions": { "rootDir": ".", "outDir": "build" }, "include": [ "index.ts" - ], - "references": [ - { - "path": "../../packages/opentelemetry-sdk-node" - }, - { - "path": "../../packages/opentelemetry-tracing" - } ] } From 4cda9bd10a8caff59f637e7d982387772c626866 Mon Sep 17 00:00:00 2001 From: Karen Xu Date: Tue, 25 May 2021 07:16:45 -0400 Subject: [PATCH 16/16] Add CodeQL Security Scan (#75) --- .github/workflows/codeql-analysis.yml | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..c9efc633 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,34 @@ +name: "CodeQL" + +on: + workflow_dispatch: + schedule: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + # │ │ │ │ │ + # * * * * * + - cron: '30 1 * * *' + +jobs: + CodeQL-Build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: javascript + + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1