@opentelemetry/exporter-collector
Advanced tools
Comparing version 0.11.1-alpha.48 to 0.11.1-alpha.53
@@ -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); | ||
@@ -56,5 +58,3 @@ this.url = this.getDefaultUrl(config); | ||
.catch((error) => { | ||
if (error.message) { | ||
this.logger.error(error.message); | ||
} | ||
core_1.globalErrorHandler(error); | ||
if (error.code && error.code < 500) { | ||
@@ -85,8 +85,22 @@ resultCallback(core_1.ExportResult.FAILED_NOT_RETRYABLE); | ||
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; | ||
} | ||
@@ -93,0 +107,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 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sendWithXhr = exports.sendWithBeacon = void 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. | ||
*/ | ||
const collectorTypes = require("../../types"); | ||
/** | ||
@@ -16,4 +32,4 @@ * Send metrics/spans using browser navigator.sendBeacon | ||
else { | ||
logger.error('sendBeacon - cannot send', body); | ||
onError({}); | ||
const error = new collectorTypes.CollectorExporterError(`sendBeacon - cannot send ${body}`); | ||
onError(error); | ||
} | ||
@@ -45,8 +61,4 @@ } | ||
else { | ||
logger.error('body', body); | ||
logger.error('xhr error', xhr); | ||
onError({ | ||
code: xhr.status, | ||
message: xhr.responseText, | ||
}); | ||
const error = new collectorTypes.CollectorExporterError(xhr.responseText, xhr.status); | ||
onError(error); | ||
} | ||
@@ -53,0 +65,0 @@ } |
@@ -20,3 +20,2 @@ "use strict"; | ||
const CollectorExporterBase_1 = require("../../CollectorExporterBase"); | ||
const collectorTypes = require("../../types"); | ||
const util_1 = require("../../util"); | ||
@@ -30,5 +29,3 @@ const util_2 = require("./util"); | ||
super(config); | ||
this.DEFAULT_HEADERS = { | ||
[collectorTypes.OT_REQUEST_HEADER]: '1', | ||
}; | ||
this.DEFAULT_HEADERS = {}; | ||
if (config.metadata) { | ||
@@ -49,3 +46,19 @@ this.logger.warn('Metadata cannot be set when using http'); | ||
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); | ||
} | ||
@@ -52,0 +65,0 @@ onShutdown() { } |
@@ -22,2 +22,3 @@ "use strict"; | ||
const https = require("https"); | ||
const collectorTypes = require("../../types"); | ||
/** | ||
@@ -47,14 +48,8 @@ * Sends data using http | ||
else { | ||
collector.logger.error(`statusCode: ${res.statusCode}`); | ||
onError({ | ||
code: res.statusCode, | ||
message: res.statusMessage, | ||
}); | ||
const error = new collectorTypes.CollectorExporterError(res.statusMessage, res.statusCode); | ||
onError(error); | ||
} | ||
}); | ||
req.on('error', (error) => { | ||
collector.logger.error('error', error.message); | ||
onError({ | ||
message: error.message, | ||
}); | ||
onError(error); | ||
}); | ||
@@ -61,0 +56,0 @@ req.write(data); |
@@ -116,4 +116,4 @@ "use strict"; | ||
const protoLink = { | ||
traceId: core.hexToBase64(link.context.traceId), | ||
spanId: core.hexToBase64(link.context.spanId), | ||
traceId: link.context.traceId, | ||
spanId: link.context.spanId, | ||
attributes: toCollectorAttributes(link.attributes || {}), | ||
@@ -132,7 +132,5 @@ droppedAttributesCount: 0, | ||
return { | ||
traceId: core.hexToBase64(span.spanContext.traceId), | ||
spanId: core.hexToBase64(span.spanContext.spanId), | ||
parentSpanId: span.parentSpanId | ||
? core.hexToBase64(span.parentSpanId) | ||
: undefined, | ||
traceId: span.spanContext.traceId, | ||
spanId: span.spanContext.spanId, | ||
parentSpanId: span.parentSpanId ? span.parentSpanId : undefined, | ||
traceState: toCollectorTraceState(span.spanContext.traceState), | ||
@@ -139,0 +137,0 @@ name: span.name, |
@@ -13,27 +13,12 @@ import { MetricRecord } from '@opentelemetry/metrics'; | ||
/** | ||
* Given a MetricDescriptor, return its type in a compatible format with the collector | ||
* @param descriptor | ||
*/ | ||
export declare function toCollectorType(metric: MetricRecord): opentelemetryProto.metrics.v1.MetricDescriptorType; | ||
/** | ||
* Given a MetricDescriptor, return its temporality in a compatible format with the collector | ||
* @param descriptor | ||
*/ | ||
export declare function toCollectorTemporality(metric: MetricRecord): opentelemetryProto.metrics.v1.MetricDescriptorTemporality; | ||
export declare function toAggregationTemporality(metric: MetricRecord): opentelemetryProto.metrics.v1.AggregationTemporality; | ||
/** | ||
* Given a MetricRecord, return the Collector compatible type of MetricDescriptor | ||
* Returns an DataPoint which can have integers or doublle values | ||
* @param metric | ||
*/ | ||
export declare function toCollectorMetricDescriptor(metric: MetricRecord): opentelemetryProto.metrics.v1.MetricDescriptor; | ||
/** | ||
* Returns an Int64Point or DoublePoint to the collector | ||
* @param metric | ||
* @param startTime | ||
*/ | ||
export declare function toSingularPoint(metric: MetricRecord, startTime: number): { | ||
labels: opentelemetryProto.common.v1.StringKeyValue[]; | ||
startTimeUnixNano: number; | ||
timeUnixNano: number; | ||
value: number; | ||
}; | ||
export declare function toDataPoint(metric: MetricRecord, startTime: number): opentelemetryProto.metrics.v1.DataPoint; | ||
/** | ||
@@ -46,8 +31,2 @@ * Returns a HistogramPoint to the collector | ||
/** | ||
* Returns a SummaryPoint to the collector | ||
* @param metric | ||
* @param startTime | ||
*/ | ||
export declare function toSummaryPoint(metric: MetricRecord, startTime: number): opentelemetryProto.metrics.v1.SummaryDataPoint; | ||
/** | ||
* Converts a metric to be compatible with the collector | ||
@@ -54,0 +33,0 @@ * @param metric |
@@ -18,3 +18,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.groupMetricsByResourceAndLibrary = exports.toCollectorExportMetricServiceRequest = exports.toCollectorMetric = exports.toSummaryPoint = exports.toHistogramPoint = exports.toSingularPoint = exports.toCollectorMetricDescriptor = exports.toCollectorTemporality = exports.toCollectorType = exports.toCollectorLabels = void 0; | ||
exports.groupMetricsByResourceAndLibrary = exports.toCollectorExportMetricServiceRequest = exports.toCollectorMetric = exports.toHistogramPoint = exports.toDataPoint = exports.toAggregationTemporality = exports.toCollectorLabels = void 0; | ||
const metrics_1 = require("@opentelemetry/metrics"); | ||
@@ -36,71 +36,35 @@ const types_1 = require("./types"); | ||
/** | ||
* Given a MetricDescriptor, return its type in a compatible format with the collector | ||
* @param descriptor | ||
*/ | ||
function toCollectorType(metric) { | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.COUNTER || | ||
metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER) { | ||
if (metric.descriptor.valueType === api.ValueType.INT) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.MONOTONIC_INT64; | ||
} | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.MONOTONIC_DOUBLE; | ||
} | ||
if (metric.aggregator instanceof metrics_1.HistogramAggregator) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.HISTOGRAM; | ||
} | ||
if (metric.aggregator instanceof metrics_1.MinMaxLastSumCountAggregator) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.SUMMARY; | ||
} | ||
if (metric.descriptor.valueType == api.ValueType.INT) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.INT64; | ||
} | ||
if (metric.descriptor.valueType === api.ValueType.DOUBLE) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.DOUBLE; | ||
} | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.INVALID_TYPE; | ||
} | ||
exports.toCollectorType = toCollectorType; | ||
/** | ||
* Given a MetricDescriptor, return its temporality in a compatible format with the collector | ||
* @param descriptor | ||
*/ | ||
function toCollectorTemporality(metric) { | ||
function toAggregationTemporality(metric) { | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.COUNTER || | ||
metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorTemporality.CUMULATIVE; | ||
metric.descriptor.metricKind === metrics_1.MetricKind.UP_DOWN_COUNTER) { | ||
return types_1.opentelemetryProto.metrics.v1.AggregationTemporality | ||
.AGGREGATION_TEMPORALITY_DELTA; | ||
} | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.UP_DOWN_COUNTER || | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.SUM_OBSERVER || | ||
metric.descriptor.metricKind === metrics_1.MetricKind.UP_DOWN_SUM_OBSERVER) { | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorTemporality.DELTA; | ||
return types_1.opentelemetryProto.metrics.v1.AggregationTemporality | ||
.AGGREGATION_TEMPORALITY_CUMULATIVE; | ||
} | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.VALUE_OBSERVER || | ||
metric.descriptor.metricKind === metrics_1.MetricKind.VALUE_RECORDER) { | ||
// TODO: Change once LastValueAggregator is implemented. | ||
// If the aggregator is LastValue or Exact, then it will be instantaneous | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorTemporality.DELTA; | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.VALUE_OBSERVER) { | ||
return types_1.opentelemetryProto.metrics.v1.AggregationTemporality | ||
.AGGREGATION_TEMPORALITY_UNSPECIFIED; | ||
} | ||
return types_1.opentelemetryProto.metrics.v1.MetricDescriptorTemporality | ||
.INVALID_TEMPORALITY; | ||
// until spec is resolved keep it as unspecified | ||
if (metric.descriptor.metricKind === metrics_1.MetricKind.VALUE_RECORDER) { | ||
return types_1.opentelemetryProto.metrics.v1.AggregationTemporality | ||
.AGGREGATION_TEMPORALITY_CUMULATIVE; | ||
} | ||
return types_1.opentelemetryProto.metrics.v1.AggregationTemporality | ||
.AGGREGATION_TEMPORALITY_UNSPECIFIED; | ||
} | ||
exports.toCollectorTemporality = toCollectorTemporality; | ||
exports.toAggregationTemporality = toAggregationTemporality; | ||
/** | ||
* Given a MetricRecord, return the Collector compatible type of MetricDescriptor | ||
* Returns an DataPoint which can have integers or doublle values | ||
* @param metric | ||
*/ | ||
function toCollectorMetricDescriptor(metric) { | ||
return { | ||
name: metric.descriptor.name, | ||
description: metric.descriptor.description, | ||
unit: metric.descriptor.unit, | ||
type: toCollectorType(metric), | ||
temporality: toCollectorTemporality(metric), | ||
}; | ||
} | ||
exports.toCollectorMetricDescriptor = toCollectorMetricDescriptor; | ||
/** | ||
* Returns an Int64Point or DoublePoint to the collector | ||
* @param metric | ||
* @param startTime | ||
*/ | ||
function toSingularPoint(metric, startTime) { | ||
function toDataPoint(metric, startTime) { | ||
return { | ||
@@ -113,3 +77,3 @@ labels: toCollectorLabels(metric.labels), | ||
} | ||
exports.toSingularPoint = toSingularPoint; | ||
exports.toDataPoint = toDataPoint; | ||
/** | ||
@@ -128,5 +92,3 @@ * Returns a HistogramPoint to the collector | ||
timeUnixNano: core.hrTimeToNanoseconds(timestamp), | ||
buckets: value.buckets.counts.map(count => { | ||
return { count }; | ||
}), | ||
bucketCounts: value.buckets.counts, | ||
explicitBounds: value.buckets.boundaries, | ||
@@ -137,22 +99,2 @@ }; | ||
/** | ||
* Returns a SummaryPoint to the collector | ||
* @param metric | ||
* @param startTime | ||
*/ | ||
function toSummaryPoint(metric, startTime) { | ||
const { value, timestamp } = metric.aggregator.toPoint(); | ||
return { | ||
labels: toCollectorLabels(metric.labels), | ||
sum: value.sum, | ||
count: value.count, | ||
startTimeUnixNano: startTime, | ||
timeUnixNano: core.hrTimeToNanoseconds(timestamp), | ||
percentileValues: [ | ||
{ percentile: 0, value: value.min }, | ||
{ percentile: 100, value: value.max }, | ||
], | ||
}; | ||
} | ||
exports.toSummaryPoint = toSummaryPoint; | ||
/** | ||
* Converts a metric to be compatible with the collector | ||
@@ -163,32 +105,53 @@ * @param metric | ||
function toCollectorMetric(metric, startTime) { | ||
if (toCollectorType(metric) === | ||
types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.HISTOGRAM) { | ||
return { | ||
metricDescriptor: toCollectorMetricDescriptor(metric), | ||
histogramDataPoints: [toHistogramPoint(metric, startTime)], | ||
}; | ||
const metricCollector = { | ||
name: metric.descriptor.name, | ||
description: metric.descriptor.description, | ||
unit: metric.descriptor.unit, | ||
}; | ||
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 (toCollectorType(metric) === | ||
types_1.opentelemetryProto.metrics.v1.MetricDescriptorType.SUMMARY) { | ||
return { | ||
metricDescriptor: toCollectorMetricDescriptor(metric), | ||
summaryDataPoints: [toSummaryPoint(metric, startTime)], | ||
}; | ||
} | ||
if (metric.descriptor.valueType == api.ValueType.INT) { | ||
return { | ||
metricDescriptor: toCollectorMetricDescriptor(metric), | ||
int64DataPoints: [toSingularPoint(metric, startTime)], | ||
}; | ||
} | ||
if (metric.descriptor.valueType === api.ValueType.DOUBLE) { | ||
return { | ||
metricDescriptor: toCollectorMetricDescriptor(metric), | ||
doubleDataPoints: [toSingularPoint(metric, startTime)], | ||
}; | ||
} | ||
return { | ||
metricDescriptor: toCollectorMetricDescriptor(metric), | ||
int64DataPoints: [], | ||
}; | ||
return metricCollector; | ||
} | ||
@@ -195,0 +158,0 @@ exports.toCollectorMetric = toCollectorMetric; |
import { SpanKind, Logger, Attributes } from '@opentelemetry/api'; | ||
import * as api from '@opentelemetry/api'; | ||
export declare const OT_REQUEST_HEADER = "x-opentelemetry-outgoing-request"; | ||
export declare namespace opentelemetryProto { | ||
@@ -28,9 +27,25 @@ namespace collector { | ||
interface Metric { | ||
metricDescriptor: opentelemetryProto.metrics.v1.MetricDescriptor; | ||
int64DataPoints?: opentelemetryProto.metrics.v1.Int64DataPoint[]; | ||
doubleDataPoints?: opentelemetryProto.metrics.v1.DoubleDataPoint[]; | ||
histogramDataPoints?: opentelemetryProto.metrics.v1.HistogramDataPoint[]; | ||
summaryDataPoints?: opentelemetryProto.metrics.v1.SummaryDataPoint[]; | ||
name: string; | ||
description: string; | ||
unit: string; | ||
intGauge?: opentelemetryProto.metrics.v1.Gauge; | ||
doubleGauge?: opentelemetryProto.metrics.v1.Gauge; | ||
intSum?: opentelemetryProto.metrics.v1.Sum; | ||
doubleSum?: opentelemetryProto.metrics.v1.Sum; | ||
intHistogram?: opentelemetryProto.metrics.v1.Histogram; | ||
doubleHistogram?: opentelemetryProto.metrics.v1.Histogram; | ||
} | ||
interface Int64DataPoint { | ||
interface Gauge { | ||
dataPoints: opentelemetryProto.metrics.v1.DataPoint[]; | ||
} | ||
interface Sum { | ||
dataPoints: opentelemetryProto.metrics.v1.DataPoint[]; | ||
aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality; | ||
isMonotonic: boolean; | ||
} | ||
interface Histogram { | ||
dataPoints: opentelemetryProto.metrics.v1.HistogramDataPoint[]; | ||
aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality; | ||
} | ||
interface DataPoint { | ||
labels: opentelemetryProto.common.v1.StringKeyValue[]; | ||
@@ -40,8 +55,10 @@ startTimeUnixNano: number; | ||
value: number; | ||
exemplars?: opentelemetryProto.metrics.v1.Exemplar[]; | ||
} | ||
interface DoubleDataPoint { | ||
labels: opentelemetryProto.common.v1.StringKeyValue[]; | ||
startTimeUnixNano: number; | ||
interface Exemplar { | ||
filteredLabels: opentelemetryProto.common.v1.StringKeyValue[]; | ||
timeUnixNano: number; | ||
value: number; | ||
spanId: Uint8Array; | ||
traceId: Uint8Array; | ||
} | ||
@@ -54,33 +71,6 @@ interface HistogramDataPoint { | ||
sum: number; | ||
buckets?: opentelemetryProto.metrics.v1.HistogramDataPointBucket[]; | ||
bucketCounts?: number[]; | ||
explicitBounds?: number[]; | ||
exemplars?: opentelemetryProto.metrics.v1.Exemplar[][]; | ||
} | ||
interface HistogramDataPointBucket { | ||
count: number; | ||
exemplar?: opentelemetryProto.metrics.v1.HistogramExemplar; | ||
} | ||
interface HistogramExemplar { | ||
value: number; | ||
timeUnixNano: number; | ||
attachments: opentelemetryProto.common.v1.StringKeyValue[]; | ||
} | ||
interface SummaryDataPoint { | ||
labels: opentelemetryProto.common.v1.StringKeyValue[]; | ||
startTimeUnixNano: number; | ||
timeUnixNano: number; | ||
count?: number; | ||
sum?: number; | ||
percentileValues: opentelemetryProto.metrics.v1.SummaryDataPointValueAtPercentile[]; | ||
} | ||
interface SummaryDataPointValueAtPercentile { | ||
percentile: number; | ||
value: number; | ||
} | ||
interface MetricDescriptor { | ||
name: string; | ||
description: string; | ||
unit: string; | ||
type: opentelemetryProto.metrics.v1.MetricDescriptorType; | ||
temporality: opentelemetryProto.metrics.v1.MetricDescriptorTemporality; | ||
} | ||
interface InstrumentationLibraryMetrics { | ||
@@ -94,17 +84,7 @@ instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary; | ||
} | ||
enum MetricDescriptorType { | ||
INVALID_TYPE = 0, | ||
INT64 = 1, | ||
MONOTONIC_INT64 = 2, | ||
DOUBLE = 3, | ||
MONOTONIC_DOUBLE = 4, | ||
HISTOGRAM = 5, | ||
SUMMARY = 6 | ||
enum AggregationTemporality { | ||
AGGREGATION_TEMPORALITY_UNSPECIFIED = 0, | ||
AGGREGATION_TEMPORALITY_DELTA = 1, | ||
AGGREGATION_TEMPORALITY_CUMULATIVE = 2 | ||
} | ||
enum MetricDescriptorTemporality { | ||
INVALID_TEMPORALITY = 0, | ||
INSTANTANEOUS = 1, | ||
DELTA = 2, | ||
CUMULATIVE = 3 | ||
} | ||
} | ||
@@ -135,7 +115,7 @@ namespace trace.v1 { | ||
SPAN_KIND_UNSPECIFIED = 0, | ||
INTERNAL = 1, | ||
SERVER = 2, | ||
CLIENT = 3, | ||
PRODUCER = 4, | ||
CONSUMER = 5 | ||
SPAN_KIND_INTERNAL = 1, | ||
SPAN_KIND_SERVER = 2, | ||
SPAN_KIND_CLIENT = 3, | ||
SPAN_KIND_PRODUCER = 4, | ||
SPAN_KIND_CONSUMER = 5 | ||
} | ||
@@ -223,6 +203,6 @@ type TraceState = string | undefined; | ||
*/ | ||
export interface CollectorExporterError { | ||
code?: number; | ||
message?: string; | ||
stack?: string; | ||
export declare class CollectorExporterError extends Error { | ||
readonly code?: number; | ||
readonly name: string; | ||
constructor(message?: string, code?: number); | ||
} | ||
@@ -233,2 +213,3 @@ /** | ||
export interface ExportServiceError { | ||
name: string; | ||
code: number; | ||
@@ -235,0 +216,0 @@ details: string; |
@@ -18,6 +18,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.COLLECTOR_SPAN_KIND_MAPPING = exports.opentelemetryProto = exports.OT_REQUEST_HEADER = void 0; | ||
exports.COLLECTOR_SPAN_KIND_MAPPING = exports.CollectorExporterError = exports.opentelemetryProto = void 0; | ||
const api_1 = require("@opentelemetry/api"); | ||
// header to prevent instrumentation on request | ||
exports.OT_REQUEST_HEADER = 'x-opentelemetry-outgoing-request'; | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
@@ -30,19 +28,68 @@ var opentelemetryProto; | ||
(function (v1) { | ||
let MetricDescriptorType; | ||
(function (MetricDescriptorType) { | ||
MetricDescriptorType[MetricDescriptorType["INVALID_TYPE"] = 0] = "INVALID_TYPE"; | ||
MetricDescriptorType[MetricDescriptorType["INT64"] = 1] = "INT64"; | ||
MetricDescriptorType[MetricDescriptorType["MONOTONIC_INT64"] = 2] = "MONOTONIC_INT64"; | ||
MetricDescriptorType[MetricDescriptorType["DOUBLE"] = 3] = "DOUBLE"; | ||
MetricDescriptorType[MetricDescriptorType["MONOTONIC_DOUBLE"] = 4] = "MONOTONIC_DOUBLE"; | ||
MetricDescriptorType[MetricDescriptorType["HISTOGRAM"] = 5] = "HISTOGRAM"; | ||
MetricDescriptorType[MetricDescriptorType["SUMMARY"] = 6] = "SUMMARY"; | ||
})(MetricDescriptorType = v1.MetricDescriptorType || (v1.MetricDescriptorType = {})); | ||
let MetricDescriptorTemporality; | ||
(function (MetricDescriptorTemporality) { | ||
MetricDescriptorTemporality[MetricDescriptorTemporality["INVALID_TEMPORALITY"] = 0] = "INVALID_TEMPORALITY"; | ||
MetricDescriptorTemporality[MetricDescriptorTemporality["INSTANTANEOUS"] = 1] = "INSTANTANEOUS"; | ||
MetricDescriptorTemporality[MetricDescriptorTemporality["DELTA"] = 2] = "DELTA"; | ||
MetricDescriptorTemporality[MetricDescriptorTemporality["CUMULATIVE"] = 3] = "CUMULATIVE"; | ||
})(MetricDescriptorTemporality = v1.MetricDescriptorTemporality || (v1.MetricDescriptorTemporality = {})); | ||
let AggregationTemporality; | ||
(function (AggregationTemporality) { | ||
// UNSPECIFIED is the default AggregationTemporality, it MUST not be used. | ||
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED"; | ||
// DELTA is an AggregationTemporality for a metric aggregator which reports | ||
// changes since last report time. Successive metrics contain aggregation of | ||
// values from continuous and non-overlapping intervals. | ||
// | ||
// The values for a DELTA metric are based only on the time interval | ||
// associated with one measurement cycle. There is no dependency on | ||
// previous measurements like is the case for CUMULATIVE metrics. | ||
// | ||
// For example, consider a system measuring the number of requests that | ||
// it receives and reports the sum of these requests every second as a | ||
// DELTA metric: | ||
// | ||
// 1. The system starts receiving at time=t_0. | ||
// 2. A request is received, the system measures 1 request. | ||
// 3. A request is received, the system measures 1 request. | ||
// 4. A request is received, the system measures 1 request. | ||
// 5. The 1 second collection cycle ends. A metric is exported for the | ||
// number of requests received over the interval of time t_0 to | ||
// t_0+1 with a value of 3. | ||
// 6. A request is received, the system measures 1 request. | ||
// 7. A request is received, the system measures 1 request. | ||
// 8. The 1 second collection cycle ends. A metric is exported for the | ||
// number of requests received over the interval of time t_0+1 to | ||
// t_0+2 with a value of 2. | ||
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA"; | ||
// CUMULATIVE is an AggregationTemporality for a metric aggregator which | ||
// reports changes since a fixed start time. This means that current values | ||
// of a CUMULATIVE metric depend on all previous measurements since the | ||
// start time. Because of this, the sender is required to retain this state | ||
// in some form. If this state is lost or invalidated, the CUMULATIVE metric | ||
// values MUST be reset and a new fixed start time following the last | ||
// reported measurement time sent MUST be used. | ||
// | ||
// For example, consider a system measuring the number of requests that | ||
// it receives and reports the sum of these requests every second as a | ||
// CUMULATIVE metric: | ||
// | ||
// 1. The system starts receiving at time=t_0. | ||
// 2. A request is received, the system measures 1 request. | ||
// 3. A request is received, the system measures 1 request. | ||
// 4. A request is received, the system measures 1 request. | ||
// 5. The 1 second collection cycle ends. A metric is exported for the | ||
// number of requests received over the interval of time t_0 to | ||
// t_0+1 with a value of 3. | ||
// 6. A request is received, the system measures 1 request. | ||
// 7. A request is received, the system measures 1 request. | ||
// 8. The 1 second collection cycle ends. A metric is exported for the | ||
// number of requests received over the interval of time t_0 to | ||
// t_0+2 with a value of 5. | ||
// 9. The system experiences a fault and loses state. | ||
// 10. The system recovers and resumes receiving at time=t_1. | ||
// 11. A request is received, the system measures 1 request. | ||
// 12. The 1 second collection cycle ends. A metric is exported for the | ||
// number of requests received over the interval of time t_1 to | ||
// t_0+1 with a value of 1. | ||
// | ||
// Note: Even though, when reporting changes since last report time, using | ||
// CUMULATIVE is valid, it is not recommended. This may cause problems for | ||
// systems that do not use start_time to determine when the aggregation | ||
// value was reset (e.g. Prometheus). | ||
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE"; | ||
})(AggregationTemporality = v1.AggregationTemporality || (v1.AggregationTemporality = {})); | ||
})(v1 = metrics.v1 || (metrics.v1 = {})); | ||
@@ -68,7 +115,7 @@ })(metrics = opentelemetryProto.metrics || (opentelemetryProto.metrics = {})); | ||
SpanKind[SpanKind["SPAN_KIND_UNSPECIFIED"] = 0] = "SPAN_KIND_UNSPECIFIED"; | ||
SpanKind[SpanKind["INTERNAL"] = 1] = "INTERNAL"; | ||
SpanKind[SpanKind["SERVER"] = 2] = "SERVER"; | ||
SpanKind[SpanKind["CLIENT"] = 3] = "CLIENT"; | ||
SpanKind[SpanKind["PRODUCER"] = 4] = "PRODUCER"; | ||
SpanKind[SpanKind["CONSUMER"] = 5] = "CONSUMER"; | ||
SpanKind[SpanKind["SPAN_KIND_INTERNAL"] = 1] = "SPAN_KIND_INTERNAL"; | ||
SpanKind[SpanKind["SPAN_KIND_SERVER"] = 2] = "SPAN_KIND_SERVER"; | ||
SpanKind[SpanKind["SPAN_KIND_CLIENT"] = 3] = "SPAN_KIND_CLIENT"; | ||
SpanKind[SpanKind["SPAN_KIND_PRODUCER"] = 4] = "SPAN_KIND_PRODUCER"; | ||
SpanKind[SpanKind["SPAN_KIND_CONSUMER"] = 5] = "SPAN_KIND_CONSUMER"; | ||
})(SpanKind = Span.SpanKind || (Span.SpanKind = {})); | ||
@@ -93,11 +140,22 @@ })(Span = v1.Span || (v1.Span = {})); | ||
/** | ||
* Interface for handling error | ||
*/ | ||
class CollectorExporterError extends Error { | ||
constructor(message, code) { | ||
super(message); | ||
this.name = 'CollectorExporterError'; | ||
this.code = code; | ||
} | ||
} | ||
exports.CollectorExporterError = CollectorExporterError; | ||
/** | ||
* Mapping between api SpanKind and proto SpanKind | ||
*/ | ||
exports.COLLECTOR_SPAN_KIND_MAPPING = { | ||
[api_1.SpanKind.INTERNAL]: opentelemetryProto.trace.v1.Span.SpanKind.INTERNAL, | ||
[api_1.SpanKind.SERVER]: opentelemetryProto.trace.v1.Span.SpanKind.SERVER, | ||
[api_1.SpanKind.CLIENT]: opentelemetryProto.trace.v1.Span.SpanKind.CLIENT, | ||
[api_1.SpanKind.PRODUCER]: opentelemetryProto.trace.v1.Span.SpanKind.PRODUCER, | ||
[api_1.SpanKind.CONSUMER]: opentelemetryProto.trace.v1.Span.SpanKind.CONSUMER, | ||
[api_1.SpanKind.INTERNAL]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL, | ||
[api_1.SpanKind.SERVER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER, | ||
[api_1.SpanKind.CLIENT]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CLIENT, | ||
[api_1.SpanKind.PRODUCER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_PRODUCER, | ||
[api_1.SpanKind.CONSUMER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CONSUMER, | ||
}; | ||
//# sourceMappingURL=types.js.map |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.11.1-alpha.48+15174c6"; | ||
export declare const VERSION = "0.11.1-alpha.53+00a8ce7f"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.11.1-alpha.48+15174c6'; | ||
exports.VERSION = '0.11.1-alpha.53+00a8ce7f'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/exporter-collector", | ||
"version": "0.11.1-alpha.48+15174c6", | ||
"version": "0.11.1-alpha.53+00a8ce7f", | ||
"description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", | ||
@@ -75,3 +75,3 @@ "main": "build/src/index.js", | ||
"ts-mocha": "7.0.0", | ||
"ts-node": "8.10.2", | ||
"ts-node": "9.0.0", | ||
"typescript": "3.9.7", | ||
@@ -83,10 +83,10 @@ "webpack": "4.44.1", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/core": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/metrics": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/resources": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/tracing": "^0.11.1-alpha.48+15174c6", | ||
"@opentelemetry/api": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/core": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/metrics": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/resources": "^0.11.1-alpha.53+00a8ce7f", | ||
"@opentelemetry/tracing": "^0.11.1-alpha.53+00a8ce7f", | ||
"axios": "^0.19.2" | ||
}, | ||
"gitHead": "15174c6647ab9863dfc1424412fa60f2fddb3351" | ||
"gitHead": "00a8ce7f982ea24bcd4bc398477112894078ab29" | ||
} |
@@ -9,3 +9,3 @@ # OpenTelemetry Collector Exporter for web and node | ||
This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.6.0**. | ||
This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.12.0**. | ||
@@ -69,3 +69,3 @@ ## Installation | ||
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { CollectorExporter } = require('@opentelemetry/exporter-collector'); | ||
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); | ||
@@ -81,3 +81,3 @@ const collectorOptions = { | ||
const provider = new BasicTracerProvider(); | ||
const exporter = new CollectorExporter(collectorOptions); | ||
const exporter = new CollectorTraceExporter(collectorOptions); | ||
provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
@@ -84,0 +84,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
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
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
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
121366
1864