@opentelemetry/sdk-node
Advanced tools
@@ -7,5 +7,5 @@ import { LogRecordProcessor } from '@opentelemetry/sdk-logs'; | ||
| /** | ||
| * Reference to the MetricReader instance by the NodeSDK | ||
| * Reference to the MetricReader instances by the NodeSDK | ||
| */ | ||
| reader?: IMetricReader; | ||
| readers?: IMetricReader[]; | ||
| /** | ||
@@ -12,0 +12,0 @@ * List of {@link ViewOptions}s that should be passed to the MeterProvider |
+11
-5
@@ -198,7 +198,13 @@ "use strict"; | ||
| } | ||
| if (configuration.metricReader || configuration.views) { | ||
| if (configuration.metricReaders || | ||
| configuration.metricReader || | ||
| configuration.views) { | ||
| const meterProviderConfig = {}; | ||
| if (configuration.metricReader) { | ||
| meterProviderConfig.reader = configuration.metricReader; | ||
| if (configuration.metricReaders) { | ||
| meterProviderConfig.readers = configuration.metricReaders; | ||
| } | ||
| else if (configuration.metricReader) { | ||
| meterProviderConfig.readers = [configuration.metricReader]; | ||
| api_1.diag.warn("The 'metricReader' option is deprecated. Please use 'metricReaders' instead."); | ||
| } | ||
| if (configuration.views) { | ||
@@ -262,4 +268,4 @@ meterProviderConfig.views = configuration.views; | ||
| const readers = []; | ||
| if (this._meterProviderConfig?.reader) { | ||
| readers.push(this._meterProviderConfig.reader); | ||
| if (this._meterProviderConfig?.readers) { | ||
| readers.push(...this._meterProviderConfig.readers); | ||
| } | ||
@@ -266,0 +272,0 @@ if (readers.length === 0) { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAM4B;AAC5B,sDAA+C;AAC/C,oEAGwC;AACxC,wDAUkC;AAClC,sDAOiC;AACjC,oFAAgG;AAChG,oFAAgG;AAChG,sFAAkG;AAClG,0FAAyG;AACzG,4FAA2G;AAC3G,0FAAyG;AACzG,4EAAoG;AACpG,4DAMoC;AACpC,kEAGuC;AACvC,kEAGuC;AACvC,8EAAwE;AAEx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ACH;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,IAAI,CAAC,qBAAqB,GAAG;gBAC3B,mBAAmB,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBAC5C,IAAI,QAAQ,YAAY,mCAAwB,EAAE;wBAChD,OAAO,IAAI,mCAAwB,CAAC,QAAQ,CAAC,CAAC;qBAC/C;yBAAM;wBACL,OAAO,IAAI,kCAAuB,CAAC,QAAQ,CAAC,CAAC;qBAC9C;gBACH,CAAC,CAAC;aACH,CAAC;SACH;IACH,CAAC;CACF;AAhTD,0BAgTC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ContextManager,\n TextMapPropagator,\n metrics,\n diag,\n DiagConsoleLogger,\n} from '@opentelemetry/api';\nimport { logs } from '@opentelemetry/api-logs';\nimport {\n Instrumentation,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n defaultResource,\n detectResources,\n envDetector,\n hostDetector,\n Resource,\n processDetector,\n ResourceDetectionConfig,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n LogRecordProcessor,\n LoggerProvider,\n BatchLogRecordProcessor,\n ConsoleLogRecordExporter,\n LogRecordExporter,\n SimpleLogRecordProcessor,\n} from '@opentelemetry/sdk-logs';\nimport { OTLPLogExporter as OTLPHttpLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPLogExporter as OTLPGrpcLogExporter } from '@opentelemetry/exporter-logs-otlp-grpc';\nimport { OTLPLogExporter as OTLPProtoLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';\nimport { OTLPMetricExporter as OTLPGrpcMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';\nimport { OTLPMetricExporter as OTLPProtoMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { OTLPMetricExporter as OTLPHttpMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';\nimport { PrometheusExporter as PrometheusMetricExporter } from '@opentelemetry/exporter-prometheus';\nimport {\n MeterProvider,\n IMetricReader,\n ViewOptions,\n ConsoleMetricExporter,\n PeriodicExportingMetricReader,\n} from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport {\n NodeTracerConfig,\n NodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport {\n getBooleanFromEnv,\n getStringFromEnv,\n getStringListFromEnv,\n diagLogLevelFromString,\n} from '@opentelemetry/core';\nimport {\n getResourceDetectorsFromEnv,\n getSpanProcessorsFromEnv,\n getPropagatorFromEnv,\n} from './utils';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\n\nexport type MeterProviderConfig = {\n /**\n * Reference to the MetricReader instance by the NodeSDK\n */\n reader?: IMetricReader;\n /**\n * List of {@link ViewOptions}s that should be passed to the MeterProvider\n */\n views?: ViewOptions[];\n};\n\nexport type LoggerProviderConfig = {\n /**\n * Reference to the LoggerRecordProcessor instance by the NodeSDK\n */\n logRecordProcessors: LogRecordProcessor[];\n};\n\n/**\n * @Returns param value, if set else returns the default value\n */\nfunction getValueInMillis(envName: string, defaultValue: number): number {\n return parseInt(process.env[envName] || '') || defaultValue;\n}\n\n/**\n *\n * @returns MetricReader[] if appropriate environment variables are configured\n */\nfunction configureMetricProviderFromEnv(): IMetricReader[] {\n const metricReaders: IMetricReader[] = [];\n const enabledExporters = getStringListFromEnv('OTEL_METRICS_EXPORTER');\n if (!enabledExporters) {\n return metricReaders;\n }\n\n if (enabledExporters.length === 0) {\n diag.debug('OTEL_METRICS_EXPORTER is empty. Using default otlp exporter.');\n }\n\n if (enabledExporters.includes('none')) {\n diag.info(\n `OTEL_METRICS_EXPORTER contains \"none\". Metric provider will not be initialized.`\n );\n return metricReaders;\n }\n enabledExporters.forEach(exporter => {\n if (exporter === 'otlp') {\n const protocol =\n process.env.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL?.trim() ||\n process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim();\n\n const exportIntervalMillis = getValueInMillis(\n 'OTEL_METRIC_EXPORT_INTERVAL',\n 60000\n );\n const exportTimeoutMillis = getValueInMillis(\n 'OTEL_METRIC_EXPORT_TIMEOUT',\n 30000\n );\n\n switch (protocol) {\n case 'grpc':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPGrpcMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n case 'http/json':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPHttpMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n case 'http/protobuf':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPProtoMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n default:\n diag.warn(\n `Unsupported OTLP metrics protocol: \"${protocol}\". Using http/protobuf.`\n );\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPProtoMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n }\n } else if (exporter === 'console') {\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new ConsoleMetricExporter(),\n })\n );\n } else if (exporter === 'prometheus') {\n metricReaders.push(new PrometheusMetricExporter());\n } else {\n diag.warn(\n `Unsupported OTEL_METRICS_EXPORTER value: \"${exporter}\". Supported values are: otlp, console, prometheus, none.`\n );\n }\n });\n\n return metricReaders;\n}\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessors: SpanProcessor[];\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _loggerProviderConfig?: LoggerProviderConfig;\n private _meterProviderConfig?: MeterProviderConfig;\n private _instrumentations: Instrumentation[];\n\n private _resource: Resource;\n private _resourceDetectors: Array<ResourceDetector>;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider;\n private _loggerProvider?: LoggerProvider;\n private _meterProvider?: MeterProvider;\n private _serviceName?: string;\n private _configuration?: Partial<NodeSDKConfiguration>;\n\n private _disabled?: boolean;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n if (getBooleanFromEnv('OTEL_SDK_DISABLED')) {\n this._disabled = true;\n // Functions with possible side-effects are set\n // to no-op via the _disabled flag\n }\n\n const logLevel = getStringFromEnv('OTEL_LOG_LEVEL');\n if (logLevel != null) {\n diag.setLogger(new DiagConsoleLogger(), {\n logLevel: diagLogLevelFromString(logLevel),\n });\n }\n\n this._configuration = configuration;\n\n this._resource = configuration.resource ?? defaultResource();\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n if (!this._autoDetectResources) {\n this._resourceDetectors = [];\n } else if (configuration.resourceDetectors != null) {\n this._resourceDetectors = configuration.resourceDetectors;\n } else if (getStringFromEnv('OTEL_NODE_RESOURCE_DETECTORS')) {\n this._resourceDetectors = getResourceDetectorsFromEnv();\n } else {\n this._resourceDetectors = [envDetector, processDetector, hostDetector];\n }\n\n this._serviceName = configuration.serviceName;\n\n // If a tracer provider can be created from manual configuration, create it\n if (\n configuration.traceExporter ||\n configuration.spanProcessor ||\n configuration.spanProcessors\n ) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n if (configuration.idGenerator) {\n tracerProviderConfig.idGenerator = configuration.idGenerator;\n }\n\n if (configuration.spanProcessor) {\n diag.warn(\n \"The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.\"\n );\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n new BatchSpanProcessor(configuration.traceExporter!);\n\n const spanProcessors = configuration.spanProcessors ?? [spanProcessor];\n\n this._tracerProviderConfig = {\n tracerConfig: tracerProviderConfig,\n spanProcessors,\n contextManager: configuration.contextManager,\n textMapPropagator: configuration.textMapPropagator,\n };\n }\n\n if (configuration.logRecordProcessors) {\n this._loggerProviderConfig = {\n logRecordProcessors: configuration.logRecordProcessors,\n };\n } else if (configuration.logRecordProcessor) {\n this._loggerProviderConfig = {\n logRecordProcessors: [configuration.logRecordProcessor],\n };\n diag.warn(\n \"The 'logRecordProcessor' option is deprecated. Please use 'logRecordProcessors' instead.\"\n );\n } else {\n this.configureLoggerProviderFromEnv();\n }\n\n if (configuration.metricReader || configuration.views) {\n const meterProviderConfig: MeterProviderConfig = {};\n if (configuration.metricReader) {\n meterProviderConfig.reader = configuration.metricReader;\n }\n\n if (configuration.views) {\n meterProviderConfig.views = configuration.views;\n }\n\n this._meterProviderConfig = meterProviderConfig;\n }\n\n this._instrumentations = configuration.instrumentations?.flat() ?? [];\n }\n\n /**\n * Call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public start(): void {\n if (this._disabled) {\n return;\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n\n if (this._autoDetectResources) {\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\n };\n\n this._resource = this._resource.merge(detectResources(internalConfig));\n }\n\n this._resource =\n this._serviceName === undefined\n ? this._resource\n : this._resource.merge(\n resourceFromAttributes({\n [ATTR_SERVICE_NAME]: this._serviceName,\n })\n );\n\n const spanProcessors = this._tracerProviderConfig\n ? this._tracerProviderConfig.spanProcessors\n : getSpanProcessorsFromEnv();\n\n this._tracerProvider = new NodeTracerProvider({\n ...this._configuration,\n resource: this._resource,\n spanProcessors,\n });\n\n // Only register if there is a span processor\n if (spanProcessors.length > 0) {\n this._tracerProvider.register({\n contextManager:\n this._tracerProviderConfig?.contextManager ??\n // _tracerProviderConfig may be undefined if trace-specific settings are not provided - fall back to raw config\n this._configuration?.contextManager,\n propagator:\n this._tracerProviderConfig?.textMapPropagator ??\n getPropagatorFromEnv(),\n });\n }\n\n if (this._loggerProviderConfig) {\n const loggerProvider = new LoggerProvider({\n resource: this._resource,\n processors: this._loggerProviderConfig.logRecordProcessors,\n });\n\n this._loggerProvider = loggerProvider;\n\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n const metricReadersFromEnv: IMetricReader[] =\n configureMetricProviderFromEnv();\n if (this._meterProviderConfig || metricReadersFromEnv.length > 0) {\n const readers: IMetricReader[] = [];\n if (this._meterProviderConfig?.reader) {\n readers.push(this._meterProviderConfig.reader);\n }\n\n if (readers.length === 0) {\n metricReadersFromEnv.forEach((r: IMetricReader) => readers.push(r));\n }\n\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n readers: readers,\n });\n\n this._meterProvider = meterProvider;\n metrics.setGlobalMeterProvider(meterProvider);\n\n // TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609\n // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.\n // This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.\n for (const instrumentation of this._instrumentations) {\n instrumentation.setMeterProvider(metrics.getMeterProvider());\n }\n }\n }\n\n public shutdown(): Promise<void> {\n const promises: Promise<unknown>[] = [];\n if (this._tracerProvider) {\n promises.push(this._tracerProvider.shutdown());\n }\n if (this._loggerProvider) {\n promises.push(this._loggerProvider.shutdown());\n }\n if (this._meterProvider) {\n promises.push(this._meterProvider.shutdown());\n }\n\n return (\n Promise.all(promises)\n // return void instead of the array from Promise.all\n .then(() => {})\n );\n }\n\n private configureLoggerProviderFromEnv(): void {\n const enabledExporters = getStringListFromEnv('OTEL_LOGS_EXPORTER') ?? [];\n\n if (enabledExporters.length === 0) {\n diag.debug('OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.');\n enabledExporters.push('otlp');\n }\n\n if (enabledExporters.includes('none')) {\n diag.info(\n `OTEL_LOGS_EXPORTER contains \"none\". Logger provider will not be initialized.`\n );\n return;\n }\n\n const exporters: LogRecordExporter[] = [];\n\n enabledExporters.forEach(exporter => {\n if (exporter === 'otlp') {\n const protocol = (\n getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_PROTOCOL') ??\n getStringFromEnv('OTEL_EXPORTER_OTLP_PROTOCOL')\n )?.trim();\n\n switch (protocol) {\n case 'grpc':\n exporters.push(new OTLPGrpcLogExporter());\n break;\n case 'http/json':\n exporters.push(new OTLPHttpLogExporter());\n break;\n case 'http/protobuf':\n exporters.push(new OTLPProtoLogExporter());\n break;\n case undefined:\n case '':\n exporters.push(new OTLPProtoLogExporter());\n break;\n default:\n diag.warn(\n `Unsupported OTLP logs protocol: \"${protocol}\". Using http/protobuf.`\n );\n exporters.push(new OTLPProtoLogExporter());\n }\n } else if (exporter === 'console') {\n exporters.push(new ConsoleLogRecordExporter());\n } else {\n diag.warn(\n `Unsupported OTEL_LOGS_EXPORTER value: \"${exporter}\". Supported values are: otlp, console, none.`\n );\n }\n });\n\n if (exporters.length > 0) {\n this._loggerProviderConfig = {\n logRecordProcessors: exporters.map(exporter => {\n if (exporter instanceof ConsoleLogRecordExporter) {\n return new SimpleLogRecordProcessor(exporter);\n } else {\n return new BatchLogRecordProcessor(exporter);\n }\n }),\n };\n }\n }\n}\n"]}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K,eAAe;wBAClB,SAAS,CAAC,IAAI,CAAC,IAAI,0CAAoB,EAAE,CAAC,CAAC;wBAC3C,MAAM;oBACR,KAAK,SAAS,CAAC;oBACf,KAAK,EAAE;wBACL,SAAS,CAAC,IAAI,CAAC,IAAI,0CAAoB,EAAE,CAAC,CAAC;wBAC3C,MAAM;oBACR;wBACE,UAAI,CAAC,IAAI,CACP,oCAAoC,QAAQ,yBAAyB,CACtE,CAAC;wBACF,SAAS,CAAC,IAAI,CAAC,IAAI,0CAAoB,EAAE,CAAC,CAAC;iBAC9C;aACF;iBAAM,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACjC,SAAS,CAAC,IAAI,CAAC,IAAI,mCAAwB,EAAE,CAAC,CAAC;aAChD;iBAAM;gBACL,UAAI,CAAC,IAAI,CACP,0CAA0C,QAAQ,+CAA+C,CAClG,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,IAAI,CAAC,qBAAqB,GAAG;gBAC3B,mBAAmB,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;oBAC5C,IAAI,QAAQ,YAAY,mCAAwB,EAAE;wBAChD,OAAO,IAAI,mCAAwB,CAAC,QAAQ,CAAC,CAAC;qBAC/C;yBAAM;wBACL,OAAO,IAAI,kCAAuB,CAAC,QAAQ,CAAC,CAAC;qBAC9C;gBACH,CAAC,CAAC;aACH,CAAC;SACH;IACH,CAAC;CACF;AA1TD,0BA0TC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ContextManager,\n TextMapPropagator,\n metrics,\n diag,\n DiagConsoleLogger,\n} from '@opentelemetry/api';\nimport { logs } from '@opentelemetry/api-logs';\nimport {\n Instrumentation,\n registerInstrumentations,\n} from '@opentelemetry/instrumentation';\nimport {\n defaultResource,\n detectResources,\n envDetector,\n hostDetector,\n Resource,\n processDetector,\n ResourceDetectionConfig,\n ResourceDetector,\n resourceFromAttributes,\n} from '@opentelemetry/resources';\nimport {\n LogRecordProcessor,\n LoggerProvider,\n BatchLogRecordProcessor,\n ConsoleLogRecordExporter,\n LogRecordExporter,\n SimpleLogRecordProcessor,\n} from '@opentelemetry/sdk-logs';\nimport { OTLPLogExporter as OTLPHttpLogExporter } from '@opentelemetry/exporter-logs-otlp-http';\nimport { OTLPLogExporter as OTLPGrpcLogExporter } from '@opentelemetry/exporter-logs-otlp-grpc';\nimport { OTLPLogExporter as OTLPProtoLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';\nimport { OTLPMetricExporter as OTLPGrpcMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';\nimport { OTLPMetricExporter as OTLPProtoMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';\nimport { OTLPMetricExporter as OTLPHttpMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';\nimport { PrometheusExporter as PrometheusMetricExporter } from '@opentelemetry/exporter-prometheus';\nimport {\n MeterProvider,\n IMetricReader,\n ViewOptions,\n ConsoleMetricExporter,\n PeriodicExportingMetricReader,\n} from '@opentelemetry/sdk-metrics';\nimport {\n BatchSpanProcessor,\n SpanProcessor,\n} from '@opentelemetry/sdk-trace-base';\nimport {\n NodeTracerConfig,\n NodeTracerProvider,\n} from '@opentelemetry/sdk-trace-node';\nimport { ATTR_SERVICE_NAME } from '@opentelemetry/semantic-conventions';\nimport { NodeSDKConfiguration } from './types';\nimport {\n getBooleanFromEnv,\n getStringFromEnv,\n getStringListFromEnv,\n diagLogLevelFromString,\n} from '@opentelemetry/core';\nimport {\n getResourceDetectorsFromEnv,\n getSpanProcessorsFromEnv,\n getPropagatorFromEnv,\n} from './utils';\n\n/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */\n\nexport type MeterProviderConfig = {\n /**\n * Reference to the MetricReader instances by the NodeSDK\n */\n readers?: IMetricReader[];\n /**\n * List of {@link ViewOptions}s that should be passed to the MeterProvider\n */\n views?: ViewOptions[];\n};\n\nexport type LoggerProviderConfig = {\n /**\n * Reference to the LoggerRecordProcessor instance by the NodeSDK\n */\n logRecordProcessors: LogRecordProcessor[];\n};\n\n/**\n * @Returns param value, if set else returns the default value\n */\nfunction getValueInMillis(envName: string, defaultValue: number): number {\n return parseInt(process.env[envName] || '') || defaultValue;\n}\n\n/**\n *\n * @returns MetricReader[] if appropriate environment variables are configured\n */\nfunction configureMetricProviderFromEnv(): IMetricReader[] {\n const metricReaders: IMetricReader[] = [];\n const enabledExporters = getStringListFromEnv('OTEL_METRICS_EXPORTER');\n if (!enabledExporters) {\n return metricReaders;\n }\n\n if (enabledExporters.length === 0) {\n diag.debug('OTEL_METRICS_EXPORTER is empty. Using default otlp exporter.');\n }\n\n if (enabledExporters.includes('none')) {\n diag.info(\n `OTEL_METRICS_EXPORTER contains \"none\". Metric provider will not be initialized.`\n );\n return metricReaders;\n }\n enabledExporters.forEach(exporter => {\n if (exporter === 'otlp') {\n const protocol =\n process.env.OTEL_EXPORTER_OTLP_METRICS_PROTOCOL?.trim() ||\n process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim();\n\n const exportIntervalMillis = getValueInMillis(\n 'OTEL_METRIC_EXPORT_INTERVAL',\n 60000\n );\n const exportTimeoutMillis = getValueInMillis(\n 'OTEL_METRIC_EXPORT_TIMEOUT',\n 30000\n );\n\n switch (protocol) {\n case 'grpc':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPGrpcMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n case 'http/json':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPHttpMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n case 'http/protobuf':\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPProtoMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n break;\n default:\n diag.warn(\n `Unsupported OTLP metrics protocol: \"${protocol}\". Using http/protobuf.`\n );\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new OTLPProtoMetricExporter(),\n exportIntervalMillis: exportIntervalMillis,\n exportTimeoutMillis: exportTimeoutMillis,\n })\n );\n }\n } else if (exporter === 'console') {\n metricReaders.push(\n new PeriodicExportingMetricReader({\n exporter: new ConsoleMetricExporter(),\n })\n );\n } else if (exporter === 'prometheus') {\n metricReaders.push(new PrometheusMetricExporter());\n } else {\n diag.warn(\n `Unsupported OTEL_METRICS_EXPORTER value: \"${exporter}\". Supported values are: otlp, console, prometheus, none.`\n );\n }\n });\n\n return metricReaders;\n}\nexport class NodeSDK {\n private _tracerProviderConfig?: {\n tracerConfig: NodeTracerConfig;\n spanProcessors: SpanProcessor[];\n contextManager?: ContextManager;\n textMapPropagator?: TextMapPropagator;\n };\n private _loggerProviderConfig?: LoggerProviderConfig;\n private _meterProviderConfig?: MeterProviderConfig;\n private _instrumentations: Instrumentation[];\n\n private _resource: Resource;\n private _resourceDetectors: Array<ResourceDetector>;\n\n private _autoDetectResources: boolean;\n\n private _tracerProvider?: NodeTracerProvider;\n private _loggerProvider?: LoggerProvider;\n private _meterProvider?: MeterProvider;\n private _serviceName?: string;\n private _configuration?: Partial<NodeSDKConfiguration>;\n\n private _disabled?: boolean;\n\n /**\n * Create a new NodeJS SDK instance\n */\n public constructor(configuration: Partial<NodeSDKConfiguration> = {}) {\n if (getBooleanFromEnv('OTEL_SDK_DISABLED')) {\n this._disabled = true;\n // Functions with possible side-effects are set\n // to no-op via the _disabled flag\n }\n\n const logLevel = getStringFromEnv('OTEL_LOG_LEVEL');\n if (logLevel != null) {\n diag.setLogger(new DiagConsoleLogger(), {\n logLevel: diagLogLevelFromString(logLevel),\n });\n }\n\n this._configuration = configuration;\n\n this._resource = configuration.resource ?? defaultResource();\n this._autoDetectResources = configuration.autoDetectResources ?? true;\n if (!this._autoDetectResources) {\n this._resourceDetectors = [];\n } else if (configuration.resourceDetectors != null) {\n this._resourceDetectors = configuration.resourceDetectors;\n } else if (getStringFromEnv('OTEL_NODE_RESOURCE_DETECTORS')) {\n this._resourceDetectors = getResourceDetectorsFromEnv();\n } else {\n this._resourceDetectors = [envDetector, processDetector, hostDetector];\n }\n\n this._serviceName = configuration.serviceName;\n\n // If a tracer provider can be created from manual configuration, create it\n if (\n configuration.traceExporter ||\n configuration.spanProcessor ||\n configuration.spanProcessors\n ) {\n const tracerProviderConfig: NodeTracerConfig = {};\n\n if (configuration.sampler) {\n tracerProviderConfig.sampler = configuration.sampler;\n }\n if (configuration.spanLimits) {\n tracerProviderConfig.spanLimits = configuration.spanLimits;\n }\n if (configuration.idGenerator) {\n tracerProviderConfig.idGenerator = configuration.idGenerator;\n }\n\n if (configuration.spanProcessor) {\n diag.warn(\n \"The 'spanProcessor' option is deprecated. Please use 'spanProcessors' instead.\"\n );\n }\n\n const spanProcessor =\n configuration.spanProcessor ??\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n new BatchSpanProcessor(configuration.traceExporter!);\n\n const spanProcessors = configuration.spanProcessors ?? [spanProcessor];\n\n this._tracerProviderConfig = {\n tracerConfig: tracerProviderConfig,\n spanProcessors,\n contextManager: configuration.contextManager,\n textMapPropagator: configuration.textMapPropagator,\n };\n }\n\n if (configuration.logRecordProcessors) {\n this._loggerProviderConfig = {\n logRecordProcessors: configuration.logRecordProcessors,\n };\n } else if (configuration.logRecordProcessor) {\n this._loggerProviderConfig = {\n logRecordProcessors: [configuration.logRecordProcessor],\n };\n diag.warn(\n \"The 'logRecordProcessor' option is deprecated. Please use 'logRecordProcessors' instead.\"\n );\n } else {\n this.configureLoggerProviderFromEnv();\n }\n\n if (\n configuration.metricReaders ||\n configuration.metricReader ||\n configuration.views\n ) {\n const meterProviderConfig: MeterProviderConfig = {};\n\n if (configuration.metricReaders) {\n meterProviderConfig.readers = configuration.metricReaders;\n } else if (configuration.metricReader) {\n meterProviderConfig.readers = [configuration.metricReader];\n diag.warn(\n \"The 'metricReader' option is deprecated. Please use 'metricReaders' instead.\"\n );\n }\n\n if (configuration.views) {\n meterProviderConfig.views = configuration.views;\n }\n\n this._meterProviderConfig = meterProviderConfig;\n }\n\n this._instrumentations = configuration.instrumentations?.flat() ?? [];\n }\n\n /**\n * Call this method to construct SDK components and register them with the OpenTelemetry API.\n */\n public start(): void {\n if (this._disabled) {\n return;\n }\n\n registerInstrumentations({\n instrumentations: this._instrumentations,\n });\n\n if (this._autoDetectResources) {\n const internalConfig: ResourceDetectionConfig = {\n detectors: this._resourceDetectors,\n };\n\n this._resource = this._resource.merge(detectResources(internalConfig));\n }\n\n this._resource =\n this._serviceName === undefined\n ? this._resource\n : this._resource.merge(\n resourceFromAttributes({\n [ATTR_SERVICE_NAME]: this._serviceName,\n })\n );\n\n const spanProcessors = this._tracerProviderConfig\n ? this._tracerProviderConfig.spanProcessors\n : getSpanProcessorsFromEnv();\n\n this._tracerProvider = new NodeTracerProvider({\n ...this._configuration,\n resource: this._resource,\n spanProcessors,\n });\n\n // Only register if there is a span processor\n if (spanProcessors.length > 0) {\n this._tracerProvider.register({\n contextManager:\n this._tracerProviderConfig?.contextManager ??\n // _tracerProviderConfig may be undefined if trace-specific settings are not provided - fall back to raw config\n this._configuration?.contextManager,\n propagator:\n this._tracerProviderConfig?.textMapPropagator ??\n getPropagatorFromEnv(),\n });\n }\n\n if (this._loggerProviderConfig) {\n const loggerProvider = new LoggerProvider({\n resource: this._resource,\n processors: this._loggerProviderConfig.logRecordProcessors,\n });\n\n this._loggerProvider = loggerProvider;\n\n logs.setGlobalLoggerProvider(loggerProvider);\n }\n\n const metricReadersFromEnv: IMetricReader[] =\n configureMetricProviderFromEnv();\n if (this._meterProviderConfig || metricReadersFromEnv.length > 0) {\n const readers: IMetricReader[] = [];\n if (this._meterProviderConfig?.readers) {\n readers.push(...this._meterProviderConfig.readers);\n }\n\n if (readers.length === 0) {\n metricReadersFromEnv.forEach((r: IMetricReader) => readers.push(r));\n }\n\n const meterProvider = new MeterProvider({\n resource: this._resource,\n views: this._meterProviderConfig?.views ?? [],\n readers: readers,\n });\n\n this._meterProvider = meterProvider;\n metrics.setGlobalMeterProvider(meterProvider);\n\n // TODO: This is a workaround to fix https://github.com/open-telemetry/opentelemetry-js/issues/3609\n // If the MeterProvider is not yet registered when instrumentations are registered, all metrics are dropped.\n // This code is obsolete once https://github.com/open-telemetry/opentelemetry-js/issues/3622 is implemented.\n for (const instrumentation of this._instrumentations) {\n instrumentation.setMeterProvider(metrics.getMeterProvider());\n }\n }\n }\n\n public shutdown(): Promise<void> {\n const promises: Promise<unknown>[] = [];\n if (this._tracerProvider) {\n promises.push(this._tracerProvider.shutdown());\n }\n if (this._loggerProvider) {\n promises.push(this._loggerProvider.shutdown());\n }\n if (this._meterProvider) {\n promises.push(this._meterProvider.shutdown());\n }\n\n return (\n Promise.all(promises)\n // return void instead of the array from Promise.all\n .then(() => {})\n );\n }\n\n private configureLoggerProviderFromEnv(): void {\n const enabledExporters = getStringListFromEnv('OTEL_LOGS_EXPORTER') ?? [];\n\n if (enabledExporters.length === 0) {\n diag.debug('OTEL_LOGS_EXPORTER is empty. Using default otlp exporter.');\n enabledExporters.push('otlp');\n }\n\n if (enabledExporters.includes('none')) {\n diag.info(\n `OTEL_LOGS_EXPORTER contains \"none\". Logger provider will not be initialized.`\n );\n return;\n }\n\n const exporters: LogRecordExporter[] = [];\n\n enabledExporters.forEach(exporter => {\n if (exporter === 'otlp') {\n const protocol = (\n getStringFromEnv('OTEL_EXPORTER_OTLP_LOGS_PROTOCOL') ??\n getStringFromEnv('OTEL_EXPORTER_OTLP_PROTOCOL')\n )?.trim();\n\n switch (protocol) {\n case 'grpc':\n exporters.push(new OTLPGrpcLogExporter());\n break;\n case 'http/json':\n exporters.push(new OTLPHttpLogExporter());\n break;\n case 'http/protobuf':\n exporters.push(new OTLPProtoLogExporter());\n break;\n case undefined:\n case '':\n exporters.push(new OTLPProtoLogExporter());\n break;\n default:\n diag.warn(\n `Unsupported OTLP logs protocol: \"${protocol}\". Using http/protobuf.`\n );\n exporters.push(new OTLPProtoLogExporter());\n }\n } else if (exporter === 'console') {\n exporters.push(new ConsoleLogRecordExporter());\n } else {\n diag.warn(\n `Unsupported OTEL_LOGS_EXPORTER value: \"${exporter}\". Supported values are: otlp, console, none.`\n );\n }\n });\n\n if (exporters.length > 0) {\n this._loggerProviderConfig = {\n logRecordProcessors: exporters.map(exporter => {\n if (exporter instanceof ConsoleLogRecordExporter) {\n return new SimpleLogRecordProcessor(exporter);\n } else {\n return new BatchLogRecordProcessor(exporter);\n }\n }),\n };\n }\n }\n}\n"]} |
@@ -15,3 +15,5 @@ import type { ContextManager } from '@opentelemetry/api'; | ||
| logRecordProcessors?: LogRecordProcessor[]; | ||
| /** @deprecated use metricReaders instead*/ | ||
| metricReader: IMetricReader; | ||
| metricReaders?: IMetricReader[]; | ||
| views: ViewOptions[]; | ||
@@ -18,0 +20,0 @@ instrumentations: (Instrumentation | Instrumentation[])[]; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ContextManager } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { Instrumentation } from '@opentelemetry/instrumentation';\nimport { Resource, ResourceDetector } from '@opentelemetry/resources';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\nimport { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n IdGenerator,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n textMapPropagator: TextMapPropagator;\n /** @deprecated use logRecordProcessors instead*/\n logRecordProcessor: LogRecordProcessor;\n logRecordProcessors?: LogRecordProcessor[];\n metricReader: IMetricReader;\n views: ViewOptions[];\n instrumentations: (Instrumentation | Instrumentation[])[];\n resource: Resource;\n resourceDetectors: Array<ResourceDetector>;\n sampler: Sampler;\n serviceName?: string;\n /** @deprecated use spanProcessors instead*/\n spanProcessor?: SpanProcessor;\n spanProcessors?: SpanProcessor[];\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]} | ||
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ContextManager } from '@opentelemetry/api';\nimport { TextMapPropagator } from '@opentelemetry/api';\nimport { Instrumentation } from '@opentelemetry/instrumentation';\nimport { Resource, ResourceDetector } from '@opentelemetry/resources';\nimport { LogRecordProcessor } from '@opentelemetry/sdk-logs';\nimport { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';\nimport {\n Sampler,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n IdGenerator,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n textMapPropagator: TextMapPropagator;\n /** @deprecated use logRecordProcessors instead*/\n logRecordProcessor: LogRecordProcessor;\n logRecordProcessors?: LogRecordProcessor[];\n /** @deprecated use metricReaders instead*/\n metricReader: IMetricReader;\n metricReaders?: IMetricReader[];\n views: ViewOptions[];\n instrumentations: (Instrumentation | Instrumentation[])[];\n resource: Resource;\n resourceDetectors: Array<ResourceDetector>;\n sampler: Sampler;\n serviceName?: string;\n /** @deprecated use spanProcessors instead*/\n spanProcessor?: SpanProcessor;\n spanProcessors?: SpanProcessor[];\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n"]} |
@@ -1,2 +0,2 @@ | ||
| export declare const VERSION = "0.203.0"; | ||
| export declare const VERSION = "0.204.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
| // this is autogenerated file, see scripts/version-update.js | ||
| exports.VERSION = '0.203.0'; | ||
| exports.VERSION = '0.204.0'; | ||
| //# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.203.0';\n"]} | ||
| {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.204.0';\n"]} |
+28
-29
| { | ||
| "name": "@opentelemetry/sdk-node", | ||
| "version": "0.203.0", | ||
| "version": "0.204.0", | ||
| "description": "OpenTelemetry SDK for Node.js", | ||
@@ -17,3 +17,3 @@ "main": "build/src/index.js", | ||
| "watch": "tsc --build --watch", | ||
| "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", | ||
| "precompile": "lerna run version --scope @opentelemetry/sdk-node --include-dependencies", | ||
| "prewatch": "npm run precompile", | ||
@@ -48,23 +48,23 @@ "peer-api-check": "node ../../../scripts/peer-api-check.js", | ||
| "dependencies": { | ||
| "@opentelemetry/api-logs": "0.203.0", | ||
| "@opentelemetry/core": "2.0.1", | ||
| "@opentelemetry/exporter-logs-otlp-grpc": "0.203.0", | ||
| "@opentelemetry/exporter-logs-otlp-http": "0.203.0", | ||
| "@opentelemetry/exporter-logs-otlp-proto": "0.203.0", | ||
| "@opentelemetry/exporter-metrics-otlp-grpc": "0.203.0", | ||
| "@opentelemetry/exporter-metrics-otlp-http": "0.203.0", | ||
| "@opentelemetry/exporter-metrics-otlp-proto": "0.203.0", | ||
| "@opentelemetry/exporter-prometheus": "0.203.0", | ||
| "@opentelemetry/exporter-trace-otlp-grpc": "0.203.0", | ||
| "@opentelemetry/exporter-trace-otlp-http": "0.203.0", | ||
| "@opentelemetry/exporter-trace-otlp-proto": "0.203.0", | ||
| "@opentelemetry/exporter-zipkin": "2.0.1", | ||
| "@opentelemetry/instrumentation": "0.203.0", | ||
| "@opentelemetry/propagator-b3": "2.0.1", | ||
| "@opentelemetry/propagator-jaeger": "2.0.1", | ||
| "@opentelemetry/resources": "2.0.1", | ||
| "@opentelemetry/sdk-logs": "0.203.0", | ||
| "@opentelemetry/sdk-metrics": "2.0.1", | ||
| "@opentelemetry/sdk-trace-base": "2.0.1", | ||
| "@opentelemetry/sdk-trace-node": "2.0.1", | ||
| "@opentelemetry/api-logs": "0.204.0", | ||
| "@opentelemetry/core": "2.1.0", | ||
| "@opentelemetry/exporter-logs-otlp-grpc": "0.204.0", | ||
| "@opentelemetry/exporter-logs-otlp-http": "0.204.0", | ||
| "@opentelemetry/exporter-logs-otlp-proto": "0.204.0", | ||
| "@opentelemetry/exporter-metrics-otlp-grpc": "0.204.0", | ||
| "@opentelemetry/exporter-metrics-otlp-http": "0.204.0", | ||
| "@opentelemetry/exporter-metrics-otlp-proto": "0.204.0", | ||
| "@opentelemetry/exporter-prometheus": "0.204.0", | ||
| "@opentelemetry/exporter-trace-otlp-grpc": "0.204.0", | ||
| "@opentelemetry/exporter-trace-otlp-http": "0.204.0", | ||
| "@opentelemetry/exporter-trace-otlp-proto": "0.204.0", | ||
| "@opentelemetry/exporter-zipkin": "2.1.0", | ||
| "@opentelemetry/instrumentation": "0.204.0", | ||
| "@opentelemetry/propagator-b3": "2.1.0", | ||
| "@opentelemetry/propagator-jaeger": "2.1.0", | ||
| "@opentelemetry/resources": "2.1.0", | ||
| "@opentelemetry/sdk-logs": "0.204.0", | ||
| "@opentelemetry/sdk-metrics": "2.1.0", | ||
| "@opentelemetry/sdk-trace-base": "2.1.0", | ||
| "@opentelemetry/sdk-trace-node": "2.1.0", | ||
| "@opentelemetry/semantic-conventions": "^1.29.0" | ||
@@ -77,13 +77,12 @@ }, | ||
| "@opentelemetry/api": "1.9.0", | ||
| "@opentelemetry/context-async-hooks": "2.0.1", | ||
| "@opentelemetry/exporter-jaeger": "2.0.1", | ||
| "@opentelemetry/context-async-hooks": "2.1.0", | ||
| "@opentelemetry/exporter-jaeger": "2.1.0", | ||
| "@types/mocha": "10.0.10", | ||
| "@types/node": "18.6.5", | ||
| "@types/sinon": "17.0.4", | ||
| "cross-var": "1.1.0", | ||
| "lerna": "6.6.2", | ||
| "mocha": "11.1.0", | ||
| "mocha": "11.7.2", | ||
| "nyc": "17.1.0", | ||
| "sinon": "18.0.1", | ||
| "ts-loader": "9.5.2", | ||
| "ts-loader": "9.5.4", | ||
| "typescript": "5.0.4" | ||
@@ -93,3 +92,3 @@ }, | ||
| "sideEffects": false, | ||
| "gitHead": "93187f022457da152becc03dd00db8b2500702db" | ||
| "gitHead": "98f9d720af84bc38074dfd4ab7760ae83a3e9826" | ||
| } |
+4
-4
@@ -112,3 +112,3 @@ # OpenTelemetry SDK for Node.js | ||
| Add a [MetricReader](../opentelemetry-sdk-metrics/src/export/MetricReader.ts) | ||
| Add a [MetricReader](../../../packages/sdk-metrics/src/export/MetricReader.ts) | ||
| that will be passed to the `MeterProvider`. If `metricReader` is not configured, | ||
@@ -120,3 +120,3 @@ the metrics SDK will not be initialized and registered. | ||
| A list of views to be passed to the `MeterProvider`. | ||
| Accepts an array of [View](../opentelemetry-sdk-metrics/src/view/View.ts)-instances. | ||
| Accepts an array of [View](../../../packages/sdk-metrics/src/view/View.ts)-instances. | ||
| This parameter can be used to configure explicit bucket sizes of histogram metrics. | ||
@@ -127,3 +127,3 @@ | ||
| Configure instrumentations. By default none of the instrumentation is enabled, | ||
| if you want to enable them you can use either [metapackage](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node) | ||
| if you want to enable them you can use either [metapackage](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/auto-instrumentations-node) | ||
| or configure each instrumentation individually. | ||
@@ -179,3 +179,3 @@ | ||
| Configure the [service name](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service). | ||
| Configure the [service name](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/registry/attributes/service.md#service-name). | ||
@@ -182,0 +182,0 @@ ## Disable the SDK from the environment |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
104118
0.89%12
-7.69%720
1.12%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated