@opentelemetry/otlp-grpc-exporter-base 0.49.0 → 0.50.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/src/OTLPGRPCExporterNodeBase.d.ts +10 -16
- package/build/src/OTLPGRPCExporterNodeBase.js +62 -43
- package/build/src/OTLPGRPCExporterNodeBase.js.map +1 -1
- package/build/src/create-service-client-constructor.d.ts +10 -0
- package/build/src/create-service-client-constructor.js +50 -0
- package/build/src/create-service-client-constructor.js.map +1 -0
- package/build/src/export-response.d.ts +10 -0
- package/build/src/export-response.js +18 -0
- package/build/src/export-response.js.map +1 -0
- package/build/src/exporter-transport.d.ts +6 -0
- package/build/src/exporter-transport.js +18 -0
- package/build/src/exporter-transport.js.map +1 -0
- package/build/src/grpc-exporter-transport.d.ts +40 -0
- package/build/src/grpc-exporter-transport.js +116 -0
- package/build/src/grpc-exporter-transport.js.map +1 -0
- package/build/src/index.d.ts +4 -3
- package/build/src/index.js +7 -15
- package/build/src/index.js.map +1 -1
- package/build/src/serializers.d.ts +12 -0
- package/build/src/serializers.js +56 -0
- package/build/src/serializers.js.map +1 -0
- package/build/src/types.d.ts +3 -15
- package/build/src/types.js +0 -7
- package/build/src/types.js.map +1 -1
- package/build/src/util.d.ts +6 -14
- package/build/src/util.js +26 -103
- 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 +7 -7
- package/build/src/LogsExportServiceClient.d.ts +0 -3
- package/build/src/LogsExportServiceClient.js +0 -46
- package/build/src/LogsExportServiceClient.js.map +0 -1
- package/build/src/MetricsExportServiceClient.d.ts +0 -3
- package/build/src/MetricsExportServiceClient.js +0 -46
- package/build/src/MetricsExportServiceClient.js.map +0 -1
- package/build/src/TraceExportServiceClient.d.ts +0 -3
- package/build/src/TraceExportServiceClient.js +0 -46
- package/build/src/TraceExportServiceClient.js.map +0 -1
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { GrpcCompressionAlgorithm } from './util';
|
|
5
|
-
import { OTLPExporterBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
1
|
+
import { GRPCQueueItem, OTLPGRPCExporterConfigNode } from './types';
|
|
2
|
+
import { CompressionAlgorithm, OTLPExporterBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
3
|
+
import { ISerializer } from './serializers';
|
|
6
4
|
/**
|
|
7
5
|
* OTLP Exporter abstract base class
|
|
8
6
|
*/
|
|
9
|
-
export declare abstract class OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest> extends OTLPExporterBase<OTLPGRPCExporterConfigNode, ExportItem, ServiceRequest> {
|
|
7
|
+
export declare abstract class OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest, ServiceResponse> extends OTLPExporterBase<OTLPGRPCExporterConfigNode, ExportItem, ServiceRequest> {
|
|
10
8
|
grpcQueue: GRPCQueueItem<ExportItem>[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private _sendPromise;
|
|
17
|
-
onInit(config: OTLPGRPCExporterConfigNode): void;
|
|
18
|
-
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
9
|
+
compression: CompressionAlgorithm;
|
|
10
|
+
private _transport;
|
|
11
|
+
private _serializer;
|
|
12
|
+
constructor(config: OTLPGRPCExporterConfigNode | undefined, signalSpecificMetadata: Record<string, string>, grpcName: string, grpcPath: string, serializer: ISerializer<ServiceRequest, ServiceResponse>);
|
|
13
|
+
onInit(): void;
|
|
19
14
|
onShutdown(): void;
|
|
20
|
-
|
|
21
|
-
abstract getServiceClientType(): ServiceClientType;
|
|
15
|
+
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
22
16
|
abstract getUrlFromConfig(config: OTLPGRPCExporterConfigNode): string;
|
|
23
17
|
}
|
|
24
18
|
//# sourceMappingURL=OTLPGRPCExporterNodeBase.d.ts.map
|
|
@@ -17,71 +17,90 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.OTLPGRPCExporterNodeBase = void 0;
|
|
19
19
|
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const grpc_js_1 = require("@grpc/grpc-js");
|
|
21
20
|
const core_1 = require("@opentelemetry/core");
|
|
22
|
-
const util_1 = require("./util");
|
|
23
21
|
const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
|
|
22
|
+
const grpc_exporter_transport_1 = require("./grpc-exporter-transport");
|
|
23
|
+
const util_1 = require("./util");
|
|
24
24
|
/**
|
|
25
25
|
* OTLP Exporter abstract base class
|
|
26
26
|
*/
|
|
27
27
|
class OTLPGRPCExporterNodeBase extends otlp_exporter_base_1.OTLPExporterBase {
|
|
28
|
-
constructor(config = {}) {
|
|
28
|
+
constructor(config = {}, signalSpecificMetadata, grpcName, grpcPath, serializer) {
|
|
29
|
+
var _a;
|
|
29
30
|
super(config);
|
|
30
31
|
this.grpcQueue = [];
|
|
31
|
-
this.
|
|
32
|
+
this._serializer = serializer;
|
|
32
33
|
if (config.headers) {
|
|
33
34
|
api_1.diag.warn('Headers cannot be set when using grpc');
|
|
34
35
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const nonSignalSpecificMetadata = core_1.baggageUtils.parseKeyPairsIntoRecord((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_HEADERS);
|
|
37
|
+
const rawMetadata = Object.assign({}, nonSignalSpecificMetadata, signalSpecificMetadata);
|
|
38
|
+
let credentialProvider = () => {
|
|
39
|
+
return (0, util_1.configureCredentials)(undefined, this.getUrlFromConfig(config));
|
|
40
|
+
};
|
|
41
|
+
if (config.credentials != null) {
|
|
42
|
+
const credentials = config.credentials;
|
|
43
|
+
credentialProvider = () => {
|
|
44
|
+
return credentials;
|
|
45
|
+
};
|
|
39
46
|
}
|
|
47
|
+
// Ensure we don't modify the original.
|
|
48
|
+
const configMetadata = (_a = config.metadata) === null || _a === void 0 ? void 0 : _a.clone();
|
|
49
|
+
const metadataProvider = () => {
|
|
50
|
+
const metadata = configMetadata !== null && configMetadata !== void 0 ? configMetadata : (0, grpc_exporter_transport_1.createEmptyMetadata)();
|
|
51
|
+
for (const [key, value] of Object.entries(rawMetadata)) {
|
|
52
|
+
// only override with env var data if the key has no values.
|
|
53
|
+
// not using Metadata.merge() as it will keep both values.
|
|
54
|
+
if (metadata.get(key).length < 1) {
|
|
55
|
+
metadata.set(key, value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return metadata;
|
|
59
|
+
};
|
|
40
60
|
this.compression = (0, util_1.configureCompression)(config.compression);
|
|
61
|
+
this._transport = new grpc_exporter_transport_1.GrpcExporterTransport({
|
|
62
|
+
address: this.getDefaultUrl(config),
|
|
63
|
+
compression: this.compression,
|
|
64
|
+
credentials: credentialProvider,
|
|
65
|
+
grpcName: grpcName,
|
|
66
|
+
grpcPath: grpcPath,
|
|
67
|
+
metadata: metadataProvider,
|
|
68
|
+
timeoutMillis: this.timeoutMillis,
|
|
69
|
+
});
|
|
41
70
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this._send(this, objects, resolve, reject);
|
|
45
|
-
}).then(onSuccess, onError);
|
|
46
|
-
this._sendingPromises.push(promise);
|
|
47
|
-
const popPromise = () => {
|
|
48
|
-
const index = this._sendingPromises.indexOf(promise);
|
|
49
|
-
this._sendingPromises.splice(index, 1);
|
|
50
|
-
};
|
|
51
|
-
promise.then(popPromise, popPromise);
|
|
71
|
+
onInit() {
|
|
72
|
+
// Intentionally left empty; nothing to do.
|
|
52
73
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// and making this impossible to be instrumented
|
|
56
|
-
setImmediate(() => {
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
58
|
-
const { onInit } = require('./util');
|
|
59
|
-
onInit(this, config);
|
|
60
|
-
});
|
|
74
|
+
onShutdown() {
|
|
75
|
+
this._transport.shutdown();
|
|
61
76
|
}
|
|
62
77
|
send(objects, onSuccess, onError) {
|
|
63
78
|
if (this._shutdownOnce.isCalled) {
|
|
64
79
|
api_1.diag.debug('Shutdown already started. Cannot send objects');
|
|
65
80
|
return;
|
|
66
81
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const { send } = require('./util');
|
|
73
|
-
this._send = send;
|
|
74
|
-
this._sendPromise(objects, onSuccess, onError);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this._sendPromise(objects, onSuccess, onError);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
onShutdown() {
|
|
82
|
-
if (this.serviceClient) {
|
|
83
|
-
this.serviceClient.close();
|
|
82
|
+
const converted = this.convert(objects);
|
|
83
|
+
const data = this._serializer.serializeRequest(converted);
|
|
84
|
+
if (data == null) {
|
|
85
|
+
onError(new Error('Could not serialize message'));
|
|
86
|
+
return;
|
|
84
87
|
}
|
|
88
|
+
const promise = this._transport.send(data).then(response => {
|
|
89
|
+
if (response.status === 'success') {
|
|
90
|
+
onSuccess();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (response.status === 'failure' && response.error) {
|
|
94
|
+
onError(response.error);
|
|
95
|
+
}
|
|
96
|
+
onError(new otlp_exporter_base_1.OTLPExporterError('Export failed with unknown error'));
|
|
97
|
+
}, onError);
|
|
98
|
+
this._sendingPromises.push(promise);
|
|
99
|
+
const popPromise = () => {
|
|
100
|
+
const index = this._sendingPromises.indexOf(promise);
|
|
101
|
+
this._sendingPromises.splice(index, 1);
|
|
102
|
+
};
|
|
103
|
+
promise.then(popPromise, popPromise);
|
|
85
104
|
}
|
|
86
105
|
}
|
|
87
106
|
exports.OTLPGRPCExporterNodeBase = OTLPGRPCExporterNodeBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPGRPCExporterNodeBase.js","sourceRoot":"","sources":["../../src/OTLPGRPCExporterNodeBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;
|
|
1
|
+
{"version":3,"file":"OTLPGRPCExporterNodeBase.js","sourceRoot":"","sources":["../../src/OTLPGRPCExporterNodeBase.ts"],"names":[],"mappings":"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","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 { GRPCQueueItem, OTLPGRPCExporterConfigNode } from './types';\nimport { baggageUtils, getEnv } from '@opentelemetry/core';\nimport {\n CompressionAlgorithm,\n OTLPExporterBase,\n OTLPExporterError,\n} from '@opentelemetry/otlp-exporter-base';\nimport {\n createEmptyMetadata,\n GrpcExporterTransport,\n} from './grpc-exporter-transport';\nimport { configureCompression, configureCredentials } from './util';\nimport { ISerializer } from './serializers';\nimport { IExporterTransport } from './exporter-transport';\n\n/**\n * OTLP Exporter abstract base class\n */\nexport abstract class OTLPGRPCExporterNodeBase<\n ExportItem,\n ServiceRequest,\n ServiceResponse,\n> extends OTLPExporterBase<\n OTLPGRPCExporterConfigNode,\n ExportItem,\n ServiceRequest\n> {\n grpcQueue: GRPCQueueItem<ExportItem>[] = [];\n compression: CompressionAlgorithm;\n private _transport: IExporterTransport;\n private _serializer: ISerializer<ServiceRequest, ServiceResponse>;\n\n constructor(\n config: OTLPGRPCExporterConfigNode = {},\n signalSpecificMetadata: Record<string, string>,\n grpcName: string,\n grpcPath: string,\n serializer: ISerializer<ServiceRequest, ServiceResponse>\n ) {\n super(config);\n this._serializer = serializer;\n if (config.headers) {\n diag.warn('Headers cannot be set when using grpc');\n }\n const nonSignalSpecificMetadata = baggageUtils.parseKeyPairsIntoRecord(\n getEnv().OTEL_EXPORTER_OTLP_HEADERS\n );\n const rawMetadata = Object.assign(\n {},\n nonSignalSpecificMetadata,\n signalSpecificMetadata\n );\n\n let credentialProvider = () => {\n return configureCredentials(undefined, this.getUrlFromConfig(config));\n };\n\n if (config.credentials != null) {\n const credentials = config.credentials;\n credentialProvider = () => {\n return credentials;\n };\n }\n\n // Ensure we don't modify the original.\n const configMetadata = config.metadata?.clone();\n const metadataProvider = () => {\n const metadata = configMetadata ?? createEmptyMetadata();\n for (const [key, value] of Object.entries(rawMetadata)) {\n // only override with env var data if the key has no values.\n // not using Metadata.merge() as it will keep both values.\n if (metadata.get(key).length < 1) {\n metadata.set(key, value);\n }\n }\n\n return metadata;\n };\n\n this.compression = configureCompression(config.compression);\n this._transport = new GrpcExporterTransport({\n address: this.getDefaultUrl(config),\n compression: this.compression,\n credentials: credentialProvider,\n grpcName: grpcName,\n grpcPath: grpcPath,\n metadata: metadataProvider,\n timeoutMillis: this.timeoutMillis,\n });\n }\n\n onInit() {\n // Intentionally left empty; nothing to do.\n }\n\n override onShutdown() {\n this._transport.shutdown();\n }\n\n send(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n if (this._shutdownOnce.isCalled) {\n diag.debug('Shutdown already started. Cannot send objects');\n return;\n }\n\n const converted = this.convert(objects);\n const data = this._serializer.serializeRequest(converted);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport.send(data).then(response => {\n if (response.status === 'success') {\n onSuccess();\n return;\n }\n if (response.status === 'failure' && response.error) {\n onError(response.error);\n }\n onError(new OTLPExporterError('Export failed with unknown error'));\n }, 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 abstract getUrlFromConfig(config: OTLPGRPCExporterConfigNode): string;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as grpc from '@grpc/grpc-js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a unary service client constructor that, when instantiated, does not serialize/deserialize anything.
|
|
4
|
+
* Allows for passing in {@link Buffer} directly, serialization can be handled via protobufjs or custom implementations.
|
|
5
|
+
*
|
|
6
|
+
* @param path service path
|
|
7
|
+
* @param name service name
|
|
8
|
+
*/
|
|
9
|
+
export declare function createServiceClientConstructor(path: string, name: string): grpc.ServiceClientConstructor;
|
|
10
|
+
//# sourceMappingURL=create-service-client-constructor.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
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.createServiceClientConstructor = void 0;
|
|
19
|
+
const grpc = require("@grpc/grpc-js");
|
|
20
|
+
/**
|
|
21
|
+
* Creates a unary service client constructor that, when instantiated, does not serialize/deserialize anything.
|
|
22
|
+
* Allows for passing in {@link Buffer} directly, serialization can be handled via protobufjs or custom implementations.
|
|
23
|
+
*
|
|
24
|
+
* @param path service path
|
|
25
|
+
* @param name service name
|
|
26
|
+
*/
|
|
27
|
+
function createServiceClientConstructor(path, name) {
|
|
28
|
+
const serviceDefinition = {
|
|
29
|
+
export: {
|
|
30
|
+
path: path,
|
|
31
|
+
requestStream: false,
|
|
32
|
+
responseStream: false,
|
|
33
|
+
requestSerialize: (arg) => {
|
|
34
|
+
return arg;
|
|
35
|
+
},
|
|
36
|
+
requestDeserialize: (arg) => {
|
|
37
|
+
return arg;
|
|
38
|
+
},
|
|
39
|
+
responseSerialize: (arg) => {
|
|
40
|
+
return arg;
|
|
41
|
+
},
|
|
42
|
+
responseDeserialize: (arg) => {
|
|
43
|
+
return arg;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
return grpc.makeGenericClientConstructor(serviceDefinition, name);
|
|
48
|
+
}
|
|
49
|
+
exports.createServiceClientConstructor = createServiceClientConstructor;
|
|
50
|
+
//# sourceMappingURL=create-service-client-constructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-service-client-constructor.js","sourceRoot":"","sources":["../../src/create-service-client-constructor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AAEtC;;;;;;GAMG;AACH,SAAgB,8BAA8B,CAC5C,IAAY,EACZ,IAAY;IAEZ,MAAM,iBAAiB,GAAG;QACxB,MAAM,EAAE;YACN,IAAI,EAAE,IAAI;YACV,aAAa,EAAE,KAAK;YACpB,cAAc,EAAE,KAAK;YACrB,gBAAgB,EAAE,CAAC,GAAW,EAAE,EAAE;gBAChC,OAAO,GAAG,CAAC;YACb,CAAC;YACD,kBAAkB,EAAE,CAAC,GAAW,EAAE,EAAE;gBAClC,OAAO,GAAG,CAAC;YACb,CAAC;YACD,iBAAiB,EAAE,CAAC,GAAW,EAAE,EAAE;gBACjC,OAAO,GAAG,CAAC;YACb,CAAC;YACD,mBAAmB,EAAE,CAAC,GAAW,EAAE,EAAE;gBACnC,OAAO,GAAG,CAAC;YACb,CAAC;SACF;KACF,CAAC;IAEF,OAAO,IAAI,CAAC,4BAA4B,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;AACpE,CAAC;AAzBD,wEAyBC","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 * as grpc from '@grpc/grpc-js';\n\n/**\n * Creates a unary service client constructor that, when instantiated, does not serialize/deserialize anything.\n * Allows for passing in {@link Buffer} directly, serialization can be handled via protobufjs or custom implementations.\n *\n * @param path service path\n * @param name service name\n */\nexport function createServiceClientConstructor(\n path: string,\n name: string\n): grpc.ServiceClientConstructor {\n const serviceDefinition = {\n export: {\n path: path,\n requestStream: false,\n responseStream: false,\n requestSerialize: (arg: Buffer) => {\n return arg;\n },\n requestDeserialize: (arg: Buffer) => {\n return arg;\n },\n responseSerialize: (arg: Buffer) => {\n return arg;\n },\n responseDeserialize: (arg: Buffer) => {\n return arg;\n },\n },\n };\n\n return grpc.makeGenericClientConstructor(serviceDefinition, name);\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ExportResponseSuccess {
|
|
2
|
+
status: 'success';
|
|
3
|
+
data?: Uint8Array;
|
|
4
|
+
}
|
|
5
|
+
export interface ExportResponseFailure {
|
|
6
|
+
status: 'failure';
|
|
7
|
+
error: Error;
|
|
8
|
+
}
|
|
9
|
+
export declare type ExportResponse = ExportResponseSuccess | ExportResponseFailure;
|
|
10
|
+
//# sourceMappingURL=export-response.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
//# sourceMappingURL=export-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-response.js","sourceRoot":"","sources":["../../src/export-response.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 interface ExportResponseSuccess {\n status: 'success';\n data?: Uint8Array;\n}\n\nexport interface ExportResponseFailure {\n status: 'failure';\n error: Error;\n}\n\nexport type ExportResponse = ExportResponseSuccess | ExportResponseFailure;\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
//# sourceMappingURL=exporter-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter-transport.js","sourceRoot":"","sources":["../../src/exporter-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","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 { ExportResponse } from './export-response';\n\nexport interface IExporterTransport {\n send(data: Uint8Array): Promise<ExportResponse>;\n shutdown(): void;\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { Metadata, ChannelCredentials } from '@grpc/grpc-js';
|
|
3
|
+
import { ExportResponse } from './export-response';
|
|
4
|
+
import { IExporterTransport } from './exporter-transport';
|
|
5
|
+
export declare function createInsecureCredentials(): ChannelCredentials;
|
|
6
|
+
export declare function createSslCredentials(rootCert?: Buffer, privateKey?: Buffer, certChain?: Buffer): ChannelCredentials;
|
|
7
|
+
export declare function createEmptyMetadata(): Metadata;
|
|
8
|
+
export interface GrpcExporterTransportParameters {
|
|
9
|
+
grpcPath: string;
|
|
10
|
+
grpcName: string;
|
|
11
|
+
address: string;
|
|
12
|
+
/**
|
|
13
|
+
* NOTE: Ensure that you're only importing/requiring gRPC inside the function providing the channel credentials,
|
|
14
|
+
* otherwise, gRPC and http/https instrumentations may break.
|
|
15
|
+
*
|
|
16
|
+
* For common cases, you can avoid to import/require gRPC your function by using
|
|
17
|
+
* - {@link createSslCredentials}
|
|
18
|
+
* - {@link createInsecureCredentials}
|
|
19
|
+
*/
|
|
20
|
+
credentials: () => ChannelCredentials;
|
|
21
|
+
/**
|
|
22
|
+
* NOTE: Ensure that you're only importing/requiring gRPC inside the function providing the metadata,
|
|
23
|
+
* otherwise, gRPC and http/https instrumentations may break.
|
|
24
|
+
*
|
|
25
|
+
* To avoid having to import/require gRPC from your function to create a new Metadata object,
|
|
26
|
+
* use {@link createEmptyMetadata}
|
|
27
|
+
*/
|
|
28
|
+
metadata: () => Metadata;
|
|
29
|
+
compression: 'gzip' | 'none';
|
|
30
|
+
timeoutMillis: number;
|
|
31
|
+
}
|
|
32
|
+
export declare class GrpcExporterTransport implements IExporterTransport {
|
|
33
|
+
private _parameters;
|
|
34
|
+
private _client?;
|
|
35
|
+
private _metadata?;
|
|
36
|
+
constructor(_parameters: GrpcExporterTransportParameters);
|
|
37
|
+
shutdown(): void;
|
|
38
|
+
send(data: Uint8Array): Promise<ExportResponse>;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=grpc-exporter-transport.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
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.GrpcExporterTransport = exports.createEmptyMetadata = exports.createSslCredentials = exports.createInsecureCredentials = void 0;
|
|
19
|
+
// values taken from '@grpc/grpc-js` so that we don't need to require/import it.
|
|
20
|
+
const GRPC_COMPRESSION_NONE = 0;
|
|
21
|
+
const GRPC_COMPRESSION_GZIP = 2;
|
|
22
|
+
function toGrpcCompression(compression) {
|
|
23
|
+
return compression === 'gzip' ? GRPC_COMPRESSION_GZIP : GRPC_COMPRESSION_NONE;
|
|
24
|
+
}
|
|
25
|
+
function createInsecureCredentials() {
|
|
26
|
+
// Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.
|
|
27
|
+
const { credentials,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
29
|
+
} = require('@grpc/grpc-js');
|
|
30
|
+
return credentials.createInsecure();
|
|
31
|
+
}
|
|
32
|
+
exports.createInsecureCredentials = createInsecureCredentials;
|
|
33
|
+
function createSslCredentials(rootCert, privateKey, certChain) {
|
|
34
|
+
// Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.
|
|
35
|
+
const { credentials,
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
37
|
+
} = require('@grpc/grpc-js');
|
|
38
|
+
return credentials.createSsl(rootCert, privateKey, certChain);
|
|
39
|
+
}
|
|
40
|
+
exports.createSslCredentials = createSslCredentials;
|
|
41
|
+
function createEmptyMetadata() {
|
|
42
|
+
// Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.
|
|
43
|
+
const { Metadata,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
45
|
+
} = require('@grpc/grpc-js');
|
|
46
|
+
return new Metadata();
|
|
47
|
+
}
|
|
48
|
+
exports.createEmptyMetadata = createEmptyMetadata;
|
|
49
|
+
class GrpcExporterTransport {
|
|
50
|
+
constructor(_parameters) {
|
|
51
|
+
this._parameters = _parameters;
|
|
52
|
+
}
|
|
53
|
+
shutdown() {
|
|
54
|
+
var _a;
|
|
55
|
+
(_a = this._client) === null || _a === void 0 ? void 0 : _a.shutdown();
|
|
56
|
+
}
|
|
57
|
+
send(data) {
|
|
58
|
+
// We need to make a for gRPC
|
|
59
|
+
const buffer = Buffer.from(data);
|
|
60
|
+
if (this._client == null) {
|
|
61
|
+
// Lazy require to ensure that grpc is not loaded before instrumentations can wrap it
|
|
62
|
+
const { createServiceClientConstructor,
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
64
|
+
} = require('./create-service-client-constructor');
|
|
65
|
+
try {
|
|
66
|
+
this._metadata = this._parameters.metadata();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
return Promise.resolve({
|
|
70
|
+
status: 'failure',
|
|
71
|
+
error: error,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const clientConstructor = createServiceClientConstructor(this._parameters.grpcPath, this._parameters.grpcName);
|
|
75
|
+
try {
|
|
76
|
+
this._client = new clientConstructor(this._parameters.address, this._parameters.credentials(), {
|
|
77
|
+
'grpc.default_compression_algorithm': toGrpcCompression(this._parameters.compression),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return Promise.resolve({
|
|
82
|
+
status: 'failure',
|
|
83
|
+
error: error,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return new Promise(resolve => {
|
|
88
|
+
// this will always be defined
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
+
const deadline = Date.now() + this._parameters.timeoutMillis;
|
|
91
|
+
// this should never happen
|
|
92
|
+
if (this._metadata == null) {
|
|
93
|
+
return resolve({
|
|
94
|
+
error: new Error('metadata was null'),
|
|
95
|
+
status: 'failure',
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
this._client.export(buffer, this._metadata, { deadline: deadline }, (err, response) => {
|
|
99
|
+
if (err) {
|
|
100
|
+
resolve({
|
|
101
|
+
status: 'failure',
|
|
102
|
+
error: err,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
resolve({
|
|
107
|
+
data: response,
|
|
108
|
+
status: 'success',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
exports.GrpcExporterTransport = GrpcExporterTransport;
|
|
116
|
+
//# sourceMappingURL=grpc-exporter-transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc-exporter-transport.js","sourceRoot":"","sources":["../../src/grpc-exporter-transport.ts"],"names":[],"mappings":"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","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// NOTE: do not change these type imports to actual imports. Doing so WILL break `@opentelemetry/instrumentation-http`,\n// as they'd be imported before the http/https modules can be wrapped.\nimport type { Metadata, ServiceError, ChannelCredentials } from '@grpc/grpc-js';\nimport { ExportResponse } from './export-response';\nimport { IExporterTransport } from './exporter-transport';\n\n// values taken from '@grpc/grpc-js` so that we don't need to require/import it.\nconst GRPC_COMPRESSION_NONE = 0;\nconst GRPC_COMPRESSION_GZIP = 2;\n\nfunction toGrpcCompression(compression: 'gzip' | 'none'): number {\n return compression === 'gzip' ? GRPC_COMPRESSION_GZIP : GRPC_COMPRESSION_NONE;\n}\n\nexport function createInsecureCredentials(): ChannelCredentials {\n // Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.\n const {\n credentials,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n } = require('@grpc/grpc-js');\n return credentials.createInsecure();\n}\n\nexport function createSslCredentials(\n rootCert?: Buffer,\n privateKey?: Buffer,\n certChain?: Buffer\n): ChannelCredentials {\n // Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.\n const {\n credentials,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n } = require('@grpc/grpc-js');\n return credentials.createSsl(rootCert, privateKey, certChain);\n}\n\nexport function createEmptyMetadata(): Metadata {\n // Lazy-load so that we don't need to require/import '@grpc/grpc-js' before it can be wrapped by instrumentation.\n const {\n Metadata,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n } = require('@grpc/grpc-js');\n return new Metadata();\n}\n\nexport interface GrpcExporterTransportParameters {\n grpcPath: string;\n grpcName: string;\n address: string;\n /**\n * NOTE: Ensure that you're only importing/requiring gRPC inside the function providing the channel credentials,\n * otherwise, gRPC and http/https instrumentations may break.\n *\n * For common cases, you can avoid to import/require gRPC your function by using\n * - {@link createSslCredentials}\n * - {@link createInsecureCredentials}\n */\n credentials: () => ChannelCredentials;\n /**\n * NOTE: Ensure that you're only importing/requiring gRPC inside the function providing the metadata,\n * otherwise, gRPC and http/https instrumentations may break.\n *\n * To avoid having to import/require gRPC from your function to create a new Metadata object,\n * use {@link createEmptyMetadata}\n */\n metadata: () => Metadata;\n compression: 'gzip' | 'none';\n timeoutMillis: number;\n}\n\nexport class GrpcExporterTransport implements IExporterTransport {\n private _client?: any;\n private _metadata?: Metadata;\n\n constructor(private _parameters: GrpcExporterTransportParameters) {}\n\n shutdown() {\n this._client?.shutdown();\n }\n\n send(data: Uint8Array): Promise<ExportResponse> {\n // We need to make a for gRPC\n const buffer = Buffer.from(data);\n\n if (this._client == null) {\n // Lazy require to ensure that grpc is not loaded before instrumentations can wrap it\n const {\n createServiceClientConstructor,\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n } = require('./create-service-client-constructor');\n\n try {\n this._metadata = this._parameters.metadata();\n } catch (error) {\n return Promise.resolve({\n status: 'failure',\n error: error,\n });\n }\n\n const clientConstructor = createServiceClientConstructor(\n this._parameters.grpcPath,\n this._parameters.grpcName\n );\n\n try {\n this._client = new clientConstructor(\n this._parameters.address,\n this._parameters.credentials(),\n {\n 'grpc.default_compression_algorithm': toGrpcCompression(\n this._parameters.compression\n ),\n }\n );\n } catch (error) {\n return Promise.resolve({\n status: 'failure',\n error: error,\n });\n }\n }\n\n return new Promise<ExportResponse>(resolve => {\n // this will always be defined\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const deadline = Date.now() + this._parameters.timeoutMillis;\n\n // this should never happen\n if (this._metadata == null) {\n return resolve({\n error: new Error('metadata was null'),\n status: 'failure',\n });\n }\n\n this._client.export(\n buffer,\n this._metadata,\n { deadline: deadline },\n (err: ServiceError, response: Buffer) => {\n if (err) {\n resolve({\n status: 'failure',\n error: err,\n });\n } else {\n resolve({\n data: response,\n status: 'success',\n });\n }\n }\n );\n });\n }\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export { DEFAULT_COLLECTOR_URL, validateAndNormalizeUrl
|
|
1
|
+
export { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';
|
|
2
|
+
export { OTLPGRPCExporterConfigNode } from './types';
|
|
3
|
+
export { DEFAULT_COLLECTOR_URL, validateAndNormalizeUrl } from './util';
|
|
4
|
+
export { MetricsSerializer, TraceSerializer, LogsSerializer, ISerializer, } from './serializers';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -14,23 +14,15 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
|
-
};
|
|
27
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(exports, "ServiceClientType", { enumerable: true, get: function () { return types_1.ServiceClientType; } });
|
|
18
|
+
exports.LogsSerializer = exports.TraceSerializer = exports.MetricsSerializer = exports.validateAndNormalizeUrl = exports.DEFAULT_COLLECTOR_URL = exports.OTLPGRPCExporterNodeBase = void 0;
|
|
19
|
+
var OTLPGRPCExporterNodeBase_1 = require("./OTLPGRPCExporterNodeBase");
|
|
20
|
+
Object.defineProperty(exports, "OTLPGRPCExporterNodeBase", { enumerable: true, get: function () { return OTLPGRPCExporterNodeBase_1.OTLPGRPCExporterNodeBase; } });
|
|
32
21
|
var util_1 = require("./util");
|
|
33
22
|
Object.defineProperty(exports, "DEFAULT_COLLECTOR_URL", { enumerable: true, get: function () { return util_1.DEFAULT_COLLECTOR_URL; } });
|
|
34
23
|
Object.defineProperty(exports, "validateAndNormalizeUrl", { enumerable: true, get: function () { return util_1.validateAndNormalizeUrl; } });
|
|
35
|
-
|
|
24
|
+
var serializers_1 = require("./serializers");
|
|
25
|
+
Object.defineProperty(exports, "MetricsSerializer", { enumerable: true, get: function () { return serializers_1.MetricsSerializer; } });
|
|
26
|
+
Object.defineProperty(exports, "TraceSerializer", { enumerable: true, get: function () { return serializers_1.TraceSerializer; } });
|
|
27
|
+
Object.defineProperty(exports, "LogsSerializer", { enumerable: true, get: function () { return serializers_1.LogsSerializer; } });
|
|
36
28
|
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AAEjC,+BAAwE;AAA/D,6GAAA,qBAAqB,OAAA;AAAE,+GAAA,uBAAuB,OAAA;AACvD,6CAKuB;AAJrB,gHAAA,iBAAiB,OAAA;AACjB,8GAAA,eAAe,OAAA;AACf,6GAAA,cAAc,OAAA","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 { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';\nexport { OTLPGRPCExporterConfigNode } from './types';\nexport { DEFAULT_COLLECTOR_URL, validateAndNormalizeUrl } from './util';\nexport {\n MetricsSerializer,\n TraceSerializer,\n LogsSerializer,\n ISerializer,\n} from './serializers';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IExportLogsServiceRequest, IExportLogsServiceResponse, IExportMetricsServiceRequest, IExportMetricsServiceResponse, IExportTraceServiceRequest, IExportTraceServiceResponse } from '@opentelemetry/otlp-transformer';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes and deserializes the OTLP request/response to and from {@link Uint8Array}
|
|
4
|
+
*/
|
|
5
|
+
export interface ISerializer<Request, Response> {
|
|
6
|
+
serializeRequest(request: Request): Uint8Array | undefined;
|
|
7
|
+
deserializeResponse(data: Uint8Array): Response;
|
|
8
|
+
}
|
|
9
|
+
export declare const LogsSerializer: ISerializer<IExportLogsServiceRequest, IExportLogsServiceResponse>;
|
|
10
|
+
export declare const TraceSerializer: ISerializer<IExportTraceServiceRequest, IExportTraceServiceResponse>;
|
|
11
|
+
export declare const MetricsSerializer: ISerializer<IExportMetricsServiceRequest, IExportMetricsServiceResponse>;
|
|
12
|
+
//# sourceMappingURL=serializers.d.ts.map
|