@opentelemetry/otlp-grpc-exporter-base 0.222.0 → 0.300.0-development.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.
Files changed (89) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +44 -0
  2. package/dist/_virtual/_rolldown/runtime.mjs +37 -0
  3. package/dist/configuration/convert-legacy-otlp-grpc-options.cjs +28 -0
  4. package/dist/configuration/convert-legacy-otlp-grpc-options.cjs.map +1 -0
  5. package/dist/configuration/convert-legacy-otlp-grpc-options.d.cts +12 -0
  6. package/dist/configuration/convert-legacy-otlp-grpc-options.d.cts.map +1 -0
  7. package/dist/configuration/convert-legacy-otlp-grpc-options.d.mts +12 -0
  8. package/dist/configuration/convert-legacy-otlp-grpc-options.d.mts.map +1 -0
  9. package/dist/configuration/convert-legacy-otlp-grpc-options.mjs +27 -0
  10. package/dist/configuration/convert-legacy-otlp-grpc-options.mjs.map +1 -0
  11. package/dist/configuration/otlp-grpc-configuration.cjs +50 -0
  12. package/dist/configuration/otlp-grpc-configuration.cjs.map +1 -0
  13. package/dist/configuration/otlp-grpc-configuration.d.cts +12 -0
  14. package/dist/configuration/otlp-grpc-configuration.d.cts.map +1 -0
  15. package/dist/configuration/otlp-grpc-configuration.d.mts +12 -0
  16. package/dist/configuration/otlp-grpc-configuration.d.mts.map +1 -0
  17. package/dist/configuration/otlp-grpc-configuration.mjs +47 -0
  18. package/dist/configuration/otlp-grpc-configuration.mjs.map +1 -0
  19. package/dist/configuration/otlp-grpc-env-configuration.cjs +117 -0
  20. package/dist/configuration/otlp-grpc-env-configuration.cjs.map +1 -0
  21. package/dist/configuration/otlp-grpc-env-configuration.mjs +114 -0
  22. package/dist/configuration/otlp-grpc-env-configuration.mjs.map +1 -0
  23. package/dist/create-service-client-constructor.cjs +50 -0
  24. package/dist/create-service-client-constructor.cjs.map +1 -0
  25. package/dist/create-service-client-constructor.mjs +37 -0
  26. package/dist/create-service-client-constructor.mjs.map +1 -0
  27. package/dist/grpc-exporter-transport.cjs +110 -0
  28. package/dist/grpc-exporter-transport.cjs.map +1 -0
  29. package/dist/grpc-exporter-transport.d.cts +10 -0
  30. package/dist/grpc-exporter-transport.d.cts.map +1 -0
  31. package/dist/grpc-exporter-transport.d.mts +10 -0
  32. package/dist/grpc-exporter-transport.d.mts.map +1 -0
  33. package/dist/grpc-exporter-transport.mjs +106 -0
  34. package/dist/grpc-exporter-transport.mjs.map +1 -0
  35. package/dist/index.cjs +11 -0
  36. package/dist/index.d.cts +5 -0
  37. package/dist/index.d.mts +5 -0
  38. package/dist/index.mjs +4 -0
  39. package/dist/otlp-grpc-export-delegate.cjs +39 -0
  40. package/dist/otlp-grpc-export-delegate.cjs.map +1 -0
  41. package/dist/otlp-grpc-export-delegate.d.cts +10 -0
  42. package/dist/otlp-grpc-export-delegate.d.cts.map +1 -0
  43. package/dist/otlp-grpc-export-delegate.d.mts +10 -0
  44. package/dist/otlp-grpc-export-delegate.d.mts.map +1 -0
  45. package/dist/otlp-grpc-export-delegate.mjs +38 -0
  46. package/dist/otlp-grpc-export-delegate.mjs.map +1 -0
  47. package/dist/semconv.cjs +19 -0
  48. package/dist/semconv.cjs.map +1 -0
  49. package/dist/semconv.mjs +18 -0
  50. package/dist/semconv.mjs.map +1 -0
  51. package/dist/types.d.cts +15 -0
  52. package/dist/types.d.cts.map +1 -0
  53. package/dist/types.d.mts +15 -0
  54. package/dist/types.d.mts.map +1 -0
  55. package/dist/version.cjs +7 -0
  56. package/dist/version.cjs.map +1 -0
  57. package/dist/version.mjs +6 -0
  58. package/dist/version.mjs.map +1 -0
  59. package/package.json +25 -16
  60. package/build/src/configuration/convert-legacy-otlp-grpc-options.d.ts +0 -9
  61. package/build/src/configuration/convert-legacy-otlp-grpc-options.js +0 -31
  62. package/build/src/configuration/convert-legacy-otlp-grpc-options.js.map +0 -1
  63. package/build/src/configuration/otlp-grpc-configuration.d.ts +0 -23
  64. package/build/src/configuration/otlp-grpc-configuration.js +0 -78
  65. package/build/src/configuration/otlp-grpc-configuration.js.map +0 -1
  66. package/build/src/configuration/otlp-grpc-env-configuration.d.ts +0 -3
  67. package/build/src/configuration/otlp-grpc-env-configuration.js +0 -159
  68. package/build/src/configuration/otlp-grpc-env-configuration.js.map +0 -1
  69. package/build/src/create-service-client-constructor.d.ts +0 -10
  70. package/build/src/create-service-client-constructor.js +0 -39
  71. package/build/src/create-service-client-constructor.js.map +0 -1
  72. package/build/src/grpc-exporter-transport.d.ts +0 -42
  73. package/build/src/grpc-exporter-transport.js +0 -137
  74. package/build/src/grpc-exporter-transport.js.map +0 -1
  75. package/build/src/index.d.ts +0 -5
  76. package/build/src/index.js +0 -17
  77. package/build/src/index.js.map +0 -1
  78. package/build/src/otlp-grpc-export-delegate.d.ts +0 -8
  79. package/build/src/otlp-grpc-export-delegate.js +0 -56
  80. package/build/src/otlp-grpc-export-delegate.js.map +0 -1
  81. package/build/src/semconv.d.ts +0 -14
  82. package/build/src/semconv.js +0 -26
  83. package/build/src/semconv.js.map +0 -1
  84. package/build/src/types.d.ts +0 -12
  85. package/build/src/types.js +0 -7
  86. package/build/src/types.js.map +0 -1
  87. package/build/src/version.d.ts +0 -2
  88. package/build/src/version.js +0 -10
  89. package/build/src/version.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ //#region src/semconv.ts
