@opentelemetry/exporter-trace-otlp-http 0.27.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -21
- package/build/esm/index.d.ts +0 -4
- package/build/esm/index.js +0 -5
- package/build/esm/index.js.map +1 -1
- package/build/esm/platform/browser/OTLPTraceExporter.d.ts +4 -5
- package/build/esm/platform/browser/OTLPTraceExporter.js +7 -8
- package/build/esm/platform/browser/OTLPTraceExporter.js.map +1 -1
- package/build/esm/platform/browser/index.d.ts +0 -1
- package/build/esm/platform/browser/index.js +0 -1
- package/build/esm/platform/browser/index.js.map +1 -1
- package/build/esm/platform/index.d.ts +0 -1
- package/build/esm/platform/index.js +0 -1
- package/build/esm/platform/index.js.map +1 -1
- package/build/esm/platform/node/OTLPTraceExporter.d.ts +5 -5
- package/build/esm/platform/node/OTLPTraceExporter.js +8 -8
- package/build/esm/platform/node/OTLPTraceExporter.js.map +1 -1
- package/build/esm/platform/node/index.d.ts +0 -3
- package/build/esm/platform/node/index.js +0 -3
- package/build/esm/platform/node/index.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/index.d.ts +2 -0
- package/build/esnext/index.js +17 -0
- package/build/esnext/index.js.map +1 -0
- package/build/esnext/platform/browser/OTLPTraceExporter.d.ts +12 -0
- package/build/esnext/platform/browser/OTLPTraceExporter.js +42 -0
- package/build/esnext/platform/browser/OTLPTraceExporter.js.map +1 -0
- package/build/esnext/platform/browser/index.d.ts +2 -0
- package/build/esnext/platform/browser/index.js +17 -0
- package/build/esnext/platform/browser/index.js.map +1 -0
- package/build/esnext/platform/index.d.ts +2 -0
- package/build/esnext/platform/index.js +17 -0
- package/build/esnext/platform/index.js.map +1 -0
- package/build/esnext/platform/node/OTLPTraceExporter.d.ts +13 -0
- package/build/esnext/platform/node/OTLPTraceExporter.js +43 -0
- package/build/esnext/platform/node/OTLPTraceExporter.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +2 -0
- package/build/esnext/platform/node/index.js +17 -0
- package/build/esnext/platform/node/index.js.map +1 -0
- package/build/esnext/version.d.ts +2 -0
- package/build/esnext/version.js +18 -0
- package/build/esnext/version.js.map +1 -0
- package/build/src/index.d.ts +0 -4
- package/build/src/index.js +0 -8
- package/build/src/index.js.map +1 -1
- package/build/src/platform/browser/OTLPTraceExporter.d.ts +4 -5
- package/build/src/platform/browser/OTLPTraceExporter.js +11 -12
- package/build/src/platform/browser/OTLPTraceExporter.js.map +1 -1
- package/build/src/platform/browser/index.d.ts +0 -1
- package/build/src/platform/browser/index.js +0 -1
- package/build/src/platform/browser/index.js.map +1 -1
- package/build/src/platform/index.d.ts +0 -1
- package/build/src/platform/index.js +0 -3
- package/build/src/platform/index.js.map +1 -1
- package/build/src/platform/node/OTLPTraceExporter.d.ts +5 -5
- package/build/src/platform/node/OTLPTraceExporter.js +12 -12
- package/build/src/platform/node/OTLPTraceExporter.js.map +1 -1
- package/build/src/platform/node/index.d.ts +0 -3
- package/build/src/platform/node/index.js +0 -3
- package/build/src/platform/node/index.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +32 -22
- package/build/esm/OTLPExporterBase.d.ts +0 -36
- package/build/esm/OTLPExporterBase.js +0 -114
- package/build/esm/OTLPExporterBase.js.map +0 -1
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +0 -18
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +0 -91
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
- package/build/esm/platform/browser/util.d.ts +0 -17
- package/build/esm/platform/browser/util.js +0 -77
- package/build/esm/platform/browser/util.js.map +0 -1
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +0 -20
- package/build/esm/platform/node/OTLPExporterNodeBase.js +0 -82
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +0 -1
- package/build/esm/platform/node/types.d.ts +0 -17
- package/build/esm/platform/node/types.js +0 -6
- package/build/esm/platform/node/types.js.map +0 -1
- package/build/esm/platform/node/util.d.ts +0 -17
- package/build/esm/platform/node/util.js +0 -113
- package/build/esm/platform/node/util.js.map +0 -1
- package/build/esm/transform.d.ts +0 -80
- package/build/esm/transform.js +0 -271
- package/build/esm/transform.js.map +0 -1
- package/build/esm/types.d.ts +0 -241
- package/build/esm/types.js +0 -176
- package/build/esm/types.js.map +0 -1
- package/build/esm/util.d.ts +0 -7
- package/build/esm/util.js +0 -40
- package/build/esm/util.js.map +0 -1
- package/build/src/OTLPExporterBase.d.ts +0 -36
- package/build/src/OTLPExporterBase.js +0 -113
- package/build/src/OTLPExporterBase.js.map +0 -1
- package/build/src/platform/browser/OTLPExporterBrowserBase.d.ts +0 -18
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +0 -74
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +0 -1
- package/build/src/platform/browser/util.d.ts +0 -17
- package/build/src/platform/browser/util.js +0 -70
- package/build/src/platform/browser/util.js.map +0 -1
- package/build/src/platform/node/OTLPExporterNodeBase.d.ts +0 -20
- package/build/src/platform/node/OTLPExporterNodeBase.js +0 -65
- package/build/src/platform/node/OTLPExporterNodeBase.js.map +0 -1
- package/build/src/platform/node/types.d.ts +0 -17
- package/build/src/platform/node/types.js +0 -9
- package/build/src/platform/node/types.js.map +0 -1
- package/build/src/platform/node/util.d.ts +0 -17
- package/build/src/platform/node/util.js +0 -107
- package/build/src/platform/node/util.js.map +0 -1
- package/build/src/transform.d.ts +0 -80
- package/build/src/transform.js +0 -282
- package/build/src/transform.js.map +0 -1
- package/build/src/types.d.ts +0 -241
- package/build/src/types.js +0 -160
- package/build/src/types.js.map +0 -1
- package/build/src/util.d.ts +0 -7
- package/build/src/util.js +0 -43
- package/build/src/util.js.map +0 -1
package/build/esm/types.js
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright The OpenTelemetry Authors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
var __extends = (this && this.__extends) || (function () {
|
|
17
|
-
var extendStatics = function (d, b) {
|
|
18
|
-
extendStatics = Object.setPrototypeOf ||
|
|
19
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
20
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
21
|
-
return extendStatics(d, b);
|
|
22
|
-
};
|
|
23
|
-
return function (d, b) {
|
|
24
|
-
if (typeof b !== "function" && b !== null)
|
|
25
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
26
|
-
extendStatics(d, b);
|
|
27
|
-
function __() { this.constructor = d; }
|
|
28
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29
|
-
};
|
|
30
|
-
})();
|
|
31
|
-
var _a;
|
|
32
|
-
import { SpanKind } from '@opentelemetry/api';
|
|
33
|
-
/* eslint-disable @typescript-eslint/no-namespace */
|
|
34
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
35
|
-
export var opentelemetryProto;
|
|
36
|
-
(function (opentelemetryProto) {
|
|
37
|
-
var metrics;
|
|
38
|
-
(function (metrics) {
|
|
39
|
-
var v1;
|
|
40
|
-
(function (v1) {
|
|
41
|
-
var AggregationTemporality;
|
|
42
|
-
(function (AggregationTemporality) {
|
|
43
|
-
// UNSPECIFIED is the default AggregationTemporality, it MUST not be used.
|
|
44
|
-
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_UNSPECIFIED"] = 0] = "AGGREGATION_TEMPORALITY_UNSPECIFIED";
|
|
45
|
-
// DELTA is an AggregationTemporality for a metric aggregator which reports
|
|
46
|
-
// changes since last report time. Successive metrics contain aggregation of
|
|
47
|
-
// values from continuous and non-overlapping intervals.
|
|
48
|
-
//
|
|
49
|
-
// The values for a DELTA metric are based only on the time interval
|
|
50
|
-
// associated with one measurement cycle. There is no dependency on
|
|
51
|
-
// previous measurements like is the case for CUMULATIVE metrics.
|
|
52
|
-
//
|
|
53
|
-
// For example, consider a system measuring the number of requests that
|
|
54
|
-
// it receives and reports the sum of these requests every second as a
|
|
55
|
-
// DELTA metric:
|
|
56
|
-
//
|
|
57
|
-
// 1. The system starts receiving at time=t_0.
|
|
58
|
-
// 2. A request is received, the system measures 1 request.
|
|
59
|
-
// 3. A request is received, the system measures 1 request.
|
|
60
|
-
// 4. A request is received, the system measures 1 request.
|
|
61
|
-
// 5. The 1 second collection cycle ends. A metric is exported for the
|
|
62
|
-
// number of requests received over the interval of time t_0 to
|
|
63
|
-
// t_0+1 with a value of 3.
|
|
64
|
-
// 6. A request is received, the system measures 1 request.
|
|
65
|
-
// 7. A request is received, the system measures 1 request.
|
|
66
|
-
// 8. The 1 second collection cycle ends. A metric is exported for the
|
|
67
|
-
// number of requests received over the interval of time t_0+1 to
|
|
68
|
-
// t_0+2 with a value of 2.
|
|
69
|
-
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_DELTA"] = 1] = "AGGREGATION_TEMPORALITY_DELTA";
|
|
70
|
-
// CUMULATIVE is an AggregationTemporality for a metric aggregator which
|
|
71
|
-
// reports changes since a fixed start time. This means that current values
|
|
72
|
-
// of a CUMULATIVE metric depend on all previous measurements since the
|
|
73
|
-
// start time. Because of this, the sender is required to retain this state
|
|
74
|
-
// in some form. If this state is lost or invalidated, the CUMULATIVE metric
|
|
75
|
-
// values MUST be reset and a new fixed start time following the last
|
|
76
|
-
// reported measurement time sent MUST be used.
|
|
77
|
-
//
|
|
78
|
-
// For example, consider a system measuring the number of requests that
|
|
79
|
-
// it receives and reports the sum of these requests every second as a
|
|
80
|
-
// CUMULATIVE metric:
|
|
81
|
-
//
|
|
82
|
-
// 1. The system starts receiving at time=t_0.
|
|
83
|
-
// 2. A request is received, the system measures 1 request.
|
|
84
|
-
// 3. A request is received, the system measures 1 request.
|
|
85
|
-
// 4. A request is received, the system measures 1 request.
|
|
86
|
-
// 5. The 1 second collection cycle ends. A metric is exported for the
|
|
87
|
-
// number of requests received over the interval of time t_0 to
|
|
88
|
-
// t_0+1 with a value of 3.
|
|
89
|
-
// 6. A request is received, the system measures 1 request.
|
|
90
|
-
// 7. A request is received, the system measures 1 request.
|
|
91
|
-
// 8. The 1 second collection cycle ends. A metric is exported for the
|
|
92
|
-
// number of requests received over the interval of time t_0 to
|
|
93
|
-
// t_0+2 with a value of 5.
|
|
94
|
-
// 9. The system experiences a fault and loses state.
|
|
95
|
-
// 10. The system recovers and resumes receiving at time=t_1.
|
|
96
|
-
// 11. A request is received, the system measures 1 request.
|
|
97
|
-
// 12. The 1 second collection cycle ends. A metric is exported for the
|
|
98
|
-
// number of requests received over the interval of time t_1 to
|
|
99
|
-
// t_0+1 with a value of 1.
|
|
100
|
-
//
|
|
101
|
-
// Note: Even though, when reporting changes since last report time, using
|
|
102
|
-
// CUMULATIVE is valid, it is not recommended. This may cause problems for
|
|
103
|
-
// systems that do not use start_time to determine when the aggregation
|
|
104
|
-
// value was reset (e.g. Prometheus).
|
|
105
|
-
AggregationTemporality[AggregationTemporality["AGGREGATION_TEMPORALITY_CUMULATIVE"] = 2] = "AGGREGATION_TEMPORALITY_CUMULATIVE";
|
|
106
|
-
})(AggregationTemporality = v1.AggregationTemporality || (v1.AggregationTemporality = {}));
|
|
107
|
-
})(v1 = metrics.v1 || (metrics.v1 = {}));
|
|
108
|
-
})(metrics = opentelemetryProto.metrics || (opentelemetryProto.metrics = {}));
|
|
109
|
-
var trace;
|
|
110
|
-
(function (trace) {
|
|
111
|
-
var v1;
|
|
112
|
-
(function (v1) {
|
|
113
|
-
var ConstantSampler;
|
|
114
|
-
(function (ConstantSampler) {
|
|
115
|
-
var ConstantDecision;
|
|
116
|
-
(function (ConstantDecision) {
|
|
117
|
-
ConstantDecision[ConstantDecision["ALWAYS_OFF"] = 0] = "ALWAYS_OFF";
|
|
118
|
-
ConstantDecision[ConstantDecision["ALWAYS_ON"] = 1] = "ALWAYS_ON";
|
|
119
|
-
ConstantDecision[ConstantDecision["ALWAYS_PARENT"] = 2] = "ALWAYS_PARENT";
|
|
120
|
-
})(ConstantDecision = ConstantSampler.ConstantDecision || (ConstantSampler.ConstantDecision = {}));
|
|
121
|
-
})(ConstantSampler = v1.ConstantSampler || (v1.ConstantSampler = {}));
|
|
122
|
-
var Span;
|
|
123
|
-
(function (Span) {
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
125
|
-
var SpanKind;
|
|
126
|
-
(function (SpanKind) {
|
|
127
|
-
SpanKind[SpanKind["SPAN_KIND_UNSPECIFIED"] = 0] = "SPAN_KIND_UNSPECIFIED";
|
|
128
|
-
SpanKind[SpanKind["SPAN_KIND_INTERNAL"] = 1] = "SPAN_KIND_INTERNAL";
|
|
129
|
-
SpanKind[SpanKind["SPAN_KIND_SERVER"] = 2] = "SPAN_KIND_SERVER";
|
|
130
|
-
SpanKind[SpanKind["SPAN_KIND_CLIENT"] = 3] = "SPAN_KIND_CLIENT";
|
|
131
|
-
SpanKind[SpanKind["SPAN_KIND_PRODUCER"] = 4] = "SPAN_KIND_PRODUCER";
|
|
132
|
-
SpanKind[SpanKind["SPAN_KIND_CONSUMER"] = 5] = "SPAN_KIND_CONSUMER";
|
|
133
|
-
})(SpanKind = Span.SpanKind || (Span.SpanKind = {}));
|
|
134
|
-
})(Span = v1.Span || (v1.Span = {}));
|
|
135
|
-
})(v1 = trace.v1 || (trace.v1 = {}));
|
|
136
|
-
})(trace = opentelemetryProto.trace || (opentelemetryProto.trace = {}));
|
|
137
|
-
var common;
|
|
138
|
-
(function (common) {
|
|
139
|
-
var v1;
|
|
140
|
-
(function (v1) {
|
|
141
|
-
var ValueType;
|
|
142
|
-
(function (ValueType) {
|
|
143
|
-
ValueType[ValueType["STRING"] = 0] = "STRING";
|
|
144
|
-
ValueType[ValueType["INT"] = 1] = "INT";
|
|
145
|
-
ValueType[ValueType["DOUBLE"] = 2] = "DOUBLE";
|
|
146
|
-
ValueType[ValueType["BOOL"] = 3] = "BOOL";
|
|
147
|
-
})(ValueType = v1.ValueType || (v1.ValueType = {}));
|
|
148
|
-
})(v1 = common.v1 || (common.v1 = {}));
|
|
149
|
-
})(common = opentelemetryProto.common || (opentelemetryProto.common = {}));
|
|
150
|
-
})(opentelemetryProto || (opentelemetryProto = {}));
|
|
151
|
-
/**
|
|
152
|
-
* Interface for handling error
|
|
153
|
-
*/
|
|
154
|
-
var OTLPExporterError = /** @class */ (function (_super) {
|
|
155
|
-
__extends(OTLPExporterError, _super);
|
|
156
|
-
function OTLPExporterError(message, code, data) {
|
|
157
|
-
var _this = _super.call(this, message) || this;
|
|
158
|
-
_this.name = 'OTLPExporterError';
|
|
159
|
-
_this.data = data;
|
|
160
|
-
_this.code = code;
|
|
161
|
-
return _this;
|
|
162
|
-
}
|
|
163
|
-
return OTLPExporterError;
|
|
164
|
-
}(Error));
|
|
165
|
-
export { OTLPExporterError };
|
|
166
|
-
/**
|
|
167
|
-
* Mapping between api SpanKind and proto SpanKind
|
|
168
|
-
*/
|
|
169
|
-
export var OTLP_SPAN_KIND_MAPPING = (_a = {},
|
|
170
|
-
_a[SpanKind.INTERNAL] = opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL,
|
|
171
|
-
_a[SpanKind.SERVER] = opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER,
|
|
172
|
-
_a[SpanKind.CLIENT] = opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CLIENT,
|
|
173
|
-
_a[SpanKind.PRODUCER] = opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_PRODUCER,
|
|
174
|
-
_a[SpanKind.CONSUMER] = opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CONSUMER,
|
|
175
|
-
_a);
|
|
176
|
-
//# sourceMappingURL=types.js.map
|
package/build/esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAkB,QAAQ,EAAkB,MAAM,oBAAoB,CAAC;AAE9E,oDAAoD;AACpD,sDAAsD;AAEtD,MAAM,KAAW,kBAAkB,CAkSlC;AAlSD,WAAiB,kBAAkB;IAyBjC,IAAiB,OAAO,CAqIvB;IArID,WAAiB,OAAO;QAAC,IAAA,EAAE,CAqI1B;QArIwB,WAAA,EAAE;YAkEzB,IAAY,sBAkEX;YAlED,WAAY,sBAAsB;gBAChC,0EAA0E;gBAC1E,iIAAuC,CAAA;gBAEvC,2EAA2E;gBAC3E,4EAA4E;gBAC5E,wDAAwD;gBACxD,EAAE;gBACF,oEAAoE;gBACpE,mEAAmE;gBACnE,iEAAiE;gBACjE,EAAE;gBACF,uEAAuE;gBACvE,sEAAsE;gBACtE,gBAAgB;gBAChB,EAAE;gBACF,gDAAgD;gBAChD,6DAA6D;gBAC7D,6DAA6D;gBAC7D,6DAA6D;gBAC7D,wEAAwE;gBACxE,oEAAoE;gBACpE,gCAAgC;gBAChC,6DAA6D;gBAC7D,6DAA6D;gBAC7D,wEAAwE;gBACxE,sEAAsE;gBACtE,gCAAgC;gBAChC,qHAAiC,CAAA;gBAEjC,wEAAwE;gBACxE,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B;IAC9D,GAAC,QAAQ,CAAC,MAAM,IAAG,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB;IAC7E,GAAC,QAAQ,CAAC,MAAM,IAAG,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB;IAC7E,GAAC,QAAQ,CAAC,QAAQ,IAChB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;IAC9D,GAAC,QAAQ,CAAC,QAAQ,IAChB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB;OAC/D,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\nimport { SpanAttributes, SpanKind, SpanStatusCode } from '@opentelemetry/api';\n\n/* eslint-disable @typescript-eslint/no-namespace */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n\nexport namespace opentelemetryProto {\n export namespace collector {\n export namespace trace.v1 {\n export interface TraceService {\n service: opentelemetryProto.collector.trace.v1.TraceService;\n }\n\n export interface ExportTraceServiceRequest {\n resourceSpans: opentelemetryProto.trace.v1.ResourceSpans[];\n }\n }\n export namespace metrics.v1 {\n export interface ExportMetricsServiceRequest {\n resourceMetrics: opentelemetryProto.metrics.v1.ResourceMetrics[];\n }\n }\n }\n\n export namespace resource.v1 {\n export interface Resource {\n attributes: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n }\n\n export namespace metrics.v1 {\n export interface Metric {\n name: string;\n description: string;\n unit: string;\n // data:\n intGauge?: opentelemetryProto.metrics.v1.Gauge;\n doubleGauge?: opentelemetryProto.metrics.v1.Gauge;\n intSum?: opentelemetryProto.metrics.v1.Sum;\n doubleSum?: opentelemetryProto.metrics.v1.Sum;\n intHistogram?: opentelemetryProto.metrics.v1.Histogram;\n doubleHistogram?: opentelemetryProto.metrics.v1.Histogram;\n }\n\n export interface Gauge {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n }\n\n export interface Sum {\n dataPoints: opentelemetryProto.metrics.v1.DataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n isMonotonic: boolean;\n }\n\n export interface Histogram {\n dataPoints: opentelemetryProto.metrics.v1.HistogramDataPoint[];\n aggregationTemporality: opentelemetryProto.metrics.v1.AggregationTemporality;\n }\n\n export interface DataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n value: number;\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[];\n }\n\n export interface Exemplar {\n filteredLabels: opentelemetryProto.common.v1.StringKeyValue[];\n timeUnixNano: number;\n value: number;\n spanId: Uint8Array;\n traceId: Uint8Array;\n }\n\n export interface HistogramDataPoint {\n labels: opentelemetryProto.common.v1.StringKeyValue[];\n startTimeUnixNano: number;\n timeUnixNano: number;\n count: number;\n sum: number;\n bucketCounts?: number[];\n explicitBounds?: number[];\n exemplars?: opentelemetryProto.metrics.v1.Exemplar[][];\n }\n\n export interface InstrumentationLibraryMetrics {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n metrics: opentelemetryProto.metrics.v1.Metric[];\n }\n\n export interface ResourceMetrics {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibraryMetrics: opentelemetryProto.metrics.v1.InstrumentationLibraryMetrics[];\n }\n\n export enum AggregationTemporality {\n // UNSPECIFIED is the default AggregationTemporality, it MUST not be used.\n AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,\n\n // DELTA is an AggregationTemporality for a metric aggregator which reports\n // changes since last report time. Successive metrics contain aggregation of\n // values from continuous and non-overlapping intervals.\n //\n // The values for a DELTA metric are based only on the time interval\n // associated with one measurement cycle. There is no dependency on\n // previous measurements like is the case for CUMULATIVE metrics.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // DELTA metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0+1 to\n // t_0+2 with a value of 2.\n AGGREGATION_TEMPORALITY_DELTA = 1,\n\n // CUMULATIVE is an AggregationTemporality for a metric aggregator which\n // reports changes since a fixed start time. This means that current values\n // of a CUMULATIVE metric depend on all previous measurements since the\n // start time. Because of this, the sender is required to retain this state\n // in some form. If this state is lost or invalidated, the CUMULATIVE metric\n // values MUST be reset and a new fixed start time following the last\n // reported measurement time sent MUST be used.\n //\n // For example, consider a system measuring the number of requests that\n // it receives and reports the sum of these requests every second as a\n // CUMULATIVE metric:\n //\n // 1. The system starts receiving at time=t_0.\n // 2. A request is received, the system measures 1 request.\n // 3. A request is received, the system measures 1 request.\n // 4. A request is received, the system measures 1 request.\n // 5. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+1 with a value of 3.\n // 6. A request is received, the system measures 1 request.\n // 7. A request is received, the system measures 1 request.\n // 8. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_0 to\n // t_0+2 with a value of 5.\n // 9. The system experiences a fault and loses state.\n // 10. The system recovers and resumes receiving at time=t_1.\n // 11. A request is received, the system measures 1 request.\n // 12. The 1 second collection cycle ends. A metric is exported for the\n // number of requests received over the interval of time t_1 to\n // t_0+1 with a value of 1.\n //\n // Note: Even though, when reporting changes since last report time, using\n // CUMULATIVE is valid, it is not recommended. This may cause problems for\n // systems that do not use start_time to determine when the aggregation\n // value was reset (e.g. Prometheus).\n AGGREGATION_TEMPORALITY_CUMULATIVE = 2,\n }\n }\n\n export namespace trace.v1 {\n export namespace ConstantSampler {\n export enum ConstantDecision {\n ALWAYS_OFF = 0,\n ALWAYS_ON = 1,\n ALWAYS_PARENT = 2,\n }\n }\n export namespace Span {\n export interface Event {\n timeUnixNano: number;\n name: string;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n export interface Link {\n traceId: string;\n spanId: string;\n traceState?: opentelemetryProto.trace.v1.Span.TraceState;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-shadow\n export enum SpanKind {\n SPAN_KIND_UNSPECIFIED,\n SPAN_KIND_INTERNAL,\n SPAN_KIND_SERVER,\n SPAN_KIND_CLIENT,\n SPAN_KIND_PRODUCER,\n SPAN_KIND_CONSUMER,\n }\n\n export type TraceState = string | undefined;\n }\n\n export interface ConstantSampler {\n decision?: opentelemetryProto.trace.v1.ConstantSampler.ConstantDecision;\n }\n\n export interface InstrumentationLibrarySpans {\n instrumentationLibrary?: opentelemetryProto.common.v1.InstrumentationLibrary;\n spans: opentelemetryProto.trace.v1.Span[];\n }\n\n export interface ProbabilitySampler {\n samplingProbability?: number | null;\n }\n\n export interface RateLimitingSampler {\n qps?: number | null;\n }\n\n export interface ResourceSpans {\n resource?: opentelemetryProto.resource.v1.Resource;\n instrumentationLibrarySpans: opentelemetryProto.trace.v1.InstrumentationLibrarySpans[];\n }\n\n export interface Span {\n traceId: string;\n spanId: string;\n traceState: opentelemetryProto.trace.v1.Span.TraceState;\n parentSpanId?: string;\n name?: string;\n kind?: opentelemetryProto.trace.v1.Span.SpanKind;\n startTimeUnixNano?: number;\n endTimeUnixNano?: number;\n attributes?: opentelemetryProto.common.v1.KeyValue[];\n droppedAttributesCount: number;\n events?: opentelemetryProto.trace.v1.Span.Event[];\n droppedEventsCount: number;\n links?: opentelemetryProto.trace.v1.Span.Link[];\n droppedLinksCount: number;\n status?: SpanStatus;\n }\n\n export interface SpanStatus {\n /** The status code of this message. */\n code: SpanStatusCode;\n /** A developer-facing error message. */\n message?: string;\n }\n\n export interface TraceConfig {\n constantSampler?: ConstantSampler | null;\n probabilitySampler?: ProbabilitySampler | null;\n rateLimitingSampler?: RateLimitingSampler | null;\n }\n }\n export namespace common.v1 {\n export interface KeyValue {\n key: string;\n value: AnyValue;\n }\n\n export type ArrayValue = {\n values: AnyValue[];\n };\n\n export interface KeyValueList {\n values: KeyValue[];\n }\n\n export type AnyValue = {\n stringValue?: string;\n boolValue?: boolean;\n intValue?: number;\n doubleValue?: number;\n arrayValue?: ArrayValue;\n kvlistValue?: KeyValueList;\n };\n\n export interface InstrumentationLibrary {\n name: string;\n version?: string;\n }\n\n export interface StringKeyValue {\n key: string;\n value: string;\n }\n\n export enum ValueType {\n STRING,\n INT,\n DOUBLE,\n BOOL,\n }\n }\n}\n\n/**\n * Interface for handling error\n */\nexport class OTLPExporterError extends Error {\n readonly code?: number;\n override readonly name: string = 'OTLPExporterError';\n readonly data?: string;\n\n constructor(message?: string, code?: number, data?: string) {\n super(message);\n this.data = data;\n this.code = code;\n }\n}\n\n/**\n * Interface for handling export service errors\n */\nexport interface ExportServiceError {\n name: string;\n code: number;\n details: string;\n metadata: { [key: string]: unknown };\n message: string;\n stack: string;\n}\n\n/**\n * Collector Exporter base config\n */\nexport interface OTLPExporterConfigBase {\n headers?: Partial<Record<string, unknown>>;\n hostname?: string;\n attributes?: SpanAttributes;\n url?: string;\n concurrencyLimit?: number;\n}\n\n/**\n * Mapping between api SpanKind and proto SpanKind\n */\nexport const OTLP_SPAN_KIND_MAPPING = {\n [SpanKind.INTERNAL]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_INTERNAL,\n [SpanKind.SERVER]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_SERVER,\n [SpanKind.CLIENT]: opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CLIENT,\n [SpanKind.PRODUCER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_PRODUCER,\n [SpanKind.CONSUMER]:\n opentelemetryProto.trace.v1.Span.SpanKind.SPAN_KIND_CONSUMER,\n};\n"]}
|
package/build/esm/util.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses headers from config leaving only those that have defined values
|
|
3
|
-
* @param partialHeaders
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseHeaders(partialHeaders?: Partial<Record<string, unknown>>): Record<string, string>;
|
|
6
|
-
export declare function appendResourcePathToUrlIfNotPresent(url: string, path: string): string;
|
|
7
|
-
//# sourceMappingURL=util.d.ts.map
|
package/build/esm/util.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright The OpenTelemetry Authors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import { diag } from '@opentelemetry/api';
|
|
17
|
-
/**
|
|
18
|
-
* Parses headers from config leaving only those that have defined values
|
|
19
|
-
* @param partialHeaders
|
|
20
|
-
*/
|
|
21
|
-
export function parseHeaders(partialHeaders) {
|
|
22
|
-
if (partialHeaders === void 0) { partialHeaders = {}; }
|
|
23
|
-
var headers = {};
|
|
24
|
-
Object.entries(partialHeaders).forEach(function (_a) {
|
|
25
|
-
var key = _a[0], value = _a[1];
|
|
26
|
-
if (typeof value !== 'undefined') {
|
|
27
|
-
headers[key] = String(value);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
diag.warn("Header \"" + key + "\" has wrong value and will be ignored");
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return headers;
|
|
34
|
-
}
|
|
35
|
-
export function appendResourcePathToUrlIfNotPresent(url, path) {
|
|
36
|
-
if (url.match(/v\d\/(traces|metrics)$/))
|
|
37
|
-
return url;
|
|
38
|
-
return url + path;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=util.js.map
|
package/build/esm/util.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,YAAY,CAC1B,cAAqD;IAArD,+BAAA,EAAA,mBAAqD;IAErD,IAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;YAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QACjD,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;SAC9B;aAAM;YACL,IAAI,CAAC,IAAI,CAAC,cAAW,GAAG,2CAAuC,CAAC,CAAC;SAClE;IACH,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,mCAAmC,CAAC,GAAW,EAAE,IAAY;IAC3E,IAAI,GAAG,CAAC,KAAK,CAAC,wBAAwB,CAAC;QAAE,OAAO,GAAG,CAAC;IAEpD,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,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\nimport { diag } from '@opentelemetry/api';\n\n/**\n * Parses headers from config leaving only those that have defined values\n * @param partialHeaders\n */\nexport function parseHeaders(\n partialHeaders: Partial<Record<string, unknown>> = {}\n): Record<string, string> {\n const headers: Record<string, string> = {};\n Object.entries(partialHeaders).forEach(([key, value]) => {\n if (typeof value !== 'undefined') {\n headers[key] = String(value);\n } else {\n diag.warn(`Header \"${key}\" has wrong value and will be ignored`);\n }\n });\n return headers;\n}\n\nexport function appendResourcePathToUrlIfNotPresent(url: string, path: string): string {\n if (url.match(/v\\d\\/(traces|metrics)$/)) return url;\n\n return url + path;\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SpanAttributes } from '@opentelemetry/api';
|
|
2
|
-
import { ExportResult } from '@opentelemetry/core';
|
|
3
|
-
import { OTLPExporterError, OTLPExporterConfigBase } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* Collector Exporter abstract base class
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class OTLPExporterBase<T extends OTLPExporterConfigBase, ExportItem, ServiceRequest> {
|
|
8
|
-
readonly url: string;
|
|
9
|
-
readonly hostname: string | undefined;
|
|
10
|
-
readonly attributes?: SpanAttributes;
|
|
11
|
-
protected _concurrencyLimit: number;
|
|
12
|
-
protected _isShutdown: boolean;
|
|
13
|
-
private _shuttingDownPromise;
|
|
14
|
-
protected _sendingPromises: Promise<unknown>[];
|
|
15
|
-
/**
|
|
16
|
-
* @param config
|
|
17
|
-
*/
|
|
18
|
-
constructor(config?: T);
|
|
19
|
-
/**
|
|
20
|
-
* Export items.
|
|
21
|
-
* @param items
|
|
22
|
-
* @param resultCallback
|
|
23
|
-
*/
|
|
24
|
-
export(items: ExportItem[], resultCallback: (result: ExportResult) => void): void;
|
|
25
|
-
private _export;
|
|
26
|
-
/**
|
|
27
|
-
* Shutdown the exporter.
|
|
28
|
-
*/
|
|
29
|
-
shutdown(): Promise<void>;
|
|
30
|
-
abstract onShutdown(): void;
|
|
31
|
-
abstract onInit(config: T): void;
|
|
32
|
-
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
33
|
-
abstract getDefaultUrl(config: T): string;
|
|
34
|
-
abstract convert(objects: ExportItem[]): ServiceRequest;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=OTLPExporterBase.d.ts.map
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.OTLPExporterBase = void 0;
|
|
19
|
-
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const core_1 = require("@opentelemetry/core");
|
|
21
|
-
/**
|
|
22
|
-
* Collector Exporter abstract base class
|
|
23
|
-
*/
|
|
24
|
-
class OTLPExporterBase {
|
|
25
|
-
/**
|
|
26
|
-
* @param config
|
|
27
|
-
*/
|
|
28
|
-
constructor(config = {}) {
|
|
29
|
-
this._isShutdown = false;
|
|
30
|
-
this._shuttingDownPromise = Promise.resolve();
|
|
31
|
-
this._sendingPromises = [];
|
|
32
|
-
this.url = this.getDefaultUrl(config);
|
|
33
|
-
if (typeof config.hostname === 'string') {
|
|
34
|
-
this.hostname = config.hostname;
|
|
35
|
-
}
|
|
36
|
-
this.attributes = config.attributes;
|
|
37
|
-
this.shutdown = this.shutdown.bind(this);
|
|
38
|
-
this._concurrencyLimit =
|
|
39
|
-
typeof config.concurrencyLimit === 'number'
|
|
40
|
-
? config.concurrencyLimit
|
|
41
|
-
: Infinity;
|
|
42
|
-
// platform dependent
|
|
43
|
-
this.onInit(config);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Export items.
|
|
47
|
-
* @param items
|
|
48
|
-
* @param resultCallback
|
|
49
|
-
*/
|
|
50
|
-
export(items, resultCallback) {
|
|
51
|
-
if (this._isShutdown) {
|
|
52
|
-
resultCallback({
|
|
53
|
-
code: core_1.ExportResultCode.FAILED,
|
|
54
|
-
error: new Error('Exporter has been shutdown'),
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (this._sendingPromises.length >= this._concurrencyLimit) {
|
|
59
|
-
resultCallback({
|
|
60
|
-
code: core_1.ExportResultCode.FAILED,
|
|
61
|
-
error: new Error('Concurrent export limit reached'),
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this._export(items)
|
|
66
|
-
.then(() => {
|
|
67
|
-
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
68
|
-
})
|
|
69
|
-
.catch((error) => {
|
|
70
|
-
resultCallback({ code: core_1.ExportResultCode.FAILED, error });
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
_export(items) {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
try {
|
|
76
|
-
api_1.diag.debug('items to be sent', items);
|
|
77
|
-
this.send(items, resolve, reject);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
reject(e);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Shutdown the exporter.
|
|
86
|
-
*/
|
|
87
|
-
shutdown() {
|
|
88
|
-
if (this._isShutdown) {
|
|
89
|
-
api_1.diag.debug('shutdown already started');
|
|
90
|
-
return this._shuttingDownPromise;
|
|
91
|
-
}
|
|
92
|
-
this._isShutdown = true;
|
|
93
|
-
api_1.diag.debug('shutdown started');
|
|
94
|
-
this._shuttingDownPromise = new Promise((resolve, reject) => {
|
|
95
|
-
Promise.resolve()
|
|
96
|
-
.then(() => {
|
|
97
|
-
return this.onShutdown();
|
|
98
|
-
})
|
|
99
|
-
.then(() => {
|
|
100
|
-
return Promise.all(this._sendingPromises);
|
|
101
|
-
})
|
|
102
|
-
.then(() => {
|
|
103
|
-
resolve();
|
|
104
|
-
})
|
|
105
|
-
.catch(e => {
|
|
106
|
-
reject(e);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
return this._shuttingDownPromise;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.OTLPExporterBase = OTLPExporterBase;
|
|
113
|
-
//# sourceMappingURL=OTLPExporterBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBase.js","sourceRoot":"","sources":["../../src/OTLPExporterBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0D;AAC1D,8CAAqE;AAOrE;;GAEG;AACH,MAAsB,gBA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C;YACZ,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE;gBACT,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACnC,CAAC;CAWF;AAlHD,4CAkHC","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 { SpanAttributes, diag } from '@opentelemetry/api';\nimport { ExportResult, ExportResultCode } from '@opentelemetry/core';\nimport {\n OTLPExporterError,\n OTLPExporterConfigBase,\n ExportServiceError,\n} from './types';\n\n/**\n * Collector Exporter abstract base class\n */\nexport abstract class OTLPExporterBase<\n T extends OTLPExporterConfigBase,\n ExportItem,\n ServiceRequest\n> {\n public readonly url: string;\n public readonly hostname: string | undefined;\n public readonly attributes?: SpanAttributes;\n protected _concurrencyLimit: number;\n protected _isShutdown: boolean = false;\n private _shuttingDownPromise: Promise<void> = Promise.resolve();\n protected _sendingPromises: Promise<unknown>[] = [];\n\n /**\n * @param config\n */\n constructor(config: T = {} as T) {\n this.url = this.getDefaultUrl(config);\n if (typeof config.hostname === 'string') {\n this.hostname = config.hostname;\n }\n\n this.attributes = config.attributes;\n\n this.shutdown = this.shutdown.bind(this);\n\n this._concurrencyLimit =\n typeof config.concurrencyLimit === 'number'\n ? config.concurrencyLimit\n : Infinity;\n\n // platform dependent\n this.onInit(config);\n }\n\n /**\n * Export items.\n * @param items\n * @param resultCallback\n */\n export(items: ExportItem[], resultCallback: (result: ExportResult) => void): void {\n if (this._isShutdown) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Exporter has been shutdown'),\n });\n return;\n }\n\n if (this._sendingPromises.length >= this._concurrencyLimit) {\n resultCallback({\n code: ExportResultCode.FAILED,\n error: new Error('Concurrent export limit reached'),\n });\n return;\n }\n\n this._export(items)\n .then(() => {\n resultCallback({ code: ExportResultCode.SUCCESS });\n })\n .catch((error: ExportServiceError) => {\n resultCallback({ code: ExportResultCode.FAILED, error });\n });\n }\n\n private _export(items: ExportItem[]): Promise<unknown> {\n return new Promise<void>((resolve, reject) => {\n try {\n diag.debug('items to be sent', items);\n this.send(items, resolve, reject);\n } catch (e) {\n reject(e);\n }\n });\n }\n\n /**\n * Shutdown the exporter.\n */\n shutdown(): Promise<void> {\n if (this._isShutdown) {\n diag.debug('shutdown already started');\n return this._shuttingDownPromise;\n }\n this._isShutdown = true;\n diag.debug('shutdown started');\n this._shuttingDownPromise = new Promise((resolve, reject) => {\n Promise.resolve()\n .then(() => {\n return this.onShutdown();\n })\n .then(() => {\n return Promise.all(this._sendingPromises);\n })\n .then(() => {\n resolve();\n })\n .catch(e => {\n reject(e);\n });\n });\n return this._shuttingDownPromise;\n }\n\n abstract onShutdown(): void;\n abstract onInit(config: T): void;\n abstract send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void;\n abstract getDefaultUrl(config: T): string;\n abstract convert(objects: ExportItem[]): ServiceRequest;\n}\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { OTLPExporterBase } from '../../OTLPExporterBase';
|
|
2
|
-
import { OTLPExporterConfigBase } from '../../types';
|
|
3
|
-
import * as otlpTypes from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* Collector Metric Exporter abstract base class
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class OTLPExporterBrowserBase<ExportItem, ServiceRequest> extends OTLPExporterBase<OTLPExporterConfigBase, ExportItem, ServiceRequest> {
|
|
8
|
-
protected _headers: Record<string, string>;
|
|
9
|
-
private _useXHR;
|
|
10
|
-
/**
|
|
11
|
-
* @param config
|
|
12
|
-
*/
|
|
13
|
-
constructor(config?: OTLPExporterConfigBase);
|
|
14
|
-
onInit(): void;
|
|
15
|
-
onShutdown(): void;
|
|
16
|
-
send(items: ExportItem[], onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=OTLPExporterBrowserBase.d.ts.map
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.OTLPExporterBrowserBase = void 0;
|
|
19
|
-
const OTLPExporterBase_1 = require("../../OTLPExporterBase");
|
|
20
|
-
const util_1 = require("../../util");
|
|
21
|
-
const util_2 = require("./util");
|
|
22
|
-
const api_1 = require("@opentelemetry/api");
|
|
23
|
-
const core_1 = require("@opentelemetry/core");
|
|
24
|
-
/**
|
|
25
|
-
* Collector Metric Exporter abstract base class
|
|
26
|
-
*/
|
|
27
|
-
class OTLPExporterBrowserBase extends OTLPExporterBase_1.OTLPExporterBase {
|
|
28
|
-
/**
|
|
29
|
-
* @param config
|
|
30
|
-
*/
|
|
31
|
-
constructor(config = {}) {
|
|
32
|
-
super(config);
|
|
33
|
-
this._useXHR = false;
|
|
34
|
-
this._useXHR =
|
|
35
|
-
!!config.headers || typeof navigator.sendBeacon !== 'function';
|
|
36
|
-
if (this._useXHR) {
|
|
37
|
-
this._headers = Object.assign({}, util_1.parseHeaders(config.headers), core_1.baggageUtils.parseKeyPairsIntoRecord(core_1.getEnv().OTEL_EXPORTER_OTLP_HEADERS));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this._headers = {};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
onInit() {
|
|
44
|
-
window.addEventListener('unload', this.shutdown);
|
|
45
|
-
}
|
|
46
|
-
onShutdown() {
|
|
47
|
-
window.removeEventListener('unload', this.shutdown);
|
|
48
|
-
}
|
|
49
|
-
send(items, onSuccess, onError) {
|
|
50
|
-
if (this._isShutdown) {
|
|
51
|
-
api_1.diag.debug('Shutdown already started. Cannot send objects');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const serviceRequest = this.convert(items);
|
|
55
|
-
const body = JSON.stringify(serviceRequest);
|
|
56
|
-
const promise = new Promise((resolve, reject) => {
|
|
57
|
-
if (this._useXHR) {
|
|
58
|
-
util_2.sendWithXhr(body, this.url, this._headers, resolve, reject);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
util_2.sendWithBeacon(body, this.url, { type: 'application/json' }, resolve, reject);
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
.then(onSuccess, onError);
|
|
65
|
-
this._sendingPromises.push(promise);
|
|
66
|
-
const popPromise = () => {
|
|
67
|
-
const index = this._sendingPromises.indexOf(promise);
|
|
68
|
-
this._sendingPromises.splice(index, 1);
|
|
69
|
-
};
|
|
70
|
-
promise.then(popPromise, popPromise);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.OTLPExporterBrowserBase = OTLPExporterBrowserBase;
|
|
74
|
-
//# sourceMappingURL=OTLPExporterBrowserBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPExporterBrowserBase.js","sourceRoot":"","sources":["../../../../src/platform/browser/OTLPExporterBrowserBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6DAA0D;AAG1D,qCAA0C;AAC1C,iCAAqD;AACrD,4CAA0C;AAC1C,8CAA2D;AAE3D;;GAEG;AACH,MAAsB,uBAGlB,SAAQ,mCAIT;IAID;;OAEG;IACH,YAAY,SAAiC,EAAE;QAC7C,KAAK,CAAC,MAAM,CAAC,CAAC;QANR,YAAO,GAAY,KAAK,CAAC;QAO/B,IAAI,CAAC,OAAO;YACV,CAAC,CAAC,MAAM,CAAC,OAAO,IAAI,OAAO,SAAS,CAAC,UAAU,KAAK,UAAU,CAAC;QACjE,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM,CAC3B,EAAE,EACF,mBAAY,CAAC,MAAM,CAAC,OAAO,CAAC,EAC5B,mBAAY,CAAC,uBAAuB,CAClC,aAAM,EAAE,CAAC,0BAA0B,CACpC,CACF,CAAC;SACH;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;SACpB;IACH,CAAC;IAED,MAAM;QACJ,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED,UAAU;QACR,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CACF,KAAmB,EACnB,SAAqB,EACrB,OAAqD;QAErD,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,UAAI,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAC5D,OAAO;SACR;QACD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAE5C,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpD,IAAI,IAAI,CAAC,OAAO,EAAE;gBAChB,kBAAW,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aAC7D;iBAAM;gBACL,qBAAc,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;aAC/E;QACH,CAAC,CAAC;aACC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAE5B,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACrD,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AAnED,0DAmEC","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 { OTLPExporterBase } from '../../OTLPExporterBase';\nimport { OTLPExporterConfigBase } from '../../types';\nimport * as otlpTypes from '../../types';\nimport { parseHeaders } from '../../util';\nimport { sendWithBeacon, sendWithXhr } from './util';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\n\n/**\n * Collector Metric Exporter abstract base class\n */\nexport abstract class OTLPExporterBrowserBase<\n ExportItem,\n ServiceRequest\n > extends OTLPExporterBase<\n OTLPExporterConfigBase,\n ExportItem,\n ServiceRequest\n > {\n protected _headers: Record<string, string>;\n private _useXHR: boolean = false;\n\n /**\n * @param config\n */\n constructor(config: OTLPExporterConfigBase = {}) {\n super(config);\n this._useXHR =\n !!config.headers || typeof navigator.sendBeacon !== 'function';\n if (this._useXHR) {\n this._headers = Object.assign(\n {},\n parseHeaders(config.headers),\n baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n )\n );\n } else {\n this._headers = {};\n }\n }\n\n onInit(): void {\n window.addEventListener('unload', this.shutdown);\n }\n\n onShutdown(): void {\n window.removeEventListener('unload', this.shutdown);\n }\n\n send(\n items: ExportItem[],\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n ): void {\n if (this._isShutdown) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n const serviceRequest = this.convert(items);\n const body = JSON.stringify(serviceRequest);\n\n const promise = new Promise<void>((resolve, reject) => {\n if (this._useXHR) {\n sendWithXhr(body, this.url, this._headers, resolve, reject);\n } else {\n sendWithBeacon(body, this.url, { type: 'application/json' }, resolve, reject);\n }\n })\n .then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n }\n promise.then(popPromise, popPromise);\n }\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as otlpTypes from '../../types';
|
|
2
|
-
/**
|
|
3
|
-
* Send metrics/spans using browser navigator.sendBeacon
|
|
4
|
-
* @param body
|
|
5
|
-
* @param onSuccess
|
|
6
|
-
* @param onError
|
|
7
|
-
*/
|
|
8
|
-
export declare function sendWithBeacon(body: string, url: string, blobPropertyBag: BlobPropertyBag, onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
9
|
-
/**
|
|
10
|
-
* function to send metrics/spans using browser XMLHttpRequest
|
|
11
|
-
* used when navigator.sendBeacon is not available
|
|
12
|
-
* @param body
|
|
13
|
-
* @param onSuccess
|
|
14
|
-
* @param onError
|
|
15
|
-
*/
|
|
16
|
-
export declare function sendWithXhr(body: string, url: string, headers: Record<string, string>, onSuccess: () => void, onError: (error: otlpTypes.OTLPExporterError) => void): void;
|
|
17
|
-
//# sourceMappingURL=util.d.ts.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendWithXhr = exports.sendWithBeacon = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright The OpenTelemetry Authors
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const otlpTypes = require("../../types");
|
|
21
|
-
/**
|
|
22
|
-
* Send metrics/spans using browser navigator.sendBeacon
|
|
23
|
-
* @param body
|
|
24
|
-
* @param onSuccess
|
|
25
|
-
* @param onError
|
|
26
|
-
*/
|
|
27
|
-
function sendWithBeacon(body, url, blobPropertyBag, onSuccess, onError) {
|
|
28
|
-
if (navigator.sendBeacon(url, new Blob([body], blobPropertyBag))) {
|
|
29
|
-
api_1.diag.debug('sendBeacon - can send', body);
|
|
30
|
-
onSuccess();
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const error = new otlpTypes.OTLPExporterError(`sendBeacon - cannot send ${body}`);
|
|
34
|
-
onError(error);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.sendWithBeacon = sendWithBeacon;
|
|
38
|
-
/**
|
|
39
|
-
* function to send metrics/spans using browser XMLHttpRequest
|
|
40
|
-
* used when navigator.sendBeacon is not available
|
|
41
|
-
* @param body
|
|
42
|
-
* @param onSuccess
|
|
43
|
-
* @param onError
|
|
44
|
-
*/
|
|
45
|
-
function sendWithXhr(body, url, headers, onSuccess, onError) {
|
|
46
|
-
const xhr = new XMLHttpRequest();
|
|
47
|
-
xhr.open('POST', url);
|
|
48
|
-
const defaultHeaders = {
|
|
49
|
-
'Accept': 'application/json',
|
|
50
|
-
'Content-Type': 'application/json',
|
|
51
|
-
};
|
|
52
|
-
Object.entries(Object.assign(Object.assign({}, defaultHeaders), headers)).forEach(([k, v]) => {
|
|
53
|
-
xhr.setRequestHeader(k, v);
|
|
54
|
-
});
|
|
55
|
-
xhr.send(body);
|
|
56
|
-
xhr.onreadystatechange = () => {
|
|
57
|
-
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
58
|
-
if (xhr.status >= 200 && xhr.status <= 299) {
|
|
59
|
-
api_1.diag.debug('xhr success', body);
|
|
60
|
-
onSuccess();
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const error = new otlpTypes.OTLPExporterError(`Failed to export with XHR (status: ${xhr.status})`, xhr.status);
|
|
64
|
-
onError(error);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
exports.sendWithXhr = sendWithXhr;
|
|
70
|
-
//# sourceMappingURL=util.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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Ac,CAAC,IAAI,EAAE;YAC1C,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE;gBAC1C,UAAI,CAAC,KAAK,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;gBAChC,SAAS,EAAE,CAAC;aACb;iBAAM;gBACL,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,iBAAiB,CAC3C,sCAAsC,GAAG,CAAC,MAAM,GAAG,EACnD,GAAG,CAAC,MAAM,CACX,CAAC;gBAEF,OAAO,CAAC,KAAK,CAAC,CAAC;aAChB;SACF;IACH,CAAC,CAAC;AACJ,CAAC;AAvCD,kCAuCC","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 */\nimport { diag } from '@opentelemetry/api';\nimport * as otlpTypes from '../../types';\n\n/**\n * Send metrics/spans using browser navigator.sendBeacon\n * @param body\n * @param onSuccess\n * @param onError\n */\nexport function sendWithBeacon(\n body: string,\n url: string,\n blobPropertyBag: BlobPropertyBag,\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n): void {\n if (navigator.sendBeacon(url, new Blob([body], blobPropertyBag))) {\n diag.debug('sendBeacon - can send', body);\n onSuccess();\n } else {\n const error = new otlpTypes.OTLPExporterError(\n `sendBeacon - cannot send ${body}`\n );\n onError(error);\n }\n}\n\n/**\n * function to send metrics/spans using browser XMLHttpRequest\n * used when navigator.sendBeacon is not available\n * @param body\n * @param onSuccess\n * @param onError\n */\nexport function sendWithXhr(\n body: string,\n url: string,\n headers: Record<string, string>,\n onSuccess: () => void,\n onError: (error: otlpTypes.OTLPExporterError) => void\n): void {\n const xhr = new XMLHttpRequest();\n xhr.open('POST', url);\n\n const defaultHeaders = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n };\n\n Object.entries({\n ...defaultHeaders,\n ...headers,\n }).forEach(([k, v]) => {\n xhr.setRequestHeader(k, v);\n });\n\n xhr.send(body);\n\n xhr.onreadystatechange = () => {\n if (xhr.readyState === XMLHttpRequest.DONE) {\n if (xhr.status >= 200 && xhr.status <= 299) {\n diag.debug('xhr success', body);\n onSuccess();\n } else {\n const error = new otlpTypes.OTLPExporterError(\n `Failed to export with XHR (status: ${xhr.status})`,\n xhr.status\n );\n\n onError(error);\n }\n }\n };\n}\n"]}
|