@opentelemetry/otlp-grpc-exporter-base 0.55.0 → 0.56.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/configuration/convert-legacy-otlp-grpc-options.d.ts +9 -0
- package/build/src/configuration/convert-legacy-otlp-grpc-options.js +35 -0
- package/build/src/configuration/convert-legacy-otlp-grpc-options.js.map +1 -0
- package/build/src/configuration/otlp-grpc-env-configuration.js +2 -2
- package/build/src/configuration/otlp-grpc-env-configuration.js.map +1 -1
- package/build/src/grpc-exporter-transport.d.ts +1 -0
- package/build/src/grpc-exporter-transport.js +5 -1
- package/build/src/grpc-exporter-transport.js.map +1 -1
- package/build/src/index.d.ts +2 -1
- package/build/src/index.js +5 -3
- package/build/src/index.js.map +1 -1
- package/build/src/otlp-grpc-export-delegate.d.ts +5 -0
- package/build/src/otlp-grpc-export-delegate.js +32 -0
- package/build/src/otlp-grpc-export-delegate.js.map +1 -0
- 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 +8 -8
- package/build/src/OTLPGRPCExporterNodeBase.d.ts +0 -15
- package/build/src/OTLPGRPCExporterNodeBase.js +0 -99
- package/build/src/OTLPGRPCExporterNodeBase.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OTLPGRPCExporterConfigNode } from '../types';
|
|
2
|
+
import { OtlpGrpcConfiguration } from './otlp-grpc-configuration';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated
|
|
5
|
+
* @param config
|
|
6
|
+
* @param signalIdentifier
|
|
7
|
+
*/
|
|
8
|
+
export declare function convertLegacyOtlpGrpcOptions(config: OTLPGRPCExporterConfigNode, signalIdentifier: string): OtlpGrpcConfiguration;
|
|
9
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertLegacyOtlpGrpcOptions = void 0;
|
|
4
|
+
const api_1 = require("@opentelemetry/api");
|
|
5
|
+
const otlp_grpc_configuration_1 = require("./otlp-grpc-configuration");
|
|
6
|
+
const grpc_exporter_transport_1 = require("../grpc-exporter-transport");
|
|
7
|
+
const otlp_grpc_env_configuration_1 = require("./otlp-grpc-env-configuration");
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated
|
|
10
|
+
* @param config
|
|
11
|
+
* @param signalIdentifier
|
|
12
|
+
*/
|
|
13
|
+
function convertLegacyOtlpGrpcOptions(config, signalIdentifier) {
|
|
14
|
+
if (config.headers) {
|
|
15
|
+
api_1.diag.warn('Headers cannot be set when using grpc');
|
|
16
|
+
}
|
|
17
|
+
// keep credentials locally in case user updates the reference on the config object
|
|
18
|
+
const userProvidedCredentials = config.credentials;
|
|
19
|
+
return (0, otlp_grpc_configuration_1.mergeOtlpGrpcConfigurationWithDefaults)({
|
|
20
|
+
url: config.url,
|
|
21
|
+
metadata: () => {
|
|
22
|
+
var _a;
|
|
23
|
+
// metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.
|
|
24
|
+
return (_a = config.metadata) !== null && _a !== void 0 ? _a : (0, grpc_exporter_transport_1.createEmptyMetadata)();
|
|
25
|
+
},
|
|
26
|
+
compression: config.compression,
|
|
27
|
+
timeoutMillis: config.timeoutMillis,
|
|
28
|
+
concurrencyLimit: config.concurrencyLimit,
|
|
29
|
+
credentials: userProvidedCredentials != null
|
|
30
|
+
? () => userProvidedCredentials
|
|
31
|
+
: undefined,
|
|
32
|
+
}, (0, otlp_grpc_env_configuration_1.getOtlpGrpcConfigurationFromEnv)(signalIdentifier), (0, otlp_grpc_configuration_1.getOtlpGrpcDefaultConfiguration)());
|
|
33
|
+
}
|
|
34
|
+
exports.convertLegacyOtlpGrpcOptions = convertLegacyOtlpGrpcOptions;
|
|
35
|
+
//# sourceMappingURL=convert-legacy-otlp-grpc-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert-legacy-otlp-grpc-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-otlp-grpc-options.ts"],"names":[],"mappings":";;;AAgBA,4CAA0C;AAC1C,uEAImC;AACnC,wEAAiE;AACjE,+EAAgF;AAEhF;;;;GAIG;AACH,SAAgB,4BAA4B,CAC1C,MAAkC,EAClC,gBAAwB;IAExB,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,UAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;KACpD;IAED,mFAAmF;IACnF,MAAM,uBAAuB,GAAG,MAAM,CAAC,WAAW,CAAC;IACnD,OAAO,IAAA,gEAAsC,EAC3C;QACE,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,QAAQ,EAAE,GAAG,EAAE;;YACb,yHAAyH;YACzH,OAAO,MAAA,MAAM,CAAC,QAAQ,mCAAI,IAAA,6CAAmB,GAAE,CAAC;QAClD,CAAC;QACD,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;QACzC,WAAW,EACT,uBAAuB,IAAI,IAAI;YAC7B,CAAC,CAAC,GAAG,EAAE,CAAC,uBAAuB;YAC/B,CAAC,CAAC,SAAS;KAChB,EACD,IAAA,6DAA+B,EAAC,gBAAgB,CAAC,EACjD,IAAA,yDAA+B,GAAE,CAClC,CAAC;AACJ,CAAC;AA5BD,oEA4BC","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 { OTLPGRPCExporterConfigNode } from '../types';\nimport { diag } from '@opentelemetry/api';\nimport {\n getOtlpGrpcDefaultConfiguration,\n mergeOtlpGrpcConfigurationWithDefaults,\n OtlpGrpcConfiguration,\n} from './otlp-grpc-configuration';\nimport { createEmptyMetadata } from '../grpc-exporter-transport';\nimport { getOtlpGrpcConfigurationFromEnv } from './otlp-grpc-env-configuration';\n\n/**\n * @deprecated\n * @param config\n * @param signalIdentifier\n */\nexport function convertLegacyOtlpGrpcOptions(\n config: OTLPGRPCExporterConfigNode,\n signalIdentifier: string\n): OtlpGrpcConfiguration {\n if (config.headers) {\n diag.warn('Headers cannot be set when using grpc');\n }\n\n // keep credentials locally in case user updates the reference on the config object\n const userProvidedCredentials = config.credentials;\n return mergeOtlpGrpcConfigurationWithDefaults(\n {\n url: config.url,\n metadata: () => {\n // metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.\n return config.metadata ?? createEmptyMetadata();\n },\n compression: config.compression,\n timeoutMillis: config.timeoutMillis,\n concurrencyLimit: config.concurrencyLimit,\n credentials:\n userProvidedCredentials != null\n ? () => userProvidedCredentials\n : undefined,\n },\n getOtlpGrpcConfigurationFromEnv(signalIdentifier),\n getOtlpGrpcDefaultConfiguration()\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getOtlpGrpcConfigurationFromEnv = void 0;
|
|
4
4
|
const core_1 = require("@opentelemetry/core");
|
|
5
5
|
const grpc_exporter_transport_1 = require("../grpc-exporter-transport");
|
|
6
|
-
const
|
|
6
|
+
const node_http_1 = require("@opentelemetry/otlp-exporter-base/node-http");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const api_1 = require("@opentelemetry/api");
|
|
@@ -129,7 +129,7 @@ function getCredentialsFromEnv(signalIdentifier) {
|
|
|
129
129
|
return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
|
|
130
130
|
}
|
|
131
131
|
function getOtlpGrpcConfigurationFromEnv(signalIdentifier) {
|
|
132
|
-
return Object.assign(Object.assign({}, (0,
|
|
132
|
+
return Object.assign(Object.assign({}, (0, node_http_1.getSharedConfigurationFromEnvironment)(signalIdentifier)), { metadata: getMetadataProviderFromEnv(signalIdentifier), url: getUrlFromEnv(signalIdentifier), credentials: (finalResolvedUrl) => {
|
|
133
133
|
// Always assume insecure on http:// and secure on https://, the protocol always takes precedence over the insecure setting.
|
|
134
134
|
// note: the spec does not make any exception for
|
|
135
135
|
// - "localhost:4317". If the protocol is omitted, credentials are required unless insecure is set
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otlp-grpc-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-grpc-env-configuration.ts"],"names":[],"mappings":";;;AAiBA,8CAAmD;AACnD,wEAIoC;AACpC,0EAA0F;AAC1F,yBAAyB;AACzB,6BAA6B;AAC7B,4CAA0C;AAE1C,SAAS,wBAAwB,CAC/B,cAAuB,EACvB,iBAA0B;IAE1B,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,EAAE,EAAE;QACnD,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,iBAAiB,IAAI,IAAI,IAAI,iBAAiB,KAAK,EAAE,EAAE;QACzD,OAAO,iBAAiB,CAAC;KAC1B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,gBAAwB;;IAClD,MAAM,wBAAwB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,UAAU,CAAC,0CAAE,IAAI,EAAE,CAAC;IACxE,MAAM,2BAA2B,GAC/B,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,0CAAE,IAAI,EAAE,CAAC;IAEpD,MAAM,qBAAqB,GAAG,mBAAY,CAAC,uBAAuB,CAChE,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,mBAAY,CAA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A4H;YAC5H,iDAAiD;YACjD,kGAAkG;YAClG,kHAAkH;YAClH,IAAI,gBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAC1C,OAAO,GAAG,EAAE;oBACV,OAAO,IAAA,mDAAyB,GAAE,CAAC;gBACrC,CAAC,CAAC;aACH;iBAAM,IAAI,gBAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;gBAClD,OAAO,GAAG,EAAE;oBACV,OAAO,mCAAmC,CAAC,gBAAgB,CAAC,CAAC;gBAC/D,CAAC,CAAC;aACH;YAED,qCAAqC;YACrC,OAAO,GAAG,EAAE;gBACV,OAAO,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;YACjD,CAAC,CAAC;QACJ,CAAC,IACD;AACJ,CAAC;AA5BD,0EA4BC","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 { UnresolvedOtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\nimport { baggageUtils } from '@opentelemetry/core';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { getSharedConfigurationFromEnvironment } from '@opentelemetry/otlp-exporter-base';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { diag } from '@opentelemetry/api';\n\nfunction fallbackIfNullishOrBlank(\n signalSpecific?: string,\n nonSignalSpecific?: string\n): string | undefined {\n if (signalSpecific != null && signalSpecific !== '') {\n return signalSpecific;\n }\n\n if (nonSignalSpecific != null && nonSignalSpecific !== '') {\n return nonSignalSpecific;\n }\n\n return undefined;\n}\n\nfunction getMetadataFromEnv(signalIdentifier: string): Metadata | undefined {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n const mergeHeaders = Object.assign(\n {},\n nonSignalSpecificHeaders,\n signalSpecificHeaders\n );\n\n const metadata = createEmptyMetadata();\n\n // for this to work, metadata MUST be empty - otherwise `Metadata#set()` will merge items.\n for (const [key, value] of Object.entries(mergeHeaders)) {\n metadata.set(key, value);\n }\n\n return metadata;\n}\n\nfunction getMetadataProviderFromEnv(\n signalIdentifier: string\n): (() => Metadata) | undefined {\n const metadata = getMetadataFromEnv(signalIdentifier);\n if (metadata == null) {\n return undefined;\n }\n\n return () => metadata;\n}\n\nfunction getUrlFromEnv(signalIdentifier: string) {\n // This does not change the string beyond trimming on purpose.\n // Normally a user would just use a host and port for gRPC, but the OTLP Exporter specification requires us to\n // use the raw provided endpoint to derive credential settings. Therefore, we only normalize right when\n // we merge user-provided, env-provided and defaults together, and we have determined which credentials to use.\n //\n // Examples:\n // - example.test:4317 -> use secure credentials from environment (or provided via code)\n // - http://example.test:4317 -> use insecure credentials if nothing else is provided\n // - https://example.test:4317 -> use secure credentials from environment (or provided via code)\n\n const specificEndpoint =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n const nonSpecificEndpoint =\n process.env[`OTEL_EXPORTER_OTLP_ENDPOINT`]?.trim();\n\n return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);\n}\n\n/**\n * Determines whether the env var for insecure credentials is set to {@code true}.\n *\n * It will allow the following values as {@code true}\n * - 'true'\n * - 'true '\n * - ' true'\n * - 'TrUE'\n * - 'TRUE'\n *\n * It will not allow:\n * - 'true false'\n * - 'false true'\n * - 'true!'\n * - 'true,true'\n * - '1'\n * - ' '\n *\n * @param signalIdentifier\n */\nfunction getInsecureSettingFromEnv(signalIdentifier: string): boolean {\n const signalSpecificInsecureValue = process.env[\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`\n ]\n ?.toLowerCase()\n .trim();\n const nonSignalSpecificInsecureValue = process.env[\n `OTEL_EXPORTER_OTLP_INSECURE`\n ]\n ?.toLowerCase()\n .trim();\n\n return (\n fallbackIfNullishOrBlank(\n signalSpecificInsecureValue,\n nonSignalSpecificInsecureValue\n ) === 'true'\n );\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();\n const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();\n\n const filePath = fallbackIfNullishOrBlank(\n signalSpecificPath,\n nonSignalSpecificPath\n );\n\n if (filePath != null) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), filePath));\n } catch {\n diag.warn(warningMessage);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction getClientCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE',\n 'Failed to read client certificate chain file'\n );\n}\n\nfunction getClientKeyFromEnv(signalIdentifier: string): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`,\n 'OTEL_EXPORTER_OTLP_CLIENT_KEY',\n 'Failed to read client certificate private key file'\n );\n}\n\nfunction getRootCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CERTIFICATE',\n 'Failed to read root certificate file'\n );\n}\n\nfunction getCredentialsFromEnvIgnoreInsecure(\n signalIdentifier: string\n): ChannelCredentials {\n const clientKey = getClientKeyFromEnv(signalIdentifier);\n const clientCertificate = getClientCertificateFromEnv(signalIdentifier);\n const rootCertificate = getRootCertificateFromEnv(signalIdentifier);\n\n // if the chain is not intact, @grpc/grpc-js will throw. This is fine when a user provides it in code, but env var\n // config is not allowed to throw, so we add this safeguard and try to make the best of it here.\n const clientChainIntact = clientKey != null && clientCertificate != null;\n if (rootCertificate != null && !clientChainIntact) {\n diag.warn(\n 'Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate'\n );\n return createSslCredentials(getRootCertificateFromEnv(signalIdentifier));\n }\n\n return createSslCredentials(rootCertificate, clientKey, clientCertificate);\n}\n\nfunction getCredentialsFromEnv(signalIdentifier: string): ChannelCredentials {\n if (getInsecureSettingFromEnv(signalIdentifier)) {\n return createInsecureCredentials();\n }\n\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n}\n\nexport function getOtlpGrpcConfigurationFromEnv(\n signalIdentifier: string\n): Partial<UnresolvedOtlpGrpcConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n metadata: getMetadataProviderFromEnv(signalIdentifier),\n url: getUrlFromEnv(signalIdentifier),\n credentials: (finalResolvedUrl: string) => {\n // Always assume insecure on http:// and secure on https://, the protocol always takes precedence over the insecure setting.\n // note: the spec does not make any exception for\n // - \"localhost:4317\". If the protocol is omitted, credentials are required unless insecure is set\n // - \"unix://\", as it's neither http:// nor https:// and therefore credentials are required unless insecure is set\n if (finalResolvedUrl.startsWith('http://')) {\n return () => {\n return createInsecureCredentials();\n };\n } else if (finalResolvedUrl.startsWith('https://')) {\n return () => {\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n };\n }\n\n // defer to env settings in this case\n return () => {\n return getCredentialsFromEnv(signalIdentifier);\n };\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"otlp-grpc-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-grpc-env-configuration.ts"],"names":[],"mappings":";;;AAiBA,8CAAmD;AACnD,wEAIoC;AACpC,2EAAoG;AACpG,yBAAyB;AACzB,6BAA6B;AAC7B,4CAA0C;AAE1C,SAAS,wBAAwB,CAC/B,cAAuB,EACvB,iBAA0B;IAE1B,IAAI,cAAc,IAAI,IAAI,IAAI,cAAc,KAAK,EAAE,EAAE;QACnD,OAAO,cAAc,CAAC;KACvB;IAED,IAAI,iBAAiB,IAAI,IAAI,IAAI,iBAAiB,KAAK,EAAE,EAAE;QACzD,OAAO,iBAAiB,CAAC;KAC1B;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,kBAAkB,CAAC,gBAAwB;;IAClD,MAAM,wBAAwB,GAC5B,MAAA,OAAO,CAAC,GAAG,CAAC,sBAAsB,gBAAgB,UAAU,CAAC,0CAAE,IAAI,EAAE,CAAC;IACxE,MAAM,2BAA2B,GAC/B,MAAA,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,0CAAE,IAAI,EAAE,CAAC;IAEpD,MAAM,qBAAqB,GAAG,mBAAY,CAAC,uBAAuB,CAChE,wBAAwB,CACzB,CAAC;IACF,MAAM,wBAAwB,GAAG,mBAAY,CAAC,uBAAuB,CACnE,2BAA2B,CAC5B,CAAC;IAEF,IACE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,KAAK,CAAC;QAC/C,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,MAAM,KAAK,CAAC,EAClD;QACA,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,YAAY,GAAG,MAAM,CAAC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E;gBAClD,OAAO,GAAG,EAAE;oBACV,OAAO,mCAAmC,CAAC,gBAAgB,CAAC,CAAC;gBAC/D,CAAC,CAAC;aACH;YAED,qCAAqC;YACrC,OAAO,GAAG,EAAE;gBACV,OAAO,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;YACjD,CAAC,CAAC;QACJ,CAAC,IACD;AACJ,CAAC;AA5BD,0EA4BC","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 { UnresolvedOtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\nimport { baggageUtils } from '@opentelemetry/core';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { getSharedConfigurationFromEnvironment } from '@opentelemetry/otlp-exporter-base/node-http';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { diag } from '@opentelemetry/api';\n\nfunction fallbackIfNullishOrBlank(\n signalSpecific?: string,\n nonSignalSpecific?: string\n): string | undefined {\n if (signalSpecific != null && signalSpecific !== '') {\n return signalSpecific;\n }\n\n if (nonSignalSpecific != null && nonSignalSpecific !== '') {\n return nonSignalSpecific;\n }\n\n return undefined;\n}\n\nfunction getMetadataFromEnv(signalIdentifier: string): Metadata | undefined {\n const signalSpecificRawHeaders =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();\n const nonSignalSpecificRawHeaders =\n process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();\n\n const signalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = baggageUtils.parseKeyPairsIntoRecord(\n nonSignalSpecificRawHeaders\n );\n\n if (\n Object.keys(signalSpecificHeaders).length === 0 &&\n Object.keys(nonSignalSpecificHeaders).length === 0\n ) {\n return undefined;\n }\n\n const mergeHeaders = Object.assign(\n {},\n nonSignalSpecificHeaders,\n signalSpecificHeaders\n );\n\n const metadata = createEmptyMetadata();\n\n // for this to work, metadata MUST be empty - otherwise `Metadata#set()` will merge items.\n for (const [key, value] of Object.entries(mergeHeaders)) {\n metadata.set(key, value);\n }\n\n return metadata;\n}\n\nfunction getMetadataProviderFromEnv(\n signalIdentifier: string\n): (() => Metadata) | undefined {\n const metadata = getMetadataFromEnv(signalIdentifier);\n if (metadata == null) {\n return undefined;\n }\n\n return () => metadata;\n}\n\nfunction getUrlFromEnv(signalIdentifier: string) {\n // This does not change the string beyond trimming on purpose.\n // Normally a user would just use a host and port for gRPC, but the OTLP Exporter specification requires us to\n // use the raw provided endpoint to derive credential settings. Therefore, we only normalize right when\n // we merge user-provided, env-provided and defaults together, and we have determined which credentials to use.\n //\n // Examples:\n // - example.test:4317 -> use secure credentials from environment (or provided via code)\n // - http://example.test:4317 -> use insecure credentials if nothing else is provided\n // - https://example.test:4317 -> use secure credentials from environment (or provided via code)\n\n const specificEndpoint =\n process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();\n const nonSpecificEndpoint =\n process.env[`OTEL_EXPORTER_OTLP_ENDPOINT`]?.trim();\n\n return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);\n}\n\n/**\n * Determines whether the env var for insecure credentials is set to {@code true}.\n *\n * It will allow the following values as {@code true}\n * - 'true'\n * - 'true '\n * - ' true'\n * - 'TrUE'\n * - 'TRUE'\n *\n * It will not allow:\n * - 'true false'\n * - 'false true'\n * - 'true!'\n * - 'true,true'\n * - '1'\n * - ' '\n *\n * @param signalIdentifier\n */\nfunction getInsecureSettingFromEnv(signalIdentifier: string): boolean {\n const signalSpecificInsecureValue = process.env[\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`\n ]\n ?.toLowerCase()\n .trim();\n const nonSignalSpecificInsecureValue = process.env[\n `OTEL_EXPORTER_OTLP_INSECURE`\n ]\n ?.toLowerCase()\n .trim();\n\n return (\n fallbackIfNullishOrBlank(\n signalSpecificInsecureValue,\n nonSignalSpecificInsecureValue\n ) === 'true'\n );\n}\n\nfunction readFileFromEnv(\n signalSpecificEnvVar: string,\n nonSignalSpecificEnvVar: string,\n warningMessage: string\n): Buffer | undefined {\n const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();\n const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();\n\n const filePath = fallbackIfNullishOrBlank(\n signalSpecificPath,\n nonSignalSpecificPath\n );\n\n if (filePath != null) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), filePath));\n } catch {\n diag.warn(warningMessage);\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction getClientCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE',\n 'Failed to read client certificate chain file'\n );\n}\n\nfunction getClientKeyFromEnv(signalIdentifier: string): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`,\n 'OTEL_EXPORTER_OTLP_CLIENT_KEY',\n 'Failed to read client certificate private key file'\n );\n}\n\nfunction getRootCertificateFromEnv(\n signalIdentifier: string\n): Buffer | undefined {\n return readFileFromEnv(\n `OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`,\n 'OTEL_EXPORTER_OTLP_CERTIFICATE',\n 'Failed to read root certificate file'\n );\n}\n\nfunction getCredentialsFromEnvIgnoreInsecure(\n signalIdentifier: string\n): ChannelCredentials {\n const clientKey = getClientKeyFromEnv(signalIdentifier);\n const clientCertificate = getClientCertificateFromEnv(signalIdentifier);\n const rootCertificate = getRootCertificateFromEnv(signalIdentifier);\n\n // if the chain is not intact, @grpc/grpc-js will throw. This is fine when a user provides it in code, but env var\n // config is not allowed to throw, so we add this safeguard and try to make the best of it here.\n const clientChainIntact = clientKey != null && clientCertificate != null;\n if (rootCertificate != null && !clientChainIntact) {\n diag.warn(\n 'Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate'\n );\n return createSslCredentials(getRootCertificateFromEnv(signalIdentifier));\n }\n\n return createSslCredentials(rootCertificate, clientKey, clientCertificate);\n}\n\nfunction getCredentialsFromEnv(signalIdentifier: string): ChannelCredentials {\n if (getInsecureSettingFromEnv(signalIdentifier)) {\n return createInsecureCredentials();\n }\n\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n}\n\nexport function getOtlpGrpcConfigurationFromEnv(\n signalIdentifier: string\n): Partial<UnresolvedOtlpGrpcConfiguration> {\n return {\n ...getSharedConfigurationFromEnvironment(signalIdentifier),\n metadata: getMetadataProviderFromEnv(signalIdentifier),\n url: getUrlFromEnv(signalIdentifier),\n credentials: (finalResolvedUrl: string) => {\n // Always assume insecure on http:// and secure on https://, the protocol always takes precedence over the insecure setting.\n // note: the spec does not make any exception for\n // - \"localhost:4317\". If the protocol is omitted, credentials are required unless insecure is set\n // - \"unix://\", as it's neither http:// nor https:// and therefore credentials are required unless insecure is set\n if (finalResolvedUrl.startsWith('http://')) {\n return () => {\n return createInsecureCredentials();\n };\n } else if (finalResolvedUrl.startsWith('https://')) {\n return () => {\n return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);\n };\n }\n\n // defer to env settings in this case\n return () => {\n return getCredentialsFromEnv(signalIdentifier);\n };\n },\n };\n}\n"]}
|
|
@@ -35,4 +35,5 @@ export declare class GrpcExporterTransport implements IExporterTransport {
|
|
|
35
35
|
shutdown(): void;
|
|
36
36
|
send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse>;
|
|
37
37
|
}
|
|
38
|
+
export declare function createOtlpGrpcExporterTransport(options: GrpcExporterTransportParameters): IExporterTransport;
|
|
38
39
|
//# sourceMappingURL=grpc-exporter-transport.d.ts.map
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.GrpcExporterTransport = exports.createEmptyMetadata = exports.createSslCredentials = exports.createInsecureCredentials = void 0;
|
|
18
|
+
exports.createOtlpGrpcExporterTransport = exports.GrpcExporterTransport = exports.createEmptyMetadata = exports.createSslCredentials = exports.createInsecureCredentials = void 0;
|
|
19
19
|
// values taken from '@grpc/grpc-js` so that we don't need to require/import it.
|
|
20
20
|
const GRPC_COMPRESSION_NONE = 0;
|
|
21
21
|
const GRPC_COMPRESSION_GZIP = 2;
|
|
@@ -113,4 +113,8 @@ class GrpcExporterTransport {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
exports.GrpcExporterTransport = GrpcExporterTransport;
|
|
116
|
+
function createOtlpGrpcExporterTransport(options) {
|
|
117
|
+
return new GrpcExporterTransport(options);
|
|
118
|
+
}
|
|
119
|
+
exports.createOtlpGrpcExporterTransport = createOtlpGrpcExporterTransport;
|
|
116
120
|
//# sourceMappingURL=grpc-exporter-transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-exporter-transport.js","sourceRoot":"","sources":["../../src/grpc-exporter-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAeH,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,SAAS,iBAAiB,CAAC,WAA4B;IACrD,OAAO,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,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QAAQ;wBACd,MAAM,EAAE,SAAS;qBAClB,CAAC,CAAC;iBACJ;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtFD,sDAsFC","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 {\n Metadata,\n ServiceError,\n ChannelCredentials,\n Client,\n} from '@grpc/grpc-js';\nimport {\n ExportResponse,\n IExporterTransport,\n} from '@opentelemetry/otlp-exporter-base';\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}\n\nexport class GrpcExporterTransport implements IExporterTransport {\n private _client?: Client;\n private _metadata?: Metadata;\n\n constructor(private _parameters: GrpcExporterTransportParameters) {}\n\n shutdown() {\n this._client?.close();\n }\n\n send(data: Uint8Array, timeoutMillis: number): 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 const deadline = Date.now() + 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 // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore The gRPC client constructor is created on runtime, so we don't have any types for the resulting client.\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"]}
|
|
1
|
+
{"version":3,"file":"grpc-exporter-transport.js","sourceRoot":"","sources":["../../src/grpc-exporter-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAeH,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,SAAS,iBAAiB,CAAC,WAA4B;IACrD,OAAO,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC;AAChF,CAAC;AAED,SAAgB,yBAAyB;IACvC,iHAAiH;IACjH,MAAM,EACJ,WAAW;IACX,8DAA8D;MAC/D,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,cAAc,EAAE,CAAC;AACtC,CAAC;AAPD,8DAOC;AAED,SAAgB,oBAAoB,CAClC,QAAiB,EACjB,UAAmB,EACnB,SAAkB;IAElB,iHAAiH;IACjH,MAAM,EACJ,WAAW;IACX,8DAA8D;MAC/D,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7B,OAAO,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAChE,CAAC;AAXD,oDAWC;AAED,SAAgB,mBAAmB;IACjC,iHAAiH;IACjH,MAAM,EACJ,QAAQ;IACR,8D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B,KAAK,EAAE,KAAK;iBACb,CAAC,CAAC;aACJ;SACF;QAED,OAAO,IAAI,OAAO,CAAiB,OAAO,CAAC,EAAE;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC;YAE5C,2BAA2B;YAC3B,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE;gBAC1B,OAAO,OAAO,CAAC;oBACb,KAAK,EAAE,IAAI,KAAK,CAAC,mBAAmB,CAAC;oBACrC,MAAM,EAAE,SAAS;iBAClB,CAAC,CAAC;aACJ;YAED,6DAA6D;YAC7D,qHAAqH;YACrH,IAAI,CAAC,OAAO,CAAC,MAAM,CACjB,MAAM,EACN,IAAI,CAAC,SAAS,EACd,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACtB,CAAC,GAAiB,EAAE,QAAgB,EAAE,EAAE;gBACtC,IAAI,GAAG,EAAE;oBACP,OAAO,CAAC;wBACN,MAAM,EAAE,SAAS;wBACjB,KAAK,EAAE,GAAG;qBACX,CAAC,CAAC;iBACJ;qBAAM;oBACL,OAAO,CAAC;wBACN,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,SAAS;qBAClB,CAAC,CAAC;iBACJ;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtFD,sDAsFC;AAED,SAAgB,+BAA+B,CAC7C,OAAwC;IAExC,OAAO,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAJD,0EAIC","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 {\n Metadata,\n ServiceError,\n ChannelCredentials,\n Client,\n} from '@grpc/grpc-js';\nimport {\n ExportResponse,\n IExporterTransport,\n} from '@opentelemetry/otlp-exporter-base';\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}\n\nexport class GrpcExporterTransport implements IExporterTransport {\n private _client?: Client;\n private _metadata?: Metadata;\n\n constructor(private _parameters: GrpcExporterTransportParameters) {}\n\n shutdown() {\n this._client?.close();\n }\n\n send(data: Uint8Array, timeoutMillis: number): 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 const deadline = Date.now() + 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 // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore The gRPC client constructor is created on runtime, so we don't have any types for the resulting client.\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\nexport function createOtlpGrpcExporterTransport(\n options: GrpcExporterTransportParameters\n): IExporterTransport {\n return new GrpcExporterTransport(options);\n}\n"]}
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { convertLegacyOtlpGrpcOptions } from './configuration/convert-legacy-otlp-grpc-options';
|
|
2
|
+
export { createOtlpGrpcExportDelegate } from './otlp-grpc-export-delegate';
|
|
2
3
|
export { OTLPGRPCExporterConfigNode } from './types';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/build/src/index.js
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
var
|
|
20
|
-
Object.defineProperty(exports, "
|
|
18
|
+
exports.createOtlpGrpcExportDelegate = exports.convertLegacyOtlpGrpcOptions = void 0;
|
|
19
|
+
var convert_legacy_otlp_grpc_options_1 = require("./configuration/convert-legacy-otlp-grpc-options");
|
|
20
|
+
Object.defineProperty(exports, "convertLegacyOtlpGrpcOptions", { enumerable: true, get: function () { return convert_legacy_otlp_grpc_options_1.convertLegacyOtlpGrpcOptions; } });
|
|
21
|
+
var otlp_grpc_export_delegate_1 = require("./otlp-grpc-export-delegate");
|
|
22
|
+
Object.defineProperty(exports, "createOtlpGrpcExportDelegate", { enumerable: true, get: function () { return otlp_grpc_export_delegate_1.createOtlpGrpcExportDelegate; } });
|
|
21
23
|
//# 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;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,qGAAgG;AAAvF,gJAAA,4BAA4B,OAAA;AACrC,yEAA2E;AAAlE,yIAAA,4BAA4B,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 { convertLegacyOtlpGrpcOptions } from './configuration/convert-legacy-otlp-grpc-options';\nexport { createOtlpGrpcExportDelegate } from './otlp-grpc-export-delegate';\nexport { OTLPGRPCExporterConfigNode } from './types';\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IOtlpExportDelegate } from '@opentelemetry/otlp-exporter-base';
|
|
2
|
+
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
3
|
+
import { OtlpGrpcConfiguration } from './configuration/otlp-grpc-configuration';
|
|
4
|
+
export declare function createOtlpGrpcExportDelegate<Internal, Response>(options: OtlpGrpcConfiguration, serializer: ISerializer<Internal, Response>, grpcName: string, grpcPath: string): IOtlpExportDelegate<Internal>;
|
|
5
|
+
//# sourceMappingURL=otlp-grpc-export-delegate.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
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.createOtlpGrpcExportDelegate = void 0;
|
|
19
|
+
const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
|
|
20
|
+
const grpc_exporter_transport_1 = require("./grpc-exporter-transport");
|
|
21
|
+
function createOtlpGrpcExportDelegate(options, serializer, grpcName, grpcPath) {
|
|
22
|
+
return (0, otlp_exporter_base_1.createOtlpNetworkExportDelegate)(options, serializer, (0, grpc_exporter_transport_1.createOtlpGrpcExporterTransport)({
|
|
23
|
+
address: options.url,
|
|
24
|
+
compression: options.compression,
|
|
25
|
+
credentials: options.credentials,
|
|
26
|
+
metadata: options.metadata,
|
|
27
|
+
grpcName,
|
|
28
|
+
grpcPath,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
exports.createOtlpGrpcExportDelegate = createOtlpGrpcExportDelegate;
|
|
32
|
+
//# sourceMappingURL=otlp-grpc-export-delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otlp-grpc-export-delegate.js","sourceRoot":"","sources":["../../src/otlp-grpc-export-delegate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,0EAG2C;AAG3C,uEAA4E;AAE5E,SAAgB,4BAA4B,CAC1C,OAA8B,EAC9B,UAA2C,EAC3C,QAAgB,EAChB,QAAgB;IAEhB,OAAO,IAAA,oDAA+B,EACpC,OAAO,EACP,UAAU,EACV,IAAA,yDAA+B,EAAC;QAC9B,OAAO,EAAE,OAAO,CAAC,GAAG;QACpB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ;QACR,QAAQ;KACT,CAAC,CACH,CAAC;AACJ,CAAC;AAlBD,oEAkBC","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 {\n createOtlpNetworkExportDelegate,\n IOtlpExportDelegate,\n} from '@opentelemetry/otlp-exporter-base';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { OtlpGrpcConfiguration } from './configuration/otlp-grpc-configuration';\nimport { createOtlpGrpcExporterTransport } from './grpc-exporter-transport';\n\nexport function createOtlpGrpcExportDelegate<Internal, Response>(\n options: OtlpGrpcConfiguration,\n serializer: ISerializer<Internal, Response>,\n grpcName: string,\n grpcPath: string\n): IOtlpExportDelegate<Internal> {\n return createOtlpNetworkExportDelegate(\n options,\n serializer,\n createOtlpGrpcExporterTransport({\n address: options.url,\n compression: options.compression,\n credentials: options.credentials,\n metadata: options.metadata,\n grpcName,\n grpcPath,\n })\n );\n}\n"]}
|
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.56.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,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.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,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.56.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/otlp-grpc-exporter-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "OpenTelemetry OTLP-gRPC Exporter base (for internal use only)",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@opentelemetry/api": "1.9.0",
|
|
50
|
-
"@opentelemetry/resources": "1.
|
|
51
|
-
"@opentelemetry/sdk-trace-base": "1.
|
|
52
|
-
"@types/mocha": "10.0.
|
|
50
|
+
"@opentelemetry/resources": "1.29.0",
|
|
51
|
+
"@opentelemetry/sdk-trace-base": "1.29.0",
|
|
52
|
+
"@types/mocha": "10.0.10",
|
|
53
53
|
"@types/node": "18.6.5",
|
|
54
54
|
"@types/sinon": "17.0.3",
|
|
55
55
|
"cross-var": "1.1.0",
|
|
@@ -65,11 +65,11 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@grpc/grpc-js": "^1.7.1",
|
|
68
|
-
"@opentelemetry/core": "1.
|
|
69
|
-
"@opentelemetry/otlp-exporter-base": "0.
|
|
70
|
-
"@opentelemetry/otlp-transformer": "0.
|
|
68
|
+
"@opentelemetry/core": "1.29.0",
|
|
69
|
+
"@opentelemetry/otlp-exporter-base": "0.56.0",
|
|
70
|
+
"@opentelemetry/otlp-transformer": "0.56.0"
|
|
71
71
|
},
|
|
72
72
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-grpc-exporter-base",
|
|
73
73
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "85dcbc7c55f002837f1bf1bf01145dbb34a55b40"
|
|
75
75
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { OTLPGRPCExporterConfigNode } from './types';
|
|
2
|
-
import { OTLPExporterBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
|
|
3
|
-
import { ISerializer } from '@opentelemetry/otlp-transformer';
|
|
4
|
-
/**
|
|
5
|
-
* OTLP Exporter abstract base class
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class OTLPGRPCExporterNodeBase<ExportItem, ServiceResponse> extends OTLPExporterBase<OTLPGRPCExporterConfigNode, ExportItem> {
|
|
8
|
-
private _transport;
|
|
9
|
-
private _serializer;
|
|
10
|
-
private _timeoutMillis;
|
|
11
|
-
constructor(config: OTLPGRPCExporterConfigNode | undefined, serializer: ISerializer<ExportItem[], ServiceResponse>, grpcName: string, grpcPath: string, signalIdentifier: string);
|
|
12
|
-
onShutdown(): void;
|
|
13
|
-
send(objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=OTLPGRPCExporterNodeBase.d.ts.map
|
|
@@ -1,99 +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.OTLPGRPCExporterNodeBase = void 0;
|
|
19
|
-
const api_1 = require("@opentelemetry/api");
|
|
20
|
-
const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
|
|
21
|
-
const grpc_exporter_transport_1 = require("./grpc-exporter-transport");
|
|
22
|
-
const otlp_grpc_configuration_1 = require("./configuration/otlp-grpc-configuration");
|
|
23
|
-
const otlp_grpc_env_configuration_1 = require("./configuration/otlp-grpc-env-configuration");
|
|
24
|
-
/**
|
|
25
|
-
* OTLP Exporter abstract base class
|
|
26
|
-
*/
|
|
27
|
-
class OTLPGRPCExporterNodeBase extends otlp_exporter_base_1.OTLPExporterBase {
|
|
28
|
-
constructor(config = {}, serializer, grpcName, grpcPath, signalIdentifier) {
|
|
29
|
-
super(config);
|
|
30
|
-
// keep credentials locally in case user updates the reference on the config object
|
|
31
|
-
const userProvidedCredentials = config.credentials;
|
|
32
|
-
const actualConfig = (0, otlp_grpc_configuration_1.mergeOtlpGrpcConfigurationWithDefaults)({
|
|
33
|
-
url: config.url,
|
|
34
|
-
metadata: () => {
|
|
35
|
-
var _a;
|
|
36
|
-
// metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.
|
|
37
|
-
return (_a = config.metadata) !== null && _a !== void 0 ? _a : (0, grpc_exporter_transport_1.createEmptyMetadata)();
|
|
38
|
-
},
|
|
39
|
-
compression: config.compression,
|
|
40
|
-
timeoutMillis: config.timeoutMillis,
|
|
41
|
-
concurrencyLimit: config.concurrencyLimit,
|
|
42
|
-
credentials: userProvidedCredentials != null
|
|
43
|
-
? () => userProvidedCredentials
|
|
44
|
-
: undefined,
|
|
45
|
-
}, (0, otlp_grpc_env_configuration_1.getOtlpGrpcConfigurationFromEnv)(signalIdentifier), (0, otlp_grpc_configuration_1.getOtlpGrpcDefaultConfiguration)());
|
|
46
|
-
this._serializer = serializer;
|
|
47
|
-
this._timeoutMillis = actualConfig.timeoutMillis;
|
|
48
|
-
this._concurrencyLimit = actualConfig.concurrencyLimit;
|
|
49
|
-
if (config.headers) {
|
|
50
|
-
api_1.diag.warn('Headers cannot be set when using grpc');
|
|
51
|
-
}
|
|
52
|
-
this._transport = new grpc_exporter_transport_1.GrpcExporterTransport({
|
|
53
|
-
address: actualConfig.url,
|
|
54
|
-
compression: actualConfig.compression,
|
|
55
|
-
credentials: actualConfig.credentials,
|
|
56
|
-
grpcName: grpcName,
|
|
57
|
-
grpcPath: grpcPath,
|
|
58
|
-
metadata: actualConfig.metadata,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
onShutdown() {
|
|
62
|
-
this._transport.shutdown();
|
|
63
|
-
}
|
|
64
|
-
send(objects, onSuccess, onError) {
|
|
65
|
-
if (this._shutdownOnce.isCalled) {
|
|
66
|
-
api_1.diag.debug('Shutdown already started. Cannot send objects');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const data = this._serializer.serializeRequest(objects);
|
|
70
|
-
if (data == null) {
|
|
71
|
-
onError(new Error('Could not serialize message'));
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const promise = this._transport
|
|
75
|
-
.send(data, this._timeoutMillis)
|
|
76
|
-
.then(response => {
|
|
77
|
-
if (response.status === 'success') {
|
|
78
|
-
onSuccess();
|
|
79
|
-
}
|
|
80
|
-
else if (response.status === 'failure' && response.error) {
|
|
81
|
-
onError(response.error);
|
|
82
|
-
}
|
|
83
|
-
else if (response.status === 'retryable') {
|
|
84
|
-
onError(new otlp_exporter_base_1.OTLPExporterError('Export failed with retryable status'));
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
onError(new otlp_exporter_base_1.OTLPExporterError('Export failed with unknown error'));
|
|
88
|
-
}
|
|
89
|
-
}, onError);
|
|
90
|
-
this._sendingPromises.push(promise);
|
|
91
|
-
const popPromise = () => {
|
|
92
|
-
const index = this._sendingPromises.indexOf(promise);
|
|
93
|
-
this._sendingPromises.splice(index, 1);
|
|
94
|
-
};
|
|
95
|
-
promise.then(popPromise, popPromise);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
exports.OTLPGRPCExporterNodeBase = OTLPGRPCExporterNodeBase;
|
|
99
|
-
//# sourceMappingURL=OTLPGRPCExporterNodeBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OTLPGRPCExporterNodeBase.js","sourceRoot":"","sources":["../../src/OTLPGRPCExporterNodeBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAE1C,0EAG2C;AAC3C,uEAGmC;AAGnC,qFAGiD;AACjD,6FAA8F;AAE9F;;GAEG;AACH,MAAsB,wBAGpB,SAAQ,qCAAwD;IAKhE,YACE,SAAqC,EAAE,EACvC,UAAsD,EACtD,QAAgB,EAChB,QAAgB,EAChB,gBAAwB;QAExB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,mFA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C;CACF;AA/FD,4DA+FC","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 { OTLPGRPCExporterConfigNode } from './types';\nimport {\n OTLPExporterBase,\n OTLPExporterError,\n} from '@opentelemetry/otlp-exporter-base';\nimport {\n createEmptyMetadata,\n GrpcExporterTransport,\n} from './grpc-exporter-transport';\nimport { ISerializer } from '@opentelemetry/otlp-transformer';\nimport { IExporterTransport } from '@opentelemetry/otlp-exporter-base';\nimport {\n getOtlpGrpcDefaultConfiguration,\n mergeOtlpGrpcConfigurationWithDefaults,\n} from './configuration/otlp-grpc-configuration';\nimport { getOtlpGrpcConfigurationFromEnv } from './configuration/otlp-grpc-env-configuration';\n\n/**\n * OTLP Exporter abstract base class\n */\nexport abstract class OTLPGRPCExporterNodeBase<\n ExportItem,\n ServiceResponse,\n> extends OTLPExporterBase<OTLPGRPCExporterConfigNode, ExportItem> {\n private _transport: IExporterTransport;\n private _serializer: ISerializer<ExportItem[], ServiceResponse>;\n private _timeoutMillis: number;\n\n constructor(\n config: OTLPGRPCExporterConfigNode = {},\n serializer: ISerializer<ExportItem[], ServiceResponse>,\n grpcName: string,\n grpcPath: string,\n signalIdentifier: string\n ) {\n super(config);\n // keep credentials locally in case user updates the reference on the config object\n const userProvidedCredentials = config.credentials;\n const actualConfig = mergeOtlpGrpcConfigurationWithDefaults(\n {\n url: config.url,\n metadata: () => {\n // metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.\n return config.metadata ?? createEmptyMetadata();\n },\n compression: config.compression,\n timeoutMillis: config.timeoutMillis,\n concurrencyLimit: config.concurrencyLimit,\n credentials:\n userProvidedCredentials != null\n ? () => userProvidedCredentials\n : undefined,\n },\n getOtlpGrpcConfigurationFromEnv(signalIdentifier),\n getOtlpGrpcDefaultConfiguration()\n );\n this._serializer = serializer;\n this._timeoutMillis = actualConfig.timeoutMillis;\n this._concurrencyLimit = actualConfig.concurrencyLimit;\n if (config.headers) {\n diag.warn('Headers cannot be set when using grpc');\n }\n\n this._transport = new GrpcExporterTransport({\n address: actualConfig.url,\n compression: actualConfig.compression,\n credentials: actualConfig.credentials,\n grpcName: grpcName,\n grpcPath: grpcPath,\n metadata: actualConfig.metadata,\n });\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 data = this._serializer.serializeRequest(objects);\n\n if (data == null) {\n onError(new Error('Could not serialize message'));\n return;\n }\n\n const promise = this._transport\n .send(data, this._timeoutMillis)\n .then(response => {\n if (response.status === 'success') {\n onSuccess();\n } else if (response.status === 'failure' && response.error) {\n onError(response.error);\n } else if (response.status === 'retryable') {\n onError(new OTLPExporterError('Export failed with retryable status'));\n } else {\n onError(new OTLPExporterError('Export failed with unknown error'));\n }\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"]}
|