@opentelemetry/tracing
Advanced tools
Comparing version 0.19.1-alpha.25 to 0.19.1-alpha.26
@@ -5,3 +5,5 @@ import { TracerProvider, TextMapPropagator } from '@opentelemetry/api'; | ||
import { SDKRegistrationConfig, TracerConfig } from './types'; | ||
import { SpanExporter } from './export/SpanExporter'; | ||
export declare type PROPAGATOR_FACTORY = () => TextMapPropagator; | ||
export declare type EXPORTER_FACTORY = () => SpanExporter; | ||
/** | ||
@@ -12,2 +14,3 @@ * This class represents a basic tracer provider which platform libraries can extend | ||
protected static readonly _registeredPropagators: Map<string, PROPAGATOR_FACTORY>; | ||
protected static readonly _registeredExporters: Map<string, EXPORTER_FACTORY>; | ||
private readonly _config; | ||
@@ -36,4 +39,6 @@ private readonly _registeredSpanProcessors; | ||
protected _getPropagator(name: string): TextMapPropagator | undefined; | ||
protected _getSpanExporter(name: string): SpanExporter | undefined; | ||
protected _buildPropagatorFromEnv(): TextMapPropagator | undefined; | ||
protected _buildExporterFromEnv(): SpanExporter | undefined; | ||
} | ||
//# sourceMappingURL=BasicTracerProvider.d.ts.map |
@@ -22,4 +22,5 @@ /* | ||
import { MultiSpanProcessor } from './MultiSpanProcessor'; | ||
import { NoopSpanProcessor } from './NoopSpanProcessor'; | ||
import { NoopSpanProcessor } from './export/NoopSpanProcessor'; | ||
var merge = require('lodash.merge'); | ||
import { BatchSpanProcessor } from './export/BatchSpanProcessor'; | ||
/** | ||
@@ -34,3 +35,2 @@ * This class represents a basic tracer provider which platform libraries can extend | ||
this._tracers = new Map(); | ||
this.activeSpanProcessor = new NoopSpanProcessor(); | ||
var mergedConfig = merge({}, DEFAULT_CONFIG, config); | ||
@@ -42,2 +42,10 @@ this.resource = | ||
}); | ||
var defaultExporter = this._buildExporterFromEnv(); | ||
if (defaultExporter !== undefined) { | ||
var batchProcessor = new BatchSpanProcessor(defaultExporter); | ||
this.activeSpanProcessor = batchProcessor; | ||
} | ||
else { | ||
this.activeSpanProcessor = new NoopSpanProcessor(); | ||
} | ||
} | ||
@@ -56,2 +64,11 @@ BasicTracerProvider.prototype.getTracer = function (name, version) { | ||
BasicTracerProvider.prototype.addSpanProcessor = function (spanProcessor) { | ||
if (this._registeredSpanProcessors.length === 0) { | ||
// since we might have enabled by default a batchProcessor, we disable it | ||
// before adding the new one | ||
this.activeSpanProcessor | ||
.shutdown() | ||
.catch(function (err) { | ||
return diag.error('Error while trying to shutdown current span processor', err); | ||
}); | ||
} | ||
this._registeredSpanProcessors.push(spanProcessor); | ||
@@ -90,2 +107,6 @@ this.activeSpanProcessor = new MultiSpanProcessor(this._registeredSpanProcessors); | ||
}; | ||
BasicTracerProvider.prototype._getSpanExporter = function (name) { | ||
var _a; | ||
return (_a = BasicTracerProvider._registeredExporters.get(name)) === null || _a === void 0 ? void 0 : _a(); | ||
}; | ||
BasicTracerProvider.prototype._buildPropagatorFromEnv = function () { | ||
@@ -120,2 +141,12 @@ var _this = this; | ||
}; | ||
BasicTracerProvider.prototype._buildExporterFromEnv = function () { | ||
var exporterName = getEnv().OTEL_TRACES_EXPORTER; | ||
if (exporterName === 'none') | ||
return; | ||
var exporter = this._getSpanExporter(exporterName); | ||
if (!exporter) { | ||
diag.error("Exporter \"" + exporterName + "\" requested through environment variable is unavailable."); | ||
} | ||
return exporter; | ||
}; | ||
BasicTracerProvider._registeredPropagators = new Map([ | ||
@@ -125,2 +156,3 @@ ['tracecontext', function () { return new HttpTraceContextPropagator(); }], | ||
]); | ||
BasicTracerProvider._registeredExporters = new Map(); | ||
return BasicTracerProvider; | ||
@@ -127,0 +159,0 @@ }()); |
@@ -9,2 +9,3 @@ export * from './Tracer'; | ||
export * from './export/SpanExporter'; | ||
export * from './export/NoopSpanProcessor'; | ||
export * from './Span'; | ||
@@ -11,0 +12,0 @@ export * from './SpanProcessor'; |
@@ -24,2 +24,3 @@ /* | ||
export * from './export/SpanExporter'; | ||
export * from './export/NoopSpanProcessor'; | ||
export * from './Span'; | ||
@@ -26,0 +27,0 @@ export * from './SpanProcessor'; |
@@ -5,3 +5,5 @@ import { TracerProvider, TextMapPropagator } from '@opentelemetry/api'; | ||
import { SDKRegistrationConfig, TracerConfig } from './types'; | ||
import { SpanExporter } from './export/SpanExporter'; | ||
export declare type PROPAGATOR_FACTORY = () => TextMapPropagator; | ||
export declare type EXPORTER_FACTORY = () => SpanExporter; | ||
/** | ||
@@ -12,2 +14,3 @@ * This class represents a basic tracer provider which platform libraries can extend | ||
protected static readonly _registeredPropagators: Map<string, PROPAGATOR_FACTORY>; | ||
protected static readonly _registeredExporters: Map<string, EXPORTER_FACTORY>; | ||
private readonly _config; | ||
@@ -36,4 +39,6 @@ private readonly _registeredSpanProcessors; | ||
protected _getPropagator(name: string): TextMapPropagator | undefined; | ||
protected _getSpanExporter(name: string): SpanExporter | undefined; | ||
protected _buildPropagatorFromEnv(): TextMapPropagator | undefined; | ||
protected _buildExporterFromEnv(): SpanExporter | undefined; | ||
} | ||
//# sourceMappingURL=BasicTracerProvider.d.ts.map |
@@ -25,4 +25,5 @@ "use strict"; | ||
const MultiSpanProcessor_1 = require("./MultiSpanProcessor"); | ||
const NoopSpanProcessor_1 = require("./NoopSpanProcessor"); | ||
const NoopSpanProcessor_1 = require("./export/NoopSpanProcessor"); | ||
const merge = require('lodash.merge'); | ||
const BatchSpanProcessor_1 = require("./export/BatchSpanProcessor"); | ||
/** | ||
@@ -36,3 +37,2 @@ * This class represents a basic tracer provider which platform libraries can extend | ||
this._tracers = new Map(); | ||
this.activeSpanProcessor = new NoopSpanProcessor_1.NoopSpanProcessor(); | ||
const mergedConfig = merge({}, config_1.DEFAULT_CONFIG, config); | ||
@@ -44,2 +44,10 @@ this.resource = | ||
}); | ||
const defaultExporter = this._buildExporterFromEnv(); | ||
if (defaultExporter !== undefined) { | ||
const batchProcessor = new BatchSpanProcessor_1.BatchSpanProcessor(defaultExporter); | ||
this.activeSpanProcessor = batchProcessor; | ||
} | ||
else { | ||
this.activeSpanProcessor = new NoopSpanProcessor_1.NoopSpanProcessor(); | ||
} | ||
} | ||
@@ -58,2 +66,9 @@ getTracer(name, version) { | ||
addSpanProcessor(spanProcessor) { | ||
if (this._registeredSpanProcessors.length === 0) { | ||
// since we might have enabled by default a batchProcessor, we disable it | ||
// before adding the new one | ||
this.activeSpanProcessor | ||
.shutdown() | ||
.catch(err => api_1.diag.error('Error while trying to shutdown current span processor', err)); | ||
} | ||
this._registeredSpanProcessors.push(spanProcessor); | ||
@@ -91,2 +106,6 @@ this.activeSpanProcessor = new MultiSpanProcessor_1.MultiSpanProcessor(this._registeredSpanProcessors); | ||
} | ||
_getSpanExporter(name) { | ||
var _a; | ||
return (_a = BasicTracerProvider._registeredExporters.get(name)) === null || _a === void 0 ? void 0 : _a(); | ||
} | ||
_buildPropagatorFromEnv() { | ||
@@ -120,2 +139,12 @@ // per spec, propagators from env must be deduplicated | ||
} | ||
_buildExporterFromEnv() { | ||
const exporterName = core_1.getEnv().OTEL_TRACES_EXPORTER; | ||
if (exporterName === 'none') | ||
return; | ||
const exporter = this._getSpanExporter(exporterName); | ||
if (!exporter) { | ||
api_1.diag.error(`Exporter "${exporterName}" requested through environment variable is unavailable.`); | ||
} | ||
return exporter; | ||
} | ||
} | ||
@@ -127,2 +156,3 @@ exports.BasicTracerProvider = BasicTracerProvider; | ||
]); | ||
BasicTracerProvider._registeredExporters = new Map(); | ||
//# sourceMappingURL=BasicTracerProvider.js.map |
@@ -9,2 +9,3 @@ export * from './Tracer'; | ||
export * from './export/SpanExporter'; | ||
export * from './export/NoopSpanProcessor'; | ||
export * from './Span'; | ||
@@ -11,0 +12,0 @@ export * from './SpanProcessor'; |
@@ -36,2 +36,3 @@ "use strict"; | ||
__exportStar(require("./export/SpanExporter"), exports); | ||
__exportStar(require("./export/NoopSpanProcessor"), exports); | ||
__exportStar(require("./Span"), exports); | ||
@@ -38,0 +39,0 @@ __exportStar(require("./SpanProcessor"), exports); |
{ | ||
"name": "@opentelemetry/tracing", | ||
"version": "0.19.1-alpha.25+02239b52", | ||
"version": "0.19.1-alpha.26+1758fa6e", | ||
"description": "OpenTelemetry Tracing", | ||
@@ -85,8 +85,8 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/core": "^0.19.1-alpha.25+02239b52", | ||
"@opentelemetry/resources": "^0.19.1-alpha.25+02239b52", | ||
"@opentelemetry/core": "^0.19.1-alpha.26+1758fa6e", | ||
"@opentelemetry/resources": "^0.19.1-alpha.26+1758fa6e", | ||
"@opentelemetry/semantic-conventions": "^0.19.0", | ||
"lodash.merge": "^4.6.2" | ||
}, | ||
"gitHead": "02239b52557fe5b4c5ae6eba742340428b856492" | ||
"gitHead": "1758fa6e84333c9c43cc468c5e99dd3646f7e3c7" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
195099
3198