2
+ /**
3
+ * Status code of the RPC returned by the RPC server or generated by the client
4
+ *
5
+ * @example OK
6
+ * @example DEADLINE_EXCEEDED
7
+ * @example -32602
8
+ *
9
+ * @note Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes.
10
+ * Semantic conventions for individual RPC frameworks **SHOULD** document what `rpc.response.status_code` means in the context of that system and which values are considered to represent errors.
11
+ *
12
+ * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
13
+ */
14
+ const ATTR_RPC_RESPONSE_STATUS_CODE = "rpc.response.status_code";
15
+ //#endregion
16
+ export { ATTR_RPC_RESPONSE_STATUS_CODE };
17
+
18
+ //# sourceMappingURL=semconv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semconv.mjs","names":[],"sources":["../src/semconv.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * Status code of the RPC returned by the RPC server or generated by the client\n *\n * @example OK\n * @example DEADLINE_EXCEEDED\n * @example -32602\n *\n * @note Usually it represents an error code, but may also represent partial success, warning, or differentiate between various types of successful outcomes.\n * Semantic conventions for individual RPC frameworks **SHOULD** document what `rpc.response.status_code` means in the context of that system and which values are considered to represent errors.\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_RPC_RESPONSE_STATUS_CODE =\n 'rpc.response.status_code' as const;\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAa,gCACX"}
@@ -0,0 +1,15 @@
1
+ import { ChannelCredentials, Metadata } from "@grpc/grpc-js";
2
+ import { CompressionAlgorithm, OTLPExporterConfigBase } from "@opentelemetry/otlp-exporter-base";
3
+ //#region src/types.d.ts
4
+ /**
5
+ * OTLP Exporter Config for Node
6
+ */
7
+ interface OTLPGRPCExporterConfigNode extends Omit<OTLPExporterConfigBase, 'headers'> {
8
+ credentials?: ChannelCredentials;
9
+ metadata?: Metadata;
10
+ compression?: CompressionAlgorithm;
11
+ userAgent?: string;
12
+ }
13
+ //#endregion
14
+ export { OTLPGRPCExporterConfigNode };
15
+ //# sourceMappingURL=types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.d.ts"],"mappings":";;;;;;UAKiB,mCAAmC,KAAK;EACrD,cAAc;EACd,WAAW;EACX,cAAc;EACd"}
@@ -0,0 +1,15 @@
1
+ import { CompressionAlgorithm, OTLPExporterConfigBase } from "@opentelemetry/otlp-exporter-base";
2
+ import { ChannelCredentials, Metadata } from "@grpc/grpc-js";
3
+ //#region src/types.d.ts
4
+ /**
5
+ * OTLP Exporter Config for Node
6
+ */
7
+ interface OTLPGRPCExporterConfigNode extends Omit<OTLPExporterConfigBase, 'headers'> {
8
+ credentials?: ChannelCredentials;
9
+ metadata?: Metadata;
10
+ compression?: CompressionAlgorithm;
11
+ userAgent?: string;
12
+ }
13
+ //#endregion
14
+ export { OTLPGRPCExporterConfigNode };
15
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.d.ts"],"mappings":";;;;;;UAKiB,mCAAmC,KAAK;EACrD,cAAc;EACd,WAAW;EACX,cAAc;EACd"}
@@ -0,0 +1,7 @@
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
+ //#region src/version.ts
3
+ const VERSION = "0.300.0-development.0";
4
+ //#endregion
5
+ exports.VERSION = VERSION;
6
+
7
+ //# sourceMappingURL=version.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.cjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.300.0-development.0';\n"],"mappings":";;AAMA,MAAa,UAAU"}
@@ -0,0 +1,6 @@
1
+ //#region src/version.ts
2
+ const VERSION = "0.300.0-development.0";
3
+ //#endregion
4
+ export { VERSION };
5
+
6
+ //# sourceMappingURL=version.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.mjs","names":[],"sources":["../src/version.ts"],"sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.300.0-development.0';\n"],"mappings":";AAMA,MAAa,UAAU"}
package/package.json CHANGED
@@ -1,22 +1,33 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-grpc-exporter-base",
3
- "version": "0.222.0",
3
+ "version": "0.300.0-development.0",
4
4
  "description": "OpenTelemetry OTLP-gRPC Exporter base (for internal use only)",
5
- "main": "build/src/index.js",
6
- "types": "build/src/index.d.ts",
5
+ "main": "./dist/index.cjs",
6
+ "types": "./dist/index.d.cts",
7
+ "exports": {
8
+ ".": {
9
+ "import": {
10
+ "types": "./dist/index.d.mts",
11
+ "default": "./dist/index.mjs"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ }
18
+ },
7
19
  "repository": "open-telemetry/opentelemetry-js",
8
20
  "scripts": {
9
21
  "prepublishOnly": "npm run compile",
10
- "compile": "tsc --build",
11
- "clean": "tsc --build --clean",
22
+ "compile": "tsdown",
23
+ "clean": "rimraf dist build",
12
24
  "lint": "eslint .",
13
25
  "lint:fix": "eslint . --fix",
14
26
  "tdd": "npm run test -- --watch-extensions ts --watch",
15
27
  "test": "nyc mocha 'test/**/*.test.ts'",
16
28
  "version": "node ../../../scripts/version-update.js",
17
29
  "watch": "tsc -w",
18
- "prewatch": "npm run precompile",
19
- "align-api-deps": "node ../../../scripts/align-api-deps.js",
30
+ "align-api-deps": "node ../../../scripts/align-api-deps.mjs",
20
31
  "maint:regenerate-test-certs": "cd test/certs && ./regenerate.sh"
21
32
  },
22
33
  "keywords": [
@@ -31,15 +42,13 @@
31
42
  "author": "OpenTelemetry Authors",
32
43
  "license": "Apache-2.0",
33
44
  "engines": {
34
- "node": "^18.19.0 || >=20.6.0"
45
+ "node": ">=22.15.0"
35
46
  },
36
47
  "files": [
37
- "build/src/**/*.js",
38
- "build/src/**/*.js.map",
39
- "build/src/**/*.d.ts",
40
48
  "doc",
41
49
  "LICENSE",
42
- "README.md"
50
+ "README.md",
51
+ "dist"
43
52
  ],
44
53
  "publishConfig": {
45
54
  "access": "public"
@@ -60,11 +69,11 @@
60
69
  },
61
70
  "dependencies": {
62
71
  "@grpc/grpc-js": "^1.14.3",
63
- "@opentelemetry/core": "2.11.0",
64
- "@opentelemetry/otlp-exporter-base": "0.222.0",
65
- "@opentelemetry/otlp-transformer": "0.222.0"
72
+ "@opentelemetry/core": "3.0.0-development.0",
73
+ "@opentelemetry/otlp-exporter-base": "0.300.0-development.0",
74
+ "@opentelemetry/otlp-transformer": "0.300.0-development.0"
66
75
  },
67
76
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-grpc-exporter-base",
68
77
  "sideEffects": false,
69
- "gitHead": "0b72a81636fa476e8f1f1afd2ae0c90a1362194c"
78
+ "gitHead": "ad3499bf70ee996f5565e5cd00f2c5fcb2e87042"
70
79
  }
@@ -1,9 +0,0 @@
1
- import type { OTLPGRPCExporterConfigNode } from '../types';
2
- import type { 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
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertLegacyOtlpGrpcOptions = void 0;
4
- const otlp_grpc_configuration_1 = require("./otlp-grpc-configuration");
5
- const grpc_exporter_transport_1 = require("../grpc-exporter-transport");
6
- const otlp_grpc_env_configuration_1 = require("./otlp-grpc-env-configuration");
7
- /**
8
- * @deprecated
9
- * @param config
10
- * @param signalIdentifier
11
- */
12
- function convertLegacyOtlpGrpcOptions(config, signalIdentifier) {
13
- // keep credentials locally in case user updates the reference on the config object
14
- const userProvidedCredentials = config.credentials;
15
- return (0, otlp_grpc_configuration_1.mergeOtlpGrpcConfigurationWithDefaults)({
16
- url: config.url,
17
- metadata: () => {
18
- // metadata resolution strategy is merge, so we can return empty here, and it will not override the rest of the settings.
19
- return config.metadata ?? (0, grpc_exporter_transport_1.createEmptyMetadata)();
20
- },
21
- compression: config.compression,
22
- timeoutMillis: config.timeoutMillis,
23
- concurrencyLimit: config.concurrencyLimit,
24
- credentials: userProvidedCredentials != null
25
- ? () => userProvidedCredentials
26
- : undefined,
27
- userAgent: config.userAgent,
28
- }, (0, otlp_grpc_env_configuration_1.getOtlpGrpcConfigurationFromEnv)(signalIdentifier), (0, otlp_grpc_configuration_1.getOtlpGrpcDefaultConfiguration)());
29
- }
30
- exports.convertLegacyOtlpGrpcOptions = convertLegacyOtlpGrpcOptions;
31
- //# sourceMappingURL=convert-legacy-otlp-grpc-options.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert-legacy-otlp-grpc-options.js","sourceRoot":"","sources":["../../../src/configuration/convert-legacy-otlp-grpc-options.ts"],"names":[],"mappings":";;;AAMA,uEAGmC;AACnC,wEAAiE;AACjE,+EAAgF;AAEhF;;;;GAIG;AACH,SAAgB,4BAA4B,CAC1C,MAAkC,EAClC,gBAAwB;IAExB,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,MAAM,CAAC,QAAQ,IAAI,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;QACf,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,EACD,IAAA,6DAA+B,EAAC,gBAAgB,CAAC,EACjD,IAAA,yDAA+B,GAAE,CAClC,CAAC;AACJ,CAAC;AAzBD,oEAyBC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { OTLPGRPCExporterConfigNode } from '../types';\nimport type { OtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport {\n getOtlpGrpcDefaultConfiguration,\n mergeOtlpGrpcConfigurationWithDefaults,\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 // 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 userAgent: config.userAgent,\n },\n getOtlpGrpcConfigurationFromEnv(signalIdentifier),\n getOtlpGrpcDefaultConfiguration()\n );\n}\n"]}
@@ -1,23 +0,0 @@
1
- import type { OtlpSharedConfiguration } from '@opentelemetry/otlp-exporter-base';
2
- import type { ChannelCredentials, Metadata } from '@grpc/grpc-js';
3
- export interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {
4
- url: string;
5
- metadata: () => Metadata;
6
- credentials: () => ChannelCredentials;
7
- userAgent?: string;
8
- }
9
- /**
10
- * Unresolved configuration where parts of the config may depend on other config options being resolved first.
11
- */
12
- export interface UnresolvedOtlpGrpcConfiguration extends OtlpSharedConfiguration {
13
- url: string;
14
- metadata: () => Metadata;
15
- /**
16
- * Credentials are based on the final resolved URL
17
- */
18
- credentials: (url: string) => () => ChannelCredentials;
19
- }
20
- export declare function validateAndNormalizeUrl(url: string): string;
21
- export declare function mergeOtlpGrpcConfigurationWithDefaults(userProvidedConfiguration: Partial<OtlpGrpcConfiguration>, fallbackConfiguration: Partial<UnresolvedOtlpGrpcConfiguration>, defaultConfiguration: UnresolvedOtlpGrpcConfiguration): OtlpGrpcConfiguration;
22
- export declare function getOtlpGrpcDefaultConfiguration(): UnresolvedOtlpGrpcConfiguration;
23
- //# sourceMappingURL=otlp-grpc-configuration.d.ts.map
@@ -1,78 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright The OpenTelemetry Authors
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.getOtlpGrpcDefaultConfiguration = exports.mergeOtlpGrpcConfigurationWithDefaults = exports.validateAndNormalizeUrl = void 0;
8
- const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
9
- const grpc_exporter_transport_1 = require("../grpc-exporter-transport");
10
- const url_1 = require("url");
11
- const api_1 = require("@opentelemetry/api");
12
- function validateAndNormalizeUrl(url) {
13
- url = url.trim();
14
- const hasProtocol = url.match(/^([\w]{1,8}):\/\//);
15
- if (!hasProtocol) {
16
- url = `https://${url}`;
17
- }
18
- const target = new url_1.URL(url);
19
- if (target.protocol === 'unix:') {
20
- return url;
21
- }
22
- if (target.pathname && target.pathname !== '/') {
23
- api_1.diag.warn('URL path should not be set when using grpc, the path part of the URL will be ignored.');
24
- }
25
- if (target.protocol !== '' && !target.protocol?.match(/^(http)s?:$/)) {
26
- api_1.diag.warn('URL protocol should be http(s)://. Using http://.');
27
- }
28
- return target.host;
29
- }
30
- exports.validateAndNormalizeUrl = validateAndNormalizeUrl;
31
- function overrideMetadataEntriesIfNotPresent(metadata, additionalMetadata) {
32
- for (const [key, value] of Object.entries(additionalMetadata.getMap())) {
33
- // only override with env var data if the key has no values.
34
- // not using Metadata.merge() as it will keep both values.
35
- if (metadata.get(key).length < 1) {
36
- metadata.set(key, value);
37
- }
38
- }
39
- }
40
- function mergeOtlpGrpcConfigurationWithDefaults(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration) {
41
- const rawUrl = userProvidedConfiguration.url ??
42
- fallbackConfiguration.url ??
43
- defaultConfiguration.url;
44
- return {
45
- ...(0, otlp_exporter_base_1.mergeOtlpSharedConfigurationWithDefaults)(userProvidedConfiguration, fallbackConfiguration, defaultConfiguration),
46
- metadata: () => {
47
- const metadata = defaultConfiguration.metadata();
48
- overrideMetadataEntriesIfNotPresent(metadata,
49
- // clone to ensure we don't modify what the user gave us in case they hold on to the returned reference
50
- userProvidedConfiguration.metadata?.().clone() ?? (0, grpc_exporter_transport_1.createEmptyMetadata)());
51
- overrideMetadataEntriesIfNotPresent(metadata, fallbackConfiguration.metadata?.() ?? (0, grpc_exporter_transport_1.createEmptyMetadata)());
52
- return metadata;
53
- },
54
- url: validateAndNormalizeUrl(rawUrl),
55
- credentials: userProvidedConfiguration.credentials ??
56
- fallbackConfiguration.credentials?.(rawUrl) ??
57
- defaultConfiguration.credentials(rawUrl),
58
- userAgent: userProvidedConfiguration.userAgent,
59
- };
60
- }
61
- exports.mergeOtlpGrpcConfigurationWithDefaults = mergeOtlpGrpcConfigurationWithDefaults;
62
- function getOtlpGrpcDefaultConfiguration() {
63
- return {
64
- ...(0, otlp_exporter_base_1.getSharedConfigurationDefaults)(),
65
- metadata: () => (0, grpc_exporter_transport_1.createEmptyMetadata)(),
66
- url: 'http://localhost:4317',
67
- credentials: (url) => {
68
- if (url.startsWith('http://')) {
69
- return () => (0, grpc_exporter_transport_1.createInsecureCredentials)();
70
- }
71
- else {
72
- return () => (0, grpc_exporter_transport_1.createSslCredentials)();
73
- }
74
- },
75
- };
76
- }
77
- exports.getOtlpGrpcDefaultConfiguration = getOtlpGrpcDefaultConfiguration;
78
- //# sourceMappingURL=otlp-grpc-configuration.js.map
@@ -1 +0,0 @@
1
- {"version":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AG,EAAE,CAAC,IAAA,8CAAoB,GAAE,CAAC;aACrC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAbD,0EAaC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { OtlpSharedConfiguration } from '@opentelemetry/otlp-exporter-base';\nimport {\n getSharedConfigurationDefaults,\n mergeOtlpSharedConfigurationWithDefaults,\n} from '@opentelemetry/otlp-exporter-base';\nimport {\n createEmptyMetadata,\n createInsecureCredentials,\n createSslCredentials,\n} from '../grpc-exporter-transport';\nimport { URL } from 'url';\nimport { diag } from '@opentelemetry/api';\n\n// NOTE: do not change this to be an actual import, doing so will break `@opentelemetry/instrumentation-grpc`\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\n\nexport interface OtlpGrpcConfiguration extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n credentials: () => ChannelCredentials;\n userAgent?: string;\n}\n\n/**\n * Unresolved configuration where parts of the config may depend on other config options being resolved first.\n */\nexport interface UnresolvedOtlpGrpcConfiguration\n extends OtlpSharedConfiguration {\n url: string;\n metadata: () => Metadata;\n /**\n * Credentials are based on the final resolved URL\n */\n credentials: (url: string) => () => ChannelCredentials;\n}\n\nexport function validateAndNormalizeUrl(url: string): string {\n url = url.trim();\n const hasProtocol = url.match(/^([\\w]{1,8}):\\/\\//);\n if (!hasProtocol) {\n url = `https://${url}`;\n }\n const target = new URL(url);\n if (target.protocol === 'unix:') {\n return url;\n }\n if (target.pathname && target.pathname !== '/') {\n diag.warn(\n 'URL path should not be set when using grpc, the path part of the URL will be ignored.'\n );\n }\n if (target.protocol !== '' && !target.protocol?.match(/^(http)s?:$/)) {\n diag.warn('URL protocol should be http(s)://. Using http://.');\n }\n return target.host;\n}\n\nfunction overrideMetadataEntriesIfNotPresent(\n metadata: Metadata,\n additionalMetadata: Metadata\n): void {\n for (const [key, value] of Object.entries(additionalMetadata.getMap())) {\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\nexport function mergeOtlpGrpcConfigurationWithDefaults(\n userProvidedConfiguration: Partial<OtlpGrpcConfiguration>,\n fallbackConfiguration: Partial<UnresolvedOtlpGrpcConfiguration>,\n defaultConfiguration: UnresolvedOtlpGrpcConfiguration\n): OtlpGrpcConfiguration {\n const rawUrl =\n userProvidedConfiguration.url ??\n fallbackConfiguration.url ??\n defaultConfiguration.url;\n\n return {\n ...mergeOtlpSharedConfigurationWithDefaults(\n userProvidedConfiguration,\n fallbackConfiguration,\n defaultConfiguration\n ),\n metadata: () => {\n const metadata = defaultConfiguration.metadata();\n overrideMetadataEntriesIfNotPresent(\n metadata,\n // clone to ensure we don't modify what the user gave us in case they hold on to the returned reference\n userProvidedConfiguration.metadata?.().clone() ?? createEmptyMetadata()\n );\n overrideMetadataEntriesIfNotPresent(\n metadata,\n fallbackConfiguration.metadata?.() ?? createEmptyMetadata()\n );\n return metadata;\n },\n url: validateAndNormalizeUrl(rawUrl),\n credentials:\n userProvidedConfiguration.credentials ??\n fallbackConfiguration.credentials?.(rawUrl) ??\n defaultConfiguration.credentials(rawUrl),\n userAgent: userProvidedConfiguration.userAgent,\n };\n}\n\nexport function getOtlpGrpcDefaultConfiguration(): UnresolvedOtlpGrpcConfiguration {\n return {\n ...getSharedConfigurationDefaults(),\n metadata: () => createEmptyMetadata(),\n url: 'http://localhost:4317',\n credentials: (url: string) => {\n if (url.startsWith('http://')) {\n return () => createInsecureCredentials();\n } else {\n return () => createSslCredentials();\n }\n },\n };\n}\n"]}
@@ -1,3 +0,0 @@
1
- import type { UnresolvedOtlpGrpcConfiguration } from './otlp-grpc-configuration';
2
- export declare function getOtlpGrpcConfigurationFromEnv(signalIdentifier: string): Partial<UnresolvedOtlpGrpcConfiguration>;
3
- //# sourceMappingURL=otlp-grpc-env-configuration.d.ts.map
@@ -1,159 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOtlpGrpcConfigurationFromEnv = void 0;
4
- const core_1 = require("@opentelemetry/core");
5
- const grpc_exporter_transport_1 = require("../grpc-exporter-transport");
6
- const node_http_1 = require("@opentelemetry/otlp-exporter-base/node-http");
7
- const fs = require("fs");
8
- const path = require("path");
9
- const api_1 = require("@opentelemetry/api");
10
- function fallbackIfNullishOrBlank(signalSpecific, nonSignalSpecific) {
11
- if (signalSpecific != null && signalSpecific !== '') {
12
- return signalSpecific;
13
- }
14
- if (nonSignalSpecific != null && nonSignalSpecific !== '') {
15
- return nonSignalSpecific;
16
- }
17
- return undefined;
18
- }
19
- function getMetadataFromEnv(signalIdentifier) {
20
- const signalSpecificRawHeaders = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_HEADERS`]?.trim();
21
- const nonSignalSpecificRawHeaders = process.env['OTEL_EXPORTER_OTLP_HEADERS']?.trim();
22
- const signalSpecificHeaders = (0, core_1.parseKeyPairsIntoRecord)(signalSpecificRawHeaders);
23
- const nonSignalSpecificHeaders = (0, core_1.parseKeyPairsIntoRecord)(nonSignalSpecificRawHeaders);
24
- if (Object.keys(signalSpecificHeaders).length === 0 &&
25
- Object.keys(nonSignalSpecificHeaders).length === 0) {
26
- return undefined;
27
- }
28
- const mergeHeaders = Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders);
29
- const metadata = (0, grpc_exporter_transport_1.createEmptyMetadata)();
30
- // for this to work, metadata MUST be empty - otherwise `Metadata#set()` will merge items.
31
- for (const [key, value] of Object.entries(mergeHeaders)) {
32
- metadata.set(key, value);
33
- }
34
- return metadata;
35
- }
36
- function getMetadataProviderFromEnv(signalIdentifier) {
37
- const metadata = getMetadataFromEnv(signalIdentifier);
38
- if (metadata == null) {
39
- return undefined;
40
- }
41
- return () => metadata;
42
- }
43
- function getUrlFromEnv(signalIdentifier) {
44
- // This does not change the string beyond trimming on purpose.
45
- // Normally a user would just use a host and port for gRPC, but the OTLP Exporter specification requires us to
46
- // use the raw provided endpoint to derive credential settings. Therefore, we only normalize right when
47
- // we merge user-provided, env-provided and defaults together, and we have determined which credentials to use.
48
- //
49
- // Examples:
50
- // - example.test:4317 -> use secure credentials from environment (or provided via code)
51
- // - http://example.test:4317 -> use insecure credentials if nothing else is provided
52
- // - https://example.test:4317 -> use secure credentials from environment (or provided via code)
53
- const specificEndpoint = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`]?.trim();
54
- const nonSpecificEndpoint = process.env['OTEL_EXPORTER_OTLP_ENDPOINT']?.trim();
55
- return fallbackIfNullishOrBlank(specificEndpoint, nonSpecificEndpoint);
56
- }
57
- /**
58
- * Determines whether the env var for insecure credentials is set to {@code true}.
59
- *
60
- * It will allow the following values as {@code true}
61
- * - 'true'
62
- * - 'true '
63
- * - ' true'
64
- * - 'TrUE'
65
- * - 'TRUE'
66
- *
67
- * It will not allow:
68
- * - 'true false'
69
- * - 'false true'
70
- * - 'true!'
71
- * - 'true,true'
72
- * - '1'
73
- * - ' '
74
- *
75
- * @param signalIdentifier
76
- */
77
- function getInsecureSettingFromEnv(signalIdentifier) {
78
- const signalSpecificInsecureValue = process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_INSECURE`]
79
- ?.toLowerCase()
80
- .trim();
81
- const nonSignalSpecificInsecureValue = process.env['OTEL_EXPORTER_OTLP_INSECURE']
82
- ?.toLowerCase()
83
- .trim();
84
- return (fallbackIfNullishOrBlank(signalSpecificInsecureValue, nonSignalSpecificInsecureValue) === 'true');
85
- }
86
- function readFileFromEnv(signalSpecificEnvVar, nonSignalSpecificEnvVar, warningMessage) {
87
- const signalSpecificPath = process.env[signalSpecificEnvVar]?.trim();
88
- const nonSignalSpecificPath = process.env[nonSignalSpecificEnvVar]?.trim();
89
- const filePath = fallbackIfNullishOrBlank(signalSpecificPath, nonSignalSpecificPath);
90
- if (filePath != null) {
91
- try {
92
- return fs.readFileSync(path.resolve(process.cwd(), filePath));
93
- }
94
- catch {
95
- api_1.diag.warn(warningMessage);
96
- return undefined;
97
- }
98
- }
99
- else {
100
- return undefined;
101
- }
102
- }
103
- function getClientCertificateFromEnv(signalIdentifier) {
104
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE', 'Failed to read client certificate chain file');
105
- }
106
- function getClientKeyFromEnv(signalIdentifier) {
107
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CLIENT_KEY`, 'OTEL_EXPORTER_OTLP_CLIENT_KEY', 'Failed to read client certificate private key file');
108
- }
109
- function getRootCertificateFromEnv(signalIdentifier) {
110
- return readFileFromEnv(`OTEL_EXPORTER_OTLP_${signalIdentifier}_CERTIFICATE`, 'OTEL_EXPORTER_OTLP_CERTIFICATE', 'Failed to read root certificate file');
111
- }
112
- function getCredentialsFromEnvIgnoreInsecure(signalIdentifier) {
113
- const clientKey = getClientKeyFromEnv(signalIdentifier);
114
- const clientCertificate = getClientCertificateFromEnv(signalIdentifier);
115
- const rootCertificate = getRootCertificateFromEnv(signalIdentifier);
116
- // if the chain is not intact, @grpc/grpc-js will throw. This is fine when a user provides it in code, but env var
117
- // config is not allowed to throw, so we add this safeguard and try to make the best of it here.
118
- const clientChainIntact = clientKey != null && clientCertificate != null;
119
- if (rootCertificate != null && !clientChainIntact) {
120
- api_1.diag.warn('Client key and certificate must both be provided, but one was missing - attempting to create credentials from just the root certificate');
121
- return (0, grpc_exporter_transport_1.createSslCredentials)(getRootCertificateFromEnv(signalIdentifier));
122
- }
123
- return (0, grpc_exporter_transport_1.createSslCredentials)(rootCertificate, clientKey, clientCertificate);
124
- }
125
- function getCredentialsFromEnv(signalIdentifier) {
126
- if (getInsecureSettingFromEnv(signalIdentifier)) {
127
- return (0, grpc_exporter_transport_1.createInsecureCredentials)();
128
- }
129
- return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
130
- }
131
- function getOtlpGrpcConfigurationFromEnv(signalIdentifier) {
132
- return {
133
- ...(0, node_http_1.getSharedConfigurationFromEnvironment)(signalIdentifier),
134
- metadata: getMetadataProviderFromEnv(signalIdentifier),
135
- url: getUrlFromEnv(signalIdentifier),
136
- credentials: (finalResolvedUrl) => {
137
- // Always assume insecure on http:// and secure on https://, the protocol always takes precedence over the insecure setting.
138
- // note: the spec does not make any exception for
139
- // - "localhost:4317". If the protocol is omitted, credentials are required unless insecure is set
140
- // - "unix://", as it's neither http:// nor https:// and therefore credentials are required unless insecure is set
141
- if (finalResolvedUrl.startsWith('http://')) {
142
- return () => {
143
- return (0, grpc_exporter_transport_1.createInsecureCredentials)();
144
- };
145
- }
146
- else if (finalResolvedUrl.startsWith('https://')) {
147
- return () => {
148
- return getCredentialsFromEnvIgnoreInsecure(signalIdentifier);
149
- };
150
- }
151
- // defer to env settings in this case
152
- return () => {
153
- return getCredentialsFromEnv(signalIdentifier);
154
- };
155
- },
156
- };
157
- }
158
- exports.getOtlpGrpcConfigurationFromEnv = getOtlpGrpcConfigurationFromEnv;
159
- //# sourceMappingURL=otlp-grpc-env-configuration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"otlp-grpc-env-configuration.js","sourceRoot":"","sources":["../../../src/configuration/otlp-grpc-env-configuration.ts"],"names":[],"mappings":";;;AAMA,8CAA8D;AAC9D,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,OAAO,C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;AAED,SAAgB,+BAA+B,CAC7C,gBAAwB;IAExB,OAAO;QACL,GAAG,IAAA,iDAAqC,EAAC,gBAAgB,CAAC;QAC1D,QAAQ,EAAE,0BAA0B,CAAC,gBAAgB,CAAC;QACtD,GAAG,EAAE,aAAa,CAAC,gBAAgB,CAAC;QACpC,WAAW,EAAE,CAAC,gBAAwB,EAAE,EAAE;YACxC,4HAA4H;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;KACF,CAAC;AACJ,CAAC;AA5BD,0EA4BC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { UnresolvedOtlpGrpcConfiguration } from './otlp-grpc-configuration';\nimport type { ChannelCredentials, Metadata } from '@grpc/grpc-js';\nimport { parseKeyPairsIntoRecord } 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 = parseKeyPairsIntoRecord(\n signalSpecificRawHeaders\n );\n const nonSignalSpecificHeaders = 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,10 +0,0 @@
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
@@ -1,39 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright The OpenTelemetry Authors
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createServiceClientConstructor = void 0;
8
- const grpc = require("@grpc/grpc-js");
9
- /**
10
- * Creates a unary service client constructor that, when instantiated, does not serialize/deserialize anything.
11
- * Allows for passing in {@link Buffer} directly, serialization can be handled via protobufjs or custom implementations.
12
- *
13
- * @param path service path
14
- * @param name service name
15
- */
16
- function createServiceClientConstructor(path, name) {
17
- const serviceDefinition = {
18
- export: {
19
- path: path,
20
- requestStream: false,
21
- responseStream: false,
22
- requestSerialize: (arg) => {
23
- return arg;
24
- },
25
- requestDeserialize: (arg) => {
26
- return arg;
27
- },
28
- responseSerialize: (arg) => {
29
- return arg;
30
- },
31
- responseDeserialize: (arg) => {
32
- return arg;
33
- },
34
- },
35
- };
36
- return grpc.makeGenericClientConstructor(serviceDefinition, name);
37
- }
38
- exports.createServiceClientConstructor = createServiceClientConstructor;
39
- //# sourceMappingURL=create-service-client-constructor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-service-client-constructor.js","sourceRoot":"","sources":["../../src/create-service-client-constructor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;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 * SPDX-License-Identifier: Apache-2.0\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"]}
@@ -1,42 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { Metadata, ChannelCredentials } from '@grpc/grpc-js';
4
- import type { ExportResponse, IExporterTransport } from '@opentelemetry/otlp-exporter-base';
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
- userAgent?: string;
31
- }
32
- export declare class GrpcExporterTransport implements IExporterTransport {
33
- private _client?;
34
- private _metadata?;
35
- private _parameters;
36
- private _deadlineExceededCount;
37
- constructor(parameters: GrpcExporterTransportParameters);
38
- shutdown(): void;
39
- send(data: Uint8Array, timeoutMillis: number): Promise<ExportResponse>;
40
- }
41
- export declare function createOtlpGrpcExporterTransport(options: GrpcExporterTransportParameters): IExporterTransport;
42
- //# sourceMappingURL=grpc-exporter-transport.d.ts.map