From 62f8695d3fe5309c62418a1043bc6e8a176bc11f Mon Sep 17 00:00:00 2001 From: Nev <54870357+MSNev@users.noreply.github.com> Date: Wed, 17 Feb 2021 12:46:27 -0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(diag-logger):=20part=202=20-=20breakin?= =?UTF-8?q?g=20changes=20-=20remove=20api.Logger,=20api=E2=80=A6=20(#1925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 47 ++ benchmark/tracer.js | 7 +- examples/collector-exporter-node/metrics.js | 2 +- examples/metrics/metrics/observer.js | 7 +- examples/tracer-web/examples/metrics/index.js | 7 +- getting-started/traced-example/tracing.js | 3 +- .../ts-example/traced-example/tracing.ts | 15 +- .../src/types/Metric.ts | 11 - packages/opentelemetry-api/src/api/diag.ts | 11 +- .../opentelemetry-api/src/common/Logger.ts | 28 -- .../src/diag/consoleLogger.ts | 24 +- .../opentelemetry-api/src/diag/logLevel.ts | 39 +- packages/opentelemetry-api/src/diag/logger.ts | 37 +- packages/opentelemetry-api/src/index.ts | 2 - .../opentelemetry-api/src/trace/NoopLogger.ts | 35 -- .../opentelemetry-api/test/api/api.test.ts | 42 ++ .../test/diag/consoleLogger.test.ts | 3 - .../test/diag/logLevel.test.ts | 410 +++++++----------- .../test/diag/logger.test.ts | 3 - .../src/common/ConsoleLogger.ts | 56 --- .../src/common/logging-error-handler.ts | 16 +- .../opentelemetry-core/src/common/types.ts | 16 - .../src/context/propagation/composite.ts | 10 +- .../src/context/propagation/types.ts | 5 +- packages/opentelemetry-core/src/index.ts | 1 - .../src/platform/BaseAbstractPlugin.ts | 4 +- .../src/platform/browser/BasePlugin.ts | 4 +- .../src/platform/node/BasePlugin.ts | 16 +- .../opentelemetry-core/src/trace/Plugin.ts | 4 +- .../src/utils/environment.ts | 42 +- .../test/common/ConsoleLogger.test.ts | 155 ------- .../test/common/logging-error-handler.test.ts | 9 +- .../test/platform/BasePlugin.test.ts | 5 +- .../test/platform/browser/BasePlugin.test.ts | 10 +- .../test/utils/environment.test.ts | 8 +- .../src/CollectorExporterNodeBase.ts | 5 +- .../src/util.ts | 5 +- .../test/CollectorMetricExporter.test.ts | 9 +- .../test/CollectorTraceExporter.test.ts | 9 +- .../src/CollectorExporterNodeBase.ts | 3 +- .../test/CollectorMetricExporter.test.ts | 8 +- .../test/CollectorTraceExporter.test.ts | 8 +- .../src/CollectorExporterBase.ts | 11 +- .../browser/CollectorExporterBrowserBase.ts | 16 +- .../src/platform/browser/util.ts | 8 +- .../node/CollectorExporterNodeBase.ts | 10 +- .../src/platform/node/util.ts | 9 +- .../src/types.ts | 8 +- .../src/util.ts | 8 +- .../browser/CollectorMetricExporter.test.ts | 24 +- .../browser/CollectorTraceExporter.test.ts | 32 +- .../common/CollectorMetricExporter.test.ts | 16 +- .../common/CollectorTraceExporter.test.ts | 16 +- .../test/common/utils.test.ts | 13 +- .../test/node/CollectorMetricExporter.test.ts | 21 +- .../test/node/CollectorTraceExporter.test.ts | 17 +- .../src/jaeger.ts | 10 +- .../src/types.ts | 3 - .../test/jaeger.test.ts | 1 - .../src/PrometheusExporter.ts | 14 +- .../src/export/types.ts | 5 - .../src/platform/browser/util.ts | 30 +- .../src/platform/node/util.ts | 14 +- .../src/types.ts | 2 - .../src/zipkin.ts | 10 +- .../test/browser/zipkin.test.ts | 5 +- .../test/common/transform.test.ts | 5 +- .../test/node/zipkin.test.ts | 9 - .../test/grpcUtils.test.ts | 22 +- .../src/fetch.ts | 4 +- .../test/fetch.test.ts | 4 +- .../src/grpc-js/index.ts | 18 +- .../src/grpc/index.ts | 20 +- .../test/helper.ts | 13 +- .../src/http.ts | 37 +- .../test/functionals/http-disable.test.ts | 9 +- .../test/functionals/http-enable.test.ts | 8 +- .../test/functionals/http-package.test.ts | 16 +- .../test/functionals/https-disable.test.ts | 9 +- .../test/functionals/https-enable.test.ts | 8 +- .../test/functionals/https-package.test.ts | 17 +- .../test/functionals/utils.test.ts | 4 +- .../test/integrations/http-enable.test.ts | 16 +- .../test/integrations/https-enable.test.ts | 16 +- .../src/xhr.ts | 10 +- .../test/xhr.test.ts | 14 +- .../opentelemetry-instrumentation/README.md | 2 - .../src/autoLoader.ts | 24 +- .../src/autoLoaderUtils.ts | 4 +- .../src/instrumentation.ts | 15 +- .../src/platform/browser/old/autoLoader.ts | 8 +- .../src/platform/node/instrumentation.ts | 3 +- .../src/platform/node/old/PluginLoader.ts | 30 +- .../src/platform/node/old/autoLoader.ts | 8 +- .../src/platform/node/old/utils.ts | 12 +- .../src/types.ts | 4 +- .../src/types_internal.ts | 3 +- .../src/types_plugin_only.ts | 4 +- .../test/node/BasePlugin.ts | 3 +- .../test/node/PluginLoader.test.ts | 56 +-- .../test/node/utils.test.ts | 5 +- .../src/BaseObserverMetric.ts | 1 - .../src/BatchObserver.ts | 10 +- .../src/BoundInstrument.ts | 25 +- .../src/CounterMetric.ts | 1 - packages/opentelemetry-metrics/src/Meter.ts | 29 +- .../src/MeterProvider.ts | 6 - packages/opentelemetry-metrics/src/Metric.ts | 3 - .../src/UpDownCounterMetric.ts | 1 - .../src/ValueRecorderMetric.ts | 1 - packages/opentelemetry-metrics/src/types.ts | 12 +- .../opentelemetry-metrics/test/Meter.test.ts | 32 +- .../test/MeterProvider.test.ts | 5 +- .../test/Processor.test.ts | 2 - .../src/NodeTracerProvider.ts | 3 +- .../test/NodeTracerProvider.test.ts | 30 +- .../src/client/loadPackageDefinition.ts | 3 +- .../src/client/patchClient.ts | 3 +- .../src/client/utils.ts | 3 +- .../src/grpcJs.ts | 17 +- .../src/server/patchServer.ts | 5 +- .../opentelemetry-plugin-grpc/src/grpc.ts | 24 +- .../opentelemetry-plugin-http/src/http.ts | 27 +- .../test/functionals/http-disable.test.ts | 9 +- .../test/functionals/http-enable.test.ts | 22 +- .../test/functionals/http-package.test.ts | 9 +- .../test/functionals/utils.test.ts | 4 +- .../test/integrations/http-enable.test.ts | 9 +- .../opentelemetry-plugin-https/src/https.ts | 9 +- .../test/functionals/https-disable.test.ts | 8 +- .../test/functionals/https-enable.test.ts | 15 +- .../test/functionals/https-package.test.ts | 10 +- .../test/integrations/https-enable.test.ts | 14 +- .../src/detectors/AwsBeanstalkDetector.ts | 7 +- .../src/detectors/AwsEc2Detector.ts | 6 +- .../src/detectors/AwsEcsDetector.ts | 17 +- .../src/detectors/AwsEksDetector.ts | 48 +- .../detectors/AwsBeanstalkDetector.test.ts | 17 +- .../test/detectors/AwsEc2Detector.test.ts | 17 +- .../test/detectors/AwsEcsDetector.test.ts | 33 +- .../test/detectors/AwsEksDetector.test.ts | 37 +- .../src/detectors/GcpDetector.ts | 9 +- .../test/detectors/GcpDetector.test.ts | 11 +- .../opentelemetry-resources/src/config.ts | 13 - .../src/platform/node/detect-resources.ts | 31 +- .../platform/node/detectors/EnvDetector.ts | 11 +- .../node/detectors/ProcessDetector.ts | 13 +- packages/opentelemetry-resources/src/types.ts | 4 +- .../test/detectors/EnvDetector.test.ts | 9 +- .../test/detectors/ProcessDetector.test.ts | 9 +- packages/opentelemetry-sdk-node/README.md | 8 - packages/opentelemetry-sdk-node/src/sdk.ts | 12 - packages/opentelemetry-sdk-node/src/types.ts | 29 +- .../opentelemetry-sdk-node/test/sdk.test.ts | 57 +-- .../src/shim.ts | 8 +- .../src/BasicTracerProvider.ts | 20 +- packages/opentelemetry-tracing/src/Span.ts | 16 +- packages/opentelemetry-tracing/src/Tracer.ts | 7 +- packages/opentelemetry-tracing/src/config.ts | 1 - packages/opentelemetry-tracing/src/types.ts | 12 +- .../test/BasicTracerProvider.test.ts | 9 - .../opentelemetry-tracing/test/Span.test.ts | 14 +- .../opentelemetry-tracing/test/Tracer.test.ts | 5 +- .../test/export/TestTracingSpanExporter.ts | 5 +- .../test/WebTracerProvider.test.ts | 6 +- 165 files changed, 927 insertions(+), 1810 deletions(-) delete mode 100644 packages/opentelemetry-api/src/common/Logger.ts delete mode 100644 packages/opentelemetry-api/src/trace/NoopLogger.ts delete mode 100644 packages/opentelemetry-core/src/common/ConsoleLogger.ts delete mode 100644 packages/opentelemetry-core/test/common/ConsoleLogger.test.ts diff --git a/README.md b/README.md index ca5955680ef..d91061e5066 100644 --- a/README.md +++ b/README.md @@ -244,6 +244,53 @@ To request automatic tracing support for a module not on this list, please [file ## Upgrade guidelines +### 0.17.0 to ??? + +[PR-1880](/~https://github.com/open-telemetry/opentelemetry-js/pull/1880) feat(diag-logger): introduce a new global level api.diag for internal diagnostic logging + +[PR-1925](/~https://github.com/open-telemetry/opentelemetry-js/pull/1925) feat(diag-logger): part 2 - breaking changes - remove api.Logger, api.NoopLogger, core.LogLevel, core.ConsoleLogger + +- These PR's remove the previous ```Logger``` and ```LogLevel``` implementations and change the way you should use the replacement ```DiagLogger``` and ```DiagLogLevel```, below are simple examples of how to change your existing usages. + +#### Setting the global diagnostic logger + +The new global [```api.diag```](/~https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-api/src/api/diag.ts#L32) provides the ability to set the global diagnostic logger ```setLogger()``` and logging level ```setLogLevel()```, it is also a ```DiagLogger``` implementation and should be directly to log diagnostic messages. + +All included logger references have been removed in preference to using the global ```api.diag``` directly, so you no longer need to pass around the logger instance via function parameters or included as part of the configuration for a component. + +```javascript +// Setting the default Global logger to use the Console +import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api"; +diag.setLogger(new DiagConsoleLogger()) + +// And optionally change the logging level (Defaults to INFO) +diag.setLogLevel(DiagLogLevel.ERROR); +``` + +#### Using the logger anywhere in the code + +```typescript +import { diag } from "@opentelemetry/api"; + +// Remove or make optional the parameter and don't use it. +export function MyFunction() { + diag.debug("..."); + diag.info("..."); + diag.warn("..."); + diag.error("..."); + diag.verbose(".."); +} + +``` + +#### Setting the logger back to a noop + +```typescript +import { diag } from "@opentelemetry/api"; +diag.setLogger(); + +``` + ### 0.16.0 to 0.17.0 [PR-1855](/~https://github.com/open-telemetry/opentelemetry-js/pull/1855) Use instrumentation loader to load plugins and instrumentations diff --git a/benchmark/tracer.js b/benchmark/tracer.js index 27ba3520c63..5fda6521b9b 100644 --- a/benchmark/tracer.js +++ b/benchmark/tracer.js @@ -4,7 +4,8 @@ const benchmark = require('./benchmark'); const opentelemetry = require('../packages/opentelemetry-api'); const { BasicTracerProvider, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('../packages/opentelemetry-tracing'); -const diagLogger = opentelemetry.createNoopDiagLogger(); +// Clear any previous global logger +opentelemetry.diag.setLogger(); const setups = [ { @@ -13,7 +14,7 @@ const setups = [ }, { name: 'BasicTracerProvider', - provider: new BasicTracerProvider({ logger: diagLogger }) + provider: new BasicTracerProvider() }, { name: 'BasicTracerProvider with SimpleSpanProcessor', @@ -63,7 +64,7 @@ for (const setup of setups) { suite.run({ async: false }); } function getProvider(processor) { - const provider = new BasicTracerProvider({ logger: diagLogger }); + const provider = new BasicTracerProvider(); provider.addSpanProcessor(processor); return provider; } diff --git a/examples/collector-exporter-node/metrics.js b/examples/collector-exporter-node/metrics.js index f7102c3bf1c..d6ba0178ef6 100644 --- a/examples/collector-exporter-node/metrics.js +++ b/examples/collector-exporter-node/metrics.js @@ -6,13 +6,13 @@ const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector') // const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector-proto'); const { MeterProvider } = require('@opentelemetry/metrics'); +// Optional and only needed to see the internal diagnostic logging (during development) diag.setLogger(new DiagConsoleLogger()); diag.setLogLevel(DiagLogLevel.DEBUG); const metricExporter = new CollectorMetricExporter({ serviceName: 'basic-metric-service', // url: 'http://localhost:55681/v1/metrics', - logger: diag, }); const meter = new MeterProvider({ diff --git a/examples/metrics/metrics/observer.js b/examples/metrics/metrics/observer.js index 010bea50da1..943774f589d 100644 --- a/examples/metrics/metrics/observer.js +++ b/examples/metrics/metrics/observer.js @@ -1,9 +1,13 @@ 'use strict'; const { MeterProvider } = require('@opentelemetry/metrics'); -const { DiagConsoleLogger, DiagLogLevel, diagLogLevelFilter } = require('@opentelemetry/api'); +const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api'); const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); +// Optional and only needed to see the internal diagnostic logging (during development) +diag.setLogger(new DiagConsoleLogger()); +diag.setLogLevel(DiagLogLevel.DEBUG); + const exporter = new PrometheusExporter( { startServer: true, @@ -61,7 +65,6 @@ meter.createBatchObserver((observerBatchResult) => { }); }, { maxTimeoutUpdateMS: 500, - logger: diagLogLevelFilter(DiagLogLevel.DEBUG, new DiagConsoleLogger()) }, ); diff --git a/examples/tracer-web/examples/metrics/index.js b/examples/tracer-web/examples/metrics/index.js index 7090c78dc3e..e24e6d6758a 100644 --- a/examples/tracer-web/examples/metrics/index.js +++ b/examples/tracer-web/examples/metrics/index.js @@ -1,12 +1,15 @@ 'use strict'; -const { DiagConsoleLogger, DiagLogLevel, diagLogLevelFilter } = require('@opentelemetry/api'); +const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api'); const { CollectorMetricExporter } = require('@opentelemetry/exporter-collector'); const { MeterProvider } = require('@opentelemetry/metrics'); +// Optional and only needed to see the internal diagnostic logging (during development) +diag.setLogger(new DiagConsoleLogger()); +diag.setLogLevel(DiagLogLevel.DEBUG); + const metricExporter = new CollectorMetricExporter({ serviceName: 'basic-metric-service', - logger: diagLogLevelFilter(DiagLogLevel.DEBUG, new DiagConsoleLogger()), }); let interval; diff --git a/getting-started/traced-example/tracing.js b/getting-started/traced-example/tracing.js index 2f581b7d86f..55b0fd62ecd 100644 --- a/getting-started/traced-example/tracing.js +++ b/getting-started/traced-example/tracing.js @@ -1,12 +1,11 @@ "use strict"; -const { LogLevel } = require("@opentelemetry/core"); const { NodeTracerProvider } = require("@opentelemetry/node"); const { SimpleSpanProcessor } = require("@opentelemetry/tracing"); const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin"); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); -const provider = new NodeTracerProvider({ logLevel: LogLevel.ERROR }); +const provider = new NodeTracerProvider(); provider.addSpanProcessor( new SimpleSpanProcessor( diff --git a/getting-started/ts-example/traced-example/tracing.ts b/getting-started/ts-example/traced-example/tracing.ts index dfb37cb1ce4..aeb626ae571 100644 --- a/getting-started/ts-example/traced-example/tracing.ts +++ b/getting-started/ts-example/traced-example/tracing.ts @@ -1,17 +1,14 @@ -import { LogLevel } from '@opentelemetry/core'; import { NodeTracerProvider } from '@opentelemetry/node'; - + import { SimpleSpanProcessor } from '@opentelemetry/tracing'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; // For Jaeger, use the following line instead: // import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; - -const provider: NodeTracerProvider = new NodeTracerProvider({ - logLevel: LogLevel.ERROR, -}); - + +const provider: NodeTracerProvider = new NodeTracerProvider(); + provider.register(); - + provider.addSpanProcessor( new SimpleSpanProcessor( new ZipkinExporter({ @@ -24,5 +21,5 @@ provider.addSpanProcessor( }), ), ); - + console.log('tracing initialized'); diff --git a/packages/opentelemetry-api-metrics/src/types/Metric.ts b/packages/opentelemetry-api-metrics/src/types/Metric.ts index a6741813896..8f38bb8812e 100644 --- a/packages/opentelemetry-api-metrics/src/types/Metric.ts +++ b/packages/opentelemetry-api-metrics/src/types/Metric.ts @@ -19,7 +19,6 @@ import { BoundCounter, BoundValueRecorder, } from './BoundInstrument'; -import { Logger } from '@opentelemetry/api'; /** * Options needed for metric creation @@ -55,11 +54,6 @@ export interface MetricOptions { */ valueType?: ValueType; - /** - * User provided logger. - */ - logger?: Logger; - /** * Boundaries optional for histogram */ @@ -71,11 +65,6 @@ export interface BatchObserverOptions { * Indicates how long the batch metric should wait to update before cancel */ maxTimeoutUpdateMS?: number; - - /** - * User provided logger. - */ - logger?: Logger; } /** The Type of value. It describes how the data is reported. */ diff --git a/packages/opentelemetry-api/src/api/diag.ts b/packages/opentelemetry-api/src/api/diag.ts index f9914b3f066..58a5cdd1439 100644 --- a/packages/opentelemetry-api/src/api/diag.ts +++ b/packages/opentelemetry-api/src/api/diag.ts @@ -99,9 +99,9 @@ export class DiagAPI implements DiagLogger { return _logger; }; - self.setLogger = (logger: DiagLogger): DiagLogger => { + self.setLogger = (logger?: DiagLogger): DiagLogger => { const prevLogger = _logger; - if (prevLogger !== logger && logger !== self) { + if (!logger || logger !== self) { // Simple special case to avoid any possible infinite recursion on the logging functions _logger = logger || createNoopDiagLogger(); _filteredLogger = createLogLevelDiagLogger(_logLevel, _logger); @@ -133,10 +133,10 @@ export class DiagAPI implements DiagLogger { /** * Set the DiagLogger instance - * @param logger - The DiagLogger instance to set as the default logger + * @param logger - [Optional] The DiagLogger instance to set as the default logger, if not provided it will set it back as a noop * @returns The previously registered DiagLogger */ - public setLogger!: (logger: DiagLogger) => DiagLogger; + public setLogger!: (logger?: DiagLogger) => DiagLogger; /** Set the default maximum diagnostic logging level */ public setLogLevel!: (maxLogLevel: DiagLogLevel) => void; @@ -146,8 +146,5 @@ export class DiagAPI implements DiagLogger { public debug!: DiagLogFunction; public info!: DiagLogFunction; public warn!: DiagLogFunction; - public startupInfo!: DiagLogFunction; public error!: DiagLogFunction; - public critical!: DiagLogFunction; - public terminal!: DiagLogFunction; } diff --git a/packages/opentelemetry-api/src/common/Logger.ts b/packages/opentelemetry-api/src/common/Logger.ts deleted file mode 100644 index 3f0d0406884..00000000000 --- a/packages/opentelemetry-api/src/common/Logger.ts +++ /dev/null @@ -1,28 +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. - */ - -export type LogFunction = (message: string, ...args: unknown[]) => void; - -/** Defines a logger interface. - * @deprecated This interface will be removed prior to v1.0, use the api.diag - * @see {@link DiagLogger} and {@link DiagAPI} - */ -export interface Logger { - error: LogFunction; - warn: LogFunction; - info: LogFunction; - debug: LogFunction; -} diff --git a/packages/opentelemetry-api/src/diag/consoleLogger.ts b/packages/opentelemetry-api/src/diag/consoleLogger.ts index 27f7cb9fbb7..7ea2e9cd790 100644 --- a/packages/opentelemetry-api/src/diag/consoleLogger.ts +++ b/packages/opentelemetry-api/src/diag/consoleLogger.ts @@ -17,20 +17,17 @@ import { DiagLogger, DiagLogFunction } from './logger'; const consoleMap: { n: keyof DiagLogger; c: keyof Console }[] = [ - { n: 'terminal', c: 'error' }, - { n: 'critical', c: 'error' }, { n: 'error', c: 'error' }, { n: 'warn', c: 'warn' }, { n: 'info', c: 'info' }, { n: 'debug', c: 'debug' }, { n: 'verbose', c: 'trace' }, - { n: 'startupInfo', c: 'info' }, ]; /** * A simple Immutable Console based diagnostic logger which will output any messages to the Console. * If you want to limit the amount of logging to a specific level or lower use the - * {@link diagLogLevelFilter} + * {@link createLogLevelDiagLogger} */ export class DiagConsoleLogger implements DiagLogger { constructor() { @@ -58,28 +55,9 @@ export class DiagConsoleLogger implements DiagLogger { } } - /** - * Log a terminal situation that would cause the API to completely fail to initialize, - * if this type of message is logged functionality of the API is not expected to be functional. - */ - public terminal!: DiagLogFunction; - - /** - * Log a critical error that NEEDS to be addressed, functionality of the component that emits - * this log detail may non-functional. While the overall API may be. - */ - public critical!: DiagLogFunction; - /** Log an error scenario that was not expected and caused the requested operation to fail. */ public error!: DiagLogFunction; - /** - * Logs a general informational message that is used for logging component startup and version - * information without causing additional general informational messages when the logging level - * is set to DiagLogLevel.WARN or lower. - */ - public startupInfo!: DiagLogFunction; - /** * Log a warning scenario to inform the developer of an issues that should be investigated. * The requested operation may or may not have succeeded or completed. diff --git a/packages/opentelemetry-api/src/diag/logLevel.ts b/packages/opentelemetry-api/src/diag/logLevel.ts index 31241801ca8..362bb135f69 100644 --- a/packages/opentelemetry-api/src/diag/logLevel.ts +++ b/packages/opentelemetry-api/src/diag/logLevel.ts @@ -15,7 +15,6 @@ */ import { DiagAPI } from '../api/diag'; -import { Logger } from '../common/Logger'; import { DiagLogger, DiagLogFunction, createNoopDiagLogger } from './logger'; /** @@ -27,24 +26,9 @@ export enum DiagLogLevel { /** Diagnostic Logging level setting to disable all logging (except and forced logs) */ NONE = 0, - /** - * Identifies a terminal situation that would cause the API to completely fail to initialize, - * if this type of error is logged functionality of the API is not expected to be functional. - */ - TERMINAL = 10, - - /** - * Identifies a critical error that needs to be addressed, functionality of the component - * that emits this log detail may non-functional. - */ - CRITICAL = 20, - /** Identifies an error scenario */ ERROR = 30, - /** Identifies startup and failure (lower) scenarios */ - STARTUP = 40, - /** Identifies a warning scenario */ WARN = 50, @@ -66,35 +50,17 @@ export enum DiagLogLevel { /** * This is equivalent to: - * type LogLevelString = 'NONE' | TERMINAL' | 'CRITICAL' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG' | 'VERBOSE' | 'ALL'; + * type LogLevelString = 'NONE' | 'ERROR' | 'WARN' | 'INFO' | 'DEBUG' | 'VERBOSE' | 'ALL'; */ export type DiagLogLevelString = keyof typeof DiagLogLevel; -/** - * Mapping from DiagLogger function name to Legacy Logger function used if - * the logger instance doesn't have the DiagLogger function - */ -const fallbackLoggerFuncMap: { [n: string]: keyof Logger } = { - terminal: 'error', - critical: 'error', - error: 'error', - warn: 'warn', - info: 'info', - debug: 'debug', - verbose: 'debug', - startupInfo: 'info', -}; - /** Mapping from DiagLogger function name to logging level. */ const levelMap: { n: keyof DiagLogger; l: DiagLogLevel }[] = [ - { n: 'terminal', l: DiagLogLevel.TERMINAL }, - { n: 'critical', l: DiagLogLevel.CRITICAL }, { n: 'error', l: DiagLogLevel.ERROR }, { n: 'warn', l: DiagLogLevel.WARN }, { n: 'info', l: DiagLogLevel.INFO }, { n: 'debug', l: DiagLogLevel.DEBUG }, { n: 'verbose', l: DiagLogLevel.VERBOSE }, - { n: 'startupInfo', l: DiagLogLevel.ERROR }, ]; /** @@ -138,8 +104,7 @@ export function createLogLevelDiagLogger( if (maxLevel >= theLevel) { return function () { const orgArguments = arguments as unknown; - const theFunc = - theLogger[funcName] || theLogger[fallbackLoggerFuncMap[funcName]]; + const theFunc = theLogger[funcName]; if (theFunc && typeof theFunc === 'function') { return theFunc.apply( logger, diff --git a/packages/opentelemetry-api/src/diag/logger.ts b/packages/opentelemetry-api/src/diag/logger.ts index 6b01ff9b1b9..f718076b6a8 100644 --- a/packages/opentelemetry-api/src/diag/logger.ts +++ b/packages/opentelemetry-api/src/diag/logger.ts @@ -14,17 +14,6 @@ * limitations under the License. */ -import { Logger } from '../common/Logger'; - -/** - * Defines a type which can be used for as a parameter without breaking backward - * compatibility. The {@link Logger} reference will be removed with the removal - * of the Logger definition, this can be used as a replacement for functions - * that are currently passing Logger references during migration to minimize - * breaks that will occur with the removal of the Logger interface. - */ -export type OptionalDiagLogger = Logger | DiagLogger | null | undefined; - export type DiagLogFunction = (message: string, ...args: unknown[]) => void; /** @@ -32,34 +21,13 @@ export type DiagLogFunction = (message: string, ...args: unknown[]) => void; * messages, you can set the default diagnostic logger via the {@link DiagAPI} setLogger function. * API provided implementations include :- * - a No-Op {@link createNoopDiagLogger} - * - a {@link DiagLogLevel} filtering wrapper {@link diagLogLevelFilter} + * - a {@link DiagLogLevel} filtering wrapper {@link createLogLevelDiagLogger} * - a general Console {@link DiagConsoleLogger} version. */ export interface DiagLogger { - /** - * Log a terminal situation that would cause the API to completely fail to initialize, - * if this type of message is logged functionality of the API is not expected to be functional. - */ - terminal: DiagLogFunction; - - /** - * Log a critical error that NEEDS to be addressed, functionality of the component that emits - * this log detail may be limited or non-functional depending on when this message is emitted. - * Unlike terminal message, it is expected that the overall API may still be functional, again - * depending on what component and when this message is emitted. - */ - critical: DiagLogFunction; - /** Log an error scenario that was not expected and caused the requested operation to fail. */ error: DiagLogFunction; - /** - * Logs a general informational message that is used for logging component startup and version - * information without causing additional general informational messages when the logging level - * is set to DiagLogLevel.WARN or lower. - */ - startupInfo: DiagLogFunction; - /** * Log a warning scenario to inform the developer of an issues that should be investigated. * The requested operation may or may not have succeeded or completed. @@ -97,10 +65,7 @@ export const diagLoggerFunctions: Array = [ 'debug', 'info', 'warn', - 'startupInfo', 'error', - 'critical', - 'terminal', ]; function noopLogFunction() {} diff --git a/packages/opentelemetry-api/src/index.ts b/packages/opentelemetry-api/src/index.ts index 2a5e99d9ba0..819918c9911 100644 --- a/packages/opentelemetry-api/src/index.ts +++ b/packages/opentelemetry-api/src/index.ts @@ -15,7 +15,6 @@ */ export * from './common/Exception'; -export * from './common/Logger'; export * from './common/Time'; export * from './context/context'; export * from './context/propagation/TextMapPropagator'; @@ -25,7 +24,6 @@ export * from './trace/attributes'; export * from './trace/Event'; export * from './trace/link_context'; export * from './trace/link'; -export * from './trace/NoopLogger'; export * from './trace/NoopTracer'; export * from './trace/NoopTracerProvider'; export * from './trace/ProxyTracer'; diff --git a/packages/opentelemetry-api/src/trace/NoopLogger.ts b/packages/opentelemetry-api/src/trace/NoopLogger.ts deleted file mode 100644 index 4dea9a5d393..00000000000 --- a/packages/opentelemetry-api/src/trace/NoopLogger.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 { Logger } from '../common/Logger'; - -/** No-op implementation of Logger - * @deprecated This class will be removed prior to v1.0, use the api.diag - * @see {@link DiagAPI}, {@link DiagLogger} and {@link createNoopDiagLogger} - */ -export class NoopLogger implements Logger { - // By default does nothing - debug(_message: string, ..._args: unknown[]) {} - - // By default does nothing - error(_message: string, ..._args: unknown[]) {} - - // By default does nothing - warn(_message: string, ..._args: unknown[]) {} - - // By default does nothing - info(_message: string, ..._args: unknown[]) {} -} diff --git a/packages/opentelemetry-api/test/api/api.test.ts b/packages/opentelemetry-api/test/api/api.test.ts index 609077f93e3..50b905be995 100644 --- a/packages/opentelemetry-api/test/api/api.test.ts +++ b/packages/opentelemetry-api/test/api/api.test.ts @@ -31,7 +31,11 @@ import api, { ROOT_CONTEXT, defaultTextMapSetter, defaultTextMapGetter, + diag, + diagLoggerFunctions, } from '../../src'; +import { DiagAPI } from '../../src/api/diag'; +import { _global } from '../../src/api/global-utils'; import { NoopSpan } from '../../src/trace/NoopSpan'; describe('API', () => { @@ -177,4 +181,42 @@ describe('API', () => { }); }); }); + + describe('Global diag', () => { + it('initialization', () => { + const inst = DiagAPI.instance(); + + assert.deepStrictEqual(diag, inst); + }); + + diagLoggerFunctions.forEach(fName => { + it(`no argument logger ${fName} message doesn't throw`, () => { + diag.setLogger(); + assert.doesNotThrow(() => { + diag[fName](`${fName} message`); + }); + }); + + it(`null logger ${fName} message doesn't throw`, () => { + diag.setLogger(null as any); + assert.doesNotThrow(() => { + diag[fName](`${fName} message`); + }); + }); + + it(`undefined logger ${fName} message doesn't throw`, () => { + diag.setLogger(undefined as any); + assert.doesNotThrow(() => { + diag[fName](`${fName} message`); + }); + }); + + it(`empty logger ${fName} message doesn't throw`, () => { + diag.setLogger({} as any); + assert.doesNotThrow(() => { + diag[fName](`${fName} message`); + }); + }); + }); + }); }); diff --git a/packages/opentelemetry-api/test/diag/consoleLogger.test.ts b/packages/opentelemetry-api/test/diag/consoleLogger.test.ts index b1150308f86..07269bc9309 100644 --- a/packages/opentelemetry-api/test/diag/consoleLogger.test.ts +++ b/packages/opentelemetry-api/test/diag/consoleLogger.test.ts @@ -28,14 +28,11 @@ const consoleFuncs: Array = [ ]; const expectedConsoleMap: { [n: string]: keyof Console } = { - terminal: 'error', - critical: 'error', error: 'error', warn: 'warn', info: 'info', debug: 'debug', verbose: 'trace', - startupInfo: 'info', }; describe('DiagConsoleLogger', () => { diff --git a/packages/opentelemetry-api/test/diag/logLevel.test.ts b/packages/opentelemetry-api/test/diag/logLevel.test.ts index b984135e1c6..3b7fa54882d 100644 --- a/packages/opentelemetry-api/test/diag/logLevel.test.ts +++ b/packages/opentelemetry-api/test/diag/logLevel.test.ts @@ -16,7 +16,6 @@ import * as assert from 'assert'; import { diag } from '../../src'; -import { Logger } from '../../src/common/Logger'; import { createNoopDiagLogger, DiagLogger, @@ -27,34 +26,21 @@ import { createLogLevelDiagLogger, } from '../../src/diag/logLevel'; -const incompleteLoggerFuncs: Array = [ +// Matches the previous Logger definition +const incompleteLoggerFuncs: Array = [ 'debug', 'info', 'warn', 'error', ]; -const expectedIncompleteMap: { [n: string]: keyof Console } = { - terminal: 'error', - critical: 'error', - error: 'error', - warn: 'warn', - info: 'info', - debug: 'debug', - verbose: 'debug', - startupInfo: 'info', -}; - describe('LogLevelFilter DiagLogger', () => { const calledArgs: any = { - terminal: null, - critical: null, error: null, warn: null, info: null, debug: null, verbose: null, - startupInfo: null, }; let dummyLogger: DiagLogger; @@ -63,8 +49,8 @@ describe('LogLevelFilter DiagLogger', () => { let incompleteLogger: DiagLogger; beforeEach(() => { - // set no logger - diag.setLogger(null as any); + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); diag.setLogLevel(DiagLogLevel.INFO); // mock @@ -90,208 +76,100 @@ describe('LogLevelFilter DiagLogger', () => { }); }); - describe('constructor', () => { - const levelMap: Array<{ - message: string; - level: DiagLogLevel; - ignoreFuncs: Array; - }> = [ - { message: 'ALL', level: DiagLogLevel.ALL, ignoreFuncs: [] }, - { message: 'greater than ALL', level: 32768, ignoreFuncs: [] }, - { message: 'VERBOSE', level: DiagLogLevel.VERBOSE, ignoreFuncs: [] }, - { message: 'DEBUG', level: DiagLogLevel.DEBUG, ignoreFuncs: ['verbose'] }, - { - message: 'INFO', - level: DiagLogLevel.INFO, - ignoreFuncs: ['verbose', 'debug'], - }, - { - message: 'WARN', - level: DiagLogLevel.WARN, - ignoreFuncs: ['verbose', 'debug', 'info'], - }, - { - message: 'ERROR', - level: DiagLogLevel.ERROR, - ignoreFuncs: ['verbose', 'debug', 'info', 'warn'], - }, - { - message: 'CRITICAL', - level: DiagLogLevel.CRITICAL, - ignoreFuncs: [ - 'verbose', - 'debug', - 'info', - 'warn', - 'error', - 'startupInfo', - ], - }, - { - message: 'TERMINAL', - level: DiagLogLevel.TERMINAL, - ignoreFuncs: [ - 'verbose', - 'debug', - 'info', - 'warn', - 'error', - 'critical', - 'startupInfo', - ], - }, - { - message: 'between TERMINAL and NONE', - level: 1, - ignoreFuncs: [ - 'verbose', - 'debug', - 'info', - 'warn', - 'error', - 'critical', - 'terminal', - 'startupInfo', - ], - }, - { - message: 'NONE', - level: DiagLogLevel.NONE, - ignoreFuncs: [ - 'verbose', - 'debug', - 'info', - 'warn', - 'error', - 'critical', - 'terminal', - 'startupInfo', - ], - }, - { - message: 'less than NONE', - level: -1000, - ignoreFuncs: [ - 'verbose', - 'debug', - 'info', - 'warn', - 'error', - 'critical', - 'terminal', - 'startupInfo', - ], - }, - ]; + const levelMap: Array<{ + message: string; + level: DiagLogLevel; + ignoreFuncs: Array; + }> = [ + { message: 'ALL', level: DiagLogLevel.ALL, ignoreFuncs: [] }, + { message: 'greater than ALL', level: 32768, ignoreFuncs: [] }, + { message: 'VERBOSE', level: DiagLogLevel.VERBOSE, ignoreFuncs: [] }, + { message: 'DEBUG', level: DiagLogLevel.DEBUG, ignoreFuncs: ['verbose'] }, + { + message: 'INFO', + level: DiagLogLevel.INFO, + ignoreFuncs: ['verbose', 'debug'], + }, + { + message: 'WARN', + level: DiagLogLevel.WARN, + ignoreFuncs: ['verbose', 'debug', 'info'], + }, + { + message: 'ERROR', + level: DiagLogLevel.ERROR, + ignoreFuncs: ['verbose', 'debug', 'info', 'warn'], + }, + { + message: 'between ERROR and NONE', + level: 1, + ignoreFuncs: ['verbose', 'debug', 'info', 'warn', 'error'], + }, + { + message: 'NONE', + level: DiagLogLevel.NONE, + ignoreFuncs: ['verbose', 'debug', 'info', 'warn', 'error'], + }, + { + message: 'less than NONE', + level: -1000, + ignoreFuncs: ['verbose', 'debug', 'info', 'warn', 'error'], + }, + ]; - levelMap.forEach(map => { + levelMap.forEach(map => { + describe(`with ${map.message} log level`, () => { diagLoggerFunctions.forEach(fName => { - it(`should log ${fName} message with ${map.message} level`, () => { - const testLogger = createLogLevelDiagLogger(map.level, dummyLogger); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { - assert.deepStrictEqual(calledArgs[lName], [ - `${fName} called %s`, - 'param1', - ]); - } else { - assert.strictEqual(calledArgs[lName], null); - } - }); - }); - - it(`should be noop for null with explicit noop Logger log ${fName} message with ${map.message} level`, () => { - const testLogger = createLogLevelDiagLogger( - map.level, - createNoopDiagLogger() - ); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - assert.strictEqual(calledArgs[lName], null); - }); - }); - - it(`should be noop and not throw for null and no default Logger log ${fName} message with ${map.message} level`, () => { - const testLogger = createLogLevelDiagLogger(map.level, null); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - assert.strictEqual(calledArgs[lName], null); - }); - }); - - it(`should be noop and not throw for undefined and no default Logger log ${fName} message with ${map.message} level`, () => { - const testLogger = createLogLevelDiagLogger(map.level, undefined); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - assert.strictEqual(calledArgs[lName], null); + describe(`calling ${fName} message`, () => { + it('should log', () => { + const testLogger = createLogLevelDiagLogger(map.level, dummyLogger); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { + assert.deepStrictEqual(calledArgs[lName], [ + `${fName} called %s`, + 'param1', + ]); + } else { + assert.strictEqual(calledArgs[lName], null); + } + }); }); - }); - it(`should use default logger for undefined and log ${fName} message with ${map.message} level`, () => { - diag.setLogger(dummyLogger); - diag.setLogLevel(DiagLogLevel.ALL); - const testLogger = createLogLevelDiagLogger(map.level, undefined); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { - assert.deepStrictEqual(calledArgs[lName], [ - `${fName} called %s`, - 'param1', - ]); - } else { + it('should be noop for null with explicit noop Logger log', () => { + const testLogger = createLogLevelDiagLogger( + map.level, + createNoopDiagLogger() + ); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { assert.strictEqual(calledArgs[lName], null); - } + }); }); - }); - it(`should use default logger for null and log ${fName} message with ${map.message} level`, () => { - diag.setLogger(dummyLogger); - diag.setLogLevel(DiagLogLevel.ALL); - const testLogger = createLogLevelDiagLogger(map.level, null); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { - assert.deepStrictEqual(calledArgs[lName], [ - `${fName} called %s`, - 'param1', - ]); - } else { + it('should be noop and not throw for null and no default Logger log', () => { + const testLogger = createLogLevelDiagLogger(map.level, null); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { assert.strictEqual(calledArgs[lName], null); - } + }); }); - }); - it(`incomplete (legacy) logger should log ${fName} message to ${expectedIncompleteMap[fName]} with ${map.message} level`, () => { - const testLogger = createLogLevelDiagLogger( - map.level, - incompleteLogger - ); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - const expectedLog = expectedIncompleteMap[lName]; - if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { - assert.deepStrictEqual(calledArgs[expectedLog], [ - `${fName} called %s`, - 'param1', - ]); - } + it('should be noop and not throw for undefined and no default Logger log', () => { + const testLogger = createLogLevelDiagLogger(map.level, undefined); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + assert.strictEqual(calledArgs[lName], null); + }); }); - }); - levelMap.forEach(masterLevelMap => { - it(`diag setLogLevel is not ignored when set to ${masterLevelMap.message} and using default logger to log ${fName} message with ${map.message} level`, () => { + it('should use default logger for undefined and log', () => { diag.setLogger(dummyLogger); - diag.setLogLevel(masterLevelMap.level); - - const testLogger = createLogLevelDiagLogger(map.level); + diag.setLogLevel(DiagLogLevel.ALL); + const testLogger = createLogLevelDiagLogger(map.level, undefined); testLogger[fName](`${fName} called %s`, 'param1'); diagLoggerFunctions.forEach(lName => { - if ( - fName === lName && - map.ignoreFuncs.indexOf(lName) === -1 && - masterLevelMap.ignoreFuncs.indexOf(lName) === -1 - ) { + if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { assert.deepStrictEqual(calledArgs[lName], [ `${fName} called %s`, 'param1', @@ -302,14 +180,10 @@ describe('LogLevelFilter DiagLogger', () => { }); }); - it(`diag setLogLevel is ignored when set to ${masterLevelMap.message} when using a specific logger to log ${fName} message with ${map.message} level`, () => { + it('should use default logger for null and log', () => { diag.setLogger(dummyLogger); - diag.setLogLevel(masterLevelMap.level); - - const testLogger = createLogLevelDiagLogger( - map.level, - diag.getLogger() - ); + diag.setLogLevel(DiagLogLevel.ALL); + const testLogger = createLogLevelDiagLogger(map.level, null); testLogger[fName](`${fName} called %s`, 'param1'); diagLoggerFunctions.forEach(lName => { if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { @@ -322,42 +196,92 @@ describe('LogLevelFilter DiagLogger', () => { } }); }); - }); - it(`diag setLogLevel and logger should log ${fName} message with ${map.message} level`, () => { - diag.setLogger(dummyLogger); - diag.setLogLevel(map.level); - diag[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { - assert.deepStrictEqual(calledArgs[lName], [ - `${fName} called %s`, - 'param1', - ]); - } else { - assert.strictEqual(calledArgs[lName], null); - } + levelMap.forEach(masterLevelMap => { + describe(`when diag logger is set to ${masterLevelMap.message}`, () => { + it('diag setLogLevel is not ignored and using default logger', () => { + diag.setLogger(dummyLogger); + diag.setLogLevel(masterLevelMap.level); + + const testLogger = createLogLevelDiagLogger(map.level); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + if ( + fName === lName && + map.ignoreFuncs.indexOf(lName) === -1 && + masterLevelMap.ignoreFuncs.indexOf(lName) === -1 + ) { + assert.deepStrictEqual(calledArgs[lName], [ + `${fName} called %s`, + 'param1', + ]); + } else { + assert.strictEqual(calledArgs[lName], null); + } + }); + }); + + it('diag setLogLevel is ignored when using a specific logger', () => { + diag.setLogger(dummyLogger); + diag.setLogLevel(masterLevelMap.level); + + const testLogger = createLogLevelDiagLogger( + map.level, + diag.getLogger() + ); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + if ( + fName === lName && + map.ignoreFuncs.indexOf(lName) === -1 + ) { + assert.deepStrictEqual(calledArgs[lName], [ + `${fName} called %s`, + 'param1', + ]); + } else { + assert.strictEqual(calledArgs[lName], null); + } + }); + }); + }); + }); + + it('diag setLogLevel and logger should log', () => { + diag.setLogger(dummyLogger); + diag.setLogLevel(map.level); + diag[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + if (fName === lName && map.ignoreFuncs.indexOf(lName) === -1) { + assert.deepStrictEqual(calledArgs[lName], [ + `${fName} called %s`, + 'param1', + ]); + } else { + assert.strictEqual(calledArgs[lName], null); + } + }); }); - }); - it(`should not throw with an invalid DiagLogger calling ${fName} with ${map.message} level`, () => { - const invalidLogger = { - debug: 1, - warn: 2, - error: 3, - trace: 4, - info: 5, - log: 6, - }; + it('should not throw with an invalid DiagLogger', () => { + const invalidLogger = { + debug: 1, + warn: 2, + error: 3, + trace: 4, + info: 5, + log: 6, + }; - const testLogger = createLogLevelDiagLogger( - map.level, - invalidLogger as any - ); + const testLogger = createLogLevelDiagLogger( + map.level, + invalidLogger as any + ); - testLogger[fName](`${fName} called %s`, 'param1'); - diagLoggerFunctions.forEach(lName => { - assert.strictEqual(calledArgs[lName], null); + testLogger[fName](`${fName} called %s`, 'param1'); + diagLoggerFunctions.forEach(lName => { + assert.strictEqual(calledArgs[lName], null); + }); }); }); }); diff --git a/packages/opentelemetry-api/test/diag/logger.test.ts b/packages/opentelemetry-api/test/diag/logger.test.ts index d1629e964e8..a957445b4b2 100644 --- a/packages/opentelemetry-api/test/diag/logger.test.ts +++ b/packages/opentelemetry-api/test/diag/logger.test.ts @@ -24,14 +24,11 @@ import { describe('DiagLogger functions', () => { const calledArgs: any = { - terminal: null, - critical: null, error: null, warn: null, info: null, debug: null, verbose: null, - startupInfo: null, }; let dummyLogger: DiagLogger; diff --git a/packages/opentelemetry-core/src/common/ConsoleLogger.ts b/packages/opentelemetry-core/src/common/ConsoleLogger.ts deleted file mode 100644 index ec430363af1..00000000000 --- a/packages/opentelemetry-core/src/common/ConsoleLogger.ts +++ /dev/null @@ -1,56 +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 { Logger } from '@opentelemetry/api'; -import { LogLevel } from './types'; -import { getEnv } from '../platform'; - -/** - * @deprecated This class will be removed prior to v1.0, use {@link DiagConsoleLogger} from the api. - * @see {@link DiagLogLevel} {@link diagLogLevelFilter} {@link DiagConsoleLogger} from the api - */ -export class ConsoleLogger implements Logger { - constructor(level: LogLevel = getEnv().OTEL_LOG_LEVEL) { - if (level >= LogLevel.DEBUG) { - this.debug = (...args) => { - console.debug(...args); - }; - } - if (level >= LogLevel.INFO) { - this.info = (...args) => { - console.info(...args); - }; - } - if (level >= LogLevel.WARN) { - this.warn = (...args) => { - console.warn(...args); - }; - } - if (level >= LogLevel.ERROR) { - this.error = (...args) => { - console.error(...args); - }; - } - } - - debug(_message: string, ..._args: unknown[]) {} - - error(_message: string, ..._args: unknown[]) {} - - warn(_message: string, ..._args: unknown[]) {} - - info(_message: string, ..._args: unknown[]) {} -} diff --git a/packages/opentelemetry-core/src/common/logging-error-handler.ts b/packages/opentelemetry-core/src/common/logging-error-handler.ts index b3b34852084..bb3b187d914 100644 --- a/packages/opentelemetry-core/src/common/logging-error-handler.ts +++ b/packages/opentelemetry-core/src/common/logging-error-handler.ts @@ -14,26 +14,16 @@ * limitations under the License. */ -import { - Logger, - Exception, - DiagLogLevel, - DiagConsoleLogger, - createLogLevelDiagLogger, -} from '@opentelemetry/api'; +import { diag, Exception } from '@opentelemetry/api'; import { ErrorHandler } from './types'; /** * Returns a function that logs an error using the provided logger, or a * console logger if one was not provided. - * @param {Logger} logger */ -export function loggingErrorHandler(logger?: Logger): ErrorHandler { - logger = - logger ?? - createLogLevelDiagLogger(DiagLogLevel.ERROR, new DiagConsoleLogger()); +export function loggingErrorHandler(): ErrorHandler { return (ex: Exception) => { - logger!.error(stringifyException(ex)); + diag.error(stringifyException(ex)); }; } diff --git a/packages/opentelemetry-core/src/common/types.ts b/packages/opentelemetry-core/src/common/types.ts index d24f7f1e5c8..6d68be37dc5 100644 --- a/packages/opentelemetry-core/src/common/types.ts +++ b/packages/opentelemetry-core/src/common/types.ts @@ -16,22 +16,6 @@ import { Exception } from '@opentelemetry/api'; -/** @deprecated This enum will be removed prior to v1.0, use the {@link DiagLogLevel} - * @see {@link DiagLogLevel} from the api - */ -export enum LogLevel { - ERROR, - WARN, - INFO, - DEBUG, -} - -/** - * This is equivalent to: - * type LogLevelString = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG'; - */ -export type LogLevelString = keyof typeof LogLevel; - /** * This interface defines a fallback to read a timeOrigin when it is not available on performance.timeOrigin, * this happens for example on Safari Mac diff --git a/packages/opentelemetry-core/src/context/propagation/composite.ts b/packages/opentelemetry-core/src/context/propagation/composite.ts index 27b4101ee49..a5a8216e78b 100644 --- a/packages/opentelemetry-core/src/context/propagation/composite.ts +++ b/packages/opentelemetry-core/src/context/propagation/composite.ts @@ -18,16 +18,14 @@ import { Context, TextMapGetter, TextMapPropagator, - Logger, + diag, TextMapSetter, - NoopLogger, } from '@opentelemetry/api'; import { CompositePropagatorConfig } from './types'; /** Combines multiple propagators into a single propagator. */ export class CompositePropagator implements TextMapPropagator { private readonly _propagators: TextMapPropagator[]; - private readonly _logger: Logger; private readonly _fields: string[]; /** @@ -37,7 +35,7 @@ export class CompositePropagator implements TextMapPropagator { */ constructor(config: CompositePropagatorConfig = {}) { this._propagators = config.propagators ?? []; - this._logger = config.logger ?? new NoopLogger(); + this._fields = Array.from( new Set( this._propagators @@ -62,7 +60,7 @@ export class CompositePropagator implements TextMapPropagator { try { propagator.inject(context, carrier, setter); } catch (err) { - this._logger.warn( + diag.warn( `Failed to inject with ${propagator.constructor.name}. Err: ${err.message}` ); } @@ -83,7 +81,7 @@ export class CompositePropagator implements TextMapPropagator { try { return propagator.extract(ctx, carrier, getter); } catch (err) { - this._logger.warn( + diag.warn( `Failed to inject with ${propagator.constructor.name}. Err: ${err.message}` ); } diff --git a/packages/opentelemetry-core/src/context/propagation/types.ts b/packages/opentelemetry-core/src/context/propagation/types.ts index 490c6ee56fd..e973c7790b2 100644 --- a/packages/opentelemetry-core/src/context/propagation/types.ts +++ b/packages/opentelemetry-core/src/context/propagation/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { TextMapPropagator, Logger } from '@opentelemetry/api'; +import { TextMapPropagator } from '@opentelemetry/api'; /** Configuration object for composite propagator */ export interface CompositePropagatorConfig { @@ -24,7 +24,4 @@ export interface CompositePropagatorConfig { * key as a propagator earlier in the list, the later on will "win". */ propagators?: TextMapPropagator[]; - - /** Instance of logger */ - logger?: Logger; } diff --git a/packages/opentelemetry-core/src/index.ts b/packages/opentelemetry-core/src/index.ts index 0a57beb2281..e0c6c75d204 100644 --- a/packages/opentelemetry-core/src/index.ts +++ b/packages/opentelemetry-core/src/index.ts @@ -15,7 +15,6 @@ */ export * from './common/attributes'; -export * from './common/ConsoleLogger'; export * from './common/global-error-handler'; export * from './common/logging-error-handler'; export * from './common/time'; diff --git a/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts b/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts index d6dcda1e472..1bc19d9cc4b 100644 --- a/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts +++ b/packages/opentelemetry-core/src/platform/BaseAbstractPlugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Tracer, Logger, TracerProvider } from '@opentelemetry/api'; +import { Tracer, TracerProvider } from '@opentelemetry/api'; import { Plugin, PluginConfig, PluginInternalFiles } from '../trace/Plugin'; /** This class represent the base to patch plugin. */ @@ -27,7 +27,6 @@ export abstract class BaseAbstractPlugin implements Plugin { protected _config!: PluginConfig; protected _internalFilesExports!: { [module: string]: unknown }; // output for internalFilesExports protected readonly _internalFilesList?: PluginInternalFiles; // required for internalFilesExports - protected _logger!: Logger; protected _moduleExports!: T; protected _tracer!: Tracer; @@ -43,7 +42,6 @@ export abstract class BaseAbstractPlugin implements Plugin { abstract enable( moduleExports: T, tracerProvider: TracerProvider, - logger: Logger, config?: PluginConfig ): T; diff --git a/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts b/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts index 124495b0a32..b067deb828a 100644 --- a/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts +++ b/packages/opentelemetry-core/src/platform/browser/BasePlugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { Plugin, PluginConfig } from '../../trace/Plugin'; import { BaseAbstractPlugin } from '../BaseAbstractPlugin'; @@ -25,7 +25,6 @@ export abstract class BasePlugin enable( moduleExports: T, tracerProvider: TracerProvider, - logger: Logger, config?: PluginConfig ): T { this._moduleExports = moduleExports; @@ -33,7 +32,6 @@ export abstract class BasePlugin this._tracerName, this._tracerVersion ); - this._logger = logger; if (config) this._config = config; return this.patch(); } diff --git a/packages/opentelemetry-core/src/platform/node/BasePlugin.ts b/packages/opentelemetry-core/src/platform/node/BasePlugin.ts index 28a4c3e322e..b711520d43b 100644 --- a/packages/opentelemetry-core/src/platform/node/BasePlugin.ts +++ b/packages/opentelemetry-core/src/platform/node/BasePlugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider, diag } from '@opentelemetry/api'; import { Plugin, PluginConfig, @@ -32,7 +32,6 @@ export abstract class BasePlugin enable( moduleExports: T, tracerProvider: TracerProvider, - logger: Logger, config?: PluginConfig ): T { this._moduleExports = moduleExports; @@ -40,7 +39,6 @@ export abstract class BasePlugin this._tracerName, this._tracerVersion ); - this._logger = logger; this._internalFilesExports = this._loadInternalFilesExports(); if (config) this._config = config; return this.patch(); @@ -61,7 +59,7 @@ export abstract class BasePlugin if (!this.version || !this.moduleName || !this._basedir) { // log here because internalFilesList was provided, so internal file loading // was expected to be working - this._logger.debug( + diag.debug( 'loadInternalFiles failed because one of the required fields was missing: moduleName=%s, version=%s, basedir=%s', this.moduleName, this.version, @@ -70,12 +68,12 @@ export abstract class BasePlugin return {}; } const extraModules: PluginInternalFiles = {}; - this._logger.debug('loadInternalFiles %o', this._internalFilesList); + diag.debug('loadInternalFiles %o', this._internalFilesList); Object.keys(this._internalFilesList).forEach(versionRange => { this._loadInternalModule(versionRange, extraModules); }); if (Object.keys(extraModules).length === 0) { - this._logger.debug( + diag.debug( 'No internal files could be loaded for %s@%s', this.moduleName, this.version @@ -90,7 +88,7 @@ export abstract class BasePlugin ): void { if (semver.satisfies(this.version!, versionRange)) { if (Object.keys(outExtraModules).length > 0) { - this._logger.warn( + diag.warn( 'Plugin for %s@%s, has overlap version range (%s) for internal files: %o', this.moduleName, this.version, @@ -114,13 +112,13 @@ export abstract class BasePlugin if (!extraModulesList) return; Object.keys(extraModulesList).forEach(moduleName => { try { - this._logger.debug('loading File %s', extraModulesList[moduleName]); + diag.debug('loading File %s', extraModulesList[moduleName]); outExtraModules[moduleName] = require(path.join( basedir, extraModulesList[moduleName] )); } catch (e) { - this._logger.error( + diag.error( 'Could not load internal file %s of module %s. Error: %s', path.join(basedir, extraModulesList[moduleName]), this.moduleName, diff --git a/packages/opentelemetry-core/src/trace/Plugin.ts b/packages/opentelemetry-core/src/trace/Plugin.ts index 6f7efdec2bc..a51543c65e4 100644 --- a/packages/opentelemetry-core/src/trace/Plugin.ts +++ b/packages/opentelemetry-core/src/trace/Plugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; /** Interface Plugin to apply patch. */ export interface Plugin { @@ -36,13 +36,11 @@ export interface Plugin { * @param moduleExports The value of the `module.exports` property that would * normally be exposed by the required module. ex: `http`, `https` etc. * @param TracerProvider a tracer provider. - * @param logger a logger instance. * @param [config] an object to configure the plugin. */ enable( moduleExports: T, TracerProvider: TracerProvider, - logger: Logger, config?: PluginConfig ): T; diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 5b3a49b1745..ad67f440a3b 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { LogLevel } from '../common/types'; +import { DiagLogLevel } from '@opentelemetry/api'; const DEFAULT_LIST_SEPARATOR = ','; @@ -64,7 +64,7 @@ export type ENVIRONMENT = { OTEL_EXPORTER_JAEGER_ENDPOINT?: string; OTEL_EXPORTER_JAEGER_PASSWORD?: string; OTEL_EXPORTER_JAEGER_USER?: string; - OTEL_LOG_LEVEL?: LogLevel; + OTEL_LOG_LEVEL?: DiagLogLevel; OTEL_RESOURCE_ATTRIBUTES?: string; } & ENVIRONMENT_NUMBERS & ENVIRONMENT_LISTS; @@ -87,7 +87,7 @@ export const DEFAULT_ENVIRONMENT: Required = { OTEL_EXPORTER_JAEGER_ENDPOINT: '', OTEL_EXPORTER_JAEGER_PASSWORD: '', OTEL_EXPORTER_JAEGER_USER: '', - OTEL_LOG_LEVEL: LogLevel.INFO, + OTEL_LOG_LEVEL: DiagLogLevel.INFO, OTEL_NO_PATCH_MODULES: [], OTEL_RESOURCE_ATTRIBUTES: '', OTEL_SAMPLING_PROBABILITY: 1, @@ -148,6 +148,17 @@ function parseStringList( } } +// The support string -> DiagLogLevel mappings +const logLevelMap: { [key: string]: DiagLogLevel } = { + ALL: DiagLogLevel.ALL, + VERBOSE: DiagLogLevel.VERBOSE, + DEBUG: DiagLogLevel.DEBUG, + INFO: DiagLogLevel.INFO, + WARN: DiagLogLevel.WARN, + ERROR: DiagLogLevel.ERROR, + NONE: DiagLogLevel.NONE, +}; + /** * Environmentally sets log level if valid log level string is provided * @param key @@ -160,26 +171,11 @@ function setLogLevelFromEnv( values: RAW_ENVIRONMENT ) { const value = values[key]; - switch (typeof value === 'string' ? value.toUpperCase() : value) { - case 'DEBUG': - environment[key] = LogLevel.DEBUG; - break; - - case 'INFO': - environment[key] = LogLevel.INFO; - break; - - case 'WARN': - environment[key] = LogLevel.WARN; - break; - - case 'ERROR': - environment[key] = LogLevel.ERROR; - break; - - default: - // do nothing - break; + if (typeof value === 'string') { + const theLevel = logLevelMap[value.toUpperCase()]; + if (theLevel != undefined) { + environment[key] = theLevel; + } } } diff --git a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts b/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts deleted file mode 100644 index b63cc58b3f0..00000000000 --- a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts +++ /dev/null @@ -1,155 +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 { ConsoleLogger } from '../../src/common/ConsoleLogger'; -import { LogLevel } from '../../src/common/types'; -import { - mockEnvironment, - removeMockEnvironment, -} from '../utils/environment.test'; - -describe('ConsoleLogger', () => { - const origDebug = console.debug; - const origInfo = console.info; - const origWarn = console.warn; - const origError = console.error; - let debugCalledArgs: unknown; - let infoCalledArgs: unknown; - let warnCalledArgs: unknown; - let errorCalledArgs: unknown; - - beforeEach(() => { - // mock - console.debug = (...args: unknown[]) => { - debugCalledArgs = args; - }; - console.info = (...args: unknown[]) => { - infoCalledArgs = args; - }; - console.warn = (...args: unknown[]) => { - warnCalledArgs = args; - }; - console.error = (...args: unknown[]) => { - errorCalledArgs = args; - }; - }); - - afterEach(() => { - // restore - debugCalledArgs = null; - infoCalledArgs = null; - warnCalledArgs = null; - errorCalledArgs = null; - console.debug = origDebug; - console.info = origInfo; - console.warn = origWarn; - console.error = origError; - removeMockEnvironment(); - }); - - describe('constructor', () => { - it('should log with default level', () => { - const consoleLogger = new ConsoleLogger(); - consoleLogger.error('error called %s', 'param1'); - assert.deepStrictEqual(errorCalledArgs, ['error called %s', 'param1']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); - consoleLogger.debug('debug called %s', 'param1'); - assert.strictEqual(debugCalledArgs, undefined); - }); - - it('should log with debug', () => { - const consoleLogger = new ConsoleLogger(LogLevel.DEBUG); - consoleLogger.error('error called'); - assert.deepStrictEqual(errorCalledArgs, ['error called']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); - consoleLogger.debug('debug called %s', 'param1'); - assert.deepStrictEqual(debugCalledArgs, ['debug called %s', 'param1']); - }); - - it('should log with info', () => { - const consoleLogger = new ConsoleLogger(LogLevel.INFO); - consoleLogger.error('error called %s', 'param1'); - assert.deepStrictEqual(errorCalledArgs, ['error called %s', 'param1']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); - consoleLogger.debug('debug called %s', 'param1'); - assert.strictEqual(debugCalledArgs, null); - }); - - it('should log with warn', () => { - const consoleLogger = new ConsoleLogger(LogLevel.WARN); - consoleLogger.error('error called %s', 'param1'); - assert.deepStrictEqual(errorCalledArgs, ['error called %s', 'param1']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.strictEqual(infoCalledArgs, null); - consoleLogger.debug('debug called %s', 'param1'); - assert.strictEqual(debugCalledArgs, null); - }); - - it('should log with error', () => { - const consoleLogger = new ConsoleLogger(LogLevel.ERROR); - consoleLogger.error('error called %s', 'param1'); - assert.deepStrictEqual(errorCalledArgs, ['error called %s', 'param1']); - consoleLogger.warn('warn called %s', 'param1'); - assert.strictEqual(warnCalledArgs, null); - consoleLogger.info('info called %s', 'param1'); - assert.strictEqual(infoCalledArgs, null); - consoleLogger.debug('debug called %s', 'param1'); - assert.strictEqual(debugCalledArgs, null); - }); - - it('should log with environmentally set level ', () => { - mockEnvironment({ - OTEL_LOG_LEVEL: 'WARN', - }); - const consoleLogger = new ConsoleLogger(); - consoleLogger.error('error called'); - assert.deepStrictEqual(errorCalledArgs, ['error called']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.deepStrictEqual(infoCalledArgs, null); - consoleLogger.debug('debug called %s', 'param1'); - assert.deepStrictEqual(debugCalledArgs, null); - }); - - it('should log with default log level if environmentally set level is invalid', () => { - mockEnvironment({ - OTEL_LOG_LEVEL: 'INVALID_VALUE', - }); - const consoleLogger = new ConsoleLogger(); - consoleLogger.error('error called'); - assert.deepStrictEqual(errorCalledArgs, ['error called']); - consoleLogger.warn('warn called %s', 'param1'); - assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); - consoleLogger.info('info called %s', 'param1'); - assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); - consoleLogger.debug('debug called %s', 'param1'); - assert.deepStrictEqual(debugCalledArgs, null); - }); - }); -}); diff --git a/packages/opentelemetry-core/test/common/logging-error-handler.test.ts b/packages/opentelemetry-core/test/common/logging-error-handler.test.ts index ddef522d09d..e89a69d0396 100644 --- a/packages/opentelemetry-core/test/common/logging-error-handler.test.ts +++ b/packages/opentelemetry-core/test/common/logging-error-handler.test.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import * as assert from 'assert'; import * as sinon from 'sinon'; import { ErrorHandler, loggingErrorHandler } from '../../src'; @@ -23,12 +24,10 @@ describe('loggingErrorHandler', () => { const errorStub = sinon.fake(); beforeEach(() => { - handler = loggingErrorHandler({ - debug: sinon.fake(), - info: sinon.fake(), - warn: sinon.fake(), + handler = loggingErrorHandler(); + diag.setLogger({ error: errorStub, - }); + } as any); }); it('logs from string', () => { diff --git a/packages/opentelemetry-core/test/platform/BasePlugin.test.ts b/packages/opentelemetry-core/test/platform/BasePlugin.test.ts index b55fde88500..092ad7393ae 100644 --- a/packages/opentelemetry-core/test/platform/BasePlugin.test.ts +++ b/packages/opentelemetry-core/test/platform/BasePlugin.test.ts @@ -14,21 +14,20 @@ * limitations under the License. */ -import { NoopTracerProvider, NoopLogger } from '@opentelemetry/api'; +import { NoopTracerProvider } from '@opentelemetry/api'; import * as assert from 'assert'; import * as path from 'path'; import { BasePlugin } from '../../src'; import * as types from '../trace/fixtures/test-package/foo/bar/internal'; const provider = new NoopTracerProvider(); -const logger = new NoopLogger(); describe('BasePlugin', () => { describe('internalFilesLoader', () => { it('should load internally exported files', () => { const testPackage = require('../trace/fixtures/test-package'); const plugin = new TestPlugin(); assert.doesNotThrow(() => { - plugin.enable(testPackage, provider, logger); + plugin.enable(testPackage, provider); }); // @TODO: /~https://github.com/open-telemetry/opentelemetry-js/issues/285 diff --git a/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts b/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts index 919acbba1b8..303e5b05aa8 100644 --- a/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts +++ b/packages/opentelemetry-core/test/platform/browser/BasePlugin.test.ts @@ -14,27 +14,21 @@ * limitations under the License. */ -import { - NOOP_TRACER, - NoopTracerProvider, - NoopLogger, -} from '@opentelemetry/api'; +import { NOOP_TRACER, NoopTracerProvider } from '@opentelemetry/api'; import * as assert from 'assert'; import { BasePlugin } from '../../../src'; const provider = new NoopTracerProvider(); -const logger = new NoopLogger(); describe('BasePlugin', () => { describe('enable', () => { it('should enable plugin', () => { const moduleExports = { foo: function () {} }; const plugin = new TestPlugin('foo', '1'); - const patch = plugin.enable(moduleExports, provider, logger); + const patch = plugin.enable(moduleExports, provider); assert.strictEqual(plugin['_tracer'], NOOP_TRACER); assert.strictEqual(plugin['_tracerName'], 'foo'); assert.strictEqual(plugin['_tracerVersion'], '1'); - assert.strictEqual(plugin['_logger'], logger); assert.strictEqual(patch, moduleExports); }); }); diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index 100a0486b6a..7071b197751 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -22,7 +22,7 @@ import { } from '../../src/utils/environment'; import * as assert from 'assert'; import * as sinon from 'sinon'; -import { LogLevel } from '../../src'; +import { DiagLogLevel } from '@opentelemetry/api'; let lastMock: RAW_ENVIRONMENT = {}; @@ -96,7 +96,7 @@ describe('environment', () => { }); const env = getEnv(); assert.deepStrictEqual(env.OTEL_NO_PATCH_MODULES, ['a', 'b', 'c']); - assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.ERROR); + assert.strictEqual(env.OTEL_LOG_LEVEL, DiagLogLevel.ERROR); assert.strictEqual(env.OTEL_SAMPLING_PROBABILITY, 0.5); assert.strictEqual(env.OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, 10); assert.strictEqual(env.OTEL_SPAN_EVENT_COUNT_LIMIT, 20); @@ -144,7 +144,7 @@ describe('environment', () => { OTEL_LOG_LEVEL: 'waRn', }); const env = getEnv(); - assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.WARN); + assert.strictEqual(env.OTEL_LOG_LEVEL, DiagLogLevel.WARN); }); it('should parse environment variables and use defaults', () => { @@ -168,7 +168,7 @@ describe('environment', () => { }); removeMockEnvironment(); const env = getEnv(); - assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.INFO); + assert.strictEqual(env.OTEL_LOG_LEVEL, DiagLogLevel.INFO); assert.strictEqual(env.OTEL_SAMPLING_PROBABILITY, 1); }); }); diff --git a/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts b/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts index 1c47d37ae66..9c7048c1889 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/CollectorExporterNodeBase.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { CollectorExporterBase, collectorTypes, @@ -45,7 +46,7 @@ export abstract class CollectorExporterNodeBase< constructor(config: CollectorExporterConfigNode = {}) { super(config); if (config.headers) { - this.logger.warn('Headers cannot be set when using grpc'); + diag.warn('Headers cannot be set when using grpc'); } this.metadata = config.metadata; } @@ -92,7 +93,7 @@ export abstract class CollectorExporterNodeBase< onError: (error: collectorTypes.CollectorExporterError) => void ): void { if (this._isShutdown) { - this.logger.debug('Shutdown already started. Cannot send objects'); + diag.debug('Shutdown already started. Cannot send objects'); return; } if (!this._send) { diff --git a/packages/opentelemetry-exporter-collector-grpc/src/util.ts b/packages/opentelemetry-exporter-collector-grpc/src/util.ts index b1800665426..7da27e95bc1 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/util.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/util.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import * as protoLoader from '@grpc/proto-loader'; import { collectorTypes } from '@opentelemetry/exporter-collector'; import * as grpc from 'grpc'; @@ -84,10 +85,10 @@ export function send( collector.metadata, (err: collectorTypes.ExportServiceError) => { if (err) { - collector.logger.error('Service request', serviceRequest); + diag.error('Service request', serviceRequest); onError(err); } else { - collector.logger.debug('Objects sent'); + diag.debug('Objects sent'); onSuccess(); } } diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts index 228cf8c818f..5a68d992d13 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorMetricExporter.test.ts @@ -20,7 +20,7 @@ import { ValueObserver, ValueRecorder, } from '@opentelemetry/api-metrics'; -import { ConsoleLogger, LogLevel } from '@opentelemetry/core'; +import { diag } from '@opentelemetry/api'; import { collectorTypes } from '@opentelemetry/exporter-collector'; import * as metrics from '@opentelemetry/metrics'; import * as assert from 'assert'; @@ -120,6 +120,8 @@ const testCollectorMetricExporter = (params: TestParams) => }); beforeEach(async () => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); const credentials = params.useTLS ? grpc.credentials.createSsl( fs.readFileSync('./test/certs/ca.crt'), @@ -164,10 +166,9 @@ const testCollectorMetricExporter = (params: TestParams) => describe('instance', () => { it('should warn about headers', () => { - const logger = new ConsoleLogger(LogLevel.DEBUG); - const spyLoggerWarn = sinon.stub(logger, 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn'); collectorExporter = new CollectorMetricExporter({ - logger, serviceName: 'basic-service', url: address, headers: { diff --git a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts index 365eb91e3ee..d3bed83ef48 100644 --- a/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-grpc/test/CollectorTraceExporter.test.ts @@ -16,7 +16,7 @@ import * as protoLoader from '@grpc/proto-loader'; import { collectorTypes } from '@opentelemetry/exporter-collector'; -import { ConsoleLogger, LogLevel } from '@opentelemetry/core'; +import { diag } from '@opentelemetry/api'; import { BasicTracerProvider, SimpleSpanProcessor, @@ -115,6 +115,8 @@ const testCollectorExporter = (params: TestParams) => }); beforeEach(done => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); const credentials = params.useTLS ? grpc.credentials.createSsl( fs.readFileSync('./test/certs/ca.crt'), @@ -141,10 +143,9 @@ const testCollectorExporter = (params: TestParams) => describe('instance', () => { it('should warn about headers when using grpc', () => { - const logger = new ConsoleLogger(LogLevel.DEBUG); - const spyLoggerWarn = sinon.stub(logger, 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn'); collectorExporter = new CollectorTraceExporter({ - logger, serviceName: 'basic-service', url: address, headers: { diff --git a/packages/opentelemetry-exporter-collector-proto/src/CollectorExporterNodeBase.ts b/packages/opentelemetry-exporter-collector-proto/src/CollectorExporterNodeBase.ts index e0945839349..3a8bc2dfa6f 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/CollectorExporterNodeBase.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/CollectorExporterNodeBase.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { CollectorExporterNodeBase as CollectorExporterBaseMain, collectorTypes, @@ -73,7 +74,7 @@ export abstract class CollectorExporterNodeBase< onError: (error: collectorTypes.CollectorExporterError) => void ): void { if (this._isShutdown) { - this.logger.debug('Shutdown already started. Cannot send objects'); + diag.debug('Shutdown already started. Cannot send objects'); return; } if (!this._send) { diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts index a8ed37a3e87..a8ec25d27a4 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorMetricExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { Counter, ValueObserver, @@ -55,12 +55,13 @@ describe('CollectorMetricExporter - node with proto over http', () => { describe('export', () => { beforeEach(async () => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); collectorExporterConfig = { headers: { foo: 'bar', }, hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -175,7 +176,8 @@ describe('CollectorMetricExporter - node with proto over http', () => { }); it('should log the successful message', done => { - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); collectorExporter.export(metrics, result => { assert.strictEqual(result.code, ExportResultCode.SUCCESS); diff --git a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts index 0f3d99a16e3..85a841025cd 100644 --- a/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector-proto/test/CollectorTraceExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResultCode } from '@opentelemetry/core'; import { CollectorExporterNodeConfigBase, @@ -46,12 +46,13 @@ describe('CollectorTraceExporter - node with proto over http', () => { describe('export', () => { beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); collectorExporterConfig = { headers: { foo: 'bar', }, hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -124,7 +125,8 @@ describe('CollectorTraceExporter - node with proto over http', () => { }); it('should log the successful message', done => { - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); collectorExporter.export(spans, result => { assert.strictEqual(result.code, ExportResultCode.SUCCESS); diff --git a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts index 4530b5fbc3c..c8a4d47637b 100644 --- a/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts +++ b/packages/opentelemetry-exporter-collector/src/CollectorExporterBase.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanAttributes, Logger, NoopLogger } from '@opentelemetry/api'; +import { SpanAttributes, diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode } from '@opentelemetry/core'; import { CollectorExporterError, @@ -32,7 +32,6 @@ export abstract class CollectorExporterBase< > { public readonly serviceName: string; public readonly url: string; - public readonly logger: Logger; public readonly hostname: string | undefined; public readonly attributes?: SpanAttributes; protected _concurrencyLimit: number; @@ -52,8 +51,6 @@ export abstract class CollectorExporterBase< this.attributes = config.attributes; - this.logger = config.logger || new NoopLogger(); - this.shutdown = this.shutdown.bind(this); this._concurrencyLimit = @@ -99,7 +96,7 @@ export abstract class CollectorExporterBase< private _export(items: ExportItem[]): Promise { return new Promise((resolve, reject) => { try { - this.logger.debug('items to be sent', items); + diag.debug('items to be sent', items); this.send(items, resolve, reject); } catch (e) { reject(e); @@ -112,11 +109,11 @@ export abstract class CollectorExporterBase< */ shutdown(): Promise { if (this._isShutdown) { - this.logger.debug('shutdown already started'); + diag.debug('shutdown already started'); return this._shuttingDownPromise; } this._isShutdown = true; - this.logger.debug('shutdown started'); + diag.debug('shutdown started'); this._shuttingDownPromise = new Promise((resolve, reject) => { Promise.resolve() .then(() => { diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporterBrowserBase.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporterBrowserBase.ts index c7b605c94dd..00a43641276 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporterBrowserBase.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorExporterBrowserBase.ts @@ -19,6 +19,7 @@ import { CollectorExporterConfigBase } from '../../types'; import * as collectorTypes from '../../types'; import { parseHeaders } from '../../util'; import { sendWithBeacon, sendWithXhr } from './util'; +import { diag } from '@opentelemetry/api'; /** * Collector Metric Exporter abstract base class @@ -42,7 +43,7 @@ export abstract class CollectorExporterBrowserBase< this._useXHR = !!config.headers || typeof navigator.sendBeacon !== 'function'; if (this._useXHR) { - this._headers = parseHeaders(config.headers, this.logger); + this._headers = parseHeaders(config.headers); } else { this._headers = {}; } @@ -62,7 +63,7 @@ export abstract class CollectorExporterBrowserBase< onError: (error: collectorTypes.CollectorExporterError) => void ) { if (this._isShutdown) { - this.logger.debug('Shutdown already started. Cannot send objects'); + diag.debug('Shutdown already started. Cannot send objects'); return; } const serviceRequest = this.convert(items); @@ -84,16 +85,9 @@ export abstract class CollectorExporterBrowserBase< }; if (this._useXHR) { - sendWithXhr( - body, - this.url, - this._headers, - this.logger, - _onSuccess, - _onError - ); + sendWithXhr(body, this.url, this._headers, _onSuccess, _onError); } else { - sendWithBeacon(body, this.url, this.logger, _onSuccess, _onError); + sendWithBeacon(body, this.url, _onSuccess, _onError); } }); this._sendingPromises.push(promise); diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts index 5b79b77061d..9e267fb6cb4 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/util.ts @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import * as collectorTypes from '../../types'; -import { Logger } from '@opentelemetry/api'; /** * Send metrics/spans using browser navigator.sendBeacon @@ -25,12 +25,11 @@ import { Logger } from '@opentelemetry/api'; export function sendWithBeacon( body: string, url: string, - logger: Logger, onSuccess: () => void, onError: (error: collectorTypes.CollectorExporterError) => void ) { if (navigator.sendBeacon(url, body)) { - logger.debug('sendBeacon - can send', body); + diag.debug('sendBeacon - can send', body); onSuccess(); } else { const error = new collectorTypes.CollectorExporterError( @@ -51,7 +50,6 @@ export function sendWithXhr( body: string, url: string, headers: { [key: string]: string }, - logger: Logger, onSuccess: () => void, onError: (error: collectorTypes.CollectorExporterError) => void ) { @@ -68,7 +66,7 @@ export function sendWithXhr( xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { if (xhr.status >= 200 && xhr.status <= 299) { - logger.debug('xhr success', body); + diag.debug('xhr success', body); onSuccess(); } else { const error = new collectorTypes.CollectorExporterError( diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporterNodeBase.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporterNodeBase.ts index cea0e43bb5c..a57e362d0d7 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporterNodeBase.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorExporterNodeBase.ts @@ -22,6 +22,7 @@ import { CollectorExporterNodeConfigBase } from './types'; import * as collectorTypes from '../../types'; import { parseHeaders } from '../../util'; import { createHttpAgent, sendWithHttp } from './util'; +import { diag } from '@opentelemetry/api'; /** * Collector Metric Exporter abstract base class @@ -40,11 +41,10 @@ export abstract class CollectorExporterNodeBase< constructor(config: CollectorExporterNodeConfigBase = {}) { super(config); if ((config as any).metadata) { - this.logger.warn('Metadata cannot be set when using http'); + diag.warn('Metadata cannot be set when using http'); } - this.headers = - parseHeaders(config.headers, this.logger) || this.DEFAULT_HEADERS; - this.agent = createHttpAgent(this.logger, config); + this.headers = parseHeaders(config.headers) || this.DEFAULT_HEADERS; + this.agent = createHttpAgent(config); } onInit(_config: CollectorExporterNodeConfigBase): void { @@ -57,7 +57,7 @@ export abstract class CollectorExporterNodeBase< onError: (error: collectorTypes.CollectorExporterError) => void ): void { if (this._isShutdown) { - this.logger.debug('Shutdown already started. Cannot send objects'); + diag.debug('Shutdown already started. Cannot send objects'); return; } const serviceRequest = this.convert(objects); diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts index 96df8bcccaa..bb0c50c5f8d 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts @@ -19,7 +19,7 @@ import * as https from 'https'; import * as collectorTypes from '../../types'; import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { CollectorExporterNodeConfigBase } from '.'; -import { Logger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; /** * Sends data using http @@ -58,7 +58,7 @@ export function sendWithHttp( res.on('data', chunk => (data += chunk)); res.on('end', () => { if (res.statusCode && res.statusCode < 299) { - collector.logger.debug(`statusCode: ${res.statusCode}`, data); + diag.debug(`statusCode: ${res.statusCode}`, data); onSuccess(); } else { const error = new collectorTypes.CollectorExporterError( @@ -79,11 +79,10 @@ export function sendWithHttp( } export function createHttpAgent( - logger: Logger, config: CollectorExporterNodeConfigBase ): http.Agent | https.Agent | undefined { if (config.httpAgentOptions && config.keepAlive === false) { - logger.warn('httpAgentOptions is used only when keepAlive is true'); + diag.warn('httpAgentOptions is used only when keepAlive is true'); return undefined; } @@ -94,7 +93,7 @@ export function createHttpAgent( const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent; return new Agent({ keepAlive: true, ...config.httpAgentOptions }); } catch (err) { - logger.error( + diag.error( `collector exporter failed to create http agent. err: ${err.message}` ); return undefined; diff --git a/packages/opentelemetry-exporter-collector/src/types.ts b/packages/opentelemetry-exporter-collector/src/types.ts index ac88d0fbe1d..f0b02825f3f 100644 --- a/packages/opentelemetry-exporter-collector/src/types.ts +++ b/packages/opentelemetry-exporter-collector/src/types.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -import { - SpanAttributes, - Logger, - SpanKind, - SpanStatusCode, -} from '@opentelemetry/api'; +import { SpanAttributes, SpanKind, SpanStatusCode } from '@opentelemetry/api'; /* eslint-disable @typescript-eslint/no-namespace */ /* eslint-disable @typescript-eslint/no-unused-vars */ @@ -348,7 +343,6 @@ export interface ExportServiceError { export interface CollectorExporterConfigBase { headers?: Partial>; hostname?: string; - logger?: Logger; serviceName?: string; attributes?: SpanAttributes; url?: string; diff --git a/packages/opentelemetry-exporter-collector/src/util.ts b/packages/opentelemetry-exporter-collector/src/util.ts index 739698f0e0c..c8f1c0bf0e0 100644 --- a/packages/opentelemetry-exporter-collector/src/util.ts +++ b/packages/opentelemetry-exporter-collector/src/util.ts @@ -14,23 +14,21 @@ * limitations under the License. */ -import { Logger, NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; /** * Parses headers from config leaving only those that have defined values * @param partialHeaders - * @param logger */ export function parseHeaders( - partialHeaders: Partial> = {}, - logger: Logger = new NoopLogger() + partialHeaders: Partial> = {} ): Record { const headers: Record = {}; Object.entries(partialHeaders).forEach(([key, value]) => { if (typeof value !== 'undefined') { headers[key] = String(value); } else { - logger.warn(`Header "${key}" has wrong value and will be ignored`); + diag.warn(`Header "${key}" has wrong value and will be ignored`); } }); return headers; diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts index 03e89e93c9b..160aa7e3a64 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorMetricExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag, DiagLogLevel } from '@opentelemetry/api'; import { Counter, ValueObserver, @@ -88,8 +88,10 @@ describe('CollectorMetricExporter - web', () => { describe('export', () => { describe('when "sendBeacon" is available', () => { beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + diag.setLogLevel(DiagLogLevel.VERBOSE); collectorExporter = new CollectorMetricExporter({ - logger: new NoopLogger(), url: 'http://foo.bar.com', serviceName: 'bar', }); @@ -167,8 +169,9 @@ describe('CollectorMetricExporter - web', () => { }); it('should log the successful message', done => { - const spyLoggerDebug = sinon.stub(collectorExporter.logger, 'debug'); - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerDebug = sinon.stub(diag.getLogger(), 'debug'); + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); spyBeacon.restore(); spyBeacon = sinon.stub(window.navigator, 'sendBeacon').returns(true); @@ -198,9 +201,11 @@ describe('CollectorMetricExporter - web', () => { describe('when "sendBeacon" is NOT available', () => { let server: any; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + diag.setLogLevel(DiagLogLevel.VERBOSE); (window.navigator as any).sendBeacon = false; collectorExporter = new CollectorMetricExporter({ - logger: new NoopLogger(), url: 'http://foo.bar.com', serviceName: 'bar', }); @@ -279,8 +284,9 @@ describe('CollectorMetricExporter - web', () => { }); it('should log the successful message', done => { - const spyLoggerDebug = sinon.stub(collectorExporter.logger, 'debug'); - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerDebug = sinon.stub(diag.getLogger(), 'debug'); + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); collectorExporter.export(metrics, () => {}); @@ -333,8 +339,10 @@ describe('CollectorMetricExporter - web', () => { let collectorExporterConfig: CollectorExporterConfigBase; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + diag.setLogLevel(DiagLogLevel.VERBOSE); collectorExporterConfig = { - logger: new NoopLogger(), headers: customHeaders, }; server = sinon.fakeServer.create(); diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts index 968b3ae8f51..ec61e8b98c7 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag, DiagLogLevel } from '@opentelemetry/api'; import { ExportResultCode } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; import * as assert from 'assert'; @@ -57,9 +57,11 @@ describe('CollectorTraceExporter - web', () => { describe('export', () => { beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + diag.setLogLevel(DiagLogLevel.VERBOSE); collectorExporterConfig = { hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -109,14 +111,9 @@ describe('CollectorTraceExporter - web', () => { }); it('should log the successful message', done => { - const spyLoggerDebug = sinon.stub( - collectorTraceExporter.logger, - 'debug' - ); - const spyLoggerError = sinon.stub( - collectorTraceExporter.logger, - 'error' - ); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerDebug = sinon.stub(diag.getLogger(), 'debug'); + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); spyBeacon.restore(); spyBeacon = sinon.stub(window.navigator, 'sendBeacon').returns(true); @@ -191,14 +188,9 @@ describe('CollectorTraceExporter - web', () => { }); it('should log the successful message', done => { - const spyLoggerDebug = sinon.stub( - collectorTraceExporter.logger, - 'debug' - ); - const spyLoggerError = sinon.stub( - collectorTraceExporter.logger, - 'error' - ); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerDebug = sinon.stub(diag.getLogger(), 'debug'); + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); collectorTraceExporter.export(spans, () => {}); @@ -250,8 +242,10 @@ describe('CollectorTraceExporter - web', () => { }; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + diag.setLogLevel(DiagLogLevel.VERBOSE); collectorExporterConfig = { - logger: new NoopLogger(), headers: customHeaders, }; server = sinon.fakeServer.create(); diff --git a/packages/opentelemetry-exporter-collector/test/common/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/common/CollectorMetricExporter.test.ts index b9a6ae2a54d..966483bfc1d 100644 --- a/packages/opentelemetry-exporter-collector/test/common/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/CollectorMetricExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { Counter, ValueObserver } from '@opentelemetry/api-metrics'; import { ExportResultCode } from '@opentelemetry/core'; import { @@ -60,10 +60,11 @@ describe('CollectorMetricExporter - common', () => { let onInitSpy: any; beforeEach(async () => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); onInitSpy = sinon.stub(CollectorMetricExporter.prototype, 'onInit'); collectorExporterConfig = { hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -108,10 +109,6 @@ describe('CollectorMetricExporter - common', () => { it('should set url', () => { assert.strictEqual(collectorExporter.url, 'http://foo.bar.com'); }); - - it('should set logger', () => { - assert.ok(collectorExporter.logger === collectorExporterConfig.logger); - }); }); describe('when config is missing certain params', () => { @@ -125,10 +122,6 @@ describe('CollectorMetricExporter - common', () => { 'collector-metric-exporter' ); }); - - it('should set default logger', () => { - assert.ok(collectorExporter.logger instanceof NoopLogger); - }); }); }); @@ -207,13 +200,14 @@ describe('CollectorMetricExporter - common', () => { describe('shutdown', () => { let onShutdownSpy: any; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); onShutdownSpy = sinon.stub( CollectorMetricExporter.prototype, 'onShutdown' ); collectorExporterConfig = { hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', diff --git a/packages/opentelemetry-exporter-collector/test/common/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/common/CollectorTraceExporter.test.ts index 7dc89886ac8..058a83cd76f 100644 --- a/packages/opentelemetry-exporter-collector/test/common/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/CollectorTraceExporter.test.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResultCode } from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; import * as assert from 'assert'; @@ -65,10 +65,11 @@ describe('CollectorTraceExporter - common', () => { let onInitSpy: any; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); onInitSpy = sinon.stub(CollectorTraceExporter.prototype, 'onInit'); collectorExporterConfig = { hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -100,10 +101,6 @@ describe('CollectorTraceExporter - common', () => { it('should set url', () => { assert.strictEqual(collectorExporter.url, 'http://foo.bar.com'); }); - - it('should set logger', () => { - assert.ok(collectorExporter.logger === collectorExporterConfig.logger); - }); }); describe('when config is missing certain params', () => { @@ -114,10 +111,6 @@ describe('CollectorTraceExporter - common', () => { it('should set default serviceName', () => { assert.strictEqual(collectorExporter.serviceName, 'collector-exporter'); }); - - it('should set default logger', () => { - assert.ok(collectorExporter.logger instanceof NoopLogger); - }); }); }); @@ -227,13 +220,14 @@ describe('CollectorTraceExporter - common', () => { describe('shutdown', () => { let onShutdownSpy: any; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); onShutdownSpy = sinon.stub( CollectorTraceExporter.prototype, 'onShutdown' ); collectorExporterConfig = { hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', diff --git a/packages/opentelemetry-exporter-collector/test/common/utils.test.ts b/packages/opentelemetry-exporter-collector/test/common/utils.test.ts index 3f31225de18..0afeede3edf 100644 --- a/packages/opentelemetry-exporter-collector/test/common/utils.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/utils.test.ts @@ -16,20 +16,25 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { parseHeaders } from '../../src/util'; describe('utils', () => { describe('parseHeaders', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); + it('should ignore undefined headers', () => { - const logger = new NoopLogger(); - const spyWarn = sinon.stub(logger, 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyWarn = sinon.stub(diag.getLogger(), 'warn'); const headers: Partial> = { foo1: undefined, foo2: 'bar', foo3: 1, }; - const result = parseHeaders(headers, logger); + const result = parseHeaders(headers); assert.deepStrictEqual(result, { foo2: 'bar', foo3: '1', diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts index 3c7233f71b8..b0ac06beceb 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { Counter, ValueObserver, @@ -64,10 +64,9 @@ describe('CollectorMetricExporter - node with json over http', () => { describe('instance', () => { it('should warn about metadata when using json', () => { const metadata = 'foo'; - const logger = new core.ConsoleLogger(core.LogLevel.DEBUG); - const spyLoggerWarn = sinon.stub(logger, 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn'); collectorExporter = new CollectorMetricExporter({ - logger, serviceName: 'basic-service', url: address, metadata, @@ -79,6 +78,8 @@ describe('CollectorMetricExporter - node with json over http', () => { describe('export', () => { beforeEach(async () => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); spyRequest = sinon.stub(http, 'request').returns(fakeRequest as any); spyWrite = sinon.stub(fakeRequest, 'write'); collectorExporterConfig = { @@ -86,7 +87,6 @@ describe('CollectorMetricExporter - node with json over http', () => { foo: 'bar', }, hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -202,7 +202,8 @@ describe('CollectorMetricExporter - node with json over http', () => { }); it('should log the successful message', done => { - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); const responseSpy = sinon.spy(); collectorExporter.export(metrics, responseSpy); @@ -226,12 +227,8 @@ describe('CollectorMetricExporter - node with json over http', () => { it('should log the error message', done => { const spyLoggerError = sinon.spy(); - const handler = core.loggingErrorHandler({ - debug: sinon.fake(), - info: sinon.fake(), - warn: sinon.fake(), - error: spyLoggerError, - }); + diag.error = spyLoggerError; + const handler = core.loggingErrorHandler(); core.setGlobalErrorHandler(handler); const responseSpy = sinon.spy(); diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts index 2a16861a5bc..6a547ff0b32 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import * as core from '@opentelemetry/core'; import { ReadableSpan } from '@opentelemetry/tracing'; import * as http from 'http'; @@ -48,12 +48,15 @@ describe('CollectorTraceExporter - node with json over http', () => { let spyWrite: sinon.SinonSpy; let spans: ReadableSpan[]; describe('instance', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); it('should warn about metadata when using json', () => { const metadata = 'foo'; - const logger = new core.ConsoleLogger(core.LogLevel.DEBUG); - const spyLoggerWarn = sinon.stub(logger, 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerWarn = sinon.stub(diag.getLogger(), 'warn'); collectorExporter = new CollectorTraceExporter({ - logger, serviceName: 'basic-service', metadata, url: address, @@ -65,6 +68,8 @@ describe('CollectorTraceExporter - node with json over http', () => { describe('export', () => { beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); spyRequest = sinon.stub(http, 'request').returns(fakeRequest as any); spyWrite = sinon.stub(fakeRequest, 'write'); collectorExporterConfig = { @@ -72,7 +77,6 @@ describe('CollectorTraceExporter - node with json over http', () => { foo: 'bar', }, hostname: 'foo', - logger: new NoopLogger(), serviceName: 'bar', attributes: {}, url: 'http://foo.bar.com', @@ -161,7 +165,8 @@ describe('CollectorTraceExporter - node with json over http', () => { }); it('should log the successful message', done => { - const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spyLoggerError = sinon.stub(diag.getLogger(), 'error'); const responseSpy = sinon.spy(); collectorExporter.export(spans, responseSpy); diff --git a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts index bcdf83aa032..7de46984e98 100644 --- a/packages/opentelemetry-exporter-jaeger/src/jaeger.ts +++ b/packages/opentelemetry-exporter-jaeger/src/jaeger.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode, getEnv } from '@opentelemetry/core'; import { ReadableSpan, SpanExporter } from '@opentelemetry/tracing'; import { Socket } from 'dgram'; @@ -25,7 +25,6 @@ import * as jaegerTypes from './types'; * Format and sends span information to Jaeger Exporter. */ export class JaegerExporter implements SpanExporter { - private readonly _logger: api.Logger; private readonly _process: jaegerTypes.ThriftProcess; private readonly _sender: typeof jaegerTypes.UDPSender; private readonly _onShutdownFlushTimeout: number; @@ -35,7 +34,6 @@ export class JaegerExporter implements SpanExporter { constructor(config: jaegerTypes.ExporterConfig) { const localConfig = Object.assign({}, config); - this._logger = localConfig.logger || new api.NoopLogger(); const tags: jaegerTypes.Tag[] = localConfig.tags || []; this._onShutdownFlushTimeout = typeof localConfig.flushTimeout === 'number' @@ -84,7 +82,7 @@ export class JaegerExporter implements SpanExporter { if (spans.length === 0) { return resultCallback({ code: ExportResultCode.SUCCESS }); } - this._logger.debug('Jaeger exporter export'); + diag.debug('Jaeger exporter export'); this._sendSpans(spans, resultCallback).catch(error => { return resultCallback({ code: ExportResultCode.FAILED, error }); }); @@ -141,7 +139,7 @@ export class JaegerExporter implements SpanExporter { if (done) return done({ code: ExportResultCode.FAILED, error }); } } - this._logger.debug('successful append for : %s', thriftSpan.length); + diag.debug('successful append for : %s', thriftSpan.length); // Flush all spans on each export. No-op if span buffer is empty await this._flush(); @@ -166,7 +164,7 @@ export class JaegerExporter implements SpanExporter { if (err) { return reject(new Error(err)); } - this._logger.debug('successful flush for %s spans', _count); + diag.debug('successful flush for %s spans', _count); resolve(); }); }); diff --git a/packages/opentelemetry-exporter-jaeger/src/types.ts b/packages/opentelemetry-exporter-jaeger/src/types.ts index d721b960281..67a9dc43631 100644 --- a/packages/opentelemetry-exporter-jaeger/src/types.ts +++ b/packages/opentelemetry-exporter-jaeger/src/types.ts @@ -14,13 +14,10 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; - /** * Options for Jaeger configuration */ export interface ExporterConfig { - logger?: api.Logger; serviceName: string; tags?: Tag[]; host?: string; // default: 'localhost' diff --git a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts index 72122b71f5c..a58a41b628c 100644 --- a/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts +++ b/packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts @@ -44,7 +44,6 @@ describe('JaegerExporter', () => { serviceName: 'opentelemetry', host: 'remotehost', port: 8080, - logger: new api.NoopLogger(), tags: [{ key: 'opentelemetry-exporter-jaeger', value: '0.1.0' }], }); assert.ok(typeof exporter.export === 'function'); diff --git a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts index bc5fec63cb1..2fcf9604517 100644 --- a/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts +++ b/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResult, globalErrorHandler, @@ -36,7 +36,6 @@ export class PrometheusExporter implements MetricExporter { appendTimestamp: true, }; - private readonly _logger: api.Logger; private readonly _host?: string; private readonly _port: number; private readonly _endpoint: string; @@ -56,7 +55,6 @@ export class PrometheusExporter implements MetricExporter { * @param callback Callback to be called after a server was started */ constructor(config: ExporterConfig = {}, callback?: () => void) { - this._logger = config.logger || new api.NoopLogger(); this._host = config.host || process.env.OTEL_EXPORTER_PROMETHEUS_HOST || @@ -83,7 +81,7 @@ export class PrometheusExporter implements MetricExporter { if (config.preventServerStart !== true) { this.startServer() .then(callback) - .catch(err => this._logger.error(err)); + .catch(err => diag.error(err)); } else if (callback) { callback(); } @@ -110,7 +108,7 @@ export class PrometheusExporter implements MetricExporter { return; } - this._logger.debug('Prometheus exporter export'); + diag.debug('Prometheus exporter export'); for (const record of records) { this._batcher.process(record); @@ -131,7 +129,7 @@ export class PrometheusExporter implements MetricExporter { */ stopServer(): Promise { if (!this._server) { - this._logger.debug( + diag.debug( 'Prometheus stopServer() was called but server was never started.' ); return Promise.resolve(); @@ -139,7 +137,7 @@ export class PrometheusExporter implements MetricExporter { return new Promise(resolve => { this._server.close(err => { if (!err) { - this._logger.debug('Prometheus exporter was stopped'); + diag.debug('Prometheus exporter was stopped'); } else { if ( ((err as unknown) as { code: string }).code !== @@ -165,7 +163,7 @@ export class PrometheusExporter implements MetricExporter { host: this._host, }, () => { - this._logger.debug( + diag.debug( `Prometheus exporter server started: ${this._host}:${this._port}/${this._endpoint}` ); resolve(); diff --git a/packages/opentelemetry-exporter-prometheus/src/export/types.ts b/packages/opentelemetry-exporter-prometheus/src/export/types.ts index ad0e6e03ca9..f43c4568138 100644 --- a/packages/opentelemetry-exporter-prometheus/src/export/types.ts +++ b/packages/opentelemetry-exporter-prometheus/src/export/types.ts @@ -14,8 +14,6 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; - /** * Configuration interface for prometheus exporter */ @@ -58,7 +56,4 @@ export interface ExporterConfig { * @default false */ preventServerStart?: boolean; - - /** Standard logging interface */ - logger?: api.Logger; } diff --git a/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts b/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts index a10bfa919c9..940f7439b99 100644 --- a/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts +++ b/packages/opentelemetry-exporter-zipkin/src/platform/browser/util.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode, @@ -25,11 +25,7 @@ import * as zipkinTypes from '../../types'; /** * Prepares send function that will send spans to the remote Zipkin service. */ -export function prepareSend( - logger: api.Logger, - urlStr: string, - headers?: Record -) { +export function prepareSend(urlStr: string, headers?: Record) { let xhrHeaders: Record; const useBeacon = navigator.sendBeacon && !headers; if (headers) { @@ -48,14 +44,14 @@ export function prepareSend( done: (result: ExportResult) => void ) { if (zipkinSpans.length === 0) { - logger.debug('Zipkin send with empty spans'); + diag.debug('Zipkin send with empty spans'); return done({ code: ExportResultCode.SUCCESS }); } const payload = JSON.stringify(zipkinSpans); if (useBeacon) { - sendWithBeacon(payload, done, urlStr, logger); + sendWithBeacon(payload, done, urlStr); } else { - sendWithXhr(payload, done, urlStr, logger, xhrHeaders); + sendWithXhr(payload, done, urlStr, xhrHeaders); } }; } @@ -65,16 +61,14 @@ export function prepareSend( * @param data * @param done * @param urlStr - * @param logger */ function sendWithBeacon( data: string, done: (result: ExportResult) => void, - urlStr: string, - logger: api.Logger + urlStr: string ) { if (navigator.sendBeacon(urlStr, data)) { - logger.debug('sendBeacon - can send', data); + diag.debug('sendBeacon - can send', data); done({ code: ExportResultCode.SUCCESS }); } else { done({ @@ -89,14 +83,12 @@ function sendWithBeacon( * @param data * @param done * @param urlStr - * @param logger * @param xhrHeaders */ function sendWithXhr( data: string, done: (result: ExportResult) => void, urlStr: string, - logger: api.Logger, xhrHeaders: Record = {} ) { const xhr = new window.XMLHttpRequest(); @@ -108,11 +100,7 @@ function sendWithXhr( xhr.onreadystatechange = () => { if (xhr.readyState === XMLHttpRequest.DONE) { const statusCode = xhr.status || 0; - logger.debug( - 'Zipkin response status code: %d, body: %s', - statusCode, - data - ); + diag.debug('Zipkin response status code: %d, body: %s', statusCode, data); if (xhr.status >= 200 && xhr.status < 400) { return done({ code: ExportResultCode.SUCCESS }); @@ -133,6 +121,6 @@ function sendWithXhr( }; // Issue request to remote service - logger.debug('Zipkin request payload: %s', data); + diag.debug('Zipkin request payload: %s', data); xhr.send(data); } diff --git a/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts b/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts index 7cafd85929f..f59301669fe 100644 --- a/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts +++ b/packages/opentelemetry-exporter-zipkin/src/platform/node/util.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode } from '@opentelemetry/core'; import * as http from 'http'; import * as https from 'https'; @@ -24,11 +24,7 @@ import * as zipkinTypes from '../../types'; /** * Prepares send function that will send spans to the remote Zipkin service. */ -export function prepareSend( - logger: api.Logger, - urlStr: string, - headers?: Record -) { +export function prepareSend(urlStr: string, headers?: Record) { const urlOpts = url.parse(urlStr); const reqOpts: http.RequestOptions = Object.assign( @@ -50,7 +46,7 @@ export function prepareSend( done: (result: ExportResult) => void ) { if (zipkinSpans.length === 0) { - logger.debug('Zipkin send with empty spans'); + diag.debug('Zipkin send with empty spans'); return done({ code: ExportResultCode.SUCCESS }); } @@ -62,7 +58,7 @@ export function prepareSend( }); res.on('end', () => { const statusCode = res.statusCode || 0; - logger.debug( + diag.debug( 'Zipkin response status code: %d, body: %s', statusCode, rawData @@ -92,7 +88,7 @@ export function prepareSend( // Issue request to remote service const payload = JSON.stringify(zipkinSpans); - logger.debug('Zipkin request payload: %s', payload); + diag.debug('Zipkin request payload: %s', payload); req.write(payload, 'utf8'); req.end(); }; diff --git a/packages/opentelemetry-exporter-zipkin/src/types.ts b/packages/opentelemetry-exporter-zipkin/src/types.ts index 7eb7eaeaf29..3e06fd3e88a 100644 --- a/packages/opentelemetry-exporter-zipkin/src/types.ts +++ b/packages/opentelemetry-exporter-zipkin/src/types.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; import { ExportResult } from '@opentelemetry/core'; /** @@ -22,7 +21,6 @@ import { ExportResult } from '@opentelemetry/core'; */ export interface ExporterConfig { headers?: { [key: string]: string }; - logger?: api.Logger; serviceName?: string; url?: string; // Optional mapping overrides for OpenTelemetry status code and description. diff --git a/packages/opentelemetry-exporter-zipkin/src/zipkin.ts b/packages/opentelemetry-exporter-zipkin/src/zipkin.ts index 469c0ad79ed..0f6e84ebc15 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 api from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { ExportResult, ExportResultCode } from '@opentelemetry/core'; import { SpanExporter, ReadableSpan } from '@opentelemetry/tracing'; import { prepareSend } from './platform/index'; @@ -32,7 +32,6 @@ import { SERVICE_RESOURCE } from '@opentelemetry/resources'; export class ZipkinExporter implements SpanExporter { static readonly DEFAULT_URL = 'http://localhost:9411/api/v2/spans'; private readonly DEFAULT_SERVICE_NAME = 'OpenTelemetry Service'; - private readonly _logger: api.Logger; private readonly _statusCodeTagName: string; private readonly _statusDescriptionTagName: string; private _send: zipkinTypes.SendFunction; @@ -42,8 +41,7 @@ export class ZipkinExporter implements SpanExporter { constructor(config: zipkinTypes.ExporterConfig = {}) { const urlStr = config.url || ZipkinExporter.DEFAULT_URL; - this._logger = config.logger || new api.NoopLogger(); - this._send = prepareSend(this._logger, urlStr, config.headers); + this._send = prepareSend(urlStr, config.headers); this._serviceName = config.serviceName; this._statusCodeTagName = config.statusCodeTagName || statusCodeTagName; this._statusDescriptionTagName = @@ -64,7 +62,7 @@ export class ZipkinExporter implements SpanExporter { this.DEFAULT_SERVICE_NAME ); } - this._logger.debug('Zipkin exporter export'); + diag.debug('Zipkin exporter export'); if (this._isShutdown) { setTimeout(() => resultCallback({ @@ -89,7 +87,7 @@ export class ZipkinExporter implements SpanExporter { * Shutdown exporter. Noop operation in this exporter. */ shutdown(): Promise { - this._logger.debug('Zipkin exporter shutdown'); + diag.debug('Zipkin exporter shutdown'); this._isShutdown = true; return new Promise((resolve, reject) => { Promise.all(this._sendingPromises).then(() => { diff --git a/packages/opentelemetry-exporter-zipkin/test/browser/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/browser/zipkin.test.ts index 8deac84c17d..3e53b4e4623 100644 --- a/packages/opentelemetry-exporter-zipkin/test/browser/zipkin.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/browser/zipkin.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { setGlobalErrorHandler, loggingErrorHandler, @@ -109,8 +109,9 @@ describe('Zipkin Exporter - web', () => { }; beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); zipkinConfig = { - logger: new NoopLogger(), headers: customHeaders, }; server = sinon.fakeServer.create(); diff --git a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts index a7e5f02ef88..dcd3b6c41e8 100644 --- a/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/common/transform.test.ts @@ -31,10 +31,7 @@ import { _toZipkinTags, } from '../../src/transform'; import * as zipkinTypes from '../../src/types'; -const logger = new api.NoopLogger(); -const tracer = new BasicTracerProvider({ - logger, -}).getTracer('default'); +const tracer = new BasicTracerProvider().getTracer('default'); const language = tracer.resource.attributes[TELEMETRY_SDK_RESOURCE.LANGUAGE]; diff --git a/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts b/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts index f62de325087..9ddeade89e9 100644 --- a/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts +++ b/packages/opentelemetry-exporter-zipkin/test/node/zipkin.test.ts @@ -76,7 +76,6 @@ describe('Zipkin Exporter - node', () => { it('should construct an exporter with logger', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); assert.ok(typeof exporter.export === 'function'); assert.ok(typeof exporter.shutdown === 'function'); @@ -111,7 +110,6 @@ describe('Zipkin Exporter - node', () => { it('should skip send with empty array', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([], (result: ExportResult) => { @@ -187,7 +185,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([span1, span2], (result: ExportResult) => { @@ -243,7 +240,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), url: 'https://localhost:9411/api/v2/spans', }); @@ -260,7 +256,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([getReadableSpan()], (result: ExportResult) => { @@ -276,7 +271,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([getReadableSpan()], (result: ExportResult) => { @@ -292,7 +286,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([getReadableSpan()], (result: ExportResult) => { @@ -304,7 +297,6 @@ describe('Zipkin Exporter - node', () => { it('should return failed result after shutdown', done => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.shutdown(); @@ -472,7 +464,6 @@ describe('Zipkin Exporter - node', () => { const exporter = new ZipkinExporter({ serviceName: 'my-service', - logger: new api.NoopLogger(), }); exporter.export([getReadableSpan()], (result: ExportResult) => { diff --git a/packages/opentelemetry-grpc-utils/test/grpcUtils.test.ts b/packages/opentelemetry-grpc-utils/test/grpcUtils.test.ts index f53055e620e..746511aff76 100644 --- a/packages/opentelemetry-grpc-utils/test/grpcUtils.test.ts +++ b/packages/opentelemetry-grpc-utils/test/grpcUtils.test.ts @@ -19,7 +19,6 @@ import { NoopTracerProvider, SpanKind, propagation, - NoopLogger, getSpan, setSpan, } from '@opentelemetry/api'; @@ -416,7 +415,7 @@ export const runTests = ( }); it('should patch client constructor makeClientConstructor() and makeGenericClientConstructor()', () => { - plugin.enable(grpc, new NoopTracerProvider(), new NoopLogger()); + plugin.enable(grpc, new NoopTracerProvider()); (plugin['_moduleExports'] as any).makeGenericClientConstructor({}); assert.ok( plugin['_moduleExports'].makeGenericClientConstructor.__wrapped @@ -666,8 +665,7 @@ export const runTests = ( }; describe('enable()', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -677,7 +675,7 @@ export const runTests = ( const config = { // TODO: add plugin options here once supported }; - const patchedGrpc = plugin.enable(grpc, provider, logger, config); + const patchedGrpc = plugin.enable(grpc, provider, config); const packageDefinition = await protoLoader.load(PROTO_PATH, options); const proto = patchedGrpc.loadPackageDefinition(packageDefinition) @@ -714,15 +712,14 @@ export const runTests = ( }); describe('disable()', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); }); before(async () => { - plugin.enable(grpc, provider, logger); + plugin.enable(grpc, provider); plugin.disable(); const packageDefinition = await protoLoader.load(PROTO_PATH, options); @@ -747,8 +744,7 @@ export const runTests = ( }); describe('Test filtering requests using metadata', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -758,7 +754,7 @@ export const runTests = ( const config = { // TODO: add plugin options here once supported }; - const patchedGrpc = plugin.enable(grpc, provider, logger, config); + const patchedGrpc = plugin.enable(grpc, provider, config); const packageDefinition = await protoLoader.load(PROTO_PATH, options); const proto = patchedGrpc.loadPackageDefinition(packageDefinition) @@ -778,8 +774,7 @@ export const runTests = ( }); describe('Test filtering requests using options', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); const checkSpans: { [key: string]: boolean } = { unaryMethod: false, UnaryMethod: false, @@ -804,7 +799,6 @@ export const runTests = ( const patchedGrpc = plugin.enable( grpc, provider, - logger, config as PluginConfig ); diff --git a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts index b2936e01073..033b6b92eeb 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/fetch.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/fetch.ts @@ -172,7 +172,7 @@ export class FetchInstrumentation extends InstrumentationBase< options: Partial = {} ): api.Span | undefined { if (core.isUrlIgnored(url, this._getConfig().ignoreUrls)) { - this._logger.debug('ignoring span as url matches ignored url'); + api.diag.debug('ignoring span as url matches ignored url'); return; } const method = (options.method || 'GET').toUpperCase(); @@ -381,7 +381,7 @@ export class FetchInstrumentation extends InstrumentationBase< enable() { if (isWrapped(window.fetch)) { this._unwrap(window, 'fetch'); - this._logger.debug('removing previous patch for constructor'); + api.diag.debug('removing previous patch for constructor'); } this._wrap(window, 'fetch', this._patchConstructor()); } diff --git a/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts b/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts index 28413baf1c8..d608059e373 100644 --- a/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts +++ b/packages/opentelemetry-instrumentation-fetch/test/fetch.test.ts @@ -216,9 +216,7 @@ describe('fetch', () => { } fetchInstrumentation = new FetchInstrumentation(config); - webTracerProviderWithZone = new WebTracerProvider({ - logLevel: core.LogLevel.ERROR, - }); + webTracerProviderWithZone = new WebTracerProvider(); registerInstrumentations({ tracerProvider: webTracerProviderWithZone, instrumentations: [fetchInstrumentation], diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts index 9729c9c0247..cfb83288bb0 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc-js/index.ts @@ -40,6 +40,7 @@ import { propagation, ROOT_CONTEXT, setSpan, + diag, } from '@opentelemetry/api'; import { RpcAttribute } from '@opentelemetry/semantic-conventions'; import { @@ -75,7 +76,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { '@grpc/grpc-js', ['1.*'], (moduleExports, version) => { - this._logger.debug(`Applying patch for @grpc/grpc-js@${version}`); + diag.debug(`Applying patch for @grpc/grpc-js@${version}`); if (isWrapped(moduleExports.Server.prototype.register)) { this._unwrap(moduleExports.Server.prototype, 'register'); } @@ -114,7 +115,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { }, (moduleExports, version) => { if (moduleExports === undefined) return; - this._logger.debug(`Removing patch for @grpc/grpc-js@${version}`); + diag.debug(`Removing patch for @grpc/grpc-js@${version}`); this._unwrap(moduleExports.Server.prototype, 'register'); this._unwrap(moduleExports, 'makeClientConstructor'); @@ -135,7 +136,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { const instrumentation = this; return (originalRegister: ServerRegisterFunction) => { const config = this._config; - instrumentation._logger.debug('patched gRPC server'); + diag.debug('patched gRPC server'); return function register( this: grpcJs.Server, name: string, @@ -185,10 +186,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { kind: SpanKind.SERVER, }; - instrumentation._logger.debug( - 'patch func: %s', - JSON.stringify(spanOptions) - ); + diag.debug('patch func: %s', JSON.stringify(spanOptions)); context.with( propagation.extract(ROOT_CONTEXT, call.metadata, { @@ -233,7 +231,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { ) => MakeClientConstructorFunction { const instrumentation = this; return (original: MakeClientConstructorFunction) => { - instrumentation._logger.debug('patching client'); + diag.debug('patching client'); return function makeClientConstructor( this: typeof grpcJs.Client, methods: grpcJs.ServiceDefinition, @@ -257,7 +255,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { */ private _patchLoadPackageDefinition(grpcClient: typeof grpcJs) { const instrumentation = this; - instrumentation._logger.debug('patching loadPackageDefinition'); + diag.debug('patching loadPackageDefinition'); return (original: typeof grpcJs.loadPackageDefinition) => { return function patchedLoadPackageDefinition( this: null, @@ -281,7 +279,7 @@ export class GrpcJsInstrumentation extends InstrumentationBase { ): (original: GrpcClientFunc) => () => EventEmitter { const instrumentation = this; return (original: GrpcClientFunc) => { - instrumentation._logger.debug('patch all client methods'); + diag.debug('patch all client methods'); return function clientMethodTrace(this: grpcJs.Client) { const name = `grpc.${original.path.replace('/', '')}`; const args = [...arguments]; diff --git a/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts b/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts index 19631739450..0fe0d30bab9 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/grpc/index.ts @@ -36,6 +36,7 @@ import { SpanOptions, SpanKind, setSpan, + diag, } from '@opentelemetry/api'; import { clientStreamAndUnaryHandler, @@ -74,7 +75,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< 'grpc', ['1.*'], (moduleExports, version) => { - this._logger.debug(`Applying patch for grpc@${version}`); + diag.debug(`Applying patch for grpc@${version}`); if (isWrapped(moduleExports.Server.prototype.register)) { this._unwrap(moduleExports.Server.prototype, 'register'); } @@ -97,7 +98,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< }, (moduleExports, version) => { if (moduleExports === undefined) return; - this._logger.debug(`Removing patch for grpc@${version}`); + diag.debug(`Removing patch for grpc@${version}`); this._unwrap(moduleExports.Server.prototype, 'register'); }, @@ -111,7 +112,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< moduleExports: GrpcInternalClientTypes, version?: string ) => { - this._logger.debug(`Applying internal patch for grpc@${version}`); + diag.debug(`Applying internal patch for grpc@${version}`); if (isWrapped(moduleExports.makeClientConstructor)) { this._unwrap(moduleExports, 'makeClientConstructor'); } @@ -127,7 +128,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< version?: string ) => { if (moduleExports === undefined) return; - this._logger.debug(`Removing internal patch for grpc@${version}`); + diag.debug(`Removing internal patch for grpc@${version}`); this._unwrap(moduleExports, 'makeClientConstructor'); }; return [ @@ -149,7 +150,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< private _patchServer(grpcModule: typeof grpcTypes) { const instrumentation = this; return (originalRegister: typeof grpcTypes.Server.prototype.register) => { - instrumentation._logger.debug('patched gRPC server'); + diag.debug('patched gRPC server'); return function register( this: grpcTypes.Server & { handlers: any }, @@ -193,10 +194,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< kind: SpanKind.SERVER, }; - instrumentation._logger.debug( - 'patch func: %s', - JSON.stringify(spanOptions) - ); + diag.debug('patch func: %s', JSON.stringify(spanOptions)); context.with( propagation.extract(context.active(), call.metadata, { @@ -248,7 +246,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< private _patchClient(grpcClient: typeof grpcTypes) { const instrumentation = this; return (original: typeof grpcTypes.makeGenericClientConstructor): never => { - instrumentation._logger.debug('patching client'); + diag.debug('patching client'); return function makeClientConstructor( this: typeof grpcTypes.Client, methods: { [key: string]: { originalName?: string } }, @@ -293,7 +291,7 @@ export class GrpcNativeInstrumentation extends InstrumentationBase< private _getPatchedClientMethods(grpcClient: typeof grpcTypes) { const instrumentation = this; return (original: GrpcClientFunc) => { - instrumentation._logger.debug('patch all client methods'); + diag.debug('patch all client methods'); return function clientMethodTrace(this: grpcTypes.Client) { const name = `grpc.${original.path.replace('/', '')}`; const args = Array.prototype.slice.call(arguments); diff --git a/packages/opentelemetry-instrumentation-grpc/test/helper.ts b/packages/opentelemetry-instrumentation-grpc/test/helper.ts index 768aeeeeb7a..1cf307ba880 100644 --- a/packages/opentelemetry-instrumentation-grpc/test/helper.ts +++ b/packages/opentelemetry-instrumentation-grpc/test/helper.ts @@ -18,7 +18,6 @@ import { context, SpanKind, propagation, - NoopLogger, setSpan, getSpan, } from '@opentelemetry/api'; @@ -650,8 +649,7 @@ export const runTests = ( }; describe('enable()', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -695,8 +693,7 @@ export const runTests = ( }); describe('disable()', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -727,8 +724,7 @@ export const runTests = ( }); describe('Test filtering requests using metadata', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -757,8 +753,7 @@ export const runTests = ( }); describe('Test filtering requests using options', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ logger }); + const provider = new NodeTracerProvider(); const checkSpans: { [key: string]: boolean } = { unaryMethod: false, UnaryMethod: false, diff --git a/packages/opentelemetry-instrumentation-http/src/http.ts b/packages/opentelemetry-instrumentation-http/src/http.ts index ca61b947e98..aaca3d38326 100644 --- a/packages/opentelemetry-instrumentation-http/src/http.ts +++ b/packages/opentelemetry-instrumentation-http/src/http.ts @@ -26,6 +26,7 @@ import { getSpan, suppressInstrumentation, NOOP_TRACER, + diag, } from '@opentelemetry/api'; import type * as http from 'http'; import type * as https from 'https'; @@ -85,7 +86,7 @@ export class HttpInstrumentation extends InstrumentationBase { 'http', ['*'], moduleExports => { - this._logger.debug(`Applying patch for http@${this._version}`); + diag.debug(`Applying patch for http@${this._version}`); if (isWrapped(moduleExports.request)) { this._unwrap(moduleExports, 'request'); } @@ -114,7 +115,7 @@ export class HttpInstrumentation extends InstrumentationBase { }, moduleExports => { if (moduleExports === undefined) return; - this._logger.debug(`Removing patch for http@${this._version}`); + diag.debug(`Removing patch for http@${this._version}`); this._unwrap(moduleExports, 'request'); this._unwrap(moduleExports, 'get'); @@ -128,7 +129,7 @@ export class HttpInstrumentation extends InstrumentationBase { 'https', ['*'], moduleExports => { - this._logger.debug(`Applying patch for https@${this._version}`); + diag.debug(`Applying patch for https@${this._version}`); if (isWrapped(moduleExports.request)) { this._unwrap(moduleExports, 'request'); } @@ -157,7 +158,7 @@ export class HttpInstrumentation extends InstrumentationBase { }, moduleExports => { if (moduleExports === undefined) return; - this._logger.debug(`Removing patch for https@${this._version}`); + diag.debug(`Removing patch for https@${this._version}`); this._unwrap(moduleExports, 'request'); this._unwrap(moduleExports, 'get'); @@ -303,9 +304,9 @@ export class HttpInstrumentation extends InstrumentationBase { } context.bind(response); - this._logger.debug('outgoingRequest on response()'); + diag.debug('outgoingRequest on response()'); response.on('end', () => { - this._logger.debug('outgoingRequest on end()'); + diag.debug('outgoingRequest on end()'); let status: SpanStatus; if (response.aborted && !response.complete) { @@ -347,7 +348,7 @@ export class HttpInstrumentation extends InstrumentationBase { this._closeHttpSpan(span); }); - this._logger.debug('http.ClientRequest return request'); + diag.debug('http.ClientRequest return request'); return request; } @@ -373,20 +374,13 @@ export class HttpInstrumentation extends InstrumentationBase { : '/'; const method = request.method || 'GET'; - instrumentation._logger.debug( - '%s instrumentation incomingRequest', - component - ); + diag.debug('%s instrumentation incomingRequest', component); if ( utils.isIgnored( pathname, instrumentation._getConfig().ignoreIncomingPaths, - (e: Error) => - instrumentation._logger.error( - 'caught ignoreIncomingPaths error: ', - e - ) + (e: Error) => diag.error('caught ignoreIncomingPaths error: ', e) ) ) { return context.with(suppressInstrumentation(context.active()), () => { @@ -523,11 +517,7 @@ export class HttpInstrumentation extends InstrumentationBase { utils.isIgnored( origin + pathname, instrumentation._getConfig().ignoreOutgoingUrls, - (e: Error) => - instrumentation._logger.error( - 'caught ignoreOutgoingUrls error: ', - e - ) + (e: Error) => diag.error('caught ignoreOutgoingUrls error: ', e) ) ) { return original.apply(this, [optionsParsed, ...args]); @@ -557,10 +547,7 @@ export class HttpInstrumentation extends InstrumentationBase { } ); - instrumentation._logger.debug( - '%s instrumentation outgoingRequest', - component - ); + diag.debug('%s instrumentation outgoingRequest', component); context.bind(request); return instrumentation._traceClientRequest( component, diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-disable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-disable.test.ts index 722922b26ff..9e29f54255b 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-disable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-disable.test.ts @@ -13,11 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - NoopTracerProvider, - NoopLogger, - NOOP_TRACER, -} from '@opentelemetry/api'; +import { NoopTracerProvider, NOOP_TRACER } from '@opentelemetry/api'; import * as assert from 'assert'; import { HttpInstrumentation } from '../../src/http'; import { AddressInfo } from 'net'; @@ -26,8 +22,7 @@ import * as sinon from 'sinon'; import { httpRequest } from '../utils/httpRequest'; import { isWrapped } from '@opentelemetry/instrumentation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts index 75d1de7bb7f..b609685fa81 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-enable.test.ts @@ -19,7 +19,6 @@ import { propagation, Span as ISpan, SpanKind, - NoopLogger, getSpan, setSpan, } from '@opentelemetry/api'; @@ -45,8 +44,7 @@ import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import type { ClientRequest, IncomingMessage, ServerResponse } from 'http'; import { isWrapped } from '@opentelemetry/instrumentation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -62,9 +60,7 @@ const hostname = 'localhost'; const pathname = '/test'; const serverName = 'my.server.name'; const memoryExporter = new InMemorySpanExporter(); -const provider = new NodeTracerProvider({ - logger, -}); +const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); instrumentation.setTracerProvider(provider); diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts index 3249ba531cd..9246e9e276b 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/http-package.test.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - context, - SpanKind, - Span, - propagation, - NoopLogger, -} from '@opentelemetry/api'; +import { context, SpanKind, Span, propagation } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NodeTracerProvider } from '@opentelemetry/node'; import { @@ -34,8 +28,7 @@ import { HttpInstrumentation } from '../../src/http'; import { assertSpan } from '../utils/assertSpan'; import { DummyPropagation } from '../utils/DummyPropagation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -61,10 +54,7 @@ describe('Packages', () => { context.disable(); }); describe('get', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); instrumentation.setTracerProvider(provider); beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/https-disable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/https-disable.test.ts index 254c6eda18d..f7ce5e1dcc2 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/https-disable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/https-disable.test.ts @@ -14,11 +14,7 @@ * limitations under the License. */ -import { - NoopTracerProvider, - NoopLogger, - NOOP_TRACER, -} from '@opentelemetry/api'; +import { NoopTracerProvider, NOOP_TRACER } from '@opentelemetry/api'; import * as assert from 'assert'; import * as fs from 'fs'; import type { AddressInfo } from 'net'; @@ -27,8 +23,7 @@ import * as sinon from 'sinon'; import { HttpInstrumentation } from '../../src'; import { isWrapped } from '@opentelemetry/instrumentation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts index cef9c33ed38..e1ee7a6a52f 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/https-enable.test.ts @@ -20,7 +20,6 @@ import { propagation, Span as ISpan, SpanKind, - NoopLogger, setSpan, } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; @@ -44,8 +43,7 @@ import { assertSpan } from '../utils/assertSpan'; import { DummyPropagation } from '../utils/DummyPropagation'; import { isWrapped } from '@opentelemetry/instrumentation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -63,9 +61,7 @@ const hostname = 'localhost'; const serverName = 'my.server.name'; const pathname = '/test'; const memoryExporter = new InMemorySpanExporter(); -const provider = new BasicTracerProvider({ - logger, -}); +const provider = new BasicTracerProvider(); instrumentation.setTracerProvider(provider); const tracer = provider.getTracer('test-https'); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts index c2779afa284..6bac953bfd4 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/https-package.test.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - context, - SpanKind, - propagation, - NoopLogger, - Span, -} from '@opentelemetry/api'; +import { context, SpanKind, propagation, Span } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NodeTracerProvider } from '@opentelemetry/node'; import { @@ -34,8 +28,7 @@ import { HttpInstrumentation } from '../../src/http'; import { assertSpan } from '../utils/assertSpan'; import { DummyPropagation } from '../utils/DummyPropagation'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -61,11 +54,7 @@ describe('Packages', () => { context.disable(); }); describe('get', () => { - const logger = new NoopLogger(); - - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); instrumentation.setTracerProvider(provider); beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts index be6432f6409..d002e477056 100644 --- a/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/functionals/utils.test.ts @@ -19,7 +19,6 @@ import { ROOT_CONTEXT, SpanKind, TraceFlags, - NoopLogger, } from '@opentelemetry/api'; import { BasicTracerProvider, Span } from '@opentelemetry/tracing'; import { HttpAttribute } from '@opentelemetry/semantic-conventions'; @@ -170,9 +169,8 @@ describe('Utility', () => { it('should not re-throw when function throws an exception', () => { satisfiesPatternStub.restore(); - const log = new NoopLogger(); const onException = (e: Error) => { - log.error('error', e); + // Do nothing }; for (const callback of [undefined, onException]) { assert.doesNotThrow(() => diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts index a47ef77cb8a..c506262d9ea 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/http-enable.test.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - SpanKind, - Span, - context, - propagation, - NoopLogger, -} from '@opentelemetry/api'; +import { SpanKind, Span, context, propagation } from '@opentelemetry/api'; import { HttpAttribute, GeneralAttribute, @@ -37,8 +31,7 @@ import { } from '@opentelemetry/tracing'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -128,10 +121,7 @@ describe('HttpInstrumentation Integration tests', () => { }); }); - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); instrumentation.setTracerProvider(provider); beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts index 8779f2d6b51..7df9f3e771b 100644 --- a/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-instrumentation-http/test/integrations/https-enable.test.ts @@ -14,13 +14,7 @@ * limitations under the License. */ -import { - SpanKind, - Span, - context, - propagation, - NoopLogger, -} from '@opentelemetry/api'; +import { SpanKind, Span, context, propagation } from '@opentelemetry/api'; import { HttpAttribute, GeneralAttribute, @@ -41,8 +35,7 @@ import { import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { HttpInstrumentation } from '../../src'; -const logger = new NoopLogger(); -const instrumentation = new HttpInstrumentation({ logger }); +const instrumentation = new HttpInstrumentation(); instrumentation.enable(); instrumentation.disable(); @@ -136,10 +129,7 @@ describe('HttpsInstrumentation Integration tests', () => { done(); }); }); - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); instrumentation.setTracerProvider(provider); beforeEach(() => { diff --git a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts index ad222d2d0ea..84c0b18c83f 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts +++ b/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts @@ -292,7 +292,7 @@ export class XMLHttpRequestInstrumentation extends InstrumentationBase { xmlHttpRequestInstrumentation = new XMLHttpRequestInstrumentation( config ); - webTracerProviderWithZone = new WebTracerProvider({ - logLevel: LogLevel.ERROR, - }); + webTracerProviderWithZone = new WebTracerProvider(); registerInstrumentations({ instrumentations: [xmlHttpRequestInstrumentation], tracerProvider: webTracerProviderWithZone, @@ -732,9 +726,7 @@ describe('xhr', () => { ); spyEntries.withArgs('resource').returns(resources); - webTracerWithZoneProvider = new WebTracerProvider({ - logLevel: LogLevel.ERROR, - }); + webTracerWithZoneProvider = new WebTracerProvider(); registerInstrumentations({ instrumentations: [new XMLHttpRequestInstrumentation()], diff --git a/packages/opentelemetry-instrumentation/README.md b/packages/opentelemetry-instrumentation/README.md index b08d3492688..de74b9cc0a2 100644 --- a/packages/opentelemetry-instrumentation/README.md +++ b/packages/opentelemetry-instrumentation/README.md @@ -224,7 +224,6 @@ registerInstrumentations({ ], meterProvider: meterProvider, tracerProvider: tracerProvider, - logger: new ConsoleLogger(), // optional }); tracerProvider.register({ @@ -254,7 +253,6 @@ registerInstrumentations({ ], meterProvider: meterProvider, tracerProvider: tracerProvider, - logger: new ConsoleLogger(), // optional }); tracerProvider.register({ diff --git a/packages/opentelemetry-instrumentation/src/autoLoader.ts b/packages/opentelemetry-instrumentation/src/autoLoader.ts index aecef78c99f..795b1f83ce3 100644 --- a/packages/opentelemetry-instrumentation/src/autoLoader.ts +++ b/packages/opentelemetry-instrumentation/src/autoLoader.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { trace } from '@opentelemetry/api'; import { metrics } from '@opentelemetry/api-metrics'; import { disableInstrumentations, @@ -38,28 +38,12 @@ export function registerInstrumentations( pluginsNode, pluginsWeb, } = parseInstrumentationOptions(options.instrumentations); - const tracerWithLogger = (options.tracerProvider as unknown) as { - logger: api.Logger; - }; - const tracerProvider = - options.tracerProvider || api.trace.getTracerProvider(); + const tracerProvider = options.tracerProvider || trace.getTracerProvider(); const meterProvider = options.meterProvider || metrics.getMeterProvider(); - const logger = - options.logger || tracerWithLogger?.logger || new api.NoopLogger(); - enableInstrumentations( - instrumentations, - logger, - tracerProvider, - meterProvider - ); + enableInstrumentations(instrumentations, tracerProvider, meterProvider); - const unload = loadOldPlugins( - pluginsNode, - pluginsWeb, - logger, - tracerProvider - ); + const unload = loadOldPlugins(pluginsNode, pluginsWeb, tracerProvider); return () => { unload(); diff --git a/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts b/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts index cb95c9c9c52..c92d4c9ffe5 100644 --- a/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts +++ b/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { MeterProvider } from '@opentelemetry/api-metrics'; import { Instrumentation } from './types'; import { AutoLoaderResult, InstrumentationOption } from './types_internal'; @@ -63,13 +63,11 @@ export function parseInstrumentationOptions( /** * Enable instrumentations * @param instrumentations - * @param logger * @param tracerProvider * @param meterProvider */ export function enableInstrumentations( instrumentations: Instrumentation[], - logger: Logger, tracerProvider?: TracerProvider, meterProvider?: MeterProvider ) { diff --git a/packages/opentelemetry-instrumentation/src/instrumentation.ts b/packages/opentelemetry-instrumentation/src/instrumentation.ts index 080a6a94ee7..091271d9521 100644 --- a/packages/opentelemetry-instrumentation/src/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/instrumentation.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { TracerProvider, Tracer, trace } from '@opentelemetry/api'; import { Meter, MeterProvider, metrics } from '@opentelemetry/api-metrics'; import * as shimmer from 'shimmer'; import { InstrumentationModuleDefinition } from './platform/node'; @@ -27,9 +27,8 @@ export abstract class InstrumentationAbstract implements types.Instrumentation { protected _config: types.InstrumentationConfig; - private _tracer: api.Tracer; + private _tracer: Tracer; private _meter: Meter; - protected _logger: api.Logger; constructor( public readonly instrumentationName: string, @@ -40,12 +39,8 @@ export abstract class InstrumentationAbstract enabled: true, ...config, }; - this._logger = this._config.logger || new api.NoopLogger(); - this._tracer = api.trace.getTracer( - instrumentationName, - instrumentationVersion - ); + this._tracer = trace.getTracer(instrumentationName, instrumentationVersion); this._meter = metrics.getMeter(instrumentationName, instrumentationVersion); } @@ -79,7 +74,7 @@ export abstract class InstrumentationAbstract * Sets TraceProvider to this plugin * @param tracerProvider */ - public setTracerProvider(tracerProvider: api.TracerProvider) { + public setTracerProvider(tracerProvider: TracerProvider) { this._tracer = tracerProvider.getTracer( this.instrumentationName, this.instrumentationVersion @@ -87,7 +82,7 @@ export abstract class InstrumentationAbstract } /* Returns tracer */ - protected get tracer(): api.Tracer { + protected get tracer(): Tracer { return this._tracer; } diff --git a/packages/opentelemetry-instrumentation/src/platform/browser/old/autoLoader.ts b/packages/opentelemetry-instrumentation/src/platform/browser/old/autoLoader.ts index 1b95510efe2..c6aedb836f2 100644 --- a/packages/opentelemetry-instrumentation/src/platform/browser/old/autoLoader.ts +++ b/packages/opentelemetry-instrumentation/src/platform/browser/old/autoLoader.ts @@ -16,25 +16,23 @@ // This should be removed after plugins are gone -import * as api from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { NodePlugins, OldClassPlugin } from '../../../types_plugin_only'; /** * Loads provided web plugins * @param pluginsNode * @param pluginsWeb - * @param logger * @param tracerProvider * @return returns function to disable all plugins */ export function loadOldPlugins( pluginsNode: NodePlugins, pluginsWeb: OldClassPlugin[], - logger: api.Logger, - tracerProvider: api.TracerProvider + tracerProvider: TracerProvider ): () => void { pluginsWeb.forEach(plugin => { - plugin.enable([], tracerProvider, logger); + plugin.enable([], tracerProvider); }); return () => { pluginsWeb.forEach(plugin => { diff --git a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts index 9da46baa728..ba94ce14114 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts @@ -20,6 +20,7 @@ import * as RequireInTheMiddle from 'require-in-the-middle'; import * as semver from 'semver'; import { InstrumentationAbstract } from '../../instrumentation'; import { InstrumentationModuleDefinition } from './types'; +import { diag } from '@opentelemetry/api'; /** * Base abstract class for instrumenting node plugins @@ -47,7 +48,7 @@ export abstract class InstrumentationBase this._modules = (modules as InstrumentationModuleDefinition[]) || []; if (this._modules.length === 0) { - this._logger.warn( + diag.warn( 'No modules instrumentation has been defined,' + ' nothing will be patched' ); diff --git a/packages/opentelemetry-instrumentation/src/platform/node/old/PluginLoader.ts b/packages/opentelemetry-instrumentation/src/platform/node/old/PluginLoader.ts index 97f32582bc8..abd84513c36 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/old/PluginLoader.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/old/PluginLoader.ts @@ -16,7 +16,7 @@ // This is copy from previous version, should be removed after plugins are gone -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider, diag } from '@opentelemetry/api'; import * as RequireInTheMiddle from 'require-in-the-middle'; import { OldClassPlugin, OldPluginConfig } from '../../../types_plugin_only'; import * as utils from './utils'; @@ -83,7 +83,7 @@ export class PluginLoader { private _hookState = HookState.UNINITIALIZED; /** Constructs a new PluginLoader instance. */ - constructor(readonly provider: TracerProvider, readonly logger: Logger) {} + constructor(readonly provider: TracerProvider) {} /** * Loads a list of plugins. Each plugin module should implement the core @@ -116,7 +116,7 @@ export class PluginLoader { } }); if (requiredModulesToHook.length > 0) { - this.logger.warn( + diag.warn( `Some modules (${requiredModulesToHook.join( ', ' )}) were already required when their respective plugin was loaded, some plugins might not work. Make sure the SDK is setup before you require in other modules.` @@ -138,31 +138,29 @@ export class PluginLoader { version = process.versions.node; } else { // Get the module version. - version = utils.getPackageVersion(this.logger, baseDir); + version = utils.getPackageVersion(baseDir); } // Skip loading of all modules if '*' is provided if (modulesToIgnore === DISABLE_ALL_PLUGINS) { - this.logger.info( + diag.info( `PluginLoader#load: skipped patching module ${name} because all plugins are disabled (${ENV_PLUGIN_DISABLED_LIST})` ); return exports; } if (modulesToIgnore.includes(name)) { - this.logger.info( + diag.info( `PluginLoader#load: skipped patching module ${name} because it was on the ignore list (${ENV_PLUGIN_DISABLED_LIST})` ); return exports; } - this.logger.info( - `PluginLoader#load: trying to load ${name}@${version}` - ); + diag.info(`PluginLoader#load: trying to load ${name}@${version}`); if (!version) return exports; - this.logger.debug( + diag.debug( `PluginLoader#load: applying patch to ${name}@${version} using ${modulePath} module` ); @@ -171,13 +169,13 @@ export class PluginLoader { const plugin: OldClassPlugin = modulePlugin ?? require(modulePath).plugin; if (!utils.isSupportedVersion(version, plugin.supportedVersions)) { - this.logger.warn( + diag.warn( `PluginLoader#load: Plugin ${name} only supports module ${plugin.moduleName} with the versions: ${plugin.supportedVersions}` ); return exports; } if (plugin.moduleName !== name) { - this.logger.error( + diag.error( `PluginLoader#load: Entry ${name} use a plugin that instruments ${plugin.moduleName}` ); return exports; @@ -185,9 +183,9 @@ export class PluginLoader { this.plugins.push(plugin); // Enable each supported plugin. - return plugin.enable(exports, this.provider, this.logger, config); + return plugin.enable(exports, this.provider, config); } catch (e) { - this.logger.error( + diag.error( `PluginLoader#load: could not load plugin ${modulePath} of module ${name}. Error: ${e.message}` ); return exports; @@ -195,11 +193,11 @@ export class PluginLoader { }); this._hookState = HookState.ENABLED; } else if (this._hookState === HookState.DISABLED) { - this.logger.error( + diag.error( 'PluginLoader#load: Currently cannot re-enable plugin loader.' ); } else { - this.logger.error('PluginLoader#load: Plugin loader already enabled.'); + diag.error('PluginLoader#load: Plugin loader already enabled.'); } return this; } diff --git a/packages/opentelemetry-instrumentation/src/platform/node/old/autoLoader.ts b/packages/opentelemetry-instrumentation/src/platform/node/old/autoLoader.ts index c3880b96ec8..2fa030f0f2d 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/old/autoLoader.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/old/autoLoader.ts @@ -16,7 +16,7 @@ // This should be removed after plugins are gone -import * as api from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { NodePlugins, OldClassPlugin } from '../../../types_plugin_only'; import { PluginLoader } from './PluginLoader'; @@ -42,18 +42,16 @@ export const DEFAULT_INSTRUMENTATION_PLUGINS: NodePlugins = { * Loads provided node plugins * @param pluginsNode * @param pluginsWeb - * @param logger * @param tracerProvider * @return returns function to disable all plugins */ export function loadOldPlugins( pluginsNode: NodePlugins, pluginsWeb: OldClassPlugin[], - logger: api.Logger, - tracerProvider: api.TracerProvider + tracerProvider: TracerProvider ): () => void { const allPlugins = mergePlugins(DEFAULT_INSTRUMENTATION_PLUGINS, pluginsNode); - const pluginLoader = new PluginLoader(tracerProvider, logger); + const pluginLoader = new PluginLoader(tracerProvider); pluginLoader.load(allPlugins); return () => { pluginLoader.unload(); diff --git a/packages/opentelemetry-instrumentation/src/platform/node/old/utils.ts b/packages/opentelemetry-instrumentation/src/platform/node/old/utils.ts index f02e48a703a..941afdeb123 100644 --- a/packages/opentelemetry-instrumentation/src/platform/node/old/utils.ts +++ b/packages/opentelemetry-instrumentation/src/platform/node/old/utils.ts @@ -16,33 +16,29 @@ // This is copy from previous version, should be removed after plugins are gone -import { Logger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import * as path from 'path'; import * as semver from 'semver'; /** * Gets the package version. - * @param logger The logger to use. * @param basedir The base directory. */ -export function getPackageVersion( - logger: Logger, - basedir: string -): string | null { +export function getPackageVersion(basedir: string): string | null { const pjsonPath = path.join(basedir, 'package.json'); try { const version = require(pjsonPath).version; // Attempt to parse a string as a semantic version, returning either a // SemVer object or null. if (!semver.parse(version)) { - logger.error( + diag.error( `getPackageVersion: [${pjsonPath}|${version}] Version string could not be parsed.` ); return null; } return version; } catch (e) { - logger.error( + diag.error( `getPackageVersion: [${pjsonPath}] An error occurred while retrieving version string. ${e.message}` ); return null; diff --git a/packages/opentelemetry-instrumentation/src/types.ts b/packages/opentelemetry-instrumentation/src/types.ts index e0eaa025919..4d54f7d02e8 100644 --- a/packages/opentelemetry-instrumentation/src/types.ts +++ b/packages/opentelemetry-instrumentation/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { MeterProvider } from '@opentelemetry/api-metrics'; /** Interface Instrumentation to apply patch. */ @@ -60,8 +60,6 @@ export interface InstrumentationConfig { */ enabled?: boolean; - logger?: Logger; - /** * Path of the trace plugin to load. * @default '@opentelemetry/plugin-http' in case of http. diff --git a/packages/opentelemetry-instrumentation/src/types_internal.ts b/packages/opentelemetry-instrumentation/src/types_internal.ts index be4399433d5..4831ad65375 100644 --- a/packages/opentelemetry-instrumentation/src/types_internal.ts +++ b/packages/opentelemetry-instrumentation/src/types_internal.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { MeterProvider } from '@opentelemetry/api-metrics'; import { InstrumentationBase } from './platform'; import { Instrumentation } from './types'; @@ -43,5 +43,4 @@ export interface AutoLoaderOptions { instrumentations?: InstrumentationOption[]; tracerProvider?: TracerProvider; meterProvider?: MeterProvider; - logger?: Logger; } diff --git a/packages/opentelemetry-instrumentation/src/types_plugin_only.ts b/packages/opentelemetry-instrumentation/src/types_plugin_only.ts index 967ea3559b2..b1e1012e3c7 100644 --- a/packages/opentelemetry-instrumentation/src/types_plugin_only.ts +++ b/packages/opentelemetry-instrumentation/src/types_plugin_only.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; export interface NodePlugins { [pluginName: string]: OldPluginConfig; @@ -44,13 +44,11 @@ export interface OldClassPlugin { * @param moduleExports The value of the `module.exports` property that would * normally be exposed by the required module. ex: `http`, `https` etc. * @param TracerProvider a tracer provider. - * @param logger a logger instance. * @param [config] an object to configure the plugin. */ enable( moduleExports: T, TracerProvider: TracerProvider, - logger: Logger, config?: OldPluginConfig ): T; diff --git a/packages/opentelemetry-instrumentation/test/node/BasePlugin.ts b/packages/opentelemetry-instrumentation/test/node/BasePlugin.ts index 462dc6cb650..937f1748601 100644 --- a/packages/opentelemetry-instrumentation/test/node/BasePlugin.ts +++ b/packages/opentelemetry-instrumentation/test/node/BasePlugin.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger, TracerProvider } from '@opentelemetry/api'; +import { TracerProvider } from '@opentelemetry/api'; import { OldClassPlugin, OldPluginConfig } from '../../src/types_plugin_only'; /** This class represent the base to patch plugin. */ @@ -29,7 +29,6 @@ export abstract class BasePlugin implements OldClassPlugin { enable( moduleExports: T, tracerProvider: TracerProvider, - logger: Logger, config?: OldPluginConfig ): T { this._moduleExports = moduleExports; diff --git a/packages/opentelemetry-instrumentation/test/node/PluginLoader.test.ts b/packages/opentelemetry-instrumentation/test/node/PluginLoader.test.ts index 6407f150291..d4d18858457 100644 --- a/packages/opentelemetry-instrumentation/test/node/PluginLoader.test.ts +++ b/packages/opentelemetry-instrumentation/test/node/PluginLoader.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger, NoopTracerProvider } from '@opentelemetry/api'; +import { NoopTracerProvider, diag } from '@opentelemetry/api'; import * as assert from 'assert'; import * as path from 'path'; import { @@ -102,7 +102,6 @@ const differentNamePlugins: Plugins = { describe('PluginLoader', () => { const provider = new NoopTracerProvider(); - const logger = new NoopLogger(); before(() => { module.paths.push(INSTALLED_PLUGINS_PATH); @@ -116,25 +115,29 @@ describe('PluginLoader', () => { describe('.state()', () => { it('returns UNINITIALIZED when first called', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['_hookState'], HookState.UNINITIALIZED); }); it('transitions from UNINITIALIZED to ENABLED', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load(simplePlugins); assert.strictEqual(pluginLoader['_hookState'], HookState.ENABLED); pluginLoader.unload(); }); it('transitions from ENABLED to DISABLED', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load(simplePlugins).unload(); assert.strictEqual(pluginLoader['_hookState'], HookState.DISABLED); }); }); describe('.load()', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); afterEach(() => { delete process.env[ENV_PLUGIN_DISABLED_LIST]; }); @@ -159,7 +162,7 @@ describe('PluginLoader', () => { it('should not load a plugin on the ignore list environment variable', () => { // Set ignore list env var process.env[ENV_PLUGIN_DISABLED_LIST] = 'simple-module'; - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load({ ...simplePlugins, ...supportedVersionPlugins }); assert.strictEqual(pluginLoader['plugins'].length, 0); @@ -180,7 +183,7 @@ describe('PluginLoader', () => { it('should not load plugins on the ignore list environment variable', () => { // Set ignore list env var process.env[ENV_PLUGIN_DISABLED_LIST] = 'simple-module,http'; - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load({ ...simplePlugins, ...supportedVersionPlugins, @@ -209,7 +212,7 @@ describe('PluginLoader', () => { it('should not load any plugins if ignore list environment variable is set to "*"', () => { // Set ignore list env var process.env[ENV_PLUGIN_DISABLED_LIST] = '*'; - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load({ ...simplePlugins, ...supportedVersionPlugins, @@ -237,7 +240,7 @@ describe('PluginLoader', () => { }); it('should load a plugin and patch the target modules', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(simplePlugins); // The hook is only called the first time the module is loaded. @@ -249,7 +252,7 @@ describe('PluginLoader', () => { }); it('should load a plugin and patch the core module', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(httpPlugins); // The hook is only called the first time the module is loaded. @@ -260,7 +263,7 @@ describe('PluginLoader', () => { }); // @TODO: simplify this test once we can load module with custom path it('should not load the plugin when supported versions does not match', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(notSupportedVersionPlugins); // The hook is only called the first time the module is loaded. @@ -270,7 +273,7 @@ describe('PluginLoader', () => { }); // @TODO: simplify this test once we can load module with custom path it('should load a plugin and patch the target modules when supported versions match', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(supportedVersionPlugins); // The hook is only called the first time the module is loaded. @@ -282,7 +285,7 @@ describe('PluginLoader', () => { }); it('should not load a plugin when value is false', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(disablePlugins); const simpleModule = require('simple-module'); @@ -293,7 +296,7 @@ describe('PluginLoader', () => { }); it('should not load a plugin when value is true but path is missing', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(missingPathPlugins); const simpleModule = require('simple-module'); @@ -304,7 +307,7 @@ describe('PluginLoader', () => { }); it('should not load a non existing plugin', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(nonexistentPlugins); assert.strictEqual(pluginLoader['plugins'].length, 0); @@ -312,31 +315,28 @@ describe('PluginLoader', () => { }); it("doesn't patch modules for which plugins aren't specified", () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load({}); assert.strictEqual(require('simple-module').value(), 0); pluginLoader.unload(); }); it('should warn when module was already loaded', callback => { - const verifyWarnLogger = { - error: logger.error, - info: logger.info, - debug: logger.debug, - warn: (message: string, ...args: unknown[]) => { - assert(message.match(/were already required when/)); - assert(message.match(/(already-require-module)/)); - return callback(); - }, + const verifyWarnLogger = Object.assign({}, diag); + verifyWarnLogger.warn = (message: string, ...args: unknown[]) => { + assert(message.match(/were already required when/)); + assert(message.match(/(already-require-module)/)); + return callback(); }; + diag.setLogger(verifyWarnLogger); require('already-require-module'); - const pluginLoader = new PluginLoader(provider, verifyWarnLogger); + const pluginLoader = new PluginLoader(provider); pluginLoader.load(alreadyRequiredPlugins); pluginLoader.unload(); }); it('should not load a plugin that patches a different module that the one configured', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(differentNamePlugins); require('random-module'); @@ -347,7 +347,7 @@ describe('PluginLoader', () => { describe('.unload()', () => { it('should unload the plugins and unpatch the target module when unloads', () => { - const pluginLoader = new PluginLoader(provider, logger); + const pluginLoader = new PluginLoader(provider); assert.strictEqual(pluginLoader['plugins'].length, 0); pluginLoader.load(simplePlugins); // The hook is only called the first time the module is loaded. diff --git a/packages/opentelemetry-instrumentation/test/node/utils.test.ts b/packages/opentelemetry-instrumentation/test/node/utils.test.ts index 273c98e2dc2..8f1c4ac8c9a 100644 --- a/packages/opentelemetry-instrumentation/test/node/utils.test.ts +++ b/packages/opentelemetry-instrumentation/test/node/utils.test.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; import * as assert from 'assert'; import * as path from 'path'; import * as utils from '../../src/platform/node/old/utils'; @@ -36,8 +35,6 @@ const TEST_MODULES: Array<{ name: string; version: string | null }> = [ ]; describe('Instrumentation#utils', () => { - const logger = new NoopLogger(); - before(() => { utils.searchPathForTest(INSTALLED_PLUGINS_PATH); }); @@ -46,7 +43,7 @@ describe('Instrumentation#utils', () => { TEST_MODULES.forEach(testCase => { it(`should return ${testCase.version} for ${testCase.name}`, () => { assert.strictEqual( - utils.getPackageVersion(logger, testCase.name), + utils.getPackageVersion(testCase.name), testCase.version ); }); diff --git a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts index 82df5a507e6..30ae3af1e85 100644 --- a/packages/opentelemetry-metrics/src/BaseObserverMetric.ts +++ b/packages/opentelemetry-metrics/src/BaseObserverMetric.ts @@ -51,7 +51,6 @@ export abstract class BaseObserverMetric labels, this._disabled, this._valueType, - this._logger, this._processor.aggregatorFor(this._descriptor) ); } diff --git a/packages/opentelemetry-metrics/src/BatchObserver.ts b/packages/opentelemetry-metrics/src/BatchObserver.ts index 3b8f8b1e021..90c53844658 100644 --- a/packages/opentelemetry-metrics/src/BatchObserver.ts +++ b/packages/opentelemetry-metrics/src/BatchObserver.ts @@ -15,7 +15,7 @@ */ import * as api from '@opentelemetry/api-metrics'; -import { Logger, NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import { BatchObserverResult } from './BatchObserverResult'; const NOOP_CALLBACK = () => {}; @@ -25,20 +25,18 @@ const MAX_TIMEOUT_UPDATE_MS = 500; export class BatchObserver { private _callback: (observerResult: api.BatchObserverResult) => void; private _maxTimeoutUpdateMS: number; - private _logger: Logger; constructor( options: api.BatchObserverOptions, callback?: (observerResult: api.BatchObserverResult) => void ) { - this._logger = options.logger ?? new NoopLogger(); this._maxTimeoutUpdateMS = options.maxTimeoutUpdateMS ?? MAX_TIMEOUT_UPDATE_MS; this._callback = callback || NOOP_CALLBACK; } collect(): Promise { - this._logger.debug('getMetricRecord - start'); + diag.debug('getMetricRecord - start'); return new Promise(resolve => { const observerResult = new BatchObserverResult(); @@ -49,14 +47,14 @@ export class BatchObserver { // for any reason the observerBatchResult will be referenced observerResult.onObserveCalled(); resolve(); - this._logger.debug('getMetricRecord - timeout'); + diag.debug('getMetricRecord - timeout'); }, this._maxTimeoutUpdateMS); // sets callback for each "observe" method observerResult.onObserveCalled(() => { clearTimeout(timer); resolve(); - this._logger.debug('getMetricRecord - end'); + diag.debug('getMetricRecord - end'); }); // calls the BatchObserverResult callback diff --git a/packages/opentelemetry-metrics/src/BoundInstrument.ts b/packages/opentelemetry-metrics/src/BoundInstrument.ts index 6a70d72848a..296bf72909e 100644 --- a/packages/opentelemetry-metrics/src/BoundInstrument.ts +++ b/packages/opentelemetry-metrics/src/BoundInstrument.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; import { Aggregator } from './export/types'; @@ -24,23 +24,20 @@ import { Aggregator } from './export/types'; */ export class BaseBoundInstrument { protected _labels: api.Labels; - protected _logger: Logger; constructor( labels: api.Labels, - logger: Logger, private readonly _disabled: boolean, private readonly _valueType: api.ValueType, private readonly _aggregator: Aggregator ) { this._labels = labels; - this._logger = logger; } update(value: number): void { if (this._disabled) return; if (typeof value !== 'number') { - this._logger.error( + diag.error( `Metric cannot accept a non-number value for ${Object.values( this._labels )}.` @@ -49,7 +46,7 @@ export class BaseBoundInstrument { } if (this._valueType === api.ValueType.INT && !Number.isInteger(value)) { - this._logger.warn( + diag.warn( `INT value type cannot accept a floating-point value for ${Object.values( this._labels )}, ignoring the fractional digits.` @@ -80,17 +77,14 @@ export class BoundCounter labels: api.Labels, disabled: boolean, valueType: api.ValueType, - logger: Logger, aggregator: Aggregator ) { - super(labels, logger, disabled, valueType, aggregator); + super(labels, disabled, valueType, aggregator); } add(value: number): void { if (value < 0) { - this._logger.error( - `Counter cannot descend for ${Object.values(this._labels)}` - ); + diag.error(`Counter cannot descend for ${Object.values(this._labels)}`); return; } @@ -110,10 +104,9 @@ export class BoundUpDownCounter labels: api.Labels, disabled: boolean, valueType: api.ValueType, - logger: Logger, aggregator: Aggregator ) { - super(labels, logger, disabled, valueType, aggregator); + super(labels, disabled, valueType, aggregator); } add(value: number): void { @@ -131,10 +124,9 @@ export class BoundValueRecorder labels: api.Labels, disabled: boolean, valueType: api.ValueType, - logger: Logger, aggregator: Aggregator ) { - super(labels, logger, disabled, valueType, aggregator); + super(labels, disabled, valueType, aggregator); } record(value: number): void { @@ -152,9 +144,8 @@ export class BoundObserver labels: api.Labels, disabled: boolean, valueType: api.ValueType, - logger: Logger, aggregator: Aggregator ) { - super(labels, logger, disabled, valueType, aggregator); + super(labels, disabled, valueType, aggregator); } } diff --git a/packages/opentelemetry-metrics/src/CounterMetric.ts b/packages/opentelemetry-metrics/src/CounterMetric.ts index d9150f26cdb..36b4fb70c74 100644 --- a/packages/opentelemetry-metrics/src/CounterMetric.ts +++ b/packages/opentelemetry-metrics/src/CounterMetric.ts @@ -38,7 +38,6 @@ export class CounterMetric extends Metric implements api.Counter { labels, this._disabled, this._valueType, - this._logger, this._processor.aggregatorFor(this._descriptor) ); } diff --git a/packages/opentelemetry-metrics/src/Meter.ts b/packages/opentelemetry-metrics/src/Meter.ts index 7bd7c22a41f..72a1967c3ee 100644 --- a/packages/opentelemetry-metrics/src/Meter.ts +++ b/packages/opentelemetry-metrics/src/Meter.ts @@ -14,9 +14,9 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; -import { ConsoleLogger, InstrumentationLibrary } from '@opentelemetry/core'; +import { InstrumentationLibrary } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import { BatchObserver } from './BatchObserver'; import { BaseBoundInstrument } from './BoundInstrument'; @@ -37,7 +37,6 @@ import merge = require('lodash.merge'); * Meter is an implementation of the {@link Meter} interface. */ export class Meter implements api.Meter { - private readonly _logger: Logger; private readonly _batchObservers: BatchObserver[] = []; private readonly _metrics = new Map>(); private readonly _processor: Processor; @@ -55,7 +54,6 @@ export class Meter implements api.Meter { config: MeterConfig = {} ) { const mergedConfig = merge({}, DEFAULT_CONFIG, config); - this._logger = mergedConfig.logger || new ConsoleLogger(config.logLevel); this._processor = mergedConfig.processor ?? new UngroupedProcessor(); this._resource = mergedConfig.resource || Resource.createTelemetrySDKResource(); @@ -76,13 +74,12 @@ export class Meter implements api.Meter { options?: api.MetricOptions ): api.ValueRecorder { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_VALUE_RECORDER_METRIC; } const opt: api.MetricOptions = { - logger: this._logger, ...DEFAULT_METRIC_OPTIONS, ...options, }; @@ -107,13 +104,12 @@ export class Meter implements api.Meter { */ createCounter(name: string, options?: api.MetricOptions): api.Counter { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_COUNTER_METRIC; } const opt: api.MetricOptions = { - logger: this._logger, ...DEFAULT_METRIC_OPTIONS, ...options, }; @@ -143,14 +139,13 @@ export class Meter implements api.Meter { options?: api.MetricOptions ): api.UpDownCounter { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_COUNTER_METRIC; } const opt: api.MetricOptions = { ...DEFAULT_METRIC_OPTIONS, - logger: this._logger, ...options, }; const upDownCounter = new UpDownCounterMetric( @@ -176,13 +171,12 @@ export class Meter implements api.Meter { callback?: (observerResult: api.ObserverResult) => unknown ): api.ValueObserver { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_VALUE_OBSERVER_METRIC; } const opt: api.MetricOptions = { - logger: this._logger, ...DEFAULT_METRIC_OPTIONS, ...options, }; @@ -204,13 +198,12 @@ export class Meter implements api.Meter { callback?: (observerResult: api.ObserverResult) => unknown ): api.SumObserver { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_SUM_OBSERVER_METRIC; } const opt: api.MetricOptions = { - logger: this._logger, ...DEFAULT_METRIC_OPTIONS, ...options, }; @@ -238,13 +231,12 @@ export class Meter implements api.Meter { callback?: (observerResult: api.ObserverResult) => unknown ): api.UpDownSumObserver { if (!this._isValidName(name)) { - this._logger.warn( + diag.warn( `Invalid metric name ${name}. Defaulting to noop metric implementation.` ); return api.NOOP_UP_DOWN_SUM_OBSERVER_METRIC; } const opt: api.MetricOptions = { - logger: this._logger, ...DEFAULT_METRIC_OPTIONS, ...options, }; @@ -270,7 +262,6 @@ export class Meter implements api.Meter { options: api.BatchObserverOptions = {} ): BatchObserver { const opt: api.BatchObserverOptions = { - logger: this._logger, ...options, }; const batchObserver = new BatchObserver(opt, callback); @@ -337,9 +328,7 @@ export class Meter implements api.Meter { metric: Metric ): void { if (this._metrics.has(name)) { - this._logger.error( - `A metric with the name ${name} has already been registered.` - ); + diag.error(`A metric with the name ${name} has already been registered.`); return; } this._metrics.set(name, metric); diff --git a/packages/opentelemetry-metrics/src/MeterProvider.ts b/packages/opentelemetry-metrics/src/MeterProvider.ts index 276d0045c1e..3b645b8a911 100644 --- a/packages/opentelemetry-metrics/src/MeterProvider.ts +++ b/packages/opentelemetry-metrics/src/MeterProvider.ts @@ -14,9 +14,7 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; -import { ConsoleLogger } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import { Meter } from '.'; import { DEFAULT_CONFIG, MeterConfig } from './types'; @@ -31,16 +29,12 @@ export class MeterProvider implements api.MeterProvider { private _shuttingDownPromise: Promise = Promise.resolve(); private _isShutdown = false; readonly resource: Resource; - readonly logger: Logger; constructor(config: MeterConfig = {}) { const mergedConfig = merge({}, DEFAULT_CONFIG, config); - this.logger = - mergedConfig.logger ?? new ConsoleLogger(mergedConfig.logLevel); this.resource = mergedConfig.resource ?? Resource.createTelemetrySDKResource(); this._config = Object.assign({}, mergedConfig, { - logger: this.logger, resource: this.resource, }); } diff --git a/packages/opentelemetry-metrics/src/Metric.ts b/packages/opentelemetry-metrics/src/Metric.ts index cc88f369d53..e806924652e 100644 --- a/packages/opentelemetry-metrics/src/Metric.ts +++ b/packages/opentelemetry-metrics/src/Metric.ts @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Logger, NoopLogger } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; import { InstrumentationLibrary } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; @@ -26,7 +25,6 @@ export abstract class Metric implements api.UnboundMetric { protected readonly _disabled: boolean; protected readonly _valueType: api.ValueType; - protected readonly _logger: Logger; protected readonly _descriptor: MetricDescriptor; protected readonly _boundaries: number[] | undefined; private readonly _instruments: Map = new Map(); @@ -43,7 +41,6 @@ export abstract class Metric typeof _options.valueType === 'number' ? _options.valueType : api.ValueType.DOUBLE; - this._logger = _options.logger ?? new NoopLogger(); this._boundaries = _options.boundaries; this._descriptor = this._getMetricDescriptor(); } diff --git a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts index cac09f0c91b..36650b2336b 100644 --- a/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts +++ b/packages/opentelemetry-metrics/src/UpDownCounterMetric.ts @@ -46,7 +46,6 @@ export class UpDownCounterMetric labels, this._disabled, this._valueType, - this._logger, this._processor.aggregatorFor(this._descriptor) ); } diff --git a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts index cf80e876b82..cda854d8ede 100644 --- a/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts +++ b/packages/opentelemetry-metrics/src/ValueRecorderMetric.ts @@ -47,7 +47,6 @@ export class ValueRecorderMetric labels, this._disabled, this._valueType, - this._logger, this._processor.aggregatorFor(this._descriptor) ); } diff --git a/packages/opentelemetry-metrics/src/types.ts b/packages/opentelemetry-metrics/src/types.ts index bc063dc70f5..a9385a3268a 100644 --- a/packages/opentelemetry-metrics/src/types.ts +++ b/packages/opentelemetry-metrics/src/types.ts @@ -14,21 +14,13 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; -import { getEnv, LogLevel } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; import { Processor } from './export/Processor'; import { MetricExporter } from './export/types'; /** MeterConfig provides an interface for configuring a Meter. */ export interface MeterConfig { - /** User provided logger. */ - logger?: Logger; - - /** level of logger. */ - logLevel?: LogLevel; - /** Metric exporter. */ exporter?: MetricExporter; @@ -43,9 +35,7 @@ export interface MeterConfig { } /** Default Meter configuration. */ -export const DEFAULT_CONFIG = { - logLevel: getEnv().OTEL_LOG_LEVEL, -}; +export const DEFAULT_CONFIG = {}; /** The default metric creation options value. */ export const DEFAULT_METRIC_OPTIONS = { diff --git a/packages/opentelemetry-metrics/test/Meter.test.ts b/packages/opentelemetry-metrics/test/Meter.test.ts index 7827d74e17e..aafbb610959 100644 --- a/packages/opentelemetry-metrics/test/Meter.test.ts +++ b/packages/opentelemetry-metrics/test/Meter.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; +import { diag } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; import { hrTime, hrTimeToNanoseconds } from '@opentelemetry/core'; import { Resource } from '@opentelemetry/resources'; @@ -79,9 +79,9 @@ describe('Meter', () => { const labels: api.Labels = { [keyb]: 'value2', [keya]: 'value1' }; beforeEach(() => { - meter = new MeterProvider({ - logger: new NoopLogger(), - }).getMeter('test-meter'); + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap warn which is already wrapped + diag.setLogger(); + meter = new MeterProvider().getMeter('test-meter'); }); describe('#counter', () => { @@ -772,13 +772,19 @@ describe('Meter', () => { }); describe('#SumObserverMetric', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); + it('should create an Sum observer', () => { const sumObserver = meter.createSumObserver('name') as SumObserverMetric; assert.ok(sumObserver instanceof Metric); }); it('should return noop observer when name is invalid', () => { - const spy = sinon.stub(meter['_logger'], 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spy = sinon.stub(diag.getLogger(), 'warn'); const sumObserver = meter.createSumObserver('na me'); assert.ok(sumObserver === api.NOOP_SUM_OBSERVER_METRIC); const args = spy.args[0]; @@ -911,6 +917,11 @@ describe('Meter', () => { }); describe('#ValueObserver', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); + it('should create a value observer', () => { const valueObserver = meter.createValueObserver( 'name' @@ -919,7 +930,8 @@ describe('Meter', () => { }); it('should return noop observer when name is invalid', () => { - const spy = sinon.stub(meter['_logger'], 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spy = sinon.stub(diag.getLogger(), 'warn'); const valueObserver = meter.createValueObserver('na me'); assert.ok(valueObserver === api.NOOP_VALUE_OBSERVER_METRIC); const args = spy.args[0]; @@ -992,6 +1004,11 @@ describe('Meter', () => { }); describe('#UpDownSumObserverMetric', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap xxxx which is already wrapped + diag.setLogger(); + }); + it('should create an UpDownSum observer', () => { const upDownSumObserver = meter.createUpDownSumObserver( 'name' @@ -1000,7 +1017,8 @@ describe('Meter', () => { }); it('should return noop observer when name is invalid', () => { - const spy = sinon.stub(meter['_logger'], 'warn'); + // Need to stub/spy on the underlying logger as the "diag" instance is global + const spy = sinon.stub(diag.getLogger(), 'warn'); const upDownSumObserver = meter.createUpDownSumObserver('na me'); assert.ok(upDownSumObserver === api.NOOP_UP_DOWN_SUM_OBSERVER_METRIC); const args = spy.args[0]; diff --git a/packages/opentelemetry-metrics/test/MeterProvider.test.ts b/packages/opentelemetry-metrics/test/MeterProvider.test.ts index 426ceebd969..98407e675be 100644 --- a/packages/opentelemetry-metrics/test/MeterProvider.test.ts +++ b/packages/opentelemetry-metrics/test/MeterProvider.test.ts @@ -17,7 +17,6 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import { MeterProvider, Meter, CounterMetric } from '../src'; -import { NoopLogger } from '@opentelemetry/api'; describe('MeterProvider', () => { describe('constructor', () => { @@ -27,9 +26,7 @@ describe('MeterProvider', () => { }); it('should construct an instance with logger', () => { - const provider = new MeterProvider({ - logger: new NoopLogger(), - }); + const provider = new MeterProvider(); assert.ok(provider instanceof MeterProvider); }); }); diff --git a/packages/opentelemetry-metrics/test/Processor.test.ts b/packages/opentelemetry-metrics/test/Processor.test.ts index a766a93a149..cd2ac2c4df2 100644 --- a/packages/opentelemetry-metrics/test/Processor.test.ts +++ b/packages/opentelemetry-metrics/test/Processor.test.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; import * as api from '@opentelemetry/api-metrics'; import * as assert from 'assert'; import { Meter, MeterProvider } from '../src'; @@ -27,7 +26,6 @@ describe('Processor', () => { let counter: api.Counter; beforeEach(() => { meter = new MeterProvider({ - logger: new NoopLogger(), interval: 10000, }).getMeter('test-meter'); counter = meter.createCounter('ungrouped-processor-test'); diff --git a/packages/opentelemetry-node/src/NodeTracerProvider.ts b/packages/opentelemetry-node/src/NodeTracerProvider.ts index 4178995ee2f..7afc9866727 100644 --- a/packages/opentelemetry-node/src/NodeTracerProvider.ts +++ b/packages/opentelemetry-node/src/NodeTracerProvider.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { AsyncHooksContextManager, AsyncLocalStorageContextManager, @@ -36,7 +37,7 @@ export class NodeTracerProvider extends BasicTracerProvider { constructor(config: NodeTracerConfig = {}) { super(config); if (config.plugins) { - console.warn( + diag.warn( 'plugins options was removed, please use' + ' "registerInstrumentations" to load plugins' ); diff --git a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts index 2ebf4b75743..c8105f2ffea 100644 --- a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts +++ b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts @@ -17,10 +17,10 @@ import { context, TraceFlags, - NoopLogger, setSpan, setSpanContext, getSpan, + diag, } from '@opentelemetry/api'; import { AlwaysOnSampler, AlwaysOffSampler } from '@opentelemetry/core'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; @@ -53,6 +53,8 @@ describe('NodeTracerProvider', () => { beforeEach(() => { contextManager = new AsyncHooksContextManager(); context.setGlobalContextManager(contextManager.enable()); + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap warn which is already wrapped + diag.setLogger(); }); afterEach(() => { @@ -63,15 +65,18 @@ describe('NodeTracerProvider', () => { }); describe('constructor', () => { + beforeEach(() => { + // Set no logger so that sinon doesn't complain about TypeError: Attempted to wrap warn which is already wrapped + diag.setLogger(); + }); + it('should construct an instance with required only options', () => { provider = new NodeTracerProvider(); assert.ok(provider instanceof NodeTracerProvider); }); it('should construct an instance with logger', () => { - provider = new NodeTracerProvider({ - logger: new NoopLogger(), - }); + provider = new NodeTracerProvider(); assert.ok(provider instanceof NodeTracerProvider); }); @@ -84,7 +89,7 @@ describe('NodeTracerProvider', () => { it('should show warning when plugins are defined', () => { const dummyPlugin1 = {}; - const spyWarn = sinon.spy(console, 'warn'); + const spyWarn = sinon.spy(diag.getLogger(), 'warn'); const plugins = [dummyPlugin1]; const options = { plugins }; @@ -99,17 +104,13 @@ describe('NodeTracerProvider', () => { describe('.startSpan()', () => { it('should start a span with name only', () => { - provider = new NodeTracerProvider({ - logger: new NoopLogger(), - }); + provider = new NodeTracerProvider(); const span = provider.getTracer('default').startSpan('my-span'); assert.ok(span); }); it('should start a span with name and options', () => { - provider = new NodeTracerProvider({ - logger: new NoopLogger(), - }); + provider = new NodeTracerProvider(); const span = provider.getTracer('default').startSpan('my-span', {}); assert.ok(span); }); @@ -117,7 +118,6 @@ describe('NodeTracerProvider', () => { it('should return a default span with no sampling (AlwaysOffSampler)', () => { provider = new NodeTracerProvider({ sampler: new AlwaysOffSampler(), - logger: new NoopLogger(), }); const span = provider.getTracer('default').startSpan('my-span'); assert.strictEqual(span.context().traceFlags, TraceFlags.NONE); @@ -127,7 +127,6 @@ describe('NodeTracerProvider', () => { it('should start a recording span with always sampling (AlwaysOnSampler)', () => { provider = new NodeTracerProvider({ sampler: new AlwaysOnSampler(), - logger: new NoopLogger(), }); const span = provider.getTracer('default').startSpan('my-span'); assert.ok(span instanceof Span); @@ -138,7 +137,6 @@ describe('NodeTracerProvider', () => { it('should sample with AlwaysOnSampler if parent was not sampled', () => { provider = new NodeTracerProvider({ sampler: new AlwaysOnSampler(), - logger: new NoopLogger(), }); const sampledParent = provider.getTracer('default').startSpan( @@ -166,9 +164,7 @@ describe('NodeTracerProvider', () => { }); it('should assign resource to span', () => { - provider = new NodeTracerProvider({ - logger: new NoopLogger(), - }); + provider = new NodeTracerProvider(); const span = provider.getTracer('default').startSpan('my-span') as Span; assert.ok(span); assert.ok(span.resource instanceof Resource); diff --git a/packages/opentelemetry-plugin-grpc-js/src/client/loadPackageDefinition.ts b/packages/opentelemetry-plugin-grpc-js/src/client/loadPackageDefinition.ts index f3bbc1f0e9a..f300d5d9d34 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/client/loadPackageDefinition.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/client/loadPackageDefinition.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { GrpcJsPlugin } from '../grpcJs'; import type * as grpcJs from '@grpc/grpc-js'; import type { PackageDefinition } from '@grpc/grpc-js/build/src/make-client'; @@ -28,7 +29,7 @@ export function patchLoadPackageDefinition(this: GrpcJsPlugin) { return (original: typeof grpcJs.loadPackageDefinition) => { const plugin = this; - plugin._logger.debug('patching loadPackageDefinition'); + diag.debug('patching loadPackageDefinition'); return function patchedLoadPackageDefinition( this: null, diff --git a/packages/opentelemetry-plugin-grpc-js/src/client/patchClient.ts b/packages/opentelemetry-plugin-grpc-js/src/client/patchClient.ts index 5685c18fa42..795c51d7705 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/client/patchClient.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/client/patchClient.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { GrpcJsPlugin } from '../grpcJs'; import type * as grpcJs from '@grpc/grpc-js'; import * as shimmer from 'shimmer'; @@ -30,7 +31,7 @@ export function patchClient( ): (original: MakeClientConstructorFunction) => MakeClientConstructorFunction { const plugin = this; return (original: MakeClientConstructorFunction) => { - plugin._logger.debug('patching client'); + diag.debug('patching client'); return function makeClientConstructor( this: typeof grpcJs.Client, methods: grpcJs.ServiceDefinition, diff --git a/packages/opentelemetry-plugin-grpc-js/src/client/utils.ts b/packages/opentelemetry-plugin-grpc-js/src/client/utils.ts index fbd448e95e9..dc696b88fb6 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/client/utils.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/client/utils.ts @@ -24,6 +24,7 @@ import { propagation, context, setSpan, + diag, } from '@opentelemetry/api'; import { RpcAttribute } from '@opentelemetry/semantic-conventions'; import type * as grpcJs from '@grpc/grpc-js'; @@ -73,7 +74,7 @@ export function getPatchedClientMethods( ): (original: GrpcClientFunc) => () => EventEmitter { const plugin = this; return (original: GrpcClientFunc) => { - plugin._logger.debug('patch all client methods'); + diag.debug('patch all client methods'); return function clientMethodTrace(this: grpcJs.Client) { const name = `grpc.${original.path.replace('/', '')}`; const args = [...arguments]; diff --git a/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts b/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts index c95db012f36..ed647040d60 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/grpcJs.ts @@ -20,7 +20,7 @@ import * as shimmer from 'shimmer'; import { patchClient, patchLoadPackageDefinition } from './client'; import { patchServer } from './server'; import { VERSION } from './version'; -import { Tracer, Logger } from '@opentelemetry/api'; +import { diag, Tracer } from '@opentelemetry/api'; import { GrpcPluginOptions } from './types'; /** @@ -47,15 +47,6 @@ export class GrpcJsPlugin extends BasePlugin { return this._tracer; } - /** - * @internal - * Public reference to the protected BasePlugin `_logger` instance to be used by this - * plugin's external helper functions - */ - get logger(): Logger { - return this._logger; - } - protected patch(): typeof grpcJs { // Patch Server methods shimmer.wrap( @@ -85,11 +76,7 @@ export class GrpcJsPlugin extends BasePlugin { } protected unpatch(): void { - this._logger.debug( - 'removing patch to %s@%s', - this.moduleName, - this.version - ); + diag.debug('removing patch to %s@%s', this.moduleName, this.version); // Unpatch server shimmer.unwrap(this._moduleExports.Server.prototype, 'register'); diff --git a/packages/opentelemetry-plugin-grpc-js/src/server/patchServer.ts b/packages/opentelemetry-plugin-grpc-js/src/server/patchServer.ts index efad948e9cf..06ff464dfe5 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/server/patchServer.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/server/patchServer.ts @@ -31,6 +31,7 @@ import { Span, ROOT_CONTEXT, setSpan, + diag, } from '@opentelemetry/api'; import { RpcAttribute } from '@opentelemetry/semantic-conventions'; import { clientStreamAndUnaryHandler } from './clientStreamAndUnary'; @@ -50,7 +51,7 @@ export function patchServer( const plugin = this; const config = this._config; - plugin.logger.debug('patched gRPC server'); + diag.debug('patched gRPC server'); return function register( this: grpcJs.Server, name: string, @@ -100,7 +101,7 @@ export function patchServer( kind: SpanKind.SERVER, }; - plugin.logger.debug('patch func: %s', JSON.stringify(spanOptions)); + diag.debug('patch func: %s', JSON.stringify(spanOptions)); context.with( propagation.extract(ROOT_CONTEXT, call.metadata, { diff --git a/packages/opentelemetry-plugin-grpc/src/grpc.ts b/packages/opentelemetry-plugin-grpc/src/grpc.ts index f27e9c18aca..9836d8bd229 100644 --- a/packages/opentelemetry-plugin-grpc/src/grpc.ts +++ b/packages/opentelemetry-plugin-grpc/src/grpc.ts @@ -24,6 +24,7 @@ import { SpanStatus, ROOT_CONTEXT, setSpan, + diag, } from '@opentelemetry/api'; import { RpcAttribute } from '@opentelemetry/semantic-conventions'; import { BasePlugin } from '@opentelemetry/core'; @@ -71,11 +72,7 @@ export class GrpcPlugin extends BasePlugin { protected readonly _basedir = basedir; protected patch(): typeof grpcTypes { - this._logger.debug( - 'applying patch to %s@%s', - this.moduleName, - this.version - ); + diag.debug('applying patch to %s@%s', this.moduleName, this.version); if (this._moduleExports.Server) { shimmer.wrap( @@ -108,11 +105,7 @@ export class GrpcPlugin extends BasePlugin { return this._moduleExports; } protected unpatch(): void { - this._logger.debug( - 'removing patch to %s@%s', - this.moduleName, - this.version - ); + diag.debug('removing patch to %s@%s', this.moduleName, this.version); if (this._moduleExports.Server) { shimmer.unwrap(this._moduleExports.Server.prototype, 'register'); @@ -134,7 +127,7 @@ export class GrpcPlugin extends BasePlugin { private _patchServer() { return (originalRegister: typeof grpcTypes.Server.prototype.register) => { const plugin = this; - plugin._logger.debug('patched gRPC server'); + diag.debug('patched gRPC server'); return function register( this: grpcTypes.Server & { handlers: any }, @@ -178,10 +171,7 @@ export class GrpcPlugin extends BasePlugin { kind: SpanKind.SERVER, }; - plugin._logger.debug( - 'patch func: %s', - JSON.stringify(spanOptions) - ); + diag.debug('patch func: %s', JSON.stringify(spanOptions)); context.with( propagation.extract(ROOT_CONTEXT, call.metadata, { @@ -340,7 +330,7 @@ export class GrpcPlugin extends BasePlugin { private _patchClient() { const plugin = this; return (original: typeof grpcTypes.makeGenericClientConstructor): never => { - plugin._logger.debug('patching client'); + diag.debug('patching client'); return function makeClientConstructor( this: typeof grpcTypes.Client, methods: { [key: string]: { originalName?: string } }, @@ -385,7 +375,7 @@ export class GrpcPlugin extends BasePlugin { private _getPatchedClientMethods() { const plugin = this; return (original: GrpcClientFunc) => { - plugin._logger.debug('patch all client methods'); + diag.debug('patch all client methods'); return function clientMethodTrace(this: grpcTypes.Client) { const name = `grpc.${original.path.replace('/', '')}`; const args = Array.prototype.slice.call(arguments); diff --git a/packages/opentelemetry-plugin-http/src/http.ts b/packages/opentelemetry-plugin-http/src/http.ts index 1efeb33dc10..1831745b53a 100644 --- a/packages/opentelemetry-plugin-http/src/http.ts +++ b/packages/opentelemetry-plugin-http/src/http.ts @@ -26,6 +26,7 @@ import { getSpan, suppressInstrumentation, NOOP_TRACER, + diag, } from '@opentelemetry/api'; import { BasePlugin } from '@opentelemetry/core'; import type { @@ -69,11 +70,7 @@ export class HttpPlugin extends BasePlugin { /** Patches HTTP incoming and outcoming request functions. */ protected patch() { - this._logger.debug( - 'applying patch to %s@%s', - this.moduleName, - this.version - ); + diag.debug('applying patch to %s@%s', this.moduleName, this.version); shimmer.wrap( this._moduleExports, @@ -102,7 +99,7 @@ export class HttpPlugin extends BasePlugin { this._getPatchIncomingRequestFunction() ); } else { - this._logger.error( + diag.error( 'Could not apply patch to %s.emit. Interface is not as expected.', this.moduleName ); @@ -210,9 +207,9 @@ export class HttpPlugin extends BasePlugin { } context.bind(response); - this._logger.debug('outgoingRequest on response()'); + diag.debug('outgoingRequest on response()'); response.on('end', () => { - this._logger.debug('outgoingRequest on end()'); + diag.debug('outgoingRequest on end()'); let status: SpanStatus; if (response.aborted && !response.complete) { @@ -254,7 +251,7 @@ export class HttpPlugin extends BasePlugin { this._closeHttpSpan(span); }); - this._logger.debug('_traceClientRequest return request'); + diag.debug('_traceClientRequest return request'); return request; } @@ -279,14 +276,13 @@ export class HttpPlugin extends BasePlugin { : '/'; const method = request.method || 'GET'; - plugin._logger.debug('%s plugin incomingRequest', plugin.moduleName); + diag.debug('%s plugin incomingRequest', plugin.moduleName); if ( utils.isIgnored( pathname, plugin._config.ignoreIncomingPaths, - (e: Error) => - plugin._logger.error('caught ignoreIncomingPaths error: ', e) + (e: Error) => diag.error('caught ignoreIncomingPaths error: ', e) ) ) { return context.with(suppressInstrumentation(context.active()), () => { @@ -398,8 +394,7 @@ export class HttpPlugin extends BasePlugin { utils.isIgnored( origin + pathname, plugin._config.ignoreOutgoingUrls, - (e: Error) => - plugin._logger.error('caught ignoreOutgoingUrls error: ', e) + (e: Error) => diag.error('caught ignoreOutgoingUrls error: ', e) ) ) { return original.apply(this, [optionsParsed, ...args]); @@ -424,7 +419,7 @@ export class HttpPlugin extends BasePlugin { true ); - plugin._logger.debug('%s plugin outgoingRequest', plugin.moduleName); + diag.debug('%s plugin outgoingRequest', plugin.moduleName); context.bind(request); return plugin._traceClientRequest(request, optionsParsed, span); }; @@ -508,7 +503,7 @@ export class HttpPlugin extends BasePlugin { this._closeHttpSpan(span); throw error; } - this._logger.error('caught error ', error); + diag.error('caught error ', error); } } } 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 55b057dbc69..d3f4db83997 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-disable.test.ts @@ -13,11 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { - NoopTracerProvider, - NoopLogger, - NOOP_TRACER, -} from '@opentelemetry/api'; +import { NoopTracerProvider, NOOP_TRACER } from '@opentelemetry/api'; import * as assert from 'assert'; import * as http from 'http'; import { AddressInfo } from 'net'; @@ -31,13 +27,12 @@ describe('HttpPlugin', () => { let serverPort = 0; describe('disable()', () => { - const logger = new NoopLogger(); const provider = new NoopTracerProvider(); before(() => { nock.cleanAll(); nock.enableNetConnect(); - plugin.enable(http, provider, logger); + plugin.enable(http, provider); // Ensure that http module is patched. assert.strictEqual(http.Server.prototype.emit.__wrapped, true); server = http.createServer((request, response) => { 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 f2411bf9e39..4514655a60f 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-enable.test.ts @@ -19,7 +19,6 @@ import { propagation, Span as ISpan, SpanKind, - NoopLogger, getSpan, setSpan, } from '@opentelemetry/api'; @@ -55,10 +54,7 @@ const hostname = 'localhost'; const pathname = '/test'; const serverName = 'my.server.name'; const memoryExporter = new InMemorySpanExporter(); -const logger = new NoopLogger(); -const provider = new NodeTracerProvider({ - logger, -}); +const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); propagation.setGlobalPropagator(new DummyPropagation()); @@ -145,7 +141,7 @@ describe('HttpPlugin', () => { plugin.component, process.versions.node ); - pluginWithBadOptions.enable(http, provider, provider.logger, config); + pluginWithBadOptions.enable(http, provider, config); server = http.createServer((request, response) => { response.end('Test Server Response'); }); @@ -209,7 +205,7 @@ describe('HttpPlugin', () => { responseHook: responseHookFunction, serverName, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); server = http.createServer((request, response) => { if (request.url?.includes('/ignored')) { provider.getTracer('test').startSpan('some-span').end(); @@ -233,7 +229,7 @@ describe('HttpPlugin', () => { const httpNotPatched = new HttpPlugin( plugin.component, process.versions.node - ).enable({} as Http, provider, provider.logger, {}); + ).enable({} as Http, provider, {}); assert.strictEqual(Object.keys(httpNotPatched).length, 0); }); @@ -727,7 +723,7 @@ describe('HttpPlugin', () => { describe('with require parent span', () => { beforeEach(done => { memoryExporter.reset(); - plugin.enable(http, provider, provider.logger, {}); + plugin.enable(http, provider, {}); server = http.createServer((request, response) => { response.end('Test Server Response'); }); @@ -745,7 +741,7 @@ describe('HttpPlugin', () => { requireParentforIncomingSpans: true, requireParentforOutgoingSpans: true, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); const testPath = '/test/test'; await httpRequest.get( `${protocol}://${hostname}:${serverPort}${testPath}` @@ -759,7 +755,7 @@ describe('HttpPlugin', () => { const config: HttpPluginConfig = { requireParentforOutgoingSpans: true, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); const testPath = '/test/test'; const result = await httpRequest.get( `${protocol}://${hostname}:${serverPort}${testPath}` @@ -783,7 +779,7 @@ describe('HttpPlugin', () => { const config: HttpPluginConfig = { requireParentforIncomingSpans: true, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); const testPath = '/test/test'; const result = await httpRequest.get( `${protocol}://${hostname}:${serverPort}${testPath}` @@ -808,7 +804,7 @@ describe('HttpPlugin', () => { requireParentforIncomingSpans: true, requireParentforOutgoingSpans: true, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); const testPath = '/test/test'; const tracer = provider.getTracer('default'); const span = tracer.startSpan('parentSpan', { 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 85396d33b0e..be05279d9a4 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/http-package.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { context, SpanKind, NoopLogger } from '@opentelemetry/api'; +import { context, SpanKind } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NodeTracerProvider } from '@opentelemetry/node'; import { @@ -90,10 +90,7 @@ describe('Packages', () => { context.disable(); }); describe('get', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -103,7 +100,7 @@ describe('Packages', () => { const config: HttpPluginConfig = { applyCustomAttributesOnSpan: customAttributeFunction, }; - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); }); after(() => { diff --git a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts index 2be3f7ab0b3..e47a35be817 100644 --- a/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts +++ b/packages/opentelemetry-plugin-http/test/functionals/utils.test.ts @@ -19,7 +19,6 @@ import { ROOT_CONTEXT, SpanKind, TraceFlags, - NoopLogger, } from '@opentelemetry/api'; import { BasicTracerProvider, Span } from '@opentelemetry/tracing'; import { HttpAttribute } from '@opentelemetry/semantic-conventions'; @@ -170,9 +169,8 @@ describe('Utility', () => { it('should not re-throw when function throws an exception', () => { satisfiesPatternStub.restore(); - const log = new NoopLogger(); const onException = (e: Error) => { - log.error('error', e); + // Do Nothing }; for (const callback of [undefined, onException]) { assert.doesNotThrow(() => 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 9552c2a97cd..88ec7d214f0 100644 --- a/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts +++ b/packages/opentelemetry-plugin-http/test/integrations/http-enable.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { SpanKind, Span, context, NoopLogger } from '@opentelemetry/api'; +import { SpanKind, Span, context } from '@opentelemetry/api'; import { HttpAttribute, GeneralAttribute, @@ -111,10 +111,7 @@ describe('HttpPlugin Integration tests', () => { }); }); - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -134,7 +131,7 @@ describe('HttpPlugin Integration tests', () => { try { plugin.disable(); } catch (e) {} - plugin.enable(http, provider, provider.logger, config); + plugin.enable(http, provider, config); }); after(() => { diff --git a/packages/opentelemetry-plugin-https/src/https.ts b/packages/opentelemetry-plugin-https/src/https.ts index 40dc543a9a1..1b31b2178e6 100644 --- a/packages/opentelemetry-plugin-https/src/https.ts +++ b/packages/opentelemetry-plugin-https/src/https.ts @@ -14,6 +14,7 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { HttpPlugin, Func, HttpRequestArgs } from '@opentelemetry/plugin-http'; import type * as http from 'http'; import type * as https from 'https'; @@ -34,11 +35,7 @@ export class HttpsPlugin extends HttpPlugin { * Patches HTTPS incoming and outcoming request functions. */ protected patch() { - this._logger.debug( - 'applying patch to %s@%s', - this.moduleName, - this.version - ); + diag.debug('applying patch to %s@%s', this.moduleName, this.version); if ( this._moduleExports && @@ -51,7 +48,7 @@ export class HttpsPlugin extends HttpPlugin { this._getPatchIncomingRequestFunction() ); } else { - this._logger.error( + diag.error( 'Could not apply patch to %s.emit. Interface is not as expected.', this.moduleName ); 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 01b9b719002..88140d73abf 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-disable.test.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -import { NoopLogger } from '@opentelemetry/api'; import { Http } from '@opentelemetry/plugin-http'; import * as assert from 'assert'; import * as fs from 'fs'; @@ -32,17 +31,14 @@ describe('HttpsPlugin', () => { let serverPort = 0; describe('disable()', () => { - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); // const tracer = provider.getTracer('test-https') let tracer: api.Tracer; before(() => { nock.cleanAll(); nock.enableNetConnect(); - plugin.enable((https as unknown) as Http, provider, provider.logger); + plugin.enable((https as unknown) as Http, provider); tracer = plugin['_tracer']; // Ensure that https module is patched. assert.strictEqual(https.Server.prototype.emit.__wrapped, true); 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 fcab8d8a64e..3c3c5911bbf 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-enable.test.ts @@ -20,7 +20,6 @@ import { propagation, Span as ISpan, SpanKind, - NoopLogger, setSpan, } from '@opentelemetry/api'; import { NodeTracerProvider } from '@opentelemetry/node'; @@ -56,10 +55,7 @@ const hostname = 'localhost'; const serverName = 'my.server.name'; const pathname = '/test'; const memoryExporter = new InMemorySpanExporter(); -const logger = new NoopLogger(); -const provider = new NodeTracerProvider({ - logger, -}); +const provider = new NodeTracerProvider(); const tracer = provider.getTracer('test-https'); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); propagation.setGlobalPropagator(new DummyPropagation()); @@ -134,7 +130,6 @@ describe('HttpsPlugin', () => { pluginWithBadOptions.enable( (https as unknown) as Http, provider, - tracer.logger, config ); server = https.createServer( @@ -204,12 +199,7 @@ describe('HttpsPlugin', () => { applyCustomAttributesOnSpan: customAttributeFunction, serverName, }; - plugin.enable( - (https as unknown) as Http, - provider, - tracer.logger, - config - ); + plugin.enable((https as unknown) as Http, provider, config); server = https.createServer( { key: fs.readFileSync('test/fixtures/server-key.pem'), @@ -239,7 +229,6 @@ describe('HttpsPlugin', () => { const httpsNotPatched = new HttpsPlugin(process.versions.node).enable( {} as Http, provider, - tracer.logger, {} ); assert.strictEqual(Object.keys(httpsNotPatched).length, 0); 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 8fed01b8fe0..e742977e867 100644 --- a/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts +++ b/packages/opentelemetry-plugin-https/test/functionals/https-package.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { context, Span, SpanKind, NoopLogger } from '@opentelemetry/api'; +import { context, Span, SpanKind } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NodeTracerProvider } from '@opentelemetry/node'; import { Http } from '@opentelemetry/plugin-http'; @@ -105,18 +105,14 @@ describe('Packages', () => { context.disable(); }); describe('get', () => { - const logger = new NoopLogger(); - - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); }); before(() => { - plugin.enable((https as unknown) as Http, provider, provider.logger); + plugin.enable((https as unknown) as Http, provider); }); after(() => { 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 74a3bbea162..74a247e909e 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -15,7 +15,7 @@ */ import { HttpPluginConfig, Http } from '@opentelemetry/plugin-http'; -import { SpanKind, Span, context, NoopLogger } from '@opentelemetry/api'; +import { SpanKind, Span, context } from '@opentelemetry/api'; import { HttpAttribute, GeneralAttribute, @@ -125,10 +125,7 @@ describe('HttpsPlugin Integration tests', () => { done(); }); }); - const logger = new NoopLogger(); - const provider = new NodeTracerProvider({ - logger, - }); + const provider = new NodeTracerProvider(); provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); beforeEach(() => { memoryExporter.reset(); @@ -148,12 +145,7 @@ describe('HttpsPlugin Integration tests', () => { try { plugin.disable(); } catch (e) {} - plugin.enable( - (https as unknown) as Http, - provider, - provider.logger, - config - ); + plugin.enable((https as unknown) as Http, provider, config); }); after(() => { diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts index f50225857b9..0cfdc3c102f 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsBeanstalkDetector.ts @@ -14,11 +14,12 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { Detector, Resource, SERVICE_RESOURCE, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, } from '@opentelemetry/resources'; import * as fs from 'fs'; import * as util from 'util'; @@ -50,7 +51,7 @@ export class AwsBeanstalkDetector implements Detector { } } - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { try { await AwsBeanstalkDetector.fileAccessAsync( this.BEANSTALK_CONF_PATH, @@ -70,7 +71,7 @@ export class AwsBeanstalkDetector implements Detector { [SERVICE_RESOURCE.INSTANCE_ID]: parsedData.deployment_id, }); } catch (e) { - config.logger.debug(`AwsBeanstalkDetector failed: ${e.message}`); + diag.debug(`AwsBeanstalkDetector failed: ${e.message}`); return Resource.empty(); } } diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts index 6acd62e4ad3..ef2db49fe5f 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEc2Detector.ts @@ -19,7 +19,7 @@ import { Resource, CLOUD_RESOURCE, HOST_RESOURCE, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, } from '@opentelemetry/resources'; import * as http from 'http'; @@ -50,9 +50,9 @@ class AwsEc2Detector implements Detector { * empty {@link Resource} if the connection or parsing of the identity * document fails. * - * @param config (unused) The resource detection config with a required logger + * @param config (unused) The resource detection config */ - async detect(_config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { const token = await this._fetchToken(); const { accountId, diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts index 32088322e48..28de093d0a6 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEcsDetector.ts @@ -14,10 +14,11 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { Detector, Resource, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, CONTAINER_RESOURCE, } from '@opentelemetry/resources'; import * as util from 'util'; @@ -35,15 +36,15 @@ export class AwsEcsDetector implements Detector { readonly DEFAULT_CGROUP_PATH = '/proc/self/cgroup'; private static readFileAsync = util.promisify(fs.readFile); - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { const env = getEnv(); if (!env.ECS_CONTAINER_METADATA_URI_V4 && !env.ECS_CONTAINER_METADATA_URI) { - config.logger.debug('AwsEcsDetector failed: Process is not on ECS'); + diag.debug('AwsEcsDetector failed: Process is not on ECS'); return Resource.empty(); } const hostName = os.hostname(); - const containerId = await this._getContainerId(config); + const containerId = await this._getContainerId(); return !hostName && !containerId ? Resource.empty() @@ -60,9 +61,7 @@ export class AwsEcsDetector implements Detector { * we do not throw an error but throw warning message * and then return null string */ - private async _getContainerId( - config: ResourceDetectionConfigWithLogger - ): Promise { + private async _getContainerId(): Promise { try { const rawData = await AwsEcsDetector.readFileAsync( this.DEFAULT_CGROUP_PATH, @@ -75,9 +74,7 @@ export class AwsEcsDetector implements Detector { } } } catch (e) { - config.logger.warn( - `AwsEcsDetector failed to read container ID: ${e.message}` - ); + diag.warn(`AwsEcsDetector failed to read container ID: ${e.message}`); } return undefined; } diff --git a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts index 5060b7d524a..54c0f63bb6b 100644 --- a/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts +++ b/packages/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts @@ -19,11 +19,12 @@ import { Resource, CONTAINER_RESOURCE, K8S_RESOURCE, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, } from '@opentelemetry/resources'; import * as https from 'https'; import * as fs from 'fs'; import * as util from 'util'; +import { diag } from '@opentelemetry/api'; /** * The AwsEksDetector can be used to detect if a process is running in AWS Elastic @@ -58,19 +59,19 @@ export class AwsEksDetector implements Detector { * populated with instance metadata. Returns a promise containing an * empty {@link Resource} if the connection to kubernetes process * or aws config maps fails - * @param config The resource detection config with a required logger + * @param config The resource detection config */ - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { try { await AwsEksDetector.fileAccessAsync(this.K8S_TOKEN_PATH); const k8scert = await AwsEksDetector.readFileAsync(this.K8S_CERT_PATH); - if (!this._isEks(config, k8scert)) { + if (!this._isEks(k8scert)) { return Resource.empty(); } - const containerId = await this._getContainerId(config); - const clusterName = await this._getClusterName(config, k8scert); + const containerId = await this._getContainerId(); + const clusterName = await this._getClusterName(k8scert); return !containerId && !clusterName ? Resource.empty() @@ -79,7 +80,7 @@ export class AwsEksDetector implements Detector { [CONTAINER_RESOURCE.ID]: containerId || '', }); } catch (e) { - config.logger.warn('Process is not running on K8S', e); + diag.warn('Process is not running on K8S', e); return Resource.empty(); } } @@ -88,16 +89,12 @@ export class AwsEksDetector implements Detector { * Attempts to make a connection to AWS Config map which will * determine whether the process is running on an EKS * process if the config map is empty or not - * @param config The resource detection config with a required logger */ - private async _isEks( - config: ResourceDetectionConfigWithLogger, - cert: Buffer - ): Promise { + private async _isEks(cert: Buffer): Promise { const options = { ca: cert, headers: { - Authorization: await this._getK8sCredHeader(config), + Authorization: await this._getK8sCredHeader(), }, hostname: this.K8S_SVC_URL, method: 'GET', @@ -110,16 +107,12 @@ export class AwsEksDetector implements Detector { /** * Attempts to make a connection to Amazon Cloudwatch * Config Maps to grab cluster name - * @param config The resource detection config with a required logger */ - private async _getClusterName( - config: ResourceDetectionConfigWithLogger, - cert: Buffer - ): Promise { + private async _getClusterName(cert: Buffer): Promise { const options = { ca: cert, headers: { - Authorization: await this._getK8sCredHeader(config), + Authorization: await this._getK8sCredHeader(), }, host: this.K8S_SVC_URL, method: 'GET', @@ -130,18 +123,15 @@ export class AwsEksDetector implements Detector { try { return JSON.parse(response).data['cluster.name']; } catch (e) { - config.logger.warn('Cannot get cluster name on EKS', e); + diag.warn('Cannot get cluster name on EKS', e); } return ''; } /** * Reads the Kubernetes token path and returns kubernetes * credential header - * @param config The resource detection config with a required logger */ - private async _getK8sCredHeader( - config: ResourceDetectionConfigWithLogger - ): Promise { + private async _getK8sCredHeader(): Promise { try { const content = await AwsEksDetector.readFileAsync( this.K8S_TOKEN_PATH, @@ -149,7 +139,7 @@ export class AwsEksDetector implements Detector { ); return 'Bearer ' + content; } catch (e) { - config.logger.warn('Unable to read Kubernetes client token.', e); + diag.warn('Unable to read Kubernetes client token.', e); } return ''; } @@ -171,9 +161,7 @@ export class AwsEksDetector implements Detector { * not contain container ID we do not throw an error but throw warning message * and then return null string */ - private async _getContainerId( - config: ResourceDetectionConfigWithLogger - ): Promise { + private async _getContainerId(): Promise { try { const rawData = await AwsEksDetector.readFileAsync( this.DEFAULT_CGROUP_PATH, @@ -186,9 +174,7 @@ export class AwsEksDetector implements Detector { } } } catch (e) { - config.logger.warn( - `AwsEksDetector failed to read container ID: ${e.message}` - ); + diag.warn(`AwsEksDetector failed to read container ID: ${e.message}`); } return undefined; } diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts index f132a8015c9..4153276fbae 100644 --- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts +++ b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsBeanstalkDetector.test.ts @@ -21,7 +21,6 @@ import { assertEmptyResource, assertServiceResource, } from '@opentelemetry/resources/test/util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; describe('BeanstalkResourceDetector', () => { const err = new Error('failed to read config file'); @@ -57,9 +56,7 @@ describe('BeanstalkResourceDetector', () => { .resolves(JSON.stringify(data)); sandbox.stub(JSON, 'parse').returns(data); - const resource = await awsBeanstalkDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsBeanstalkDetector.detect(); sandbox.assert.calledOnce(fileStub); sandbox.assert.calledOnce(readStub); @@ -81,9 +78,7 @@ describe('BeanstalkResourceDetector', () => { .resolves(JSON.stringify(noisyData)); sandbox.stub(JSON, 'parse').returns(noisyData); - const resource = await awsBeanstalkDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsBeanstalkDetector.detect(); sandbox.assert.calledOnce(fileStub); sandbox.assert.calledOnce(readStub); @@ -104,9 +99,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsBeanstalkDetector, 'readFileAsync' as any) .rejects(err); - const resource = await awsBeanstalkDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsBeanstalkDetector.detect(); sandbox.assert.calledOnce(fileStub); sandbox.assert.calledOnce(readStub); @@ -122,9 +115,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsBeanstalkDetector, 'readFileAsync' as any) .resolves(JSON.stringify(data)); - const resource = await awsBeanstalkDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsBeanstalkDetector.detect(); sandbox.assert.calledOnce(fileStub); sandbox.assert.notCalled(readStub); diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts index 340328551b8..4eebb7febaf 100644 --- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts +++ b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEc2Detector.test.ts @@ -22,7 +22,6 @@ import { assertCloudResource, assertHostResource, } from '@opentelemetry/resources/test/util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; const AWS_HOST = 'http://' + awsEc2Detector.AWS_IDMS_ENDPOINT; const AWS_TOKEN_PATH = awsEc2Detector.AWS_INSTANCE_TOKEN_DOCUMENT_PATH; @@ -65,9 +64,7 @@ describe('awsEc2Detector', () => { .matchHeader(AWS_METADATA_TOKEN_HEADER, mockedTokenResponse) .reply(200, () => mockedHostResponse); - const resource: Resource = await awsEc2Detector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEc2Detector.detect(); scope.done(); @@ -103,9 +100,7 @@ describe('awsEc2Detector', () => { .reply(404, () => new Error()); try { - await awsEc2Detector.detect({ - logger: new NoopLogger(), - }); + await awsEc2Detector.detect(); assert.ok(false, 'Expected to throw'); } catch (err) { assert.deepStrictEqual(err, expectedError); @@ -129,9 +124,7 @@ describe('awsEc2Detector', () => { .reply(200, () => mockedHostResponse); try { - await awsEc2Detector.detect({ - logger: new NoopLogger(), - }); + await awsEc2Detector.detect(); assert.ok(false, 'Expected to throw'); } catch (err) { assert.deepStrictEqual(err, expectedError); @@ -151,9 +144,7 @@ describe('awsEc2Detector', () => { .replyWithError(expectedError.message); try { - await awsEc2Detector.detect({ - logger: new NoopLogger(), - }); + await awsEc2Detector.detect(); assert.ok(false, 'Expected to throw'); } catch (err) { assert.deepStrictEqual(err, expectedError); diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts index 8dd102bb7e8..a2abc7cb718 100644 --- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts +++ b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEcsDetector.test.ts @@ -24,7 +24,6 @@ import { assertEmptyResource, assertContainerResource, } from '@opentelemetry/resources/test/util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; import * as os from 'os'; describe('BeanstalkResourceDetector', () => { @@ -60,9 +59,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(correctCgroupData); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -79,9 +76,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(noisyCgroupData); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -98,9 +93,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(multiValidCgroupData); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -116,9 +109,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(correctCgroupData); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.notCalled(readStub); assert.ok(resource); @@ -132,9 +123,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .rejects(errorMsg.fileNotFoundError); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -150,9 +139,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(''); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -168,9 +155,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .resolves(correctCgroupData); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); @@ -186,9 +171,7 @@ describe('BeanstalkResourceDetector', () => { .stub(AwsEcsDetector, 'readFileAsync' as any) .rejects(errorMsg.fileNotFoundError); - const resource = await awsEcsDetector.detect({ - logger: new NoopLogger(), - }); + const resource = await awsEcsDetector.detect(); sandbox.assert.calledOnce(readStub); assert.ok(resource); diff --git a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts index 7356240bc32..017ee92bfd4 100644 --- a/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts +++ b/packages/opentelemetry-resource-detector-aws/test/detectors/AwsEksDetector.test.ts @@ -24,7 +24,6 @@ import { assertContainerResource, assertEmptyResource, } from '@opentelemetry/resources/test/util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; const K8S_SVC_URL = awsEksDetector.K8S_SVC_URL; const AUTH_CONFIGMAP_PATH = awsEksDetector.AUTH_CONFIGMAP_PATH; @@ -74,9 +73,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => mockedClusterResponse); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.done(); @@ -113,9 +110,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => mockedClusterResponse); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.done(); @@ -144,9 +139,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => ''); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.done(); @@ -176,9 +169,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => mockedClusterResponse); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.done(); @@ -205,9 +196,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => ''); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.done(); @@ -223,9 +212,7 @@ describe('awsEksDetector', () => { .stub(AwsEksDetector, 'fileAccessAsync' as any) .rejects(errorMsg.fileNotFoundError); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); assert.ok(resource); assertEmptyResource(resource); @@ -252,9 +239,7 @@ describe('awsEksDetector', () => { .matchHeader('Authorization', k8s_token) .reply(200, () => ''); - const resource: Resource = await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await awsEksDetector.detect(); scope.isDone(); @@ -283,9 +268,7 @@ describe('awsEksDetector', () => { .reply(200, () => mockedAwsAuth); try { - await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + await awsEksDetector.detect(); } catch (err) { assert.deepStrictEqual(err, expectedError); } @@ -311,9 +294,7 @@ describe('awsEksDetector', () => { .reply(404, () => new Error()); try { - await awsEksDetector.detect({ - logger: new NoopLogger(), - }); + await awsEksDetector.detect(); } catch (err) { assert.deepStrictEqual(err, expectedError); } diff --git a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts b/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts index 271f8078ece..9a76067f685 100644 --- a/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts +++ b/packages/opentelemetry-resource-detector-gcp/src/detectors/GcpDetector.ts @@ -16,9 +16,10 @@ import * as semver from 'semver'; import * as gcpMetadata from 'gcp-metadata'; +import { diag } from '@opentelemetry/api'; import { Detector, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, Resource, ResourceAttributes, CLOUD_RESOURCE, @@ -40,14 +41,14 @@ class GcpDetector implements Detector { * populated with instance metadata. Returns a promise containing an * empty {@link Resource} if the connection or parsing of the metadata fails. * - * @param config The resource detection config with a required logger + * @param config The resource detection config */ - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { if ( !semver.satisfies(process.version, '>=10') || !(await gcpMetadata.isAvailable()) ) { - config.logger.debug('GcpDetector failed: GCP Metadata unavailable.'); + diag.debug('GcpDetector failed: GCP Metadata unavailable.'); return Resource.empty(); } diff --git a/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts b/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts index f64e684d084..297e17692cd 100644 --- a/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts +++ b/packages/opentelemetry-resource-detector-gcp/test/detectors/GcpDetector.test.ts @@ -32,7 +32,6 @@ import { assertContainerResource, assertEmptyResource, } from '@opentelemetry/resources/test/util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; import { Resource } from '@opentelemetry/resources'; const HEADERS = { @@ -84,9 +83,7 @@ const CLUSTER_NAME_PATH = BASE_PATH + '/instance/attributes/cluster-name'; const secondaryScope = nock(SECONDARY_HOST_ADDRESS) .get(INSTANCE_PATH) .reply(200, {}, HEADERS); - const resource: Resource = await gcpDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await gcpDetector.detect(); secondaryScope.done(); scope.done(); @@ -117,7 +114,7 @@ const CLUSTER_NAME_PATH = BASE_PATH + '/instance/attributes/cluster-name'; const secondaryScope = nock(SECONDARY_HOST_ADDRESS) .get(INSTANCE_PATH) .reply(200, {}, HEADERS); - const resource = await gcpDetector.detect({ logger: new NoopLogger() }); + const resource = await gcpDetector.detect(); secondaryScope.done(); scope.done(); @@ -149,7 +146,7 @@ const CLUSTER_NAME_PATH = BASE_PATH + '/instance/attributes/cluster-name'; const secondaryScope = nock(SECONDARY_HOST_ADDRESS) .get(INSTANCE_PATH) .reply(200, {}, HEADERS); - const resource = await gcpDetector.detect({ logger: new NoopLogger() }); + const resource = await gcpDetector.detect(); secondaryScope.done(); scope.done(); @@ -161,7 +158,7 @@ const CLUSTER_NAME_PATH = BASE_PATH + '/instance/attributes/cluster-name'; }); it('returns empty resource if not detected', async () => { - const resource = await gcpDetector.detect({ logger: new NoopLogger() }); + const resource = await gcpDetector.detect(); assertEmptyResource(resource); }); }); diff --git a/packages/opentelemetry-resources/src/config.ts b/packages/opentelemetry-resources/src/config.ts index 250d055f7ee..915aad0764f 100644 --- a/packages/opentelemetry-resources/src/config.ts +++ b/packages/opentelemetry-resources/src/config.ts @@ -14,24 +14,11 @@ * limitations under the License. */ -import { Logger } from '@opentelemetry/api'; import type { Detector } from './types'; /** * ResourceDetectionConfig provides an interface for configuring resource auto-detection. */ export interface ResourceDetectionConfig { - /** Optional Logger. */ - logger?: Logger; detectors?: Array; } - -/** - * ResourceDetectionConfigWithLogger provides an interface for interacting with - * {@link ResourceDetectionConfig} instances that must have a logger defined. - */ -export interface ResourceDetectionConfigWithLogger - extends ResourceDetectionConfig { - /** Required Logger */ - logger: Logger; -} diff --git a/packages/opentelemetry-resources/src/platform/node/detect-resources.ts b/packages/opentelemetry-resources/src/platform/node/detect-resources.ts index cb29dc7c40e..a8e07ba42c3 100644 --- a/packages/opentelemetry-resources/src/platform/node/detect-resources.ts +++ b/packages/opentelemetry-resources/src/platform/node/detect-resources.ts @@ -15,11 +15,8 @@ */ import { Resource } from '../../Resource'; -import { - ResourceDetectionConfig, - ResourceDetectionConfigWithLogger, -} from '../../config'; -import { Logger, NoopLogger } from '@opentelemetry/api'; +import { ResourceDetectionConfig } from '../../config'; +import { diag } from '@opentelemetry/api'; import * as util from 'util'; /** @@ -31,29 +28,24 @@ import * as util from 'util'; export const detectResources = async ( config: ResourceDetectionConfig = {} ): Promise => { - const internalConfig: ResourceDetectionConfigWithLogger = Object.assign( - { - logger: new NoopLogger(), - }, - config - ); + const internalConfig: ResourceDetectionConfig = Object.assign(config); const resources: Array = await Promise.all( (internalConfig.detectors || []).map(async d => { try { const resource = await d.detect(internalConfig); - config.logger?.debug(`${d.constructor.name} found resource.`, resource); + diag.debug(`${d.constructor.name} found resource.`, resource); return resource; } catch (e) { - config.logger?.debug(`${d.constructor.name} failed: ${e.message}`); + diag.debug(`${d.constructor.name} failed: ${e.message}`); return Resource.empty(); } }) ); - // Log Resources only if there is a user-provided logger - if (config.logger) { - logResources(config.logger, resources); - } + + // Future check if verbose logging is enabled issue #1903 + logResources(resources); + return resources.reduce( (acc, resource) => acc.merge(resource), Resource.createTelemetrySDKResource() @@ -63,10 +55,9 @@ export const detectResources = async ( /** * Writes debug information about the detected resources to the logger defined in the resource detection config, if one is provided. * - * @param logger The {@link Logger} to write the debug information to. * @param resources The array of {@link Resource} that should be logged. Empty entried will be ignored. */ -const logResources = (logger: Logger, resources: Array) => { +const logResources = (resources: Array) => { resources.forEach(resource => { // Print only populated resources if (Object.keys(resource.attributes).length > 0) { @@ -76,7 +67,7 @@ const logResources = (logger: Logger, resources: Array) => { sorted: true, compact: false, }); - logger.debug(resourceDebugString); + diag.verbose(resourceDebugString); } }); }; diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts index 98edcc6752b..bd2449921b2 100644 --- a/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts +++ b/packages/opentelemetry-resources/src/platform/node/detectors/EnvDetector.ts @@ -14,11 +14,12 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { getEnv } from '@opentelemetry/core'; import { Detector, Resource, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, ResourceAttributes, } from '../../../'; @@ -51,13 +52,13 @@ class EnvDetector implements Detector { * OTEL_RESOURCE_ATTRIBUTES environment variable. Note this is an async * function to conform to the Detector interface. * - * @param config The resource detection config with a required logger + * @param config The resource detection config */ - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(_config?: ResourceDetectionConfig): Promise { try { const rawAttributes = getEnv().OTEL_RESOURCE_ATTRIBUTES; if (!rawAttributes) { - config.logger.debug( + diag.debug( 'EnvDetector failed: Environment variable "OTEL_RESOURCE_ATTRIBUTES" is missing.' ); return Resource.empty(); @@ -65,7 +66,7 @@ class EnvDetector implements Detector { const attributes = this._parseResourceAttributes(rawAttributes); return new Resource(attributes); } catch (e) { - config.logger.debug(`EnvDetector failed: ${e.message}`); + diag.debug(`EnvDetector failed: ${e.message}`); return Resource.empty(); } } diff --git a/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts b/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts index 3ba48d3f3a6..04608266c30 100644 --- a/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts +++ b/packages/opentelemetry-resources/src/platform/node/detectors/ProcessDetector.ts @@ -14,20 +14,21 @@ * limitations under the License. */ +import { diag } from '@opentelemetry/api'; import { Detector, Resource, PROCESS_RESOURCE, - ResourceDetectionConfigWithLogger, + ResourceDetectionConfig, } from '../../../'; import { ResourceAttributes } from '../../../types'; /** - * ProcessDetector will be used to detect the resoureces related current process running - * and being instumented from the NodeJS Process module. + * ProcessDetector will be used to detect the resources related current process running + * and being instrumented from the NodeJS Process module. */ class ProcessDetector implements Detector { - async detect(config: ResourceDetectionConfigWithLogger): Promise { + async detect(config?: ResourceDetectionConfig): Promise { const processResource: ResourceAttributes = { [PROCESS_RESOURCE.PID]: process.pid, [PROCESS_RESOURCE.NAME]: process.title || '', @@ -45,7 +46,7 @@ class ProcessDetector implements Detector { */ private _getResourceAttributes( processResource: ResourceAttributes, - config: ResourceDetectionConfigWithLogger + _config?: ResourceDetectionConfig ) { if ( processResource[PROCESS_RESOURCE.NAME] === '' || @@ -53,7 +54,7 @@ class ProcessDetector implements Detector { processResource[PROCESS_RESOURCE.COMMAND] === '' || processResource[PROCESS_RESOURCE.COMMAND_LINE] === '' ) { - config.logger.debug( + diag.debug( 'ProcessDetector failed: Unable to find required process resources. ' ); return Resource.empty(); diff --git a/packages/opentelemetry-resources/src/types.ts b/packages/opentelemetry-resources/src/types.ts index d31d17515d2..94d5e4b8928 100644 --- a/packages/opentelemetry-resources/src/types.ts +++ b/packages/opentelemetry-resources/src/types.ts @@ -15,7 +15,7 @@ */ import { Resource } from './Resource'; -import { ResourceDetectionConfigWithLogger } from './config'; +import { ResourceDetectionConfig } from './config'; /** Interface for Resource attributes */ export interface ResourceAttributes { @@ -27,5 +27,5 @@ export interface ResourceAttributes { * a detector returns a Promise containing a Resource. */ export interface Detector { - detect(config: ResourceDetectionConfigWithLogger): Promise; + detect(config?: ResourceDetectionConfig): Promise; } diff --git a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts index c2056d0031b..5c8d338a261 100644 --- a/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts +++ b/packages/opentelemetry-resources/test/detectors/EnvDetector.test.ts @@ -19,7 +19,6 @@ import { assertK8sResource, assertEmptyResource, } from '../util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; describe('envDetector()', () => { describe('with valid env', () => { @@ -33,9 +32,7 @@ describe('envDetector()', () => { }); it('should return resource information from environment variable', async () => { - const resource: Resource = await envDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await envDetector.detect(); assertK8sResource(resource, { [K8S_RESOURCE.POD_NAME]: 'pod-xyz-123', [K8S_RESOURCE.CLUSTER_NAME]: 'c1', @@ -46,9 +43,7 @@ describe('envDetector()', () => { describe('with empty env', () => { it('should return empty resource', async () => { - const resource: Resource = await envDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await envDetector.detect(); assertEmptyResource(resource); }); }); diff --git a/packages/opentelemetry-resources/test/detectors/ProcessDetector.test.ts b/packages/opentelemetry-resources/test/detectors/ProcessDetector.test.ts index c4f8ce9569a..013b919a512 100644 --- a/packages/opentelemetry-resources/test/detectors/ProcessDetector.test.ts +++ b/packages/opentelemetry-resources/test/detectors/ProcessDetector.test.ts @@ -19,7 +19,6 @@ import { assertProcessResource, assertEmptyResource, } from '../util/resource-assertions'; -import { NoopLogger } from '@opentelemetry/api'; describe('processDetector()', () => { let sandbox: sinon.SinonSandbox; @@ -39,9 +38,7 @@ describe('processDetector()', () => { .stub(process, 'argv') .value(['/tmp/node', '/home/ot/test.js', 'arg1', 'arg2']); - const resource: Resource = await processDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await processDetector.detect(); assertProcessResource(resource, { pid: 1234, name: 'otProcess', @@ -53,9 +50,7 @@ describe('processDetector()', () => { sandbox.stub(process, 'pid').value(1234); sandbox.stub(process, 'title').value(undefined); sandbox.stub(process, 'argv').value([]); - const resource: Resource = await processDetector.detect({ - logger: new NoopLogger(), - }); + const resource: Resource = await processDetector.detect(); assertEmptyResource(resource); }); }); diff --git a/packages/opentelemetry-sdk-node/README.md b/packages/opentelemetry-sdk-node/README.md index 5c28882a866..e59671ff7af 100644 --- a/packages/opentelemetry-sdk-node/README.md +++ b/packages/opentelemetry-sdk-node/README.md @@ -91,14 +91,6 @@ Use a custom context manager. Default: [AsyncHooksContextManager](../opentelemet Use a custom propagator. Default: [CompositePropagator](../opentelemetry-core/src/context/propagation/composite.ts) using [W3C Trace Context](../opentelemetry-core/README.md#httptracecontext-propagator) and [Baggage](../opentelemetry-core/README.md#baggage-propagator) -### logger - -Use a custom logger. Default: Logging disabled - -### logLevel - -Default: [INFO](../opentelemetry-core/src/common/types.ts#L19) - ### metricProcessor Use a custom processor for metrics. Default: [UngroupedProcessor](../opentelemetry-metrics/src/export/Processor.ts#L50) diff --git a/packages/opentelemetry-sdk-node/src/sdk.ts b/packages/opentelemetry-sdk-node/src/sdk.ts index 11fb7a5b777..23f8ab7ec80 100644 --- a/packages/opentelemetry-sdk-node/src/sdk.ts +++ b/packages/opentelemetry-sdk-node/src/sdk.ts @@ -64,12 +64,6 @@ export class NodeSDK { if (configuration.spanProcessor || configuration.traceExporter) { const tracerProviderConfig: NodeTracerConfig = {}; - if (typeof configuration.logLevel === 'number') { - tracerProviderConfig.logLevel = configuration.logLevel; - } - if (configuration.logger) { - tracerProviderConfig.logger = configuration.logger; - } if (configuration.sampler) { tracerProviderConfig.sampler = configuration.sampler; } @@ -101,12 +95,6 @@ export class NodeSDK { if (typeof configuration.metricInterval === 'number') { meterConfig.interval = configuration.metricInterval; } - if (typeof configuration.logLevel === 'number') { - meterConfig.logLevel = configuration.logLevel; - } - if (configuration.logger) { - meterConfig.logger = configuration.logger; - } this.configureMeterProvider(meterConfig); } diff --git a/packages/opentelemetry-sdk-node/src/types.ts b/packages/opentelemetry-sdk-node/src/types.ts index d3da15274b1..abcad0a274b 100644 --- a/packages/opentelemetry-sdk-node/src/types.ts +++ b/packages/opentelemetry-sdk-node/src/types.ts @@ -14,26 +14,31 @@ * limitations under the License. */ +import { SpanAttributes, TextMapPropagator, Sampler } from '@opentelemetry/api'; import type { ContextManager } from '@opentelemetry/context-base'; -import type { api, core, metrics, resources, tracing } from '.'; import { InstrumentationOption } from '@opentelemetry/instrumentation'; +import { MetricExporter, Processor } from '@opentelemetry/metrics'; +import { Resource } from '@opentelemetry/resources'; +import { + SpanExporter, + SpanProcessor, + TraceParams, +} from '@opentelemetry/tracing'; export interface NodeSDKConfiguration { autoDetectResources: boolean; contextManager: ContextManager; - defaultAttributes: api.SpanAttributes; - textMapPropagator: api.TextMapPropagator; - logger: api.Logger; - logLevel: core.LogLevel; - metricProcessor: metrics.Processor; - metricExporter: metrics.MetricExporter; + defaultAttributes: SpanAttributes; + textMapPropagator: TextMapPropagator; + metricProcessor: Processor; + metricExporter: MetricExporter; metricInterval: number; /* Deprecated */ plugins: InstrumentationOption[]; instrumentations: InstrumentationOption[]; - resource: resources.Resource; - sampler: api.Sampler; - spanProcessor: tracing.SpanProcessor; - traceExporter: tracing.SpanExporter; - traceParams: tracing.TraceParams; + resource: Resource; + sampler: Sampler; + spanProcessor: SpanProcessor; + traceExporter: SpanExporter; + traceParams: TraceParams; } diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts index 06e397d25dc..3b8f69f560a 100644 --- a/packages/opentelemetry-sdk-node/test/sdk.test.ts +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -21,6 +21,8 @@ import { propagation, ProxyTracerProvider, trace, + diag, + DiagLogLevel, } from '@opentelemetry/api'; import { metrics, NoopMeterProvider } from '@opentelemetry/api-metrics'; import { @@ -353,24 +355,29 @@ describe('Node SDK', () => { regex: RegExp ): boolean => { return mockedFunction.getCalls().some(call => { - return regex.test(call.args.toString()); + return call.args.some(callArgs => regex.test(callArgs.toString())); }); }; + beforeEach(() => { + diag.setLogLevel(DiagLogLevel.VERBOSE); + diag.setLogger(); + }); + it('prints detected resources and debug messages to the logger', async () => { const sdk = new NodeSDK({ autoDetectResources: true, }); + // This test depends on the env detector to be functioning as intended const mockedLoggerMethod = Sinon.fake(); - await sdk.detectResources({ - logger: { - debug: mockedLoggerMethod, - info: Sinon.fake(), - warn: Sinon.fake(), - error: Sinon.fake(), - }, - }); + const mockedVerboseLoggerMethod = Sinon.fake(); + diag.setLogger({ + debug: mockedLoggerMethod, + verbose: mockedVerboseLoggerMethod, + } as any); + + await sdk.detectResources(); // Test for AWS and GCP Detector failure assert.ok( @@ -392,7 +399,7 @@ describe('Node SDK', () => { // Regex formatting accounts for whitespace variations in util.inspect output over different node versions assert.ok( callArgsMatches( - mockedLoggerMethod, + mockedVerboseLoggerMethod, /{\s+'service\.instance\.id':\s+'627cc493',\s+'service\.name':\s+'my-service',\s+'service\.namespace':\s+'default',\s+'service\.version':\s+'0\.0\.1'\s+}\s*/ ) ); @@ -401,6 +408,8 @@ describe('Node SDK', () => { describe('with missing environment variable', () => { beforeEach(() => { delete process.env.OTEL_RESOURCE_ATTRIBUTES; + diag.setLogLevel(DiagLogLevel.DEBUG); + diag.setLogger(); }); it('prints correct error messages when EnvDetector has no env variable', async () => { @@ -408,14 +417,11 @@ describe('Node SDK', () => { autoDetectResources: true, }); const mockedLoggerMethod = Sinon.fake(); - await sdk.detectResources({ - logger: { - debug: mockedLoggerMethod, - info: Sinon.fake(), - warn: Sinon.fake(), - error: Sinon.fake(), - }, - }); + diag.setLogger({ + debug: mockedLoggerMethod, + } as any); + + await sdk.detectResources(); assert.ok( callArgsContains( @@ -429,6 +435,8 @@ describe('Node SDK', () => { describe('with a faulty environment variable', () => { beforeEach(() => { process.env.OTEL_RESOURCE_ATTRIBUTES = 'bad=~attribute'; + diag.setLogLevel(DiagLogLevel.DEBUG); + diag.setLogger(); }); it('prints correct error messages when EnvDetector has an invalid variable', async () => { @@ -436,14 +444,11 @@ describe('Node SDK', () => { autoDetectResources: true, }); const mockedLoggerMethod = Sinon.fake(); - await sdk.detectResources({ - logger: { - debug: mockedLoggerMethod, - info: Sinon.fake(), - warn: Sinon.fake(), - error: Sinon.fake(), - }, - }); + diag.setLogger({ + debug: mockedLoggerMethod, + } as any); + + await sdk.detectResources(); assert.ok( callArgsContains( diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts index 61faf9d6202..84d786d70d1 100644 --- a/packages/opentelemetry-shim-opentracing/src/shim.ts +++ b/packages/opentelemetry-shim-opentracing/src/shim.ts @@ -121,13 +121,11 @@ export class SpanContextShim extends opentracing.SpanContext { */ export class TracerShim extends opentracing.Tracer { private readonly _tracer: api.Tracer; - private readonly _logger: api.Logger; - constructor(tracer: api.Tracer, logger?: api.Logger) { + constructor(tracer: api.Tracer) { super(); this._tracer = tracer; - this._logger = logger || new api.NoopLogger(); } startSpan( @@ -178,7 +176,7 @@ export class TracerShim extends opentracing.Tracer { return; } case opentracing.FORMAT_BINARY: { - this._logger.warn( + api.diag.warn( 'OpentracingShim.inject() does not support FORMAT_BINARY' ); // @todo: Implement binary formats @@ -206,7 +204,7 @@ export class TracerShim extends opentracing.Tracer { } case opentracing.FORMAT_BINARY: { // @todo: Implement binary format - this._logger.warn( + api.diag.warn( 'OpentracingShim.extract() does not support FORMAT_BINARY' ); return null; diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts index 913b448ac52..5eee7bea22e 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts @@ -14,10 +14,14 @@ * limitations under the License. */ -import * as api from '@opentelemetry/api'; +import { + TracerProvider, + trace, + context, + propagation, +} from '@opentelemetry/api'; import { CompositePropagator, - ConsoleLogger, HttpBaggage, HttpTraceContext, } from '@opentelemetry/core'; @@ -31,23 +35,19 @@ import merge = require('lodash.merge'); /** * This class represents a basic tracer provider which platform libraries can extend */ -export class BasicTracerProvider implements api.TracerProvider { +export class BasicTracerProvider implements TracerProvider { private readonly _config: TracerConfig; private readonly _registeredSpanProcessors: SpanProcessor[] = []; private readonly _tracers: Map = new Map(); activeSpanProcessor: SpanProcessor = new NoopSpanProcessor(); - readonly logger: api.Logger; readonly resource: Resource; constructor(config: TracerConfig = {}) { const mergedConfig = merge({}, DEFAULT_CONFIG, config); - this.logger = - mergedConfig.logger ?? new ConsoleLogger(mergedConfig.logLevel); this.resource = mergedConfig.resource ?? Resource.createTelemetrySDKResource(); this._config = Object.assign({}, mergedConfig, { - logger: this.logger, resource: this.resource, }); } @@ -84,7 +84,7 @@ export class BasicTracerProvider implements api.TracerProvider { * @param config Configuration object for SDK registration */ register(config: SDKRegistrationConfig = {}) { - api.trace.setGlobalTracerProvider(this); + trace.setGlobalTracerProvider(this); if (config.propagator === undefined) { config.propagator = new CompositePropagator({ propagators: [new HttpBaggage(), new HttpTraceContext()], @@ -92,11 +92,11 @@ export class BasicTracerProvider implements api.TracerProvider { } if (config.contextManager) { - api.context.setGlobalContextManager(config.contextManager); + context.setGlobalContextManager(config.contextManager); } if (config.propagator) { - api.propagation.setGlobalPropagator(config.propagator); + propagation.setGlobalPropagator(config.propagator); } } diff --git a/packages/opentelemetry-tracing/src/Span.ts b/packages/opentelemetry-tracing/src/Span.ts index d7ba0ef635a..ea6ebce1823 100644 --- a/packages/opentelemetry-tracing/src/Span.ts +++ b/packages/opentelemetry-tracing/src/Span.ts @@ -56,7 +56,6 @@ export class Span implements api.Span, ReadableSpan { endTime: api.HrTime = [0, 0]; private _ended = false; private _duration: api.HrTime = [-1, -1]; - private readonly _logger: api.Logger; private readonly _spanProcessor: SpanProcessor; private readonly _traceParams: TraceParams; @@ -79,7 +78,6 @@ export class Span implements api.Span, ReadableSpan { this.startTime = timeInputToHrTime(startTime); this.resource = parentTracer.resource; this.instrumentationLibrary = parentTracer.instrumentationLibrary; - this._logger = parentTracer.logger; this._traceParams = parentTracer.getActiveTraceParams(); this._spanProcessor = parentTracer.getActiveSpanProcessor(); this._spanProcessor.onStart(this, context); @@ -93,11 +91,11 @@ export class Span implements api.Span, ReadableSpan { setAttribute(key: string, value: unknown): this { if (value == null || this._isSpanEnded()) return this; if (key.length === 0) { - this._logger.warn(`Invalid attribute key: ${key}`); + api.diag.warn(`Invalid attribute key: ${key}`); return this; } if (!isAttributeValue(value)) { - this._logger.warn(`Invalid attribute value set for key: ${key}`); + api.diag.warn(`Invalid attribute value set for key: ${key}`); return this; } @@ -133,7 +131,7 @@ export class Span implements api.Span, ReadableSpan { ): this { if (this._isSpanEnded()) return this; if (this.events.length >= this._traceParams.numberOfEventsPerSpan!) { - this._logger.warn('Dropping extra events.'); + api.diag.warn('Dropping extra events.'); this.events.shift(); } if (isTimeInput(attributesOrStartTime)) { @@ -167,7 +165,7 @@ export class Span implements api.Span, ReadableSpan { end(endTime: api.TimeInput = hrTime()): void { if (this._isSpanEnded()) { - this._logger.error('You can only call end() on a span once.'); + api.diag.error('You can only call end() on a span once.'); return; } this._ended = true; @@ -175,7 +173,7 @@ export class Span implements api.Span, ReadableSpan { this._duration = hrTimeDuration(this.startTime, this.endTime); if (this._duration[0] < 0) { - this._logger.warn( + api.diag.warn( 'Inconsistent start and end time, startTime > endTime', this.startTime, this.endTime @@ -214,7 +212,7 @@ export class Span implements api.Span, ReadableSpan { ) { this.addEvent(ExceptionEventName, attributes as api.SpanAttributes, time); } else { - this._logger.warn(`Failed to record an exception ${exception}`); + api.diag.warn(`Failed to record an exception ${exception}`); } } @@ -228,7 +226,7 @@ export class Span implements api.Span, ReadableSpan { private _isSpanEnded(): boolean { if (this._ended) { - this._logger.warn( + api.diag.warn( 'Can not execute the operation on ended Span {traceId: %s, spanId: %s}', this.spanContext.traceId, this.spanContext.spanId diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts index d35162fcc2b..49eebd8fc5f 100644 --- a/packages/opentelemetry-tracing/src/Tracer.ts +++ b/packages/opentelemetry-tracing/src/Tracer.ts @@ -16,7 +16,6 @@ import * as api from '@opentelemetry/api'; import { - ConsoleLogger, InstrumentationLibrary, IdGenerator, RandomIdGenerator, @@ -37,7 +36,6 @@ export class Tracer implements api.Tracer { private readonly _idGenerator: IdGenerator; readonly resource: Resource; readonly instrumentationLibrary: InstrumentationLibrary; - readonly logger: api.Logger; /** * Constructs a new Tracer instance. @@ -53,7 +51,6 @@ export class Tracer implements api.Tracer { this._idGenerator = config.idGenerator || new RandomIdGenerator(); this.resource = _tracerProvider.resource; this.instrumentationLibrary = instrumentationLibrary; - this.logger = config.logger || new ConsoleLogger(config.logLevel); } /** @@ -66,7 +63,7 @@ export class Tracer implements api.Tracer { context = api.context.active() ): api.Span { if (api.isInstrumentationSuppressed(context)) { - this.logger.debug('Instrumentation suppressed, returning Noop Span'); + api.diag.debug('Instrumentation suppressed, returning Noop Span'); return api.NOOP_TRACER.startSpan(name, options, context); } @@ -102,7 +99,7 @@ export class Tracer implements api.Tracer { : api.TraceFlags.NONE; const spanContext = { traceId, spanId, traceFlags, traceState }; if (samplingResult.decision === api.SamplingDecision.NOT_RECORD) { - this.logger.debug('Recording is off, starting no recording span'); + api.diag.debug('Recording is off, starting no recording span'); return api.NOOP_TRACER.startSpan( name, options, diff --git a/packages/opentelemetry-tracing/src/config.ts b/packages/opentelemetry-tracing/src/config.ts index f9087aedb47..a079458cd4a 100644 --- a/packages/opentelemetry-tracing/src/config.ts +++ b/packages/opentelemetry-tracing/src/config.ts @@ -23,7 +23,6 @@ import { AlwaysOnSampler, getEnv } from '@opentelemetry/core'; * used to extend the default value. */ export const DEFAULT_CONFIG = { - logLevel: getEnv().OTEL_LOG_LEVEL, sampler: new AlwaysOnSampler(), traceParams: { numberOfAttributesPerSpan: getEnv().OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, diff --git a/packages/opentelemetry-tracing/src/types.ts b/packages/opentelemetry-tracing/src/types.ts index 0102c902abd..10961a51171 100644 --- a/packages/opentelemetry-tracing/src/types.ts +++ b/packages/opentelemetry-tracing/src/types.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { TextMapPropagator, Logger, Sampler } from '@opentelemetry/api'; -import { LogLevel, IdGenerator } from '@opentelemetry/core'; +import { TextMapPropagator, Sampler } from '@opentelemetry/api'; +import { IdGenerator } from '@opentelemetry/core'; import { ContextManager } from '@opentelemetry/context-base'; import { Resource } from '@opentelemetry/resources'; @@ -24,14 +24,6 @@ import { Resource } from '@opentelemetry/resources'; * TracerConfig provides an interface for configuring a Basic Tracer. */ export interface TracerConfig { - /** - * User provided logger. - */ - logger?: Logger; - - /** level of logger. */ - logLevel?: LogLevel; - /** * Sampler determines if a span should be recorded or should be a NoopSpan. */ diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts index b688f11ced1..cbceebb7424 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts @@ -19,7 +19,6 @@ import { SpanContext, TraceFlags, ROOT_CONTEXT, - NoopLogger, setSpan, setSpanContext, getSpan, @@ -57,13 +56,6 @@ describe('BasicTracerProvider', () => { assert.ok(provider instanceof BasicTracerProvider); }); - it('should construct an instance with logger', () => { - const provider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); - assert.ok(provider instanceof BasicTracerProvider); - }); - it('should construct an instance with sampler', () => { const provider = new BasicTracerProvider({ sampler: new AlwaysOnSampler(), @@ -260,7 +252,6 @@ describe('BasicTracerProvider', () => { it('should return a non recording span when never sampling', () => { const tracer = new BasicTracerProvider({ sampler: new AlwaysOffSampler(), - logger: new NoopLogger(), }).getTracer('default'); const span = tracer.startSpan('my-span'); assert.ok(!span.isRecording()); diff --git a/packages/opentelemetry-tracing/test/Span.test.ts b/packages/opentelemetry-tracing/test/Span.test.ts index 5989ba39996..5597223e026 100644 --- a/packages/opentelemetry-tracing/test/Span.test.ts +++ b/packages/opentelemetry-tracing/test/Span.test.ts @@ -22,7 +22,6 @@ import { SpanContext, SpanKind, TraceFlags, - NoopLogger, } from '@opentelemetry/api'; import { hrTime, @@ -38,7 +37,6 @@ const performanceTimeOrigin = hrTime(); describe('Span', () => { const tracer = new BasicTracerProvider({ - logger: new NoopLogger(), traceParams: { numberOfAttributesPerSpan: 100, numberOfEventsPerSpan: 100, @@ -566,9 +564,7 @@ describe('Span', () => { shutdown: () => Promise.resolve(), }; - const provider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); + const provider = new BasicTracerProvider(); provider.addSpanProcessor(processor); @@ -587,9 +583,7 @@ describe('Span', () => { shutdown: () => Promise.resolve(), }; - const provider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); + const provider = new BasicTracerProvider(); provider.addSpanProcessor(processor); @@ -607,9 +601,7 @@ describe('Span', () => { shutdown: () => Promise.resolve(), }; - const provider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); + const provider = new BasicTracerProvider(); provider.addSpanProcessor(processor); diff --git a/packages/opentelemetry-tracing/test/Tracer.test.ts b/packages/opentelemetry-tracing/test/Tracer.test.ts index 9f90c387d86..3da1eadb62c 100644 --- a/packages/opentelemetry-tracing/test/Tracer.test.ts +++ b/packages/opentelemetry-tracing/test/Tracer.test.ts @@ -21,7 +21,6 @@ import { TraceFlags, ROOT_CONTEXT, suppressInstrumentation, - NoopLogger, } from '@opentelemetry/api'; import { BasicTracerProvider, Tracer, Span } from '../src'; import { @@ -31,9 +30,7 @@ import { } from '@opentelemetry/core'; describe('Tracer', () => { - const tracerProvider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); + const tracerProvider = new BasicTracerProvider(); class TestSampler implements Sampler { shouldSample() { diff --git a/packages/opentelemetry-tracing/test/export/TestTracingSpanExporter.ts b/packages/opentelemetry-tracing/test/export/TestTracingSpanExporter.ts index cff7c0e9f45..499faf91ebd 100644 --- a/packages/opentelemetry-tracing/test/export/TestTracingSpanExporter.ts +++ b/packages/opentelemetry-tracing/test/export/TestTracingSpanExporter.ts @@ -22,7 +22,6 @@ import { SpanProcessor, } from '../../src'; import { ExportResult, AlwaysOnSampler } from '@opentelemetry/core'; -import { NoopLogger } from '@opentelemetry/api'; /** * A test-only span exporter that naively simulates triggering instrumentation @@ -35,9 +34,7 @@ export class TestTracingSpanExporter extends InMemorySpanExporter { constructor() { super(); - const tracerProvider = new BasicTracerProvider({ - logger: new NoopLogger(), - }); + const tracerProvider = new BasicTracerProvider(); const spanProcessor: SpanProcessor = { forceFlush: () => { diff --git a/packages/opentelemetry-web/test/WebTracerProvider.test.ts b/packages/opentelemetry-web/test/WebTracerProvider.test.ts index 10b1f5e2748..b5f0c65d2d8 100644 --- a/packages/opentelemetry-web/test/WebTracerProvider.test.ts +++ b/packages/opentelemetry-web/test/WebTracerProvider.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { context, NoopLogger, getSpan, setSpan } from '@opentelemetry/api'; +import { context, getSpan, setSpan } from '@opentelemetry/api'; import { ContextManager } from '@opentelemetry/context-base'; import { ZoneContextManager } from '@opentelemetry/context-zone'; import { B3Propagator } from '@opentelemetry/propagator-b3'; @@ -143,9 +143,7 @@ describe('WebTracerProvider', () => { describe('.startSpan()', () => { it('should assign resource to span', () => { - const provider = new WebTracerProvider({ - logger: new NoopLogger(), - }); + const provider = new WebTracerProvider(); const span = provider.getTracer('default').startSpan('my-span') as Span; assert.ok(span); assert.ok(span.resource instanceof Resource); From a91ea7617f288af632934334d0c8ecece318ce73 Mon Sep 17 00:00:00 2001 From: Daniel Dyla Date: Wed, 17 Feb 2021 16:06:47 -0500 Subject: [PATCH 2/2] chore: release 0.17.0 proposal (#1926) * chore: release 0.17.0 proposal * chore: bump backwards compatibility version * chore: relock * chore: update changelog --- CHANGELOG.md | 55 +++++++++++++++++++ backwards-compatability/node10/package.json | 6 +- backwards-compatability/node12/package.json | 6 +- backwards-compatability/node8/package.json | 6 +- examples/basic-tracer-node/package.json | 8 +-- examples/collector-exporter-node/package.json | 16 +++--- examples/grpc-js/package.json | 16 +++--- examples/grpc/package.json | 16 +++--- examples/http/package.json | 16 +++--- examples/https/package.json | 16 +++--- examples/metrics/package.json | 8 +-- examples/opentracing-shim/package.json | 14 ++--- examples/prometheus/package.json | 6 +- examples/tracer-web/package.json | 26 ++++----- getting-started/example/package.json | 2 +- .../monitored-example/package.json | 6 +- getting-started/traced-example/package.json | 4 +- .../ts-example/monitored-example/package.json | 6 +- .../ts-example/traced-example/package.json | 2 +- .../package.json | 10 ++-- lerna.json | 2 +- metapackages/plugins-node-core/package.json | 10 ++-- metapackages/plugins-web-core/package.json | 4 +- package-lock.json | 2 +- package.json | 2 +- .../opentelemetry-api-metrics/package.json | 4 +- .../opentelemetry-api-metrics/src/version.ts | 2 +- packages/opentelemetry-api/package.json | 4 +- .../opentelemetry-api/src/api/global-utils.ts | 2 +- packages/opentelemetry-api/src/version.ts | 2 +- .../package.json | 4 +- .../src/version.ts | 2 +- .../opentelemetry-context-base/package.json | 2 +- .../opentelemetry-context-base/src/version.ts | 2 +- .../package.json | 4 +- .../src/version.ts | 2 +- .../opentelemetry-context-zone/package.json | 4 +- .../opentelemetry-context-zone/src/version.ts | 2 +- packages/opentelemetry-core/package.json | 8 +-- packages/opentelemetry-core/src/version.ts | 2 +- .../package.json | 16 +++--- .../src/version.ts | 2 +- .../package.json | 16 +++--- .../src/version.ts | 2 +- .../package.json | 14 ++--- .../src/version.ts | 2 +- .../package.json | 10 ++-- .../src/version.ts | 2 +- .../package.json | 10 ++-- .../src/version.ts | 2 +- .../package.json | 10 ++-- .../src/version.ts | 2 +- .../opentelemetry-grpc-utils/package.json | 16 +++--- .../opentelemetry-grpc-utils/src/version.ts | 2 +- .../package.json | 18 +++--- .../src/version.ts | 2 +- .../package.json | 20 +++---- .../src/version.ts | 2 +- .../package.json | 18 +++--- .../src/version.ts | 2 +- .../package.json | 18 +++--- .../src/version.ts | 2 +- .../package.json | 6 +- .../src/version.ts | 2 +- packages/opentelemetry-metrics/package.json | 10 ++-- packages/opentelemetry-metrics/src/version.ts | 2 +- packages/opentelemetry-node/package.json | 14 ++--- packages/opentelemetry-node/src/version.ts | 2 +- .../opentelemetry-plugin-grpc-js/package.json | 18 +++--- .../src/version.ts | 2 +- .../opentelemetry-plugin-grpc/package.json | 18 +++--- .../opentelemetry-plugin-grpc/src/version.ts | 2 +- .../opentelemetry-plugin-http/package.json | 16 +++--- .../opentelemetry-plugin-http/src/version.ts | 2 +- .../opentelemetry-plugin-https/package.json | 18 +++--- .../opentelemetry-plugin-https/src/version.ts | 2 +- .../opentelemetry-propagator-b3/package.json | 6 +- .../src/version.ts | 2 +- .../package.json | 8 +-- .../src/version.ts | 2 +- .../package.json | 8 +-- .../src/version.ts | 2 +- packages/opentelemetry-resources/package.json | 6 +- .../opentelemetry-resources/src/version.ts | 2 +- packages/opentelemetry-sdk-node/package.json | 26 ++++----- .../opentelemetry-sdk-node/src/version.ts | 2 +- .../package.json | 2 +- .../src/version.ts | 2 +- .../package.json | 8 +-- .../src/version.ts | 2 +- packages/opentelemetry-tracing/package.json | 12 ++-- packages/opentelemetry-tracing/src/version.ts | 2 +- packages/opentelemetry-web/package.json | 18 +++--- packages/opentelemetry-web/src/version.ts | 2 +- packages/template/package.json | 2 +- 95 files changed, 391 insertions(+), 336 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5597559340b..76b3f4cd910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,61 @@ All notable changes to this project will be documented in this file. ## Unreleased +## 0.17.0 + +### :boom: Breaking Change + +* `opentelemetry-api-metrics`, `opentelemetry-api`, `opentelemetry-core`, `opentelemetry-exporter-collector-grpc`, `opentelemetry-exporter-collector-proto`, `opentelemetry-exporter-collector`, `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-prometheus`, `opentelemetry-exporter-zipkin`, `opentelemetry-grpc-utils`, `opentelemetry-instrumentation-fetch`, `opentelemetry-instrumentation-grpc`, `opentelemetry-instrumentation-http`, `opentelemetry-instrumentation-xml-http-request`, `opentelemetry-instrumentation`, `opentelemetry-metrics`, `opentelemetry-node`, `opentelemetry-plugin-grpc-js`, `opentelemetry-plugin-grpc`, `opentelemetry-plugin-http`, `opentelemetry-plugin-https`, `opentelemetry-resource-detector-aws`, `opentelemetry-resource-detector-gcp`, `opentelemetry-resources`, `opentelemetry-sdk-node`, `opentelemetry-shim-opentracing`, `opentelemetry-tracing`, `opentelemetry-web` + * [#1925](/~https://github.com/open-telemetry/opentelemetry-js/pull/1925) feat(diag-logger): replace logger with diag logger ([@MSNev](/~https://github.com/MSNev)) +* `opentelemetry-api`, `opentelemetry-instrumentation-http`, `opentelemetry-node`, `opentelemetry-plugin-http`, `opentelemetry-tracing` + * [#1899](/~https://github.com/open-telemetry/opentelemetry-js/pull/1899) chore: create NoopSpan instead reusing NOOP_SPAN ([@Flarna](/~https://github.com/Flarna)) +* `opentelemetry-tracing` + * [#1908](/~https://github.com/open-telemetry/opentelemetry-js/pull/1908) chore: remove config from BasicTracerProvider#getTracer ([@Flarna](/~https://github.com/Flarna)) +* `opentelemetry-core`, `opentelemetry-instrumentation-http`, `opentelemetry-node`, `opentelemetry-plugin-http`, `opentelemetry-tracing` + * [#1900](/~https://github.com/open-telemetry/opentelemetry-js/pull/1900) chore: remove NoRecordingSpan ([@Flarna](/~https://github.com/Flarna)) +* `opentelemetry-instrumentation-fetch`, `opentelemetry-instrumentation-xml-http-request`, `opentelemetry-instrumentation`, `opentelemetry-node`, `opentelemetry-sdk-node`, `opentelemetry-web` + * [#1855](/~https://github.com/open-telemetry/opentelemetry-js/pull/1855) Use instrumentation loader to load plugins and instrumentations ([@obecny](/~https://github.com/obecny)) +* `opentelemetry-api`, `opentelemetry-core`, `opentelemetry-shim-opentracing` + * [#1876](/~https://github.com/open-telemetry/opentelemetry-js/pull/1876) refactor!: specification compliant baggage ([@dyladan](/~https://github.com/dyladan)) +* `opentelemetry-api-metrics`, `opentelemetry-api`, `opentelemetry-context-async-hooks`, `opentelemetry-context-base`, `opentelemetry-context-zone-peer-dep`, `opentelemetry-context-zone`, `opentelemetry-core`, `opentelemetry-exporter-collector-grpc`, `opentelemetry-exporter-collector-proto`, `opentelemetry-exporter-collector`, `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-prometheus`, `opentelemetry-exporter-zipkin`, `opentelemetry-grpc-utils`, `opentelemetry-instrumentation-fetch`, `opentelemetry-instrumentation-grpc`, `opentelemetry-instrumentation-http`, `opentelemetry-instrumentation-xml-http-request`, `opentelemetry-instrumentation`, `opentelemetry-metrics`, `opentelemetry-node`, `opentelemetry-plugin-grpc-js`, `opentelemetry-plugin-grpc`, `opentelemetry-plugin-http`, `opentelemetry-plugin-https`, `opentelemetry-propagator-b3`, `opentelemetry-resource-detector-aws`, `opentelemetry-resource-detector-gcp`, `opentelemetry-resources`, `opentelemetry-sdk-node`, `opentelemetry-semantic-conventions`, `opentelemetry-shim-opentracing`, `opentelemetry-tracing`, `opentelemetry-web` + * [#1874](/~https://github.com/open-telemetry/opentelemetry-js/pull/1874) More specific api type names ([@dyladan](/~https://github.com/dyladan)) + +### :rocket: (Enhancement) + +* `opentelemetry-exporter-prometheus` + * [#1857](/~https://github.com/open-telemetry/opentelemetry-js/pull/1857) feat: add prometheus exporter host and port env vars ([@naseemkullah](/~https://github.com/naseemkullah)) + * [#1879](/~https://github.com/open-telemetry/opentelemetry-js/pull/1879) feat(prometheus): add `getMetricsRequestHandler`-method to Prometheus ([@weyert](/~https://github.com/weyert)) +* `opentelemetry-core`, `opentelemetry-tracing` + * [#1918](/~https://github.com/open-telemetry/opentelemetry-js/pull/1918) chore: batch processor, aligning with latest spec changes for environments variables ([@obecny](/~https://github.com/obecny)) +* `opentelemetry-instrumentation-grpc` + * [#1806](/~https://github.com/open-telemetry/opentelemetry-js/pull/1806) feat: merge grpc-js into grpc instrumentation #1657 ([@vmarchaud](/~https://github.com/vmarchaud)) +* `opentelemetry-api`, `opentelemetry-core` + * [#1880](/~https://github.com/open-telemetry/opentelemetry-js/pull/1880) feat(diag-logger): introduce a new global level api.diag for internal diagnostic logging ([@MSNev](/~https://github.com/MSNev)) +* Other + * [#1920](/~https://github.com/open-telemetry/opentelemetry-js/pull/1920) chore: adding compatibility matrix for core and contrib versions ([@obecny](/~https://github.com/obecny)) +* `opentelemetry-api`, `opentelemetry-context-async-hooks`, `opentelemetry-context-base`, `opentelemetry-context-zone-peer-dep`, `opentelemetry-tracing`, `opentelemetry-web` + * [#1883](/~https://github.com/open-telemetry/opentelemetry-js/pull/1883) feat: add support to forward args in context.with ([@Flarna](/~https://github.com/Flarna)) +* `opentelemetry-api`, `opentelemetry-core`, `opentelemetry-shim-opentracing` + * [#1876](/~https://github.com/open-telemetry/opentelemetry-js/pull/1876) refactor!: specification compliant baggage ([@dyladan](/~https://github.com/dyladan)) + +### :books: (Refine Doc) + +* Other + * [#1904](/~https://github.com/open-telemetry/opentelemetry-js/pull/1904) chore: fix upgrade guideline ([@dyladan](/~https://github.com/dyladan)) +* `opentelemetry-api` + * [#1901](/~https://github.com/open-telemetry/opentelemetry-js/pull/1901) doc: correct tracer docs ([@Flarna](/~https://github.com/Flarna)) + +### Committers: 8 + +* 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)) +* Nev ([@MSNev](/~https://github.com/MSNev)) +* Srikanth Chekuri ([@lonewolf3739](/~https://github.com/lonewolf3739)) +* Valentin Marchaud ([@vmarchaud](/~https://github.com/vmarchaud)) +* Weyert de Boer ([@weyert](/~https://github.com/weyert)) + ## 0.16.0 ### :boom: Breaking Change diff --git a/backwards-compatability/node10/package.json b/backwards-compatability/node10/package.json index e1248cf43c7..4e8f2c69915 100644 --- a/backwards-compatability/node10/package.json +++ b/backwards-compatability/node10/package.json @@ -1,6 +1,6 @@ { "name": "backcompat-node10", - "version": "0.16.0", + "version": "0.17.0", "private": true, "description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK", "main": "index.js", @@ -8,8 +8,8 @@ "test:backcompat": "tsc --noEmit index.ts" }, "dependencies": { - "@opentelemetry/sdk-node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/sdk-node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "devDependencies": { "@types/node": "10.17.50", diff --git a/backwards-compatability/node12/package.json b/backwards-compatability/node12/package.json index c8f58ae0358..39f88627d79 100644 --- a/backwards-compatability/node12/package.json +++ b/backwards-compatability/node12/package.json @@ -1,6 +1,6 @@ { "name": "backcompat-node12", - "version": "0.16.0", + "version": "0.17.0", "private": true, "description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK", "main": "index.js", @@ -8,8 +8,8 @@ "test:backcompat": "tsc --noEmit index.ts" }, "dependencies": { - "@opentelemetry/sdk-node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/sdk-node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "devDependencies": { "@types/node": "12.19.13", diff --git a/backwards-compatability/node8/package.json b/backwards-compatability/node8/package.json index be776a6c775..5abd56e75f4 100644 --- a/backwards-compatability/node8/package.json +++ b/backwards-compatability/node8/package.json @@ -1,6 +1,6 @@ { "name": "backcompat-node8", - "version": "0.16.0", + "version": "0.17.0", "private": true, "description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK", "main": "index.js", @@ -8,8 +8,8 @@ "test:backcompat": "tsc --noEmit index.ts" }, "dependencies": { - "@opentelemetry/sdk-node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/sdk-node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "devDependencies": { "@types/node": "8.10.66", diff --git a/examples/basic-tracer-node/package.json b/examples/basic-tracer-node/package.json index c91504a97bf..a48c82c57c4 100644 --- a/examples/basic-tracer-node/package.json +++ b/examples/basic-tracer-node/package.json @@ -1,7 +1,7 @@ { "name": "example-basic-tracer-node", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/tracing in Node.js", "main": "index.js", "scripts": { @@ -24,9 +24,9 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/collector-exporter-node/package.json b/examples/collector-exporter-node/package.json index 22404991716..bd09e6bf68e 100644 --- a/examples/collector-exporter-node/package.json +++ b/examples/collector-exporter-node/package.json @@ -1,7 +1,7 @@ { "name": "example-collector-exporter-node", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/collector-exporter in Node.js", "main": "index.js", "scripts": { @@ -28,13 +28,13 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/exporter-collector": "^0.16.0", - "@opentelemetry/exporter-collector-grpc": "^0.16.0", - "@opentelemetry/exporter-collector-proto": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/exporter-collector": "^0.17.0", + "@opentelemetry/exporter-collector-grpc": "^0.17.0", + "@opentelemetry/exporter-collector-proto": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/grpc-js/package.json b/examples/grpc-js/package.json index 8a91ed23bc3..738dd9568bb 100644 --- a/examples/grpc-js/package.json +++ b/examples/grpc-js/package.json @@ -1,7 +1,7 @@ { "name": "grpc-js-example", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of @grpc/grpc-js integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -29,13 +29,13 @@ }, "dependencies": { "@grpc/grpc-js": "^1.0.5", - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/plugin-grpc-js": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/plugin-grpc-js": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "google-protobuf": "^3.9.2" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/examples/grpc/package.json b/examples/grpc/package.json index 376f4772878..32d25d0595c 100644 --- a/examples/grpc/package.json +++ b/examples/grpc/package.json @@ -1,7 +1,7 @@ { "name": "grpc-example", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of gRPC integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -28,13 +28,13 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/plugin-grpc": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/plugin-grpc": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "google-protobuf": "^3.9.2", "grpc": "^1.23.3", "node-pre-gyp": "0.14.0" diff --git a/examples/http/package.json b/examples/http/package.json index bb2855589c8..65d4e9c8da2 100644 --- a/examples/http/package.json +++ b/examples/http/package.json @@ -1,7 +1,7 @@ { "name": "http-example", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of HTTP integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -28,13 +28,13 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/plugin-http": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/plugin-http": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { diff --git a/examples/https/package.json b/examples/https/package.json index e980b874a2e..43884d786f0 100644 --- a/examples/https/package.json +++ b/examples/https/package.json @@ -1,7 +1,7 @@ { "name": "https-example", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of HTTPs integration with OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -29,13 +29,13 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/plugin-https": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/plugin-https": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { diff --git a/examples/metrics/package.json b/examples/metrics/package.json index bdb2a9c7c92..2bef79928b7 100644 --- a/examples/metrics/package.json +++ b/examples/metrics/package.json @@ -1,7 +1,7 @@ { "name": "example-metrics", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/metrics", "main": "index.js", "scripts": { @@ -26,9 +26,9 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/exporter-prometheus": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0" + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/exporter-prometheus": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/opentracing-shim/package.json b/examples/opentracing-shim/package.json index bd075610093..2cbd42c40d7 100644 --- a/examples/opentracing-shim/package.json +++ b/examples/opentracing-shim/package.json @@ -1,7 +1,7 @@ { "name": "opentracing-shim", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/shim-opentracing in Node.js", "main": "index.js", "scripts": { @@ -29,12 +29,12 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/exporter-jaeger": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/shim-opentracing": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/exporter-jaeger": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/shim-opentracing": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "opentracing": "^0.14.4" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/examples/prometheus/package.json b/examples/prometheus/package.json index 56eb9b7e14b..4c23a5012f8 100644 --- a/examples/prometheus/package.json +++ b/examples/prometheus/package.json @@ -1,6 +1,6 @@ { "name": "prometheus-example", - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/metrics and @opentelemetry/exporter-prometheus", "main": "index.js", "scripts": { @@ -9,7 +9,7 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/exporter-prometheus": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0" + "@opentelemetry/exporter-prometheus": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0" } } diff --git a/examples/tracer-web/package.json b/examples/tracer-web/package.json index ca1094ecda1..d31fa8a2314 100644 --- a/examples/tracer-web/package.json +++ b/examples/tracer-web/package.json @@ -1,7 +1,7 @@ { "name": "web-tracer-example", "private": true, - "version": "0.16.0", + "version": "0.17.0", "description": "Example of using @opentelemetry/web in browser", "main": "index.js", "scripts": { @@ -34,20 +34,20 @@ "webpack-merge": "^4.2.2" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-zone": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/exporter-collector": "^0.16.0", - "@opentelemetry/exporter-zipkin": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/instrumentation-fetch": "^0.16.0", - "@opentelemetry/instrumentation-xml-http-request": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-zone": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/exporter-collector": "^0.17.0", + "@opentelemetry/exporter-zipkin": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/instrumentation-fetch": "^0.17.0", + "@opentelemetry/instrumentation-xml-http-request": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", "@opentelemetry/plugin-document-load": "^0.12.0", "@opentelemetry/plugin-user-interaction": "^0.12.0", - "@opentelemetry/propagator-b3": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", - "@opentelemetry/web": "^0.16.0" + "@opentelemetry/propagator-b3": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", + "@opentelemetry/web": "^0.17.0" }, "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/getting-started/example/package.json b/getting-started/example/package.json index 38362990afc..3df947cde1f 100644 --- a/getting-started/example/package.json +++ b/getting-started/example/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/getting-started-example", - "version": "0.16.0", + "version": "0.17.0", "description": "This repository provides everything required to follow the OpenTelemetry Getting Started Guide", "main": "app.js", "scripts": { diff --git a/getting-started/monitored-example/package.json b/getting-started/monitored-example/package.json index ebcdc454cb2..f95b084d226 100644 --- a/getting-started/monitored-example/package.json +++ b/getting-started/monitored-example/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/getting-started-monitored-example", - "version": "0.16.0", + "version": "0.17.0", "description": "This repository provides everything required to follow the OpenTelemetry Getting Started Guide", "main": "app.js", "scripts": { @@ -9,8 +9,8 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/exporter-prometheus": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", + "@opentelemetry/exporter-prometheus": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", "axios": "^0.21.0", "express": "^4.17.1" } diff --git a/getting-started/traced-example/package.json b/getting-started/traced-example/package.json index 85b6088f492..c095b816a95 100644 --- a/getting-started/traced-example/package.json +++ b/getting-started/traced-example/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/getting-started-traced-example", - "version": "0.16.0", + "version": "0.17.0", "description": "This repository provides everything required to follow the OpenTelemetry Getting Started Guide", "main": "app.js", "scripts": { @@ -12,7 +12,7 @@ "@opentelemetry/core": "^0.14.0", "@opentelemetry/exporter-zipkin": "^0.14.0", "@opentelemetry/node": "^0.14.0", - "@opentelemetry/instrumentation": "^0.16.0", + "@opentelemetry/instrumentation": "^0.17.0", "@opentelemetry/plugin-express": "^0.12.1", "@opentelemetry/plugin-http": "^0.14.0", "@opentelemetry/plugin-https": "^0.14.0", diff --git a/getting-started/ts-example/monitored-example/package.json b/getting-started/ts-example/monitored-example/package.json index 6dc49609699..ee423582459 100644 --- a/getting-started/ts-example/monitored-example/package.json +++ b/getting-started/ts-example/monitored-example/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/getting-started-monitored-ts-example", - "version": "0.16.0", + "version": "0.17.0", "description": "This repository provides everything required to follow the OpenTelemetry Getting Started Guide", "main": "app.ts", "scripts": { @@ -14,8 +14,8 @@ "ts-node": "8.10.2" }, "dependencies": { - "@opentelemetry/exporter-prometheus": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", + "@opentelemetry/exporter-prometheus": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", "axios": "^0.21.0", "express": "^4.17.1" } diff --git a/getting-started/ts-example/traced-example/package.json b/getting-started/ts-example/traced-example/package.json index af48f04aa97..104213fbb0c 100644 --- a/getting-started/ts-example/traced-example/package.json +++ b/getting-started/ts-example/traced-example/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/getting-started-traced-ts-example", - "version": "0.16.0", + "version": "0.17.0", "description": "This repository provides everything required to follow the OpenTelemetry Getting Started Guide", "main": "app.ts", "scripts": { diff --git a/integration-tests/propagation-validation-server/package.json b/integration-tests/propagation-validation-server/package.json index 3e38e6fc71d..5d3a93f982e 100644 --- a/integration-tests/propagation-validation-server/package.json +++ b/integration-tests/propagation-validation-server/package.json @@ -1,6 +1,6 @@ { "name": "propagation-validation-server", - "version": "0.16.0", + "version": "0.17.0", "description": "server for w3c tests", "main": "validation_server.js", "private": true, @@ -11,10 +11,10 @@ "compile": "tsc --build" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "axios": "0.21.1", "body-parser": "1.19.0", "express": "4.17.1" diff --git a/lerna.json b/lerna.json index 47313895b40..4ae937b81a8 100644 --- a/lerna.json +++ b/lerna.json @@ -8,7 +8,7 @@ "packages/*", "integration-tests/*" ], - "version": "0.16.0", + "version": "0.17.0", "changelog": { "repo": "open-telemetry/opentelemetry-js", "labels": { diff --git a/metapackages/plugins-node-core/package.json b/metapackages/plugins-node-core/package.json index bdf089477d1..ff91ddc5194 100644 --- a/metapackages/plugins-node-core/package.json +++ b/metapackages/plugins-node-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugins-node-core", - "version": "0.16.0", + "version": "0.17.0", "description": "Metapackage which bundles all opentelemetry node core plugins", "author": "OpenTelemetry Authors", "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", @@ -16,9 +16,9 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/plugin-grpc": "^0.16.0", - "@opentelemetry/plugin-grpc-js": "^0.16.0", - "@opentelemetry/plugin-http": "^0.16.0", - "@opentelemetry/plugin-https": "^0.16.0" + "@opentelemetry/plugin-grpc": "^0.17.0", + "@opentelemetry/plugin-grpc-js": "^0.17.0", + "@opentelemetry/plugin-http": "^0.17.0", + "@opentelemetry/plugin-https": "^0.17.0" } } diff --git a/metapackages/plugins-web-core/package.json b/metapackages/plugins-web-core/package.json index b0df8da0724..3a6d87c0b22 100644 --- a/metapackages/plugins-web-core/package.json +++ b/metapackages/plugins-web-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugins-web-core", - "version": "0.16.0", + "version": "0.17.0", "description": "Metapackage which bundles all opentelemetry web core plugins", "author": "OpenTelemetry Authors", "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", @@ -16,6 +16,6 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/instrumentation-xml-http-request": "^0.16.0" + "@opentelemetry/instrumentation-xml-http-request": "^0.17.0" } } diff --git a/package-lock.json b/package-lock.json index f679a22af6a..031ce78725a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "opentelemetry-base", - "version": "0.16.0", + "version": "0.17.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d741c43c6f3..ef2107e5001 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opentelemetry-base", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry is a distributed tracing and stats collection framework.", "main": "build/src/index.js", "types": "build/src/index.d.ts", diff --git a/packages/opentelemetry-api-metrics/package.json b/packages/opentelemetry-api-metrics/package.json index 8d69e94a244..44da79ad82c 100644 --- a/packages/opentelemetry-api-metrics/package.json +++ b/packages/opentelemetry-api-metrics/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api-metrics", - "version": "0.16.0", + "version": "0.17.0", "description": "Public metrics API for OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -48,7 +48,7 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "^0.16.0" + "@opentelemetry/api": "^0.17.0" }, "devDependencies": { "@types/mocha": "8.2.0", diff --git a/packages/opentelemetry-api-metrics/src/version.ts b/packages/opentelemetry-api-metrics/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-api-metrics/src/version.ts +++ b/packages/opentelemetry-api-metrics/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json index ed942a8df39..3c9e10aae78 100644 --- a/packages/opentelemetry-api/package.json +++ b/packages/opentelemetry-api/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api", - "version": "0.16.0", + "version": "0.17.0", "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -50,7 +50,7 @@ "access": "public" }, "dependencies": { - "@opentelemetry/context-base": "^0.16.0" + "@opentelemetry/context-base": "^0.17.0" }, "devDependencies": { "@types/mocha": "8.2.0", diff --git a/packages/opentelemetry-api/src/api/global-utils.ts b/packages/opentelemetry-api/src/api/global-utils.ts index b0a0e522247..a4b8f6f2800 100644 --- a/packages/opentelemetry-api/src/api/global-utils.ts +++ b/packages/opentelemetry-api/src/api/global-utils.ts @@ -67,4 +67,4 @@ export function makeGetter( * version. If the global API is not compatible with the API package * attempting to get it, a NOOP API implementation will be returned. */ -export const API_BACKWARDS_COMPATIBILITY_VERSION = 4; +export const API_BACKWARDS_COMPATIBILITY_VERSION = 5; diff --git a/packages/opentelemetry-api/src/version.ts b/packages/opentelemetry-api/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-api/src/version.ts +++ b/packages/opentelemetry-api/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 24fe969da35..fbd1ce4b02c 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-async-hooks", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry AsyncHooks-based Context Manager", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -53,6 +53,6 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/context-base": "^0.16.0" + "@opentelemetry/context-base": "^0.17.0" } } diff --git a/packages/opentelemetry-context-async-hooks/src/version.ts b/packages/opentelemetry-context-async-hooks/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-context-async-hooks/src/version.ts +++ b/packages/opentelemetry-context-async-hooks/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-context-base/package.json b/packages/opentelemetry-context-base/package.json index cd2b9b6e27d..ff3cbe3ce5c 100644 --- a/packages/opentelemetry-context-base/package.json +++ b/packages/opentelemetry-context-base/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-base", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Base Context Manager", "main": "build/src/index.js", "types": "build/src/index.d.ts", diff --git a/packages/opentelemetry-context-base/src/version.ts b/packages/opentelemetry-context-base/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-context-base/src/version.ts +++ b/packages/opentelemetry-context-base/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index d8ce2941495..b21698246f9 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-zone-peer-dep", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Context Zone with peer dependency for zone.js", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -70,7 +70,7 @@ "zone.js": "0.11.3" }, "dependencies": { - "@opentelemetry/context-base": "^0.16.0" + "@opentelemetry/context-base": "^0.17.0" }, "peerDependencies": { "zone.js": "^0.10.2 || ^0.11.0" diff --git a/packages/opentelemetry-context-zone-peer-dep/src/version.ts b/packages/opentelemetry-context-zone-peer-dep/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/version.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index e64497b0b7e..f923d2643ad 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-zone", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Context Zone", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -64,7 +64,7 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/context-zone-peer-dep": "^0.16.0", + "@opentelemetry/context-zone-peer-dep": "^0.17.0", "zone.js": "^0.11.0" }, "sideEffects": true diff --git a/packages/opentelemetry-context-zone/src/version.ts b/packages/opentelemetry-context-zone/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-context-zone/src/version.ts +++ b/packages/opentelemetry-context-zone/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 542b074c327..c1711837b67 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/core", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics", "main": "build/src/index.js", "browser": { @@ -50,7 +50,7 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/propagator-b3": "^0.16.0", + "@opentelemetry/propagator-b3": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -76,8 +76,8 @@ "webpack": "4.46.0" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", "semver": "^7.1.3" } } diff --git a/packages/opentelemetry-core/src/version.ts b/packages/opentelemetry-core/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-core/src/version.ts +++ b/packages/opentelemetry-core/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-collector-grpc/package.json b/packages/opentelemetry-exporter-collector-grpc/package.json index 44532de384c..cf5b2fb952e 100644 --- a/packages/opentelemetry-exporter-collector-grpc/package.json +++ b/packages/opentelemetry-exporter-collector-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-collector-grpc", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -46,7 +46,7 @@ }, "devDependencies": { "@babel/core": "7.12.10", - "@opentelemetry/api-metrics": "^0.16.0", + "@opentelemetry/api-metrics": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/sinon": "9.0.10", @@ -64,12 +64,12 @@ }, "dependencies": { "@grpc/proto-loader": "^0.5.4", - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/exporter-collector": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/exporter-collector": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "grpc": "^1.24.2" } } diff --git a/packages/opentelemetry-exporter-collector-grpc/src/version.ts b/packages/opentelemetry-exporter-collector-grpc/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-collector-grpc/src/version.ts +++ b/packages/opentelemetry-exporter-collector-grpc/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-collector-proto/package.json b/packages/opentelemetry-exporter-collector-proto/package.json index ba044bed240..3494fd1c1b3 100644 --- a/packages/opentelemetry-exporter-collector-proto/package.json +++ b/packages/opentelemetry-exporter-collector-proto/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-collector-proto", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -46,7 +46,7 @@ }, "devDependencies": { "@babel/core": "7.12.10", - "@opentelemetry/api-metrics": "^0.16.0", + "@opentelemetry/api-metrics": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/sinon": "9.0.10", @@ -64,12 +64,12 @@ }, "dependencies": { "@grpc/proto-loader": "^0.5.4", - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/exporter-collector": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/exporter-collector": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "protobufjs": "^6.9.0" } } diff --git a/packages/opentelemetry-exporter-collector-proto/src/version.ts b/packages/opentelemetry-exporter-collector-proto/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-collector-proto/src/version.ts +++ b/packages/opentelemetry-exporter-collector-proto/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index 03b3b4e158a..c4697ecc218 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-collector", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -77,11 +77,11 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" } } diff --git a/packages/opentelemetry-exporter-collector/src/version.ts b/packages/opentelemetry-exporter-collector/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-collector/src/version.ts +++ b/packages/opentelemetry-exporter-collector/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index cef114ebe3e..fc6af3a595b 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-jaeger", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Exporter Jaeger allows user to send collected traces to Jaeger", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -40,7 +40,7 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/resources": "^0.16.0", + "@opentelemetry/resources": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/sinon": "9.0.10", @@ -56,9 +56,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "jaeger-client": "^3.15.0" } } diff --git a/packages/opentelemetry-exporter-jaeger/src/version.ts b/packages/opentelemetry-exporter-jaeger/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-jaeger/src/version.ts +++ b/packages/opentelemetry-exporter-jaeger/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index d3d53820466..cb768917ce0 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-prometheus", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -53,9 +53,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0" } } diff --git a/packages/opentelemetry-exporter-prometheus/src/version.ts b/packages/opentelemetry-exporter-prometheus/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-prometheus/src/version.ts +++ b/packages/opentelemetry-exporter-prometheus/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index d1ebcc1ee9e..93bcdd63c02 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-zipkin", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Zipkin Exporter allows the user to send collected traces to Zipkin.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -75,9 +75,9 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" } } diff --git a/packages/opentelemetry-exporter-zipkin/src/version.ts b/packages/opentelemetry-exporter-zipkin/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-exporter-zipkin/src/version.ts +++ b/packages/opentelemetry-exporter-zipkin/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-grpc-utils/package.json b/packages/opentelemetry-grpc-utils/package.json index 5203859c4f0..1929f1bd649 100644 --- a/packages/opentelemetry-grpc-utils/package.json +++ b/packages/opentelemetry-grpc-utils/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/grpc-utils", - "version": "0.16.0", + "version": "0.17.0", "private": true, "description": "OpenTelemetry grpc plugin utility functions.", "main": "build/src/index.js", @@ -42,10 +42,10 @@ "devDependencies": { "@grpc/grpc-js": "1.2.3", "@grpc/proto-loader": "0.5.5", - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -65,9 +65,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "shimmer": "1.2.1" } } diff --git a/packages/opentelemetry-grpc-utils/src/version.ts b/packages/opentelemetry-grpc-utils/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-grpc-utils/src/version.ts +++ b/packages/opentelemetry-grpc-utils/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-instrumentation-fetch/package.json b/packages/opentelemetry-instrumentation-fetch/package.json index 9b56089c900..1026cbb51ad 100644 --- a/packages/opentelemetry-instrumentation-fetch/package.json +++ b/packages/opentelemetry-instrumentation-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-fetch", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry fetch automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,9 +43,9 @@ }, "devDependencies": { "@babel/core": "7.12.10", - "@opentelemetry/context-zone": "^0.16.0", - "@opentelemetry/propagator-b3": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-zone": "^0.17.0", + "@opentelemetry/propagator-b3": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/shimmer": "1.0.1", @@ -74,10 +74,10 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", - "@opentelemetry/web": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", + "@opentelemetry/web": "^0.17.0" } } diff --git a/packages/opentelemetry-instrumentation-fetch/src/version.ts b/packages/opentelemetry-instrumentation-fetch/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-instrumentation-fetch/src/version.ts +++ b/packages/opentelemetry-instrumentation-fetch/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-instrumentation-grpc/package.json b/packages/opentelemetry-instrumentation-grpc/package.json index 10efa653eb7..8f222485d0b 100644 --- a/packages/opentelemetry-instrumentation-grpc/package.json +++ b/packages/opentelemetry-instrumentation-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-grpc", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry grpc automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,11 +43,11 @@ "devDependencies": { "@grpc/grpc-js": "1.2.3", "@grpc/proto-loader": "0.5.5", - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -67,9 +67,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0" } } diff --git a/packages/opentelemetry-instrumentation-grpc/src/version.ts b/packages/opentelemetry-instrumentation-grpc/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-instrumentation-grpc/src/version.ts +++ b/packages/opentelemetry-instrumentation-grpc/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-instrumentation-http/package.json b/packages/opentelemetry-instrumentation-http/package.json index d1dc58c4a93..103723711d5 100644 --- a/packages/opentelemetry-instrumentation-http/package.json +++ b/packages/opentelemetry-instrumentation-http/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-http", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry http/https automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -41,11 +41,11 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/got": "9.6.11", "@types/mocha": "8.2.0", "@types/node": "14.14.20", @@ -70,9 +70,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "semver": "^7.1.3" } } diff --git a/packages/opentelemetry-instrumentation-http/src/version.ts b/packages/opentelemetry-instrumentation-http/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-instrumentation-http/src/version.ts +++ b/packages/opentelemetry-instrumentation-http/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-instrumentation-xml-http-request/package.json b/packages/opentelemetry-instrumentation-xml-http-request/package.json index 0572aab4ec3..57848399875 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation-xml-http-request", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry XMLHttpRequest automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,9 +43,9 @@ }, "devDependencies": { "@babel/core": "7.12.10", - "@opentelemetry/context-zone": "^0.16.0", - "@opentelemetry/propagator-b3": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-zone": "^0.17.0", + "@opentelemetry/propagator-b3": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/sinon": "9.0.10", @@ -73,10 +73,10 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", - "@opentelemetry/web": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", + "@opentelemetry/web": "^0.17.0" } } diff --git a/packages/opentelemetry-instrumentation-xml-http-request/src/version.ts b/packages/opentelemetry-instrumentation-xml-http-request/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-instrumentation-xml-http-request/src/version.ts +++ b/packages/opentelemetry-instrumentation-xml-http-request/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-instrumentation/package.json b/packages/opentelemetry-instrumentation/package.json index f245f9d6448..16e9a437c63 100644 --- a/packages/opentelemetry-instrumentation/package.json +++ b/packages/opentelemetry-instrumentation/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/instrumentation", - "version": "0.16.0", + "version": "0.17.0", "description": "Base class for node which OpenTelemetry instrumentation modules extend", "author": "OpenTelemetry Authors", "homepage": "/~https://github.com/open-telemetry/opentelemetry-js#readme", @@ -54,8 +54,8 @@ "url": "/~https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", "require-in-the-middle": "^5.0.3", "semver": "^7.3.2", "shimmer": "^1.2.1" diff --git a/packages/opentelemetry-instrumentation/src/version.ts b/packages/opentelemetry-instrumentation/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-instrumentation/src/version.ts +++ b/packages/opentelemetry-instrumentation/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index b7724ace7c8..ab05a5c8612 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/metrics", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry metrics SDK", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -55,10 +55,10 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", "lodash.merge": "^4.6.2" } } diff --git a/packages/opentelemetry-metrics/src/version.ts b/packages/opentelemetry-metrics/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-metrics/src/version.ts +++ b/packages/opentelemetry-metrics/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 10a6dc68818..92d4a5cdf0e 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/node", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Node SDK provides automatic telemetry (tracing, metrics, etc) for Node.js applications", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -41,8 +41,8 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -60,10 +60,10 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "semver": "^7.1.3" } } diff --git a/packages/opentelemetry-node/src/version.ts b/packages/opentelemetry-node/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-node/src/version.ts +++ b/packages/opentelemetry-node/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-plugin-grpc-js/package.json b/packages/opentelemetry-plugin-grpc-js/package.json index 809da5ff89c..17f823e272c 100644 --- a/packages/opentelemetry-plugin-grpc-js/package.json +++ b/packages/opentelemetry-plugin-grpc-js/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-grpc-js", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry @grpc/grpc-js automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,11 +43,11 @@ }, "devDependencies": { "@grpc/grpc-js": "1.2.3", - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/grpc-utils": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/grpc-utils": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -65,9 +65,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "shimmer": "1.2.1" } } diff --git a/packages/opentelemetry-plugin-grpc-js/src/version.ts b/packages/opentelemetry-plugin-grpc-js/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/version.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json index 96551643f36..52420f3f52e 100644 --- a/packages/opentelemetry-plugin-grpc/package.json +++ b/packages/opentelemetry-plugin-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-grpc", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry grpc automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -40,11 +40,11 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/grpc-utils": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/grpc-utils": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -64,9 +64,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-grpc/src/version.ts b/packages/opentelemetry-plugin-grpc/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-plugin-grpc/src/version.ts +++ b/packages/opentelemetry-plugin-grpc/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-plugin-http/package.json b/packages/opentelemetry-plugin-http/package.json index a5eca9ef85e..9c01644d1af 100644 --- a/packages/opentelemetry-plugin-http/package.json +++ b/packages/opentelemetry-plugin-http/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-http", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry http automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -41,10 +41,10 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/got": "9.6.11", "@types/mocha": "8.2.0", "@types/node": "14.14.20", @@ -70,9 +70,9 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "semver": "^7.1.3", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-http/src/version.ts b/packages/opentelemetry-plugin-http/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-plugin-http/src/version.ts +++ b/packages/opentelemetry-plugin-http/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json index bff552f8b37..0650680a44a 100644 --- a/packages/opentelemetry-plugin-https/package.json +++ b/packages/opentelemetry-plugin-https/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-https", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry https automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -40,10 +40,10 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "@types/got": "9.6.11", "@types/mocha": "8.2.0", "@types/node": "14.14.20", @@ -69,10 +69,10 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/plugin-http": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/plugin-http": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "semver": "^7.1.3", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-https/src/version.ts b/packages/opentelemetry-plugin-https/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-plugin-https/src/version.ts +++ b/packages/opentelemetry-plugin-https/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index 2f11f7bc10b..7ca41c14476 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/propagator-b3", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry B3 propagator provides context propagation for systems that are using the B3 header format", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -39,10 +39,10 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "^0.16.0" + "@opentelemetry/api": "^0.17.0" }, "devDependencies": { - "@opentelemetry/context-base": "^0.16.0", + "@opentelemetry/context-base": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "codecov": "3.8.1", diff --git a/packages/opentelemetry-propagator-b3/src/version.ts b/packages/opentelemetry-propagator-b3/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-propagator-b3/src/version.ts +++ b/packages/opentelemetry-propagator-b3/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-resource-detector-aws/package.json b/packages/opentelemetry-resource-detector-aws/package.json index 4c5e6a2aebe..f93258f70da 100644 --- a/packages/opentelemetry-resource-detector-aws/package.json +++ b/packages/opentelemetry-resource-detector-aws/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/resource-detector-aws", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry SDK resource detector for AWS", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -54,8 +54,8 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/resources": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/resources": "^0.17.0" } } diff --git a/packages/opentelemetry-resource-detector-aws/src/version.ts b/packages/opentelemetry-resource-detector-aws/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-resource-detector-aws/src/version.ts +++ b/packages/opentelemetry-resource-detector-aws/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-resource-detector-gcp/package.json b/packages/opentelemetry-resource-detector-gcp/package.json index c2a91ad4d05..0e96e073df3 100644 --- a/packages/opentelemetry-resource-detector-gcp/package.json +++ b/packages/opentelemetry-resource-detector-gcp/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/resource-detector-gcp", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry SDK resource detector for GCP", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -39,7 +39,7 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/core": "^0.16.0", + "@opentelemetry/core": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", @@ -54,8 +54,8 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", "gcp-metadata": "^4.1.4", "semver": "7.3.4" } diff --git a/packages/opentelemetry-resource-detector-gcp/src/version.ts b/packages/opentelemetry-resource-detector-gcp/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-resource-detector-gcp/src/version.ts +++ b/packages/opentelemetry-resource-detector-gcp/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index bf163234cbf..516e61aeb4a 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/resources", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry SDK resources", "main": "build/src/index.js", "browser": { @@ -58,7 +58,7 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0" } } diff --git a/packages/opentelemetry-resources/src/version.ts b/packages/opentelemetry-resources/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-resources/src/version.ts +++ b/packages/opentelemetry-resources/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json index 417953ed1e6..dc30733ff03 100644 --- a/packages/opentelemetry-sdk-node/package.json +++ b/packages/opentelemetry-sdk-node/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/sdk-node", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry SDK for Node.js", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -40,21 +40,21 @@ "access": "public" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/api-metrics": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/instrumentation": "^0.16.0", - "@opentelemetry/metrics": "^0.16.0", - "@opentelemetry/node": "^0.16.0", - "@opentelemetry/resource-detector-aws": "^0.16.0", - "@opentelemetry/resource-detector-gcp": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/api-metrics": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/instrumentation": "^0.17.0", + "@opentelemetry/metrics": "^0.17.0", + "@opentelemetry/node": "^0.17.0", + "@opentelemetry/resource-detector-aws": "^0.17.0", + "@opentelemetry/resource-detector-gcp": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0", "nock": "12.0.3" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.16.0", + "@opentelemetry/context-async-hooks": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "@types/semver": "7.3.4", diff --git a/packages/opentelemetry-sdk-node/src/version.ts b/packages/opentelemetry-sdk-node/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-sdk-node/src/version.ts +++ b/packages/opentelemetry-sdk-node/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index 88dc22ba48d..5faf00475f8 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/semantic-conventions", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry semantic conventions", "main": "build/src/index.js", "types": "build/src/index.d.ts", diff --git a/packages/opentelemetry-semantic-conventions/src/version.ts b/packages/opentelemetry-semantic-conventions/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-semantic-conventions/src/version.ts +++ b/packages/opentelemetry-semantic-conventions/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index afb22f98d97..915b81dc334 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/shim-opentracing", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTracing to OpenTelemetry shim", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -38,7 +38,7 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/tracing": "^0.16.0", + "@opentelemetry/tracing": "^0.17.0", "@types/mocha": "8.2.0", "@types/node": "14.14.20", "codecov": "3.8.1", @@ -53,8 +53,8 @@ "typescript": "4.1.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/core": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/core": "^0.17.0", "opentracing": "^0.14.4" } } diff --git a/packages/opentelemetry-shim-opentracing/src/version.ts b/packages/opentelemetry-shim-opentracing/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-shim-opentracing/src/version.ts +++ b/packages/opentelemetry-shim-opentracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index e2bd41085b8..fac68331610 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/tracing", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Tracing", "main": "build/src/index.js", "browser": { @@ -73,11 +73,11 @@ "webpack": "4.46.0" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", "lodash.merge": "^4.6.2" } } diff --git a/packages/opentelemetry-tracing/src/version.ts b/packages/opentelemetry-tracing/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-tracing/src/version.ts +++ b/packages/opentelemetry-tracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index 34e256d721d..7d70693849f 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/web", - "version": "0.16.0", + "version": "0.17.0", "description": "OpenTelemetry Web Tracer", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,9 +42,9 @@ }, "devDependencies": { "@babel/core": "7.12.10", - "@opentelemetry/context-zone": "^0.16.0", - "@opentelemetry/propagator-b3": "^0.16.0", - "@opentelemetry/resources": "^0.16.0", + "@opentelemetry/context-zone": "^0.17.0", + "@opentelemetry/propagator-b3": "^0.17.0", + "@opentelemetry/resources": "^0.17.0", "@types/jquery": "3.5.5", "@types/mocha": "8.2.0", "@types/node": "14.14.20", @@ -74,10 +74,10 @@ "webpack-merge": "5.7.3" }, "dependencies": { - "@opentelemetry/api": "^0.16.0", - "@opentelemetry/context-base": "^0.16.0", - "@opentelemetry/core": "^0.16.0", - "@opentelemetry/semantic-conventions": "^0.16.0", - "@opentelemetry/tracing": "^0.16.0" + "@opentelemetry/api": "^0.17.0", + "@opentelemetry/context-base": "^0.17.0", + "@opentelemetry/core": "^0.17.0", + "@opentelemetry/semantic-conventions": "^0.17.0", + "@opentelemetry/tracing": "^0.17.0" } } diff --git a/packages/opentelemetry-web/src/version.ts b/packages/opentelemetry-web/src/version.ts index eacb17da857..2544b647a56 100644 --- a/packages/opentelemetry-web/src/version.ts +++ b/packages/opentelemetry-web/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.16.0'; +export const VERSION = '0.17.0'; diff --git a/packages/template/package.json b/packages/template/package.json index 71b6f646758..62c4287d353 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/template", - "version": "0.16.0", + "version": "0.17.0", "private": true, "publishConfig": { "access": "restricted"