New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@opentelemetry/exporter-collector

Package Overview
Dependencies
Maintainers
4
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/exporter-collector - npm Package Compare versions

Comparing version 0.12.1-alpha.54 to 0.13.0

15

build/src/CollectorExporterBase.js

@@ -49,3 +49,6 @@ "use strict";

if (this._isShutdown) {
resultCallback(core_1.ExportResult.FAILED_NOT_RETRYABLE);
resultCallback({
code: core_1.ExportResultCode.FAILED,
error: new Error('Exporter has been shutdown'),
});
return;

@@ -55,12 +58,6 @@ }

.then(() => {
resultCallback(core_1.ExportResult.SUCCESS);
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
})
.catch((error) => {
core_1.globalErrorHandler(error);
if (error.code && error.code < 500) {
resultCallback(core_1.ExportResult.FAILED_NOT_RETRYABLE);
}
else {
resultCallback(core_1.ExportResult.FAILED_RETRYABLE);
}
resultCallback({ code: core_1.ExportResultCode.FAILED, error });
});

@@ -67,0 +64,0 @@ }

2

build/src/platform/browser/CollectorExporterBrowserBase.js

@@ -64,5 +64,5 @@ "use strict";

const _onFinish = () => {
resolve();
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
resolve();
};

@@ -69,0 +69,0 @@ if (this._useXHR) {

@@ -28,3 +28,3 @@ "use strict";

convert(spans) {
return transform_1.toCollectorExportTraceServiceRequest(spans, this);
return transform_1.toCollectorExportTraceServiceRequest(spans, this, true);
}

@@ -31,0 +31,0 @@ getDefaultUrl(config) {

@@ -60,3 +60,3 @@ "use strict";

else {
const error = new collectorTypes.CollectorExporterError(xhr.responseText, xhr.status);
const error = new collectorTypes.CollectorExporterError(`Failed to export with XHR (status: ${xhr.status})`, xhr.status);
onError(error);

@@ -63,0 +63,0 @@ }

@@ -11,3 +11,3 @@ import { CollectorExporterBase } from '../../CollectorExporterBase';

constructor(config?: CollectorExporterConfigBase);
onInit(config: CollectorExporterConfigBase): void;
onInit(_config: CollectorExporterConfigBase): void;
send(objects: ExportItem[], onSuccess: () => void, onError: (error: collectorTypes.CollectorExporterError) => void): void;

@@ -14,0 +14,0 @@ onShutdown(): void;

@@ -35,3 +35,3 @@ "use strict";

}
onInit(config) {
onInit(_config) {
this._isShutdown = false;

@@ -55,5 +55,5 @@ }

const _onFinish = () => {
resolve();
const index = this._sendingPromises.indexOf(promise);
this._sendingPromises.splice(index, 1);
resolve();
};

@@ -60,0 +60,0 @@ util_2.sendWithHttp(this, JSON.stringify(serviceRequest), 'application/json', _onSuccess, _onError);

@@ -28,3 +28,3 @@ "use strict";

convert(spans) {
return transform_1.toCollectorExportTraceServiceRequest(spans, this);
return transform_1.toCollectorExportTraceServiceRequest(spans, this, true);
}

@@ -31,0 +31,0 @@ getDefaultUrl(config) {

@@ -42,10 +42,14 @@ "use strict";

const req = request(options, (res) => {
if (res.statusCode && res.statusCode < 299) {
collector.logger.debug(`statusCode: ${res.statusCode}`);
onSuccess();
}
else {
const error = new collectorTypes.CollectorExporterError(res.statusMessage, res.statusCode);
onError(error);
}
let data = '';
res.on('data', chunk => (data += chunk));
res.on('end', () => {
if (res.statusCode && res.statusCode < 299) {
collector.logger.debug(`statusCode: ${res.statusCode}`, data);
onSuccess();
}
else {
const error = new collectorTypes.CollectorExporterError(res.statusMessage, res.statusCode, data);
onError(error);
}
});
});

@@ -52,0 +56,0 @@ req.on('error', (error) => {

@@ -39,11 +39,7 @@ import { Attributes, SpanKind, TimedEvent, TraceState } from '@opentelemetry/api';

/**
* Converts links
* @param span
*/
export declare function toCollectorLinks(span: ReadableSpan): opentelemetryProto.trace.v1.Span.Link[];
/**
* Converts span
* @param span
* @param useHex - if ids should be kept as hex without converting to base64
*/
export declare function toCollectorSpan(span: ReadableSpan): opentelemetryProto.trace.v1.Span;
export declare function toCollectorSpan(span: ReadableSpan, useHex?: boolean): opentelemetryProto.trace.v1.Span;
/**

@@ -71,4 +67,5 @@ * Converts resource

* @param collectorExporterBase
* @param useHex - if ids should be kept as hex without converting to base64
*/
export declare function toCollectorExportTraceServiceRequest<T extends CollectorExporterConfigBase>(spans: ReadableSpan[], collectorTraceExporterBase: CollectorExporterBase<T, ReadableSpan, opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest>): opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest;
export declare function toCollectorExportTraceServiceRequest<T extends CollectorExporterConfigBase>(spans: ReadableSpan[], collectorTraceExporterBase: CollectorExporterBase<T, ReadableSpan, opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest>, useHex?: boolean): opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest;
/**

@@ -75,0 +72,0 @@ * Takes an array of spans and groups them by resource and instrumentation

@@ -18,3 +18,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.groupSpansByResourceAndLibrary = exports.toCollectorExportTraceServiceRequest = exports.toCollectorTraceState = exports.toCollectorKind = exports.toCollectorResource = exports.toCollectorSpan = exports.toCollectorLinks = exports.toCollectorEvents = exports.toCollectorAnyValue = exports.toCollectorAttributeKeyValue = exports.toCollectorKeyValueList = exports.toCollectorArrayValue = exports.toCollectorAttributes = void 0;
exports.groupSpansByResourceAndLibrary = exports.toCollectorExportTraceServiceRequest = exports.toCollectorTraceState = exports.toCollectorKind = exports.toCollectorResource = exports.toCollectorSpan = exports.toCollectorEvents = exports.toCollectorAnyValue = exports.toCollectorAttributeKeyValue = exports.toCollectorKeyValueList = exports.toCollectorArrayValue = exports.toCollectorAttributes = void 0;
const core = require("@opentelemetry/core");

@@ -113,8 +113,13 @@ const types_1 = require("./types");

* @param span
* @param useHex - if ids should be kept as hex without converting to base64
*/
function toCollectorLinks(span) {
function toCollectorLinks(span, useHex) {
return span.links.map((link) => {
const protoLink = {
traceId: link.context.traceId,
spanId: link.context.spanId,
traceId: useHex
? link.context.traceId
: core.hexToBase64(link.context.traceId),
spanId: useHex
? link.context.spanId
: core.hexToBase64(link.context.spanId),
attributes: toCollectorAttributes(link.attributes || {}),

@@ -126,12 +131,20 @@ droppedAttributesCount: 0,

}
exports.toCollectorLinks = toCollectorLinks;
/**
* Converts span
* @param span
* @param useHex - if ids should be kept as hex without converting to base64
*/
function toCollectorSpan(span) {
function toCollectorSpan(span, useHex) {
return {
traceId: span.spanContext.traceId,
spanId: span.spanContext.spanId,
parentSpanId: span.parentSpanId ? span.parentSpanId : undefined,
traceId: useHex
? span.spanContext.traceId
: core.hexToBase64(span.spanContext.traceId),
spanId: useHex
? span.spanContext.spanId
: core.hexToBase64(span.spanContext.spanId),
parentSpanId: span.parentSpanId
? useHex
? span.parentSpanId
: core.hexToBase64(span.parentSpanId)
: undefined,
traceState: toCollectorTraceState(span.spanContext.traceState),

@@ -147,3 +160,3 @@ name: span.name,

status: span.status,
links: toCollectorLinks(span),
links: toCollectorLinks(span, useHex),
droppedLinksCount: 0,

@@ -192,4 +205,5 @@ };

* @param collectorExporterBase
* @param useHex - if ids should be kept as hex without converting to base64
*/
function toCollectorExportTraceServiceRequest(spans, collectorTraceExporterBase) {
function toCollectorExportTraceServiceRequest(spans, collectorTraceExporterBase, useHex) {
const groupedSpans = groupSpansByResourceAndLibrary(spans);

@@ -200,3 +214,3 @@ const additionalAttributes = Object.assign({}, collectorTraceExporterBase.attributes, {

return {
resourceSpans: toCollectorResourceSpans(groupedSpans, additionalAttributes),
resourceSpans: toCollectorResourceSpans(groupedSpans, additionalAttributes, useHex),
};

@@ -233,6 +247,7 @@ }

* @param spans
* @param useHex - if ids should be kept as hex without converting to base64
*/
function toCollectorInstrumentationLibrarySpans(instrumentationLibrary, spans) {
function toCollectorInstrumentationLibrarySpans(instrumentationLibrary, spans, useHex) {
return {
spans: spans.map(toCollectorSpan),
spans: spans.map(span => toCollectorSpan(span, useHex)),
instrumentationLibrary,

@@ -245,8 +260,9 @@ };

* @param baseAttributes
* @param useHex - if ids should be kept as hex without converting to base64
*/
function toCollectorResourceSpans(groupedSpans, baseAttributes) {
function toCollectorResourceSpans(groupedSpans, baseAttributes, useHex) {
return Array.from(groupedSpans, ([resource, libSpans]) => {
return {
resource: toCollectorResource(resource, baseAttributes),
instrumentationLibrarySpans: Array.from(libSpans, ([instrumentationLibrary, spans]) => toCollectorInstrumentationLibrarySpans(instrumentationLibrary, spans)),
instrumentationLibrarySpans: Array.from(libSpans, ([instrumentationLibrary, spans]) => toCollectorInstrumentationLibrarySpans(instrumentationLibrary, spans, useHex)),
};

@@ -253,0 +269,0 @@ });

@@ -105,47 +105,41 @@ "use strict";

};
switch (metric.aggregator.kind) {
case metrics_1.AggregatorKind.SUM:
{
const result = {
dataPoints: [toDataPoint(metric, startTime)],
isMonotonic: metric.descriptor.metricKind === metrics_1.MetricKind.COUNTER ||
metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER,
aggregationTemporality: toAggregationTemporality(metric),
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intSum = result;
}
else {
metricCollector.doubleSum = result;
}
}
break;
case metrics_1.AggregatorKind.LAST_VALUE:
{
const result = {
dataPoints: [toDataPoint(metric, startTime)],
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intGauge = result;
}
else {
metricCollector.doubleGauge = result;
}
}
break;
case metrics_1.AggregatorKind.HISTOGRAM:
{
const result = {
dataPoints: [toHistogramPoint(metric, startTime)],
aggregationTemporality: toAggregationTemporality(metric),
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intHistogram = result;
}
else {
metricCollector.doubleHistogram = result;
}
}
break;
if (metric.aggregator.kind === metrics_1.AggregatorKind.SUM ||
metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER ||
metric.descriptor.metricKind === metrics_1.MetricKind.UP_DOWN_SUM_OBSERVER) {
const result = {
dataPoints: [toDataPoint(metric, startTime)],
isMonotonic: metric.descriptor.metricKind === metrics_1.MetricKind.COUNTER ||
metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER,
aggregationTemporality: toAggregationTemporality(metric),
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intSum = result;
}
else {
metricCollector.doubleSum = result;
}
}
else if (metric.aggregator.kind === metrics_1.AggregatorKind.LAST_VALUE) {
const result = {
dataPoints: [toDataPoint(metric, startTime)],
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intGauge = result;
}
else {
metricCollector.doubleGauge = result;
}
}
else if (metric.aggregator.kind === metrics_1.AggregatorKind.HISTOGRAM) {
const result = {
dataPoints: [toHistogramPoint(metric, startTime)],
aggregationTemporality: toAggregationTemporality(metric),
};
if (metric.descriptor.valueType === api.ValueType.INT) {
metricCollector.intHistogram = result;
}
else {
metricCollector.doubleHistogram = result;
}
}
return metricCollector;

@@ -152,0 +146,0 @@ }

@@ -201,3 +201,4 @@ import { SpanKind, Logger, Attributes } from '@opentelemetry/api';

readonly name: string;
constructor(message?: string, code?: number);
readonly data?: string;
constructor(message?: string, code?: number, data?: string);
}

@@ -204,0 +205,0 @@ /**

@@ -140,5 +140,6 @@ "use strict";

class CollectorExporterError extends Error {
constructor(message, code) {
constructor(message, code, data) {
super(message);
this.name = 'CollectorExporterError';
this.data = data;
this.code = code;

@@ -145,0 +146,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "0.12.1-alpha.54+3f72613a";
export declare const VERSION = "0.13.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.12.1-alpha.54+3f72613a';
exports.VERSION = '0.13.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/exporter-collector",
"version": "0.12.1-alpha.54+3f72613a",
"version": "0.13.0",
"description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector",

@@ -53,13 +53,13 @@ "main": "build/src/index.js",

"devDependencies": {
"@babel/core": "7.11.1",
"@types/mocha": "8.0.2",
"@types/node": "14.0.27",
"@types/sinon": "9.0.4",
"@types/webpack-env": "1.15.2",
"babel-loader": "8.1.0",
"codecov": "3.7.2",
"@babel/core": "7.12.9",
"@types/mocha": "8.0.4",
"@types/node": "14.14.10",
"@types/sinon": "9.0.9",
"@types/webpack-env": "1.16.0",
"babel-loader": "8.2.2",
"codecov": "3.8.1",
"cpx": "1.5.0",
"gts": "2.0.2",
"istanbul-instrumenter-loader": "3.0.1",
"karma": "5.1.1",
"karma": "5.2.3",
"karma-chrome-launcher": "3.1.0",

@@ -73,20 +73,20 @@ "karma-coverage-istanbul-reporter": "3.0.3",

"rimraf": "3.0.2",
"sinon": "9.0.3",
"ts-loader": "8.0.2",
"ts-mocha": "7.0.0",
"sinon": "9.2.1",
"ts-loader": "8.0.11",
"ts-mocha": "8.0.0",
"ts-node": "9.0.0",
"typescript": "3.9.7",
"webpack": "4.44.1",
"webpack-cli": "3.3.12",
"webpack-merge": "5.1.1"
"webpack": "4.44.2",
"webpack-cli": "4.2.0",
"webpack-merge": "5.4.0"
},
"dependencies": {
"@opentelemetry/api": "^0.12.1-alpha.54+3f72613a",
"@opentelemetry/core": "^0.12.1-alpha.54+3f72613a",
"@opentelemetry/metrics": "^0.12.1-alpha.54+3f72613a",
"@opentelemetry/resources": "^0.12.1-alpha.54+3f72613a",
"@opentelemetry/tracing": "^0.12.1-alpha.54+3f72613a",
"axios": "^0.19.2"
"@opentelemetry/api": "^0.13.0",
"@opentelemetry/core": "^0.13.0",
"@opentelemetry/metrics": "^0.13.0",
"@opentelemetry/resources": "^0.13.0",
"@opentelemetry/tracing": "^0.13.0",
"axios": "^0.21.0"
},
"gitHead": "3f72613a36b6f97555a0fa7481755cf8b6cce1a7"
"gitHead": "86cbd6798f9318c5920f9d9055f289a1c3f26500"
}

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc