@opentelemetry/otlp-grpc-exporter-base 0.29.2 → 0.30.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.
@@ -7,3 +7,4 @@ This package describes the OpenTelemetry collector protocol.
7
7
  1. `common` package contains the common messages shared between different services.
8
8
  2. `trace` package contains the Trace Service protos.
9
9
  3. `metrics` package contains the Metrics Service protos.
10
+ 4. `logs` package contains the Logs Service protos.
@@ -14,9 +14,6 @@
14
14
 
15
15
  syntax = "proto3";
16
16
 
17
- // NOTE: This proto is experimental and is subject to change at this point.
18
- // Please do not use it at the moment.
19
-
20
17
  package opentelemetry.proto.collector.logs.v1;
21
18
 
22
19
  import "opentelemetry/proto/logs/v1/logs.proto";
@@ -492,6 +492,12 @@ message HistogramDataPoint {
492
492
  // Flags that apply to this specific data point. See DataPointFlags
493
493
  // for the available flags and their meaning.
494
494
  uint32 flags = 10;
495
+
496
+ // min is the minimum value over (start_time, end_time].
497
+ optional double min = 11;
498
+
499
+ // max is the maximum value over (start_time, end_time].
500
+ optional double max = 12;
495
501
  }
496
502
 
497
503
  // ExponentialHistogramDataPoint is a single data point in a timeseries that describes the
@@ -532,7 +538,7 @@ message ExponentialHistogramDataPoint {
532
538
  // Negative events *can* be recorded, but sum should not be filled out when
533
539
  // doing so. This is specifically to enforce compatibility w/ OpenMetrics,
534
540
  // see: https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md#histogram
535
- double sum = 5;
541
+ optional double sum = 5;
536
542
 
537
543
  // scale describes the resolution of the histogram. Boundaries are
538
544
  // located at powers of the base, where:
@@ -594,6 +600,12 @@ message ExponentialHistogramDataPoint {
594
600
  // (Optional) List of exemplars collected from
595
601
  // measurements that were used to form the data point
596
602
  repeated Exemplar exemplars = 11;
603
+
604
+ // min is the minimum value over (start_time, end_time].
605
+ optional double min = 12;
606
+
607
+ // max is the maximum value over (start_time, end_time].
608
+ optional double max = 13;
597
609
  }
598
610
 
599
611
  // SummaryDataPoint is a single data point in a timeseries that describes the
@@ -19,5 +19,6 @@ export declare abstract class OTLPGRPCExporterNodeBase<ExportItem, ServiceReques
19
19
  onShutdown(): void;
20
20
  abstract getServiceProtoPath(): string;
21
21
  abstract getServiceClientType(): ServiceClientType;
22
+ abstract getUrlFromConfig(config: OTLPGRPCExporterConfigNode): string;
22
23
  }
23
24
  //# sourceMappingURL=OTLPGRPCExporterNodeBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OTLPGRPCExporterNodeBase.js","sourceRoot":"","sources":["../../src/OTLPGRPCExporterNodeBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,2CAAyC;AAOzC,8CAA2D;AAC3D,iCAAwE;AACxE,0EAAwF;AAExF;;GAEG;AACH,MAAsB,wBAGpB,SAAQ,qCAIT;IAOC,YAAY,SAAqC,EAAE;QACjD,KAAK,CAAC,MAAM,CAAC,CAAC;QAPhB,cAAS,GAAgC,EAAE,CAAC;QAE5C,kBAAa,GAAmB,SAAS,CAAC;QAMxC,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,UAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;SACpD;QACD,MAAM,OAAO,GAAG,mBAAY,CAAC,uBAAuB,CAAC,IAAA,aAAM,GAAE,CAAC,0BAA0B,CAAC,CAAC;QAC1F,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,kBAAQ,EAAE,CAAC;QAClD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACzB;QACD,IAAI,CAAC,WAAW,GAAG,IAAA,2BAAoB,EAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;IAEO,YAAY,CAClB,OA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,GAAG,IAAI,CAAC;gBAElB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SAChD;IACH,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;SAC5B;IACH,CAAC;CAIF;AAvFD,4DAuFC","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 { Metadata } from '@grpc/grpc-js';\nimport {\n OTLPGRPCExporterConfigNode,\n GRPCQueueItem,\n ServiceClientType,\n} from './types';\nimport { ServiceClient } from './types';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { configureCompression, GrpcCompressionAlgorithm } from './util';\nimport { OTLPExporterBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\n\n/**\n * OTLP Exporter abstract base class\n */\nexport abstract class OTLPGRPCExporterNodeBase<\n ExportItem,\n ServiceRequest\n> extends OTLPExporterBase<\n OTLPGRPCExporterConfigNode,\n ExportItem,\n ServiceRequest\n> {\n grpcQueue: GRPCQueueItem<ExportItem>[] = [];\n metadata?: Metadata;\n serviceClient?: ServiceClient = undefined;\n private _send!: Function;\n compression: GrpcCompressionAlgorithm;\n\n constructor(config: OTLPGRPCExporterConfigNode = {}) {\n super(config);\n if (config.headers) {\n diag.warn('Headers cannot be set when using grpc');\n }\n const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS);\n this.metadata = config.metadata || new Metadata();\n for (const [k, v] of Object.entries(headers)) {\n this.metadata.set(k, v);\n }\n this.compression = configureCompression(config.compression);\n }\n\n private _sendPromise(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n const promise = new Promise<void>((resolve, reject) => {\n this._send(this, objects, resolve, reject);\n })\n .then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n\n onInit(config: OTLPGRPCExporterConfigNode): void {\n // defer to next tick and lazy load to avoid loading grpc too early\n // and making this impossible to be instrumented\n setImmediate(() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { onInit } = require('./util');\n onInit(this, config);\n });\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 if (!this._send) {\n // defer to next tick and lazy load to avoid loading grpc too early\n // and making this impossible to be instrumented\n setImmediate(() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { send } = require('./util');\n this._send = send;\n\n this._sendPromise(objects, onSuccess, onError);\n });\n } else {\n this._sendPromise(objects, onSuccess, onError);\n }\n }\n\n onShutdown(): void {\n if (this.serviceClient) {\n this.serviceClient.close();\n }\n }\n\n abstract getServiceProtoPath(): string;\n abstract getServiceClientType(): ServiceClientType;\n}\n"]}
1
+ {"version":3,"file":"OTLPGRPCExporterNodeBase.js","sourceRoot":"","sources":["../../src/OTLPGRPCExporterNodeBase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,2CAAyC;AAOzC,8CAA2D;AAC3D,iCA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MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,MAAkC;QACvC,mEAAmE;QACnE,gDAAgD;QAChD,YAAY,CAAC,GAAG,EAAE;YAChB,8DAA8D;YAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CACF,OAAqB,EACrB,SAAqB,EACrB,OAA2C;QAE3C,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;YAC/B,UAAI,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;YAC5D,OAAO;SACR;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,mEAAmE;YACnE,gDAAgD;YAChD,YAAY,CAAC,GAAG,EAAE;gBAChB,8DAA8D;gBAC9D,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;gBAElB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YACjD,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;SAChD;IACH,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;SAC5B;IACH,CAAC;CAKF;AAxFD,4DAwFC","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 { Metadata } from '@grpc/grpc-js';\nimport {\n OTLPGRPCExporterConfigNode,\n GRPCQueueItem,\n ServiceClientType,\n} from './types';\nimport { ServiceClient } from './types';\nimport { getEnv, baggageUtils } from '@opentelemetry/core';\nimport { configureCompression, GrpcCompressionAlgorithm } from './util';\nimport { OTLPExporterBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\n\n/**\n * OTLP Exporter abstract base class\n */\nexport abstract class OTLPGRPCExporterNodeBase<\n ExportItem,\n ServiceRequest\n> extends OTLPExporterBase<\n OTLPGRPCExporterConfigNode,\n ExportItem,\n ServiceRequest\n> {\n grpcQueue: GRPCQueueItem<ExportItem>[] = [];\n metadata?: Metadata;\n serviceClient?: ServiceClient = undefined;\n private _send!: Function;\n compression: GrpcCompressionAlgorithm;\n\n constructor(config: OTLPGRPCExporterConfigNode = {}) {\n super(config);\n if (config.headers) {\n diag.warn('Headers cannot be set when using grpc');\n }\n const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_HEADERS);\n this.metadata = config.metadata || new Metadata();\n for (const [k, v] of Object.entries(headers)) {\n this.metadata.set(k, v);\n }\n this.compression = configureCompression(config.compression);\n }\n\n private _sendPromise(\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n ): void {\n const promise = new Promise<void>((resolve, reject) => {\n this._send(this, objects, resolve, reject);\n })\n .then(onSuccess, onError);\n\n this._sendingPromises.push(promise);\n const popPromise = () => {\n const index = this._sendingPromises.indexOf(promise);\n this._sendingPromises.splice(index, 1);\n };\n promise.then(popPromise, popPromise);\n }\n\n onInit(config: OTLPGRPCExporterConfigNode): void {\n // defer to next tick and lazy load to avoid loading grpc too early\n // and making this impossible to be instrumented\n setImmediate(() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { onInit } = require('./util');\n onInit(this, config);\n });\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 if (!this._send) {\n // defer to next tick and lazy load to avoid loading grpc too early\n // and making this impossible to be instrumented\n setImmediate(() => {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { send } = require('./util');\n this._send = send;\n\n this._sendPromise(objects, onSuccess, onError);\n });\n } else {\n this._sendPromise(objects, onSuccess, onError);\n }\n }\n\n onShutdown(): void {\n if (this.serviceClient) {\n this.serviceClient.close();\n }\n }\n\n abstract getServiceProtoPath(): string;\n abstract getServiceClientType(): ServiceClientType;\n abstract getUrlFromConfig(config: OTLPGRPCExporterConfigNode): string;\n}\n"]}
package/build/src/util.js CHANGED
@@ -28,7 +28,7 @@ const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
28
28
  exports.DEFAULT_COLLECTOR_URL = 'http://localhost:4317';
29
29
  function onInit(collector, config) {
30
30
  collector.grpcQueue = [];
31
- const credentials = configureSecurity(config.credentials, collector.url);
31
+ const credentials = configureSecurity(config.credentials, collector.getUrlFromConfig(config));
32
32
  const includeDirs = [path.resolve(__dirname, '..', 'protos')];
33
33
  protoLoader
34
34
  .load(collector.getServiceProtoPath(), {
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AACtC,kDAAkD;AAClD,4CAA0C;AAC1C,8CAAiE;AACjE,6BAA6B;AAE7B,6BAA0B;AAC1B,yBAAyB;AACzB,mCAAwF;AACxF,0EAAgH;AAEnG,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D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version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as grpc from '@grpc/grpc-js';\nimport * as protoLoader from '@grpc/proto-loader';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, globalErrorHandler } from '@opentelemetry/core';\nimport * as path from 'path';\nimport { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';\nimport { URL } from 'url';\nimport * as fs from 'fs';\nimport { GRPCQueueItem, OTLPGRPCExporterConfigNode, ServiceClientType, } from './types';\nimport { CompressionAlgorithm, ExportServiceError, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\n\nexport const DEFAULT_COLLECTOR_URL = 'http://localhost:4317';\n\nexport function onInit<ExportItem, ServiceRequest>(\n collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>,\n config: OTLPGRPCExporterConfigNode\n): void {\n collector.grpcQueue = [];\n\n const credentials: grpc.ChannelCredentials = configureSecurity(config.credentials, collector.url);\n\n const includeDirs = [path.resolve(__dirname, '..', 'protos')];\n\n protoLoader\n .load(collector.getServiceProtoPath(), {\n keepCase: false,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n includeDirs,\n })\n .then(packageDefinition => {\n const packageObject: any = grpc.loadPackageDefinition(packageDefinition);\n\n const options = { 'grpc.default_compression_algorithm': collector.compression };\n\n if (collector.getServiceClientType() === ServiceClientType.SPANS) {\n collector.serviceClient =\n new packageObject.opentelemetry.proto.collector.trace.v1.TraceService(\n collector.url,\n credentials,\n options,\n );\n } else {\n collector.serviceClient =\n new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService(\n collector.url,\n credentials,\n options,\n );\n }\n\n if (collector.grpcQueue.length > 0) {\n const queue = collector.grpcQueue.splice(0);\n queue.forEach((item: GRPCQueueItem<ExportItem>) => {\n collector.send(item.objects, item.onSuccess, item.onError);\n });\n }\n })\n .catch(err => {\n globalErrorHandler(err);\n });\n}\n\nexport function send<ExportItem, ServiceRequest>(\n collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>,\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n if (collector.serviceClient) {\n const serviceRequest = collector.convert(objects);\n const deadline = Date.now() + collector.timeoutMillis;\n\n collector.serviceClient.export(\n serviceRequest,\n collector.metadata || new grpc.Metadata(),\n {deadline: deadline},\n (err: ExportServiceError) => {\n if (err) {\n diag.error('Service request', serviceRequest);\n onError(err);\n } else {\n diag.debug('Objects sent');\n onSuccess();\n }\n }\n );\n } else {\n collector.grpcQueue.push({\n objects,\n onSuccess,\n onError,\n });\n }\n}\n\nexport function validateAndNormalizeUrl(url: string): string {\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.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(\n 'URL protocol should be http(s)://. Using http://.'\n );\n }\n return target.host;\n}\n\nexport function configureSecurity(credentials: grpc.ChannelCredentials | undefined, endpoint: string):\n grpc.ChannelCredentials {\n\n let insecure: boolean;\n\n if (credentials) {\n return credentials;\n } else if (endpoint.startsWith('https://')) {\n insecure = false;\n } else if (endpoint.startsWith('http://') || endpoint === DEFAULT_COLLECTOR_URL) {\n insecure = true;\n } else {\n insecure = getSecurityFromEnv();\n }\n\n if (insecure) {\n return grpc.credentials.createInsecure();\n } else {\n return useSecureConnection();\n }\n}\n\nfunction getSecurityFromEnv(): boolean {\n const definedInsecure =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_INSECURE ||\n getEnv().OTEL_EXPORTER_OTLP_INSECURE;\n\n if (definedInsecure) {\n return definedInsecure.toLowerCase() === 'true';\n } else {\n return false;\n }\n}\n\nexport function useSecureConnection(): grpc.ChannelCredentials {\n const rootCertPath = retrieveRootCert();\n const privateKeyPath = retrievePrivateKey();\n const certChainPath = retrieveCertChain();\n\n return grpc.credentials.createSsl(rootCertPath, privateKeyPath, certChainPath);\n}\n\nfunction retrieveRootCert(): Buffer | undefined {\n const rootCertificate =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE ||\n getEnv().OTEL_EXPORTER_OTLP_CERTIFICATE;\n\n if (rootCertificate) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), rootCertificate));\n } catch {\n diag.warn('Failed to read root certificate file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction retrievePrivateKey(): Buffer | undefined {\n const clientKey =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY ||\n getEnv().OTEL_EXPORTER_OTLP_CLIENT_KEY;\n\n if (clientKey) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), clientKey));\n } catch {\n diag.warn('Failed to read client certificate private key file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction retrieveCertChain(): Buffer | undefined {\n const clientChain =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE ||\n getEnv().OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE;\n\n if (clientChain) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), clientChain));\n } catch {\n diag.warn('Failed to read client certificate chain file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction toGrpcCompression(compression: CompressionAlgorithm): GrpcCompressionAlgorithm {\n if(compression === CompressionAlgorithm.NONE)\n return GrpcCompressionAlgorithm.NONE;\n else if (compression === CompressionAlgorithm.GZIP)\n return GrpcCompressionAlgorithm.GZIP;\n return GrpcCompressionAlgorithm.NONE;\n}\n\n/**\n * These values are defined by grpc client\n */\nexport enum GrpcCompressionAlgorithm {\n NONE = 0,\n GZIP = 2\n}\n\nexport function configureCompression(compression: CompressionAlgorithm | undefined): GrpcCompressionAlgorithm {\n if (compression) {\n return toGrpcCompression(compression);\n } else {\n const definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION || getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n\n return definedCompression === 'gzip' ? GrpcCompressionAlgorithm.GZIP: GrpcCompressionAlgorithm.NONE;\n }\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AACtC,kDAAkD;AAClD,4CAA0C;AAC1C,8CAAiE;AACjE,6BAA6B;AAE7B,6BAA0B;AAC1B,yBAAyB;AACzB,mCAAwF;AACxF,0EAAgH;AAEnG,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAE7D,SAAgB,MAAM,CACpB,SAA+D,EAC/D,MAAkC;IAElC,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;IAEzB,MAAM,WAAW,GAA4B,iBAAiB,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvH,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE9D,WAAW;SACR,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE;QACrC,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,WAAW;KACZ,CAAC;SACD,IAAI,CAAC,iBAAiB,CAAC,EAAE;QACxB,MAAM,aAAa,GAAQ,IAAI,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC;QAEzE,M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CAAC;IACvC,OAAO,wBAAwB,CAAC,IAAI,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,uEAAQ,CAAA;IACR,uEAAQ,CAAA;AACV,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC;AAED,SAAgB,oBAAoB,CAAC,WAA6C;IAChF,IAAI,WAAW,EAAE;QACf,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC;KACvC;SAAM;QACL,MAAM,kBAAkB,GAAG,IAAA,aAAM,GAAE,CAAC,qCAAqC,IAAI,IAAA,aAAM,GAAE,CAAC,8BAA8B,CAAC;QAErH,OAAO,kBAAkB,KAAK,MAAM,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC;KACtG;AACH,CAAC;AARD,oDAQC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as grpc from '@grpc/grpc-js';\nimport * as protoLoader from '@grpc/proto-loader';\nimport { diag } from '@opentelemetry/api';\nimport { getEnv, globalErrorHandler } from '@opentelemetry/core';\nimport * as path from 'path';\nimport { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';\nimport { URL } from 'url';\nimport * as fs from 'fs';\nimport { GRPCQueueItem, OTLPGRPCExporterConfigNode, ServiceClientType, } from './types';\nimport { CompressionAlgorithm, ExportServiceError, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\n\nexport const DEFAULT_COLLECTOR_URL = 'http://localhost:4317';\n\nexport function onInit<ExportItem, ServiceRequest>(\n collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>,\n config: OTLPGRPCExporterConfigNode\n): void {\n collector.grpcQueue = [];\n\n const credentials: grpc.ChannelCredentials = configureSecurity(config.credentials, collector.getUrlFromConfig(config));\n\n const includeDirs = [path.resolve(__dirname, '..', 'protos')];\n\n protoLoader\n .load(collector.getServiceProtoPath(), {\n keepCase: false,\n longs: String,\n enums: String,\n defaults: true,\n oneofs: true,\n includeDirs,\n })\n .then(packageDefinition => {\n const packageObject: any = grpc.loadPackageDefinition(packageDefinition);\n\n const options = { 'grpc.default_compression_algorithm': collector.compression };\n\n if (collector.getServiceClientType() === ServiceClientType.SPANS) {\n collector.serviceClient =\n new packageObject.opentelemetry.proto.collector.trace.v1.TraceService(\n collector.url,\n credentials,\n options,\n );\n } else {\n collector.serviceClient =\n new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService(\n collector.url,\n credentials,\n options,\n );\n }\n\n if (collector.grpcQueue.length > 0) {\n const queue = collector.grpcQueue.splice(0);\n queue.forEach((item: GRPCQueueItem<ExportItem>) => {\n collector.send(item.objects, item.onSuccess, item.onError);\n });\n }\n })\n .catch(err => {\n globalErrorHandler(err);\n });\n}\n\nexport function send<ExportItem, ServiceRequest>(\n collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>,\n objects: ExportItem[],\n onSuccess: () => void,\n onError: (error: OTLPExporterError) => void\n): void {\n if (collector.serviceClient) {\n const serviceRequest = collector.convert(objects);\n const deadline = Date.now() + collector.timeoutMillis;\n\n collector.serviceClient.export(\n serviceRequest,\n collector.metadata || new grpc.Metadata(),\n { deadline: deadline },\n (err: ExportServiceError) => {\n if (err) {\n diag.error('Service request', serviceRequest);\n onError(err);\n } else {\n diag.debug('Objects sent');\n onSuccess();\n }\n }\n );\n } else {\n collector.grpcQueue.push({\n objects,\n onSuccess,\n onError,\n });\n }\n}\n\nexport function validateAndNormalizeUrl(url: string): string {\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.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(\n 'URL protocol should be http(s)://. Using http://.'\n );\n }\n return target.host;\n}\n\nexport function configureSecurity(credentials: grpc.ChannelCredentials | undefined, endpoint: string):\n grpc.ChannelCredentials {\n\n let insecure: boolean;\n\n if (credentials) {\n return credentials;\n } else if (endpoint.startsWith('https://')) {\n insecure = false;\n } else if (endpoint.startsWith('http://') || endpoint === DEFAULT_COLLECTOR_URL) {\n insecure = true;\n } else {\n insecure = getSecurityFromEnv();\n }\n\n if (insecure) {\n return grpc.credentials.createInsecure();\n } else {\n return useSecureConnection();\n }\n}\n\nfunction getSecurityFromEnv(): boolean {\n const definedInsecure =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_INSECURE ||\n getEnv().OTEL_EXPORTER_OTLP_INSECURE;\n\n if (definedInsecure) {\n return definedInsecure.toLowerCase() === 'true';\n } else {\n return false;\n }\n}\n\nexport function useSecureConnection(): grpc.ChannelCredentials {\n const rootCertPath = retrieveRootCert();\n const privateKeyPath = retrievePrivateKey();\n const certChainPath = retrieveCertChain();\n\n return grpc.credentials.createSsl(rootCertPath, privateKeyPath, certChainPath);\n}\n\nfunction retrieveRootCert(): Buffer | undefined {\n const rootCertificate =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE ||\n getEnv().OTEL_EXPORTER_OTLP_CERTIFICATE;\n\n if (rootCertificate) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), rootCertificate));\n } catch {\n diag.warn('Failed to read root certificate file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction retrievePrivateKey(): Buffer | undefined {\n const clientKey =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY ||\n getEnv().OTEL_EXPORTER_OTLP_CLIENT_KEY;\n\n if (clientKey) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), clientKey));\n } catch {\n diag.warn('Failed to read client certificate private key file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction retrieveCertChain(): Buffer | undefined {\n const clientChain =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE ||\n getEnv().OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE;\n\n if (clientChain) {\n try {\n return fs.readFileSync(path.resolve(process.cwd(), clientChain));\n } catch {\n diag.warn('Failed to read client certificate chain file');\n return undefined;\n }\n } else {\n return undefined;\n }\n}\n\nfunction toGrpcCompression(compression: CompressionAlgorithm): GrpcCompressionAlgorithm {\n if (compression === CompressionAlgorithm.NONE)\n return GrpcCompressionAlgorithm.NONE;\n else if (compression === CompressionAlgorithm.GZIP)\n return GrpcCompressionAlgorithm.GZIP;\n return GrpcCompressionAlgorithm.NONE;\n}\n\n/**\n * These values are defined by grpc client\n */\nexport enum GrpcCompressionAlgorithm {\n NONE = 0,\n GZIP = 2\n}\n\nexport function configureCompression(compression: CompressionAlgorithm | undefined): GrpcCompressionAlgorithm {\n if (compression) {\n return toGrpcCompression(compression);\n } else {\n const definedCompression = getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION || getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n\n return definedCompression === 'gzip' ? GrpcCompressionAlgorithm.GZIP : GrpcCompressionAlgorithm.NONE;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.29.2";
1
+ export declare const VERSION = "0.30.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -17,5 +17,5 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VERSION = void 0;
19
19
  // this is autogenerated file, see scripts/version-update.js
20
- exports.VERSION = '0.29.2';
20
+ exports.VERSION = '0.30.0';
21
21
  //# sourceMappingURL=version.js.map
@@ -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.29.2';\n"]}
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.30.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-grpc-exporter-base",
3
- "version": "0.29.2",
3
+ "version": "0.30.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",
@@ -34,7 +34,7 @@
34
34
  "author": "OpenTelemetry Authors",
35
35
  "license": "Apache-2.0",
36
36
  "engines": {
37
- "node": ">=8.12.0"
37
+ "node": ">=14"
38
38
  },
39
39
  "files": [
40
40
  "build/src/**/*.js",
@@ -51,9 +51,9 @@
51
51
  "devDependencies": {
52
52
  "@babel/core": "7.16.0",
53
53
  "@opentelemetry/api": "^1.0.0",
54
- "@opentelemetry/otlp-transformer": "0.29.2",
55
- "@opentelemetry/resources": "1.3.1",
56
- "@opentelemetry/sdk-trace-base": "1.3.1",
54
+ "@opentelemetry/otlp-transformer": "0.30.0",
55
+ "@opentelemetry/resources": "1.4.0",
56
+ "@opentelemetry/sdk-trace-base": "1.4.0",
57
57
  "@types/mocha": "8.2.3",
58
58
  "@types/node": "14.17.33",
59
59
  "@types/sinon": "10.0.6",
@@ -73,8 +73,8 @@
73
73
  "dependencies": {
74
74
  "@grpc/grpc-js": "^1.5.9",
75
75
  "@grpc/proto-loader": "^0.6.9",
76
- "@opentelemetry/core": "1.3.1",
77
- "@opentelemetry/otlp-exporter-base": "0.29.2"
76
+ "@opentelemetry/core": "1.4.0",
77
+ "@opentelemetry/otlp-exporter-base": "0.30.0"
78
78
  },
79
- "gitHead": "51afd54bd63e46d5d530266761144c7be2f6b3a7"
79
+ "gitHead": "e39ab883b18636238ef0fd741df4ce5ed53e8d04"
80
80
  }