@opentelemetry/otlp-exporter-base 0.28.0 → 0.29.0
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/build/esm/OTLPExporterBase.d.ts +40 -0
- package/build/esm/OTLPExporterBase.js +104 -0
- package/build/esm/OTLPExporterBase.js.map +1 -0
- package/build/esm/index.d.ts +5 -0
- package/build/esm/index.js +20 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.d.ts +18 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js +91 -0
- package/build/esm/platform/browser/OTLPExporterBrowserBase.js.map +1 -0
- package/build/esm/platform/browser/index.d.ts +2 -0
- package/build/esm/platform/browser/index.js +17 -0
- package/build/esm/platform/browser/index.js.map +1 -0
- package/build/esm/platform/browser/util.d.ts +21 -0
- package/build/esm/platform/browser/util.js +108 -0
- package/build/esm/platform/browser/util.js.map +1 -0
- package/build/esm/platform/index.d.ts +3 -0
- package/build/esm/platform/index.js +18 -0
- package/build/esm/platform/index.js.map +1 -0
- package/build/esm/platform/node/OTLPExporterNodeBase.d.ts +20 -0
- package/build/esm/platform/node/OTLPExporterNodeBase.js +79 -0
- package/build/esm/platform/node/OTLPExporterNodeBase.js.map +1 -0
- package/build/esm/platform/node/index.d.ts +4 -0
- package/build/esm/platform/node/index.js +19 -0
- package/build/esm/platform/node/index.js.map +1 -0
- package/build/esm/platform/node/types.d.ts +17 -0
- package/build/esm/platform/node/types.js +6 -0
- package/build/esm/platform/node/types.js.map +1 -0
- package/build/esm/platform/node/util.d.ts +19 -0
- package/build/esm/platform/node/util.js +151 -0
- package/build/esm/platform/node/util.js.map +1 -0
- package/build/esm/types.d.ts +37 -0
- package/build/esm/types.js +46 -0
- package/build/esm/types.js.map +1 -0
- package/build/esm/util.d.ts +27 -0
- package/build/esm/util.js +110 -0
- package/build/esm/util.js.map +1 -0
- package/build/esm/version.d.ts +2 -0
- package/build/esm/version.js +18 -0
- package/build/esm/version.js.map +1 -0
- package/build/esnext/OTLPExporterBase.d.ts +40 -0
- package/build/esnext/OTLPExporterBase.js +100 -0
- package/build/esnext/OTLPExporterBase.js.map +1 -0
- package/build/esnext/index.d.ts +5 -0
- package/build/esnext/index.js +20 -0
- package/build/esnext/index.js.map +1 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.d.ts +18 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.js +70 -0
- package/build/esnext/platform/browser/OTLPExporterBrowserBase.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/browser/util.d.ts +21 -0
- package/build/esnext/platform/browser/util.js +80 -0
- package/build/esnext/platform/browser/util.js.map +1 -0
- package/build/esnext/platform/index.d.ts +3 -0
- package/build/esnext/platform/index.js +18 -0
- package/build/esnext/platform/index.js.map +1 -0
- package/build/esnext/platform/node/OTLPExporterNodeBase.d.ts +20 -0
- package/build/esnext/platform/node/OTLPExporterNodeBase.js +58 -0
- package/build/esnext/platform/node/OTLPExporterNodeBase.js.map +1 -0
- package/build/esnext/platform/node/index.d.ts +4 -0
- package/build/esnext/platform/node/index.js +19 -0
- package/build/esnext/platform/node/index.js.map +1 -0
- package/build/esnext/platform/node/types.d.ts +17 -0
- package/build/esnext/platform/node/types.js +6 -0
- package/build/esnext/platform/node/types.js.map +1 -0
- package/build/esnext/platform/node/util.d.ts +19 -0
- package/build/esnext/platform/node/util.js +140 -0
- package/build/esnext/platform/node/util.js.map +1 -0
- package/build/esnext/types.d.ts +37 -0
- package/build/esnext/types.js +27 -0
- package/build/esnext/types.js.map +1 -0
- package/build/esnext/util.d.ts +27 -0
- package/build/esnext/util.js +92 -0
- package/build/esnext/util.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/OTLPExporterBase.d.ts +1 -0
- package/build/src/OTLPExporterBase.js +2 -0
- package/build/src/OTLPExporterBase.js.map +1 -1
- package/build/src/platform/browser/OTLPExporterBrowserBase.js +1 -1
- package/build/src/platform/browser/OTLPExporterBrowserBase.js.map +1 -1
- package/build/src/platform/browser/util.d.ts +1 -1
- package/build/src/platform/browser/util.js +12 -1
- package/build/src/platform/browser/util.js.map +1 -1
- package/build/src/platform/node/util.js +37 -8
- package/build/src/platform/node/util.js.map +1 -1
- package/build/src/types.d.ts +3 -0
- package/build/src/types.js.map +1 -1
- package/build/src/util.d.ts +21 -1
- package/build/src/util.js +62 -5
- package/build/src/util.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 +10 -4
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
export * from './OTLPExporterNodeBase';
|
|
17
|
+
export * from './util';
|
|
18
|
+
export * from './types';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/platform/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,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\nexport * from './OTLPExporterNodeBase';\nexport * from './util';\nexport * from './types';\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type * as http from 'http';
|
|
3
|
+
import type * as https from 'https';
|
|
4
|
+
import { OTLPExporterConfigBase } from '../../types';
|
|
5
|
+
/**
|
|
6
|
+
* Collector Exporter node base config
|
|
7
|
+
*/
|
|
8
|
+
export interface OTLPExporterNodeConfigBase extends OTLPExporterConfigBase {
|
|
9
|
+
keepAlive?: boolean;
|
|
10
|
+
compression?: CompressionAlgorithm;
|
|
11
|
+
httpAgentOptions?: http.AgentOptions | https.AgentOptions;
|
|
12
|
+
}
|
|
13
|
+
export declare enum CompressionAlgorithm {
|
|
14
|
+
NONE = "none",
|
|
15
|
+
GZIP = "gzip"
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/platform/node/types.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,qCAAa,CAAA;IACb,qCAAa,CAAA;AACf,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","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 type * as http from 'http';\nimport type * as https from 'https';\n\nimport { OTLPExporterConfigBase } from '../../types';\n\n/**\n * Collector Exporter node base config\n */\nexport interface OTLPExporterNodeConfigBase\n extends OTLPExporterConfigBase {\n keepAlive?: boolean;\n compression?: CompressionAlgorithm;\n httpAgentOptions?: http.AgentOptions | https.AgentOptions;\n}\n\nexport enum CompressionAlgorithm {\n NONE = 'none',\n GZIP = 'gzip'\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as http from 'http';
|
|
3
|
+
import * as https from 'https';
|
|
4
|
+
import { OTLPExporterNodeBase } from './OTLPExporterNodeBase';
|
|
5
|
+
import { OTLPExporterNodeConfigBase } from '.';
|
|
6
|
+
import { CompressionAlgorithm } from './types';
|
|
7
|
+
import { OTLPExporterError } from '../../types';
|
|
8
|
+
/**
|
|
9
|
+
* Sends data using http
|
|
10
|
+
* @param collector
|
|
11
|
+
* @param data
|
|
12
|
+
* @param contentType
|
|
13
|
+
* @param onSuccess
|
|
14
|
+
* @param onError
|
|
15
|
+
*/
|
|
16
|
+
export declare function sendWithHttp<ExportItem, ServiceRequest>(collector: OTLPExporterNodeBase<ExportItem, ServiceRequest>, data: string | Buffer, contentType: string, onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
17
|
+
export declare function createHttpAgent(config: OTLPExporterNodeConfigBase): http.Agent | https.Agent | undefined;
|
|
18
|
+
export declare function configureCompression(compression: CompressionAlgorithm | undefined): CompressionAlgorithm;
|
|
19
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
/*
|
|
13
|
+
* Copyright The OpenTelemetry Authors
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
import * as url from 'url';
|
|
28
|
+
import * as http from 'http';
|
|
29
|
+
import * as https from 'https';
|
|
30
|
+
import * as zlib from 'zlib';
|
|
31
|
+
import { Readable } from 'stream';
|
|
32
|
+
import { diag } from '@opentelemetry/api';
|
|
33
|
+
import { CompressionAlgorithm } from './types';
|
|
34
|
+
import { getEnv } from '@opentelemetry/core';
|
|
35
|
+
import { OTLPExporterError } from '../../types';
|
|
36
|
+
var gzip;
|
|
37
|
+
/**
|
|
38
|
+
* Sends data using http
|
|
39
|
+
* @param collector
|
|
40
|
+
* @param data
|
|
41
|
+
* @param contentType
|
|
42
|
+
* @param onSuccess
|
|
43
|
+
* @param onError
|
|
44
|
+
*/
|
|
45
|
+
export function sendWithHttp(collector, data, contentType, onSuccess, onError) {
|
|
46
|
+
var exporterTimeout = collector.timeoutMillis;
|
|
47
|
+
var parsedUrl = new url.URL(collector.url);
|
|
48
|
+
var reqIsDestroyed;
|
|
49
|
+
var nodeVersion = Number(process.versions.node.split('.')[0]);
|
|
50
|
+
var exporterTimer = setTimeout(function () {
|
|
51
|
+
reqIsDestroyed = true;
|
|
52
|
+
// req.abort() was deprecated since v14
|
|
53
|
+
if (nodeVersion >= 14) {
|
|
54
|
+
req.destroy();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
req.abort();
|
|
58
|
+
}
|
|
59
|
+
}, exporterTimeout);
|
|
60
|
+
var options = {
|
|
61
|
+
hostname: parsedUrl.hostname,
|
|
62
|
+
port: parsedUrl.port,
|
|
63
|
+
path: parsedUrl.pathname,
|
|
64
|
+
method: 'POST',
|
|
65
|
+
headers: __assign({ 'Content-Type': contentType }, collector.headers),
|
|
66
|
+
agent: collector.agent,
|
|
67
|
+
};
|
|
68
|
+
var request = parsedUrl.protocol === 'http:' ? http.request : https.request;
|
|
69
|
+
var req = request(options, function (res) {
|
|
70
|
+
var responseData = '';
|
|
71
|
+
res.on('data', function (chunk) { return (responseData += chunk); });
|
|
72
|
+
res.on('aborted', function () {
|
|
73
|
+
if (reqIsDestroyed) {
|
|
74
|
+
var err = new OTLPExporterError('Request Timeout');
|
|
75
|
+
onError(err);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
res.on('end', function () {
|
|
79
|
+
if (!reqIsDestroyed) {
|
|
80
|
+
if (res.statusCode && res.statusCode < 299) {
|
|
81
|
+
diag.debug("statusCode: " + res.statusCode, responseData);
|
|
82
|
+
onSuccess();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
var error = new OTLPExporterError(res.statusMessage, res.statusCode, responseData);
|
|
86
|
+
onError(error);
|
|
87
|
+
}
|
|
88
|
+
clearTimeout(exporterTimer);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
req.on('error', function (error) {
|
|
93
|
+
if (reqIsDestroyed) {
|
|
94
|
+
var err = new OTLPExporterError('Request Timeout', error.code);
|
|
95
|
+
onError(err);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
clearTimeout(exporterTimer);
|
|
99
|
+
onError(error);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
switch (collector.compression) {
|
|
103
|
+
case CompressionAlgorithm.GZIP: {
|
|
104
|
+
if (!gzip) {
|
|
105
|
+
gzip = zlib.createGzip();
|
|
106
|
+
}
|
|
107
|
+
req.setHeader('Content-Encoding', 'gzip');
|
|
108
|
+
var dataStream = readableFromBuffer(data);
|
|
109
|
+
dataStream.on('error', onError)
|
|
110
|
+
.pipe(gzip).on('error', onError)
|
|
111
|
+
.pipe(req);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
req.end(data);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function readableFromBuffer(buff) {
|
|
120
|
+
var readable = new Readable();
|
|
121
|
+
readable.push(buff);
|
|
122
|
+
readable.push(null);
|
|
123
|
+
return readable;
|
|
124
|
+
}
|
|
125
|
+
export function createHttpAgent(config) {
|
|
126
|
+
if (config.httpAgentOptions && config.keepAlive === false) {
|
|
127
|
+
diag.warn('httpAgentOptions is used only when keepAlive is true');
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
if (config.keepAlive === false || !config.url)
|
|
131
|
+
return undefined;
|
|
132
|
+
try {
|
|
133
|
+
var parsedUrl = new url.URL(config.url);
|
|
134
|
+
var Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;
|
|
135
|
+
return new Agent(__assign({ keepAlive: true }, config.httpAgentOptions));
|
|
136
|
+
}
|
|
137
|
+
catch (err) {
|
|
138
|
+
diag.error("collector exporter failed to create http agent. err: " + err.message);
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function configureCompression(compression) {
|
|
143
|
+
if (compression) {
|
|
144
|
+
return compression;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
var definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION || getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;
|
|
148
|
+
return definedCompression === CompressionAlgorithm.GZIP ? CompressionAlgorithm.GZIP : CompressionAlgorithm.NONE;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../src/platform/node/util.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,IAAI,IAA2B,CAAC;AAEhC;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,SAA2D,EAC3D,IAAqB,EACrB,WAAmB,EACnB,SAAqB,EACrB,OAA2C;IAE3C,IAAM,eAAe,GAAG,SAAS,CAAC,aAAa,CAAC;IAChD,IAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,cAAuB,CAAC;IAC5B,IAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,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C,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC;KACjH;AACH,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 */\nimport * as url from 'url';\nimport * as http from 'http';\nimport * as https from 'https';\nimport * as zlib from 'zlib';\nimport { Readable } from 'stream';\nimport { OTLPExporterNodeBase } from './OTLPExporterNodeBase';\nimport { OTLPExporterNodeConfigBase } from '.';\nimport { diag } from '@opentelemetry/api';\nimport { CompressionAlgorithm } from './types';\nimport { getEnv } from '@opentelemetry/core';\nimport { OTLPExporterError } from '../../types';\n\nlet gzip: zlib.Gzip | undefined;\n\n/**\n * Sends data using http\n * @param collector\n * @param data\n * @param contentType\n * @param onSuccess\n * @param onError\n */\nexport function sendWithHttp<ExportItem, ServiceRequest>(\n collector: OTLPExporterNodeBase<ExportItem, ServiceRequest>,\n data: string | Buffer,\n contentType: string,\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n const exporterTimeout = collector.timeoutMillis;\n const parsedUrl = new url.URL(collector.url);\n let reqIsDestroyed: boolean;\n const nodeVersion = Number(process.versions.node.split('.')[0]);\n\n const exporterTimer = setTimeout(() => {\n reqIsDestroyed = true;\n // req.abort() was deprecated since v14\n if (nodeVersion >= 14) {\n req.destroy();\n } else {\n req.abort();\n }\n }, exporterTimeout);\n\n const options: http.RequestOptions | https.RequestOptions = {\n hostname: parsedUrl.hostname,\n port: parsedUrl.port,\n path: parsedUrl.pathname,\n method: 'POST',\n headers: {\n 'Content-Type': contentType,\n ...collector.headers,\n },\n agent: collector.agent,\n };\n\n const request = parsedUrl.protocol === 'http:' ? http.request : https.request;\n\n const req = request(options, (res: http.IncomingMessage) => {\n let responseData = '';\n res.on('data', chunk => (responseData += chunk));\n\n res.on('aborted', () => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError(\n 'Request Timeout'\n );\n onError(err);\n }\n });\n\n res.on('end', () => {\n if (!reqIsDestroyed) {\n if (res.statusCode && res.statusCode < 299) {\n diag.debug(`statusCode: ${res.statusCode}`, responseData);\n onSuccess();\n } else {\n const error = new OTLPExporterError(\n res.statusMessage,\n res.statusCode,\n responseData\n );\n onError(error);\n }\n clearTimeout(exporterTimer);\n }\n });\n });\n\n req.on('error', (error: Error | any) => {\n if (reqIsDestroyed) {\n const err = new OTLPExporterError(\n 'Request Timeout', error.code\n );\n onError(err);\n } else {\n clearTimeout(exporterTimer);\n onError(error);\n }\n });\n\n switch (collector.compression) {\n case CompressionAlgorithm.GZIP: {\n if (!gzip) {\n gzip = zlib.createGzip();\n }\n req.setHeader('Content-Encoding', 'gzip');\n const dataStream = readableFromBuffer(data);\n dataStream.on('error', onError)\n .pipe(gzip).on('error', onError)\n .pipe(req);\n\n break;\n }\n default:\n req.end(data);\n break;\n }\n}\n\nfunction readableFromBuffer(buff: string | Buffer): Readable {\n const readable = new Readable();\n readable.push(buff);\n readable.push(null);\n\n return readable;\n}\n\nexport function createHttpAgent(\n config: OTLPExporterNodeConfigBase\n): http.Agent | https.Agent | undefined {\n if (config.httpAgentOptions && config.keepAlive === false) {\n diag.warn('httpAgentOptions is used only when keepAlive is true');\n return undefined;\n }\n\n if (config.keepAlive === false || !config.url) return undefined;\n\n try {\n const parsedUrl = new url.URL(config.url as string);\n const Agent = parsedUrl.protocol === 'http:' ? http.Agent : https.Agent;\n return new Agent({ keepAlive: true, ...config.httpAgentOptions });\n } catch (err) {\n diag.error(\n `collector exporter failed to create http agent. err: ${err.message}`\n );\n return undefined;\n }\n}\n\nexport function configureCompression(compression: CompressionAlgorithm | undefined): CompressionAlgorithm {\n if (compression) {\n return compression;\n } else {\n const definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION || getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n return definedCompression === CompressionAlgorithm.GZIP ? CompressionAlgorithm.GZIP : CompressionAlgorithm.NONE;\n }\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SpanAttributes } from '@opentelemetry/api';
|
|
2
|
+
/**
|
|
3
|
+
* Interface for handling error
|
|
4
|
+
*/
|
|
5
|
+
export declare class OTLPExporterError extends Error {
|
|
6
|
+
readonly code?: number;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly data?: string;
|
|
9
|
+
constructor(message?: string, code?: number, data?: string);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Interface for handling export service errors
|
|
13
|
+
*/
|
|
14
|
+
export interface ExportServiceError {
|
|
15
|
+
name: string;
|
|
16
|
+
code: number;
|
|
17
|
+
details: string;
|
|
18
|
+
metadata: {
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
};
|
|
21
|
+
message: string;
|
|
22
|
+
stack: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Collector Exporter base config
|
|
26
|
+
*/
|
|
27
|
+
export interface OTLPExporterConfigBase {
|
|
28
|
+
headers?: Partial<Record<string, unknown>>;
|
|
29
|
+
hostname?: string;
|
|
30
|
+
attributes?: SpanAttributes;
|
|
31
|
+
url?: string;
|
|
32
|
+
concurrencyLimit?: number;
|
|
33
|
+
/** Maximum time the OTLP exporter will wait for each batch export.
|
|
34
|
+
* The default value is 10000ms. */
|
|
35
|
+
timeoutMillis?: number;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* Interface for handling error
|
|
33
|
+
*/
|
|
34
|
+
var OTLPExporterError = /** @class */ (function (_super) {
|
|
35
|
+
__extends(OTLPExporterError, _super);
|
|
36
|
+
function OTLPExporterError(message, code, data) {
|
|
37
|
+
var _this = _super.call(this, message) || this;
|
|
38
|
+
_this.name = 'OTLPExporterError';
|
|
39
|
+
_this.data = data;
|
|
40
|
+
_this.code = code;
|
|
41
|
+
return _this;
|
|
42
|
+
}
|
|
43
|
+
return OTLPExporterError;
|
|
44
|
+
}(Error));
|
|
45
|
+
export { OTLPExporterError };
|
|
46
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;AAIH;;GAEG;AACH;IAAuC,qCAAK;IAK1C,2BAAY,OAAgB,EAAE,IAAa,EAAE,IAAa;QAA1D,YACE,kBAAM,OAAO,CAAC,SAGf;QAPiB,UAAI,GAAW,mBAAmB,CAAC;QAKnD,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,wBAAC;AAAD,CAAC,AAVD,CAAuC,KAAK,GAU3C","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 } from '@opentelemetry/api';\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 /** Maximum time the OTLP exporter will wait for each batch export.\n * The default value is 10000ms. */\n timeoutMillis?: number;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/**
|
|
7
|
+
* Adds path (version + signal) to a no per-signal endpoint
|
|
8
|
+
* @param url
|
|
9
|
+
* @param path
|
|
10
|
+
* @returns url + path
|
|
11
|
+
*/
|
|
12
|
+
export declare function appendResourcePathToUrl(url: string, path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Adds root path to signal specific endpoint when endpoint contains no path part and no root path
|
|
15
|
+
* @param url
|
|
16
|
+
* @param path
|
|
17
|
+
* @returns url
|
|
18
|
+
*/
|
|
19
|
+
export declare function appendRootPathToUrlIfNeeded(url: string, path: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Configure exporter trace timeout value from passed in value or environment variables
|
|
22
|
+
* @param timeoutMillis
|
|
23
|
+
* @returns timeout value in milliseconds
|
|
24
|
+
*/
|
|
25
|
+
export declare function configureExporterTimeout(timeoutMillis: number | undefined): number;
|
|
26
|
+
export declare function invalidTimeout(timeout: number, defaultTimeout: number): number;
|
|
27
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
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 __read = (this && this.__read) || function (o, n) {
|
|
17
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
18
|
+
if (!m) return o;
|
|
19
|
+
var i = m.call(o), r, ar = [], e;
|
|
20
|
+
try {
|
|
21
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
22
|
+
}
|
|
23
|
+
catch (error) { e = { error: error }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e) throw e.error; }
|
|
29
|
+
}
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
import { diag } from '@opentelemetry/api';
|
|
33
|
+
import { getEnv } from '@opentelemetry/core';
|
|
34
|
+
var DEFAULT_TRACE_TIMEOUT = 10000;
|
|
35
|
+
/**
|
|
36
|
+
* Parses headers from config leaving only those that have defined values
|
|
37
|
+
* @param partialHeaders
|
|
38
|
+
*/
|
|
39
|
+
export function parseHeaders(partialHeaders) {
|
|
40
|
+
if (partialHeaders === void 0) { partialHeaders = {}; }
|
|
41
|
+
var headers = {};
|
|
42
|
+
Object.entries(partialHeaders).forEach(function (_a) {
|
|
43
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
44
|
+
if (typeof value !== 'undefined') {
|
|
45
|
+
headers[key] = String(value);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
diag.warn("Header \"" + key + "\" has wrong value and will be ignored");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return headers;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Adds path (version + signal) to a no per-signal endpoint
|
|
55
|
+
* @param url
|
|
56
|
+
* @param path
|
|
57
|
+
* @returns url + path
|
|
58
|
+
*/
|
|
59
|
+
export function appendResourcePathToUrl(url, path) {
|
|
60
|
+
if (!url.endsWith('/')) {
|
|
61
|
+
url = url + '/';
|
|
62
|
+
}
|
|
63
|
+
return url + path;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Adds root path to signal specific endpoint when endpoint contains no path part and no root path
|
|
67
|
+
* @param url
|
|
68
|
+
* @param path
|
|
69
|
+
* @returns url
|
|
70
|
+
*/
|
|
71
|
+
export function appendRootPathToUrlIfNeeded(url, path) {
|
|
72
|
+
if (!url.includes(path) && !url.endsWith('/')) {
|
|
73
|
+
url = url + '/';
|
|
74
|
+
}
|
|
75
|
+
return url;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Configure exporter trace timeout value from passed in value or environment variables
|
|
79
|
+
* @param timeoutMillis
|
|
80
|
+
* @returns timeout value in milliseconds
|
|
81
|
+
*/
|
|
82
|
+
export function configureExporterTimeout(timeoutMillis) {
|
|
83
|
+
if (typeof timeoutMillis === 'number') {
|
|
84
|
+
if (timeoutMillis <= 0) {
|
|
85
|
+
// OTLP exporter configured timeout - using default value of 10000ms
|
|
86
|
+
return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);
|
|
87
|
+
}
|
|
88
|
+
return timeoutMillis;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return getExporterTimeoutFromEnv();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function getExporterTimeoutFromEnv() {
|
|
95
|
+
var _a;
|
|
96
|
+
var definedTimeout = Number((_a = getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT) !== null && _a !== void 0 ? _a : getEnv().OTEL_EXPORTER_OTLP_TIMEOUT);
|
|
97
|
+
if (definedTimeout <= 0) {
|
|
98
|
+
// OTLP exporter configured timeout - using default value of 10000ms
|
|
99
|
+
return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return definedTimeout;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// OTLP exporter configured timeout - using default value of 10000ms
|
|
106
|
+
export function invalidTimeout(timeout, defaultTimeout) {
|
|
107
|
+
diag.warn('Timeout must be greater than 0', timeout);
|
|
108
|
+
return defaultTimeout;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,IAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC;;;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;YAAZ,KAAA,aAAY,EAAX,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;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAW,EAAE,IAAY;IAC/D,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtB,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KACjB;IACD,OAAO,GAAG,GAAG,IAAI,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,GAAW,EAAE,IAAY;IACnE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC7C,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;KACjB;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,aAAiC;IACxE,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;QACrC,IAAI,aAAa,IAAI,CAAC,EAAE;YACtB,oEAAoE;YACpE,OAAO,cAAc,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;SAC7D;QACD,OAAO,aAAa,CAAC;KACtB;SAAM;QACL,OAAO,yBAAyB,EAAE,CAAC;KACpC;AACH,CAAC;AAED,SAAS,yBAAyB;;IAChC,IAAM,cAAc,GAClB,MAAM,CAAC,MAAA,MAAM,EAAE,CAAC,iCAAiC,mCACjD,MAAM,EAAE,CAAC,0BAA0B,CAAC,CAAC;IAEvC,IAAI,cAAc,IAAI,CAAC,EAAE;QACvB,oEAAoE;QACpE,OAAO,cAAc,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;KAC9D;SAAM;QACL,OAAO,cAAc,CAAC;KACvB;AACH,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,cAAsB;IACpE,IAAI,CAAC,IAAI,CAAC,gCAAgC,EAAE,OAAO,CAAC,CAAC;IAErD,OAAO,cAAc,CAAC;AACxB,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';\nimport { getEnv } from '@opentelemetry/core';\n\nconst DEFAULT_TRACE_TIMEOUT = 10000;\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\n/**\n * Adds path (version + signal) to a no per-signal endpoint\n * @param url\n * @param path\n * @returns url + path\n */\nexport function appendResourcePathToUrl(url: string, path: string): string {\n if (!url.endsWith('/')) {\n url = url + '/';\n }\n return url + path;\n}\n\n/**\n * Adds root path to signal specific endpoint when endpoint contains no path part and no root path\n * @param url\n * @param path\n * @returns url\n */\nexport function appendRootPathToUrlIfNeeded(url: string, path: string): string {\n if (!url.includes(path) && !url.endsWith('/')) {\n url = url + '/';\n }\n return url;\n}\n\n/**\n * Configure exporter trace timeout value from passed in value or environment variables\n * @param timeoutMillis\n * @returns timeout value in milliseconds\n */\nexport function configureExporterTimeout(timeoutMillis: number | undefined): number {\n if (typeof timeoutMillis === 'number') {\n if (timeoutMillis <= 0) {\n // OTLP exporter configured timeout - using default value of 10000ms\n return invalidTimeout(timeoutMillis, DEFAULT_TRACE_TIMEOUT);\n }\n return timeoutMillis;\n } else {\n return getExporterTimeoutFromEnv();\n }\n}\n\nfunction getExporterTimeoutFromEnv(): number {\n const definedTimeout =\n Number(getEnv().OTEL_EXPORTER_OTLP_TRACES_TIMEOUT ??\n getEnv().OTEL_EXPORTER_OTLP_TIMEOUT);\n\n if (definedTimeout <= 0) {\n // OTLP exporter configured timeout - using default value of 10000ms\n return invalidTimeout(definedTimeout, DEFAULT_TRACE_TIMEOUT);\n } else {\n return definedTimeout;\n }\n}\n\n// OTLP exporter configured timeout - using default value of 10000ms\nexport function invalidTimeout(timeout: number, defaultTimeout: number): number {\n diag.warn('Timeout must be greater than 0', timeout);\n\n return defaultTimeout;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
// this is autogenerated file, see scripts/version-update.js
|
|
17
|
+
export var VERSION = '0.29.0';
|
|
18
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,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\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.29.0';\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SpanAttributes } from '@opentelemetry/api';
|
|
2
|
+
import { ExportResult, BindOnceFuture } 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
|
+
readonly timeoutMillis: number;
|
|
12
|
+
protected _concurrencyLimit: number;
|
|
13
|
+
protected _sendingPromises: Promise<unknown>[];
|
|
14
|
+
protected _shutdownOnce: BindOnceFuture<void>;
|
|
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
|
+
/**
|
|
31
|
+
* Called by _shutdownOnce with BindOnceFuture
|
|
32
|
+
*/
|
|
33
|
+
private _shutdown;
|
|
34
|
+
abstract onShutdown(): void;
|
|
35
|
+
abstract onInit(config: T): void;
|
|
36
|
+
abstract send(items: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
37
|
+
abstract getDefaultUrl(config: T): string;
|
|
38
|
+
abstract convert(objects: ExportItem[]): ServiceRequest;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=OTLPExporterBase.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
import { ExportResultCode, BindOnceFuture } from '@opentelemetry/core';
|
|
18
|
+
import { configureExporterTimeout } from './util';
|
|
19
|
+
/**
|
|
20
|
+
* Collector Exporter abstract base class
|
|
21
|
+
*/
|
|
22
|
+
export class OTLPExporterBase {
|
|
23
|
+
/**
|
|
24
|
+
* @param config
|
|
25
|
+
*/
|
|
26
|
+
constructor(config = {}) {
|
|
27
|
+
this._sendingPromises = [];
|
|
28
|
+
this.url = this.getDefaultUrl(config);
|
|
29
|
+
if (typeof config.hostname === 'string') {
|
|
30
|
+
this.hostname = config.hostname;
|
|
31
|
+
}
|
|
32
|
+
this.attributes = config.attributes;
|
|
33
|
+
this.shutdown = this.shutdown.bind(this);
|
|
34
|
+
this._shutdownOnce = new BindOnceFuture(this._shutdown, this);
|
|
35
|
+
this._concurrencyLimit =
|
|
36
|
+
typeof config.concurrencyLimit === 'number'
|
|
37
|
+
? config.concurrencyLimit
|
|
38
|
+
: Infinity;
|
|
39
|
+
this.timeoutMillis = configureExporterTimeout(config.timeoutMillis);
|
|
40
|
+
// platform dependent
|
|
41
|
+
this.onInit(config);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Export items.
|
|
45
|
+
* @param items
|
|
46
|
+
* @param resultCallback
|
|
47
|
+
*/
|
|
48
|
+
export(items, resultCallback) {
|
|
49
|
+
if (this._shutdownOnce.isCalled) {
|
|
50
|
+
resultCallback({
|
|
51
|
+
code: ExportResultCode.FAILED,
|
|
52
|
+
error: new Error('Exporter has been shutdown'),
|
|
53
|
+
});
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (this._sendingPromises.length >= this._concurrencyLimit) {
|
|
57
|
+
resultCallback({
|
|
58
|
+
code: ExportResultCode.FAILED,
|
|
59
|
+
error: new Error('Concurrent export limit reached'),
|
|
60
|
+
});
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._export(items)
|
|
64
|
+
.then(() => {
|
|
65
|
+
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
66
|
+
})
|
|
67
|
+
.catch((error) => {
|
|
68
|
+
resultCallback({ code: ExportResultCode.FAILED, error });
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
_export(items) {
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
try {
|
|
74
|
+
diag.debug('items to be sent', items);
|
|
75
|
+
this.send(items, resolve, reject);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
reject(e);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Shutdown the exporter.
|
|
84
|
+
*/
|
|
85
|
+
shutdown() {
|
|
86
|
+
return this._shutdownOnce.call();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Called by _shutdownOnce with BindOnceFuture
|
|
90
|
+
*/
|
|
91
|
+
_shutdown() {
|
|
92
|
+
diag.debug('shutdown started');
|
|
93
|
+
this.onShutdown();
|
|
94
|
+
return Promise.all(this._sendingPromises)
|
|
95
|
+
.then(() => {
|
|
96
|
+
/** ignore resolved values */
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=OTLPExporterBase.js.map
|