@opentelemetry/exporter-collector
Advanced tools
Comparing version 0.11.0 to 0.11.1-alpha.15
@@ -14,2 +14,4 @@ import { Attributes, Logger } from '@opentelemetry/api'; | ||
protected _isShutdown: boolean; | ||
private _shuttingDownPromise; | ||
protected _sendingPromises: Promise<unknown>[]; | ||
/** | ||
@@ -29,3 +31,3 @@ * @param config | ||
*/ | ||
shutdown(): void; | ||
shutdown(): Promise<void>; | ||
abstract onShutdown(): void; | ||
@@ -32,0 +34,0 @@ abstract onInit(config: T): void; |
@@ -29,2 +29,4 @@ "use strict"; | ||
this._isShutdown = false; | ||
this._shuttingDownPromise = Promise.resolve(); | ||
this._sendingPromises = []; | ||
this.serviceName = this.getDefaultServiceName(config); | ||
@@ -84,8 +86,22 @@ this.url = this.getDefaultUrl(config); | ||
this.logger.debug('shutdown already started'); | ||
return; | ||
return this._shuttingDownPromise; | ||
} | ||
this._isShutdown = true; | ||
this.logger.debug('shutdown started'); | ||
// platform dependent | ||
this.onShutdown(); | ||
this._shuttingDownPromise = new Promise((resolve, reject) => { | ||
Promise.resolve() | ||
.then(() => { | ||
return this.onShutdown(); | ||
}) | ||
.then(() => { | ||
return Promise.all(this._sendingPromises); | ||
}) | ||
.then(() => { | ||
resolve(); | ||
}) | ||
.catch(e => { | ||
reject(e); | ||
}); | ||
}); | ||
return this._shuttingDownPromise; | ||
} | ||
@@ -92,0 +108,0 @@ } |
@@ -48,10 +48,30 @@ "use strict"; | ||
send(items, onSuccess, onError) { | ||
if (this._isShutdown) { | ||
this.logger.debug('Shutdown already started. Cannot send objects'); | ||
return; | ||
} | ||
const serviceRequest = this.convert(items); | ||
const body = JSON.stringify(serviceRequest); | ||
if (this._useXHR) { | ||
util_2.sendWithXhr(body, this.url, this._headers, this.logger, onSuccess, onError); | ||
} | ||
else { | ||
util_2.sendWithBeacon(body, this.url, this.logger, onSuccess, onError); | ||
} | ||
const promise = new Promise(resolve => { | ||
const _onSuccess = () => { | ||
onSuccess(); | ||
_onFinish(); | ||
}; | ||
const _onError = (error) => { | ||
onError(error); | ||
_onFinish(); | ||
}; | ||
const _onFinish = () => { | ||
const index = this._sendingPromises.indexOf(promise); | ||
this._sendingPromises.splice(index, 1); | ||
resolve(); | ||
}; | ||
if (this._useXHR) { | ||
util_2.sendWithXhr(body, this.url, this._headers, this.logger, _onSuccess, _onError); | ||
} | ||
else { | ||
util_2.sendWithBeacon(body, this.url, this.logger, _onSuccess, _onError); | ||
} | ||
}); | ||
this._sendingPromises.push(promise); | ||
} | ||
@@ -58,0 +78,0 @@ } |
@@ -47,3 +47,19 @@ "use strict"; | ||
const serviceRequest = this.convert(objects); | ||
util_2.sendWithHttp(this, JSON.stringify(serviceRequest), 'application/json', onSuccess, onError); | ||
const promise = new Promise(resolve => { | ||
const _onSuccess = () => { | ||
onSuccess(); | ||
_onFinish(); | ||
}; | ||
const _onError = (error) => { | ||
onError(error); | ||
_onFinish(); | ||
}; | ||
const _onFinish = () => { | ||
const index = this._sendingPromises.indexOf(promise); | ||
this._sendingPromises.splice(index, 1); | ||
resolve(); | ||
}; | ||
util_2.sendWithHttp(this, JSON.stringify(serviceRequest), 'application/json', _onSuccess, _onError); | ||
}); | ||
this._sendingPromises.push(promise); | ||
} | ||
@@ -50,0 +66,0 @@ onShutdown() { } |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.11.0"; | ||
export declare const VERSION = "0.11.1-alpha.15+e170039"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.11.0'; | ||
exports.VERSION = '0.11.1-alpha.15+e170039'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/exporter-collector", | ||
"version": "0.11.0", | ||
"version": "0.11.1-alpha.15+e170039", | ||
"description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", | ||
@@ -82,10 +82,10 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.11.0", | ||
"@opentelemetry/core": "^0.11.0", | ||
"@opentelemetry/metrics": "^0.11.0", | ||
"@opentelemetry/resources": "^0.11.0", | ||
"@opentelemetry/tracing": "^0.11.0", | ||
"@opentelemetry/api": "^0.11.1-alpha.15+e170039", | ||
"@opentelemetry/core": "^0.11.1-alpha.15+e170039", | ||
"@opentelemetry/metrics": "^0.11.1-alpha.15+e170039", | ||
"@opentelemetry/resources": "^0.11.1-alpha.15+e170039", | ||
"@opentelemetry/tracing": "^0.11.1-alpha.15+e170039", | ||
"axios": "^0.19.2" | ||
}, | ||
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351" | ||
"gitHead": "e170039015e8a1a7419bb835a00659b2a734b8a6" | ||
} |
@@ -68,3 +68,3 @@ # OpenTelemetry Collector Exporter for web and node | ||
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { CollectorExporter } = require('@opentelemetry/exporter-collector'); | ||
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); | ||
@@ -80,3 +80,3 @@ const collectorOptions = { | ||
const provider = new BasicTracerProvider(); | ||
const exporter = new CollectorExporter(collectorOptions); | ||
const exporter = new CollectorTraceExporter(collectorOptions); | ||
provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
@@ -83,0 +83,0 @@ |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
121164
1884
57
+ Added@opentelemetry/api@0.11.1-alpha.53(transitive)
+ Added@opentelemetry/core@0.11.1-alpha.53(transitive)
+ Added@opentelemetry/metrics@0.11.1-alpha.53(transitive)
+ Added@opentelemetry/resources@0.11.1-alpha.53(transitive)
+ Added@opentelemetry/tracing@0.11.1-alpha.53(transitive)
- Removed@opentelemetry/api@0.11.0(transitive)
- Removed@opentelemetry/core@0.11.0(transitive)
- Removed@opentelemetry/metrics@0.11.0(transitive)
- Removed@opentelemetry/resources@0.11.0(transitive)
- Removed@opentelemetry/tracing@0.11.0(transitive)