@opentelemetry/otlp-grpc-exporter-base 0.37.0 → 0.39.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 (34) hide show
  1. package/build/src/LogsExportServiceClient.d.ts +3 -0
  2. package/build/src/LogsExportServiceClient.js +46 -0
  3. package/build/src/LogsExportServiceClient.js.map +1 -0
  4. package/build/src/MetricsExportServiceClient.d.ts +3 -0
  5. package/build/src/MetricsExportServiceClient.js +46 -0
  6. package/build/src/MetricsExportServiceClient.js.map +1 -0
  7. package/build/src/TraceExportServiceClient.d.ts +3 -0
  8. package/build/src/TraceExportServiceClient.js +46 -0
  9. package/build/src/TraceExportServiceClient.js.map +1 -0
  10. package/build/src/generated/root.d.ts +4 -0
  11. package/build/src/generated/root.js +13013 -0
  12. package/build/src/generated/root.js.map +1 -0
  13. package/build/src/internal-types.d.ts +8 -0
  14. package/build/src/internal-types.js +18 -0
  15. package/build/src/internal-types.js.map +1 -0
  16. package/build/src/types.d.ts +6 -4
  17. package/build/src/types.js +1 -0
  18. package/build/src/types.js.map +1 -1
  19. package/build/src/util.d.ts +1 -1
  20. package/build/src/util.js +32 -28
  21. package/build/src/util.js.map +1 -1
  22. package/build/src/version.d.ts +1 -1
  23. package/build/src/version.js +1 -1
  24. package/build/src/version.js.map +1 -1
  25. package/package.json +13 -14
  26. package/build/protos/opentelemetry/proto/collector/logs/v1/logs_service.proto +0 -45
  27. package/build/protos/opentelemetry/proto/collector/metrics/v1/metrics_service.proto +0 -45
  28. package/build/protos/opentelemetry/proto/collector/trace/v1/trace_service.proto +0 -45
  29. package/build/protos/opentelemetry/proto/common/v1/common.proto +0 -87
  30. package/build/protos/opentelemetry/proto/logs/v1/logs.proto +0 -222
  31. package/build/protos/opentelemetry/proto/metrics/v1/metrics.proto +0 -711
  32. package/build/protos/opentelemetry/proto/resource/v1/resource.proto +0 -36
  33. package/build/protos/opentelemetry/proto/trace/v1/trace.proto +0 -331
  34. package/build/protos/opentelemetry/proto/trace/v1/trace_config.proto +0 -78
@@ -0,0 +1,8 @@
1
+ import type * as protobuf from 'protobufjs';
2
+ export interface ExportType<T, R = T & {
3
+ toJSON: () => unknown;
4
+ }> {
5
+ encode(message: T, writer?: protobuf.Writer): protobuf.Writer;
6
+ decode(reader: protobuf.Reader | Uint8Array, length?: number): R;
7
+ }
8
+ //# sourceMappingURL=internal-types.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright The OpenTelemetry Authors
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * https://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ //# sourceMappingURL=internal-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../../src/internal-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as protobuf from 'protobufjs';\n\nexport interface ExportType<T, R = T & { toJSON: () => unknown }> {\n encode(message: T, writer?: protobuf.Writer): protobuf.Writer;\n decode(reader: protobuf.Reader | Uint8Array, length?: number): R;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import { CompressionAlgorithm, OTLPExporterConfigBase, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
3
3
  /**
4
- * Queue item to be used to save temporary spans/metrics in case the GRPC service
4
+ * Queue item to be used to save temporary spans/metrics/logs in case the GRPC service
5
5
  * hasn't been fully initialized yet
6
6
  */
7
7
  export interface GRPCQueueItem<ExportedItem> {
@@ -10,10 +10,11 @@ export interface GRPCQueueItem<ExportedItem> {
10
10
  onError: (error: OTLPExporterError) => void;
11
11
  }
12
12
  /**
13
- * Service Client for sending spans or metrics
13
+ * Service Client for sending spans/metrics/logs
14
14
  */
15
- export interface ServiceClient extends grpc.Client {
15
+ export interface ServiceClient {
16
16
  export: (request: any, metadata: grpc.Metadata, options: grpc.CallOptions, callback: Function) => {};
17
+ close(): void;
17
18
  }
18
19
  /**
19
20
  * OTLP Exporter Config for Node
@@ -25,6 +26,7 @@ export interface OTLPGRPCExporterConfigNode extends OTLPExporterConfigBase {
25
26
  }
26
27
  export declare enum ServiceClientType {
27
28
  SPANS = 0,
28
- METRICS = 1
29
+ METRICS = 1,
30
+ LOGS = 2
29
31
  }
30
32
  //# sourceMappingURL=types.d.ts.map
@@ -20,5 +20,6 @@ var ServiceClientType;
20
20
  (function (ServiceClientType) {
21
21
  ServiceClientType[ServiceClientType["SPANS"] = 0] = "SPANS";
22
22
  ServiceClientType[ServiceClientType["METRICS"] = 1] = "METRICS";
23
+ ServiceClientType[ServiceClientType["LOGS"] = 2] = "LOGS";
23
24
  })(ServiceClientType = exports.ServiceClientType || (exports.ServiceClientType = {}));
24
25
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAwCH,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,2DAAK,CAAA;IACL,+DAAO,CAAA;AACT,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B","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 {\n CompressionAlgorithm,\n OTLPExporterConfigBase,\n OTLPExporterError,\n} from '@opentelemetry/otlp-exporter-base';\n\n/**\n * Queue item to be used to save temporary spans/metrics in case the GRPC service\n * hasn't been fully initialized yet\n */\nexport interface GRPCQueueItem<ExportedItem> {\n objects: ExportedItem[];\n onSuccess: () => void;\n onError: (error: OTLPExporterError) => void;\n}\n\n/**\n * Service Client for sending spans or metrics\n */\nexport interface ServiceClient extends grpc.Client {\n export: (\n request: any,\n metadata: grpc.Metadata,\n options: grpc.CallOptions,\n callback: Function\n ) => {};\n}\n\n/**\n * OTLP Exporter Config for Node\n */\nexport interface OTLPGRPCExporterConfigNode extends OTLPExporterConfigBase {\n credentials?: grpc.ChannelCredentials;\n metadata?: grpc.Metadata;\n compression?: CompressionAlgorithm;\n}\n\nexport enum ServiceClientType {\n SPANS,\n METRICS,\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA0CH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,2DAAK,CAAA;IACL,+DAAO,CAAA;IACP,yDAAI,CAAA;AACN,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B","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 {\n CompressionAlgorithm,\n OTLPExporterConfigBase,\n OTLPExporterError,\n} from '@opentelemetry/otlp-exporter-base';\n\n/**\n * Queue item to be used to save temporary spans/metrics/logs in case the GRPC service\n * hasn't been fully initialized yet\n */\nexport interface GRPCQueueItem<ExportedItem> {\n objects: ExportedItem[];\n onSuccess: () => void;\n onError: (error: OTLPExporterError) => void;\n}\n\n/**\n * Service Client for sending spans/metrics/logs\n */\nexport interface ServiceClient {\n export: (\n request: any,\n metadata: grpc.Metadata,\n options: grpc.CallOptions,\n callback: Function\n ) => {};\n\n close(): void;\n}\n\n/**\n * OTLP Exporter Config for Node\n */\nexport interface OTLPGRPCExporterConfigNode extends OTLPExporterConfigBase {\n credentials?: grpc.ChannelCredentials;\n metadata?: grpc.Metadata;\n compression?: CompressionAlgorithm;\n}\n\nexport enum ServiceClientType {\n SPANS,\n METRICS,\n LOGS,\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import * as grpc from '@grpc/grpc-js';
2
2
  import { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';
3
3
  import { OTLPGRPCExporterConfigNode } from './types';
4
- import { CompressionAlgorithm, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
4
+ import { OTLPExporterError, CompressionAlgorithm } from '@opentelemetry/otlp-exporter-base';
5
5
  export declare const DEFAULT_COLLECTOR_URL = "http://localhost:4317";
6
6
  export declare function onInit<ExportItem, ServiceRequest>(collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>, config: OTLPGRPCExporterConfigNode): void;
7
7
  export declare function send<ExportItem, ServiceRequest>(collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>, objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
package/build/src/util.js CHANGED
@@ -17,7 +17,6 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.configureCompression = exports.GrpcCompressionAlgorithm = exports.useSecureConnection = exports.configureSecurity = exports.validateAndNormalizeUrl = exports.send = exports.onInit = exports.DEFAULT_COLLECTOR_URL = void 0;
19
19
  const grpc = require("@grpc/grpc-js");
20
- const protoLoader = require("@grpc/proto-loader");
21
20
  const api_1 = require("@opentelemetry/api");
22
21
  const core_1 = require("@opentelemetry/core");
23
22
  const path = require("path");
@@ -25,43 +24,48 @@ const url_1 = require("url");
25
24
  const fs = require("fs");
26
25
  const types_1 = require("./types");
27
26
  const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
27
+ const MetricsExportServiceClient_1 = require("./MetricsExportServiceClient");
28
+ const TraceExportServiceClient_1 = require("./TraceExportServiceClient");
29
+ const LogsExportServiceClient_1 = require("./LogsExportServiceClient");
28
30
  exports.DEFAULT_COLLECTOR_URL = 'http://localhost:4317';
29
31
  function onInit(collector, config) {
30
32
  collector.grpcQueue = [];
31
33
  const credentials = configureSecurity(config.credentials, collector.getUrlFromConfig(config));
32
- const includeDirs = [path.resolve(__dirname, '..', 'protos')];
33
- protoLoader
34
- .load(collector.getServiceProtoPath(), {
35
- keepCase: false,
36
- longs: String,
37
- enums: String,
38
- defaults: true,
39
- oneofs: true,
40
- includeDirs,
41
- })
42
- .then(packageDefinition => {
43
- const packageObject = grpc.loadPackageDefinition(packageDefinition);
44
- const options = {
45
- 'grpc.default_compression_algorithm': collector.compression,
46
- };
34
+ try {
47
35
  if (collector.getServiceClientType() === types_1.ServiceClientType.SPANS) {
48
- collector.serviceClient =
49
- new packageObject.opentelemetry.proto.collector.trace.v1.TraceService(collector.url, credentials, options);
36
+ const client = new TraceExportServiceClient_1.TraceExportServiceClient(collector.url, credentials, {
37
+ 'grpc.default_compression_algorithm': collector.compression.valueOf(),
38
+ });
39
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
40
+ // @ts-ignore
41
+ collector.serviceClient = client;
50
42
  }
51
- else {
52
- collector.serviceClient =
53
- new packageObject.opentelemetry.proto.collector.metrics.v1.MetricsService(collector.url, credentials, options);
43
+ else if (collector.getServiceClientType() === types_1.ServiceClientType.METRICS) {
44
+ const client = new MetricsExportServiceClient_1.MetricExportServiceClient(collector.url, credentials, {
45
+ 'grpc.default_compression_algorithm': collector.compression.valueOf(),
46
+ });
47
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
48
+ // @ts-ignore
49
+ collector.serviceClient = client;
54
50
  }
55
- if (collector.grpcQueue.length > 0) {
56
- const queue = collector.grpcQueue.splice(0);
57
- queue.forEach((item) => {
58
- collector.send(item.objects, item.onSuccess, item.onError);
51
+ else if (collector.getServiceClientType() === types_1.ServiceClientType.LOGS) {
52
+ const client = new LogsExportServiceClient_1.LogsExportServiceClient(collector.url, credentials, {
53
+ 'grpc.default_compression_algorithm': collector.compression.valueOf(),
59
54
  });
55
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
56
+ // @ts-ignore
57
+ collector.serviceClient = client;
60
58
  }
61
- })
62
- .catch(err => {
59
+ }
60
+ catch (err) {
63
61
  (0, core_1.globalErrorHandler)(err);
64
- });
62
+ }
63
+ if (collector.grpcQueue.length > 0) {
64
+ const queue = collector.grpcQueue.splice(0);
65
+ queue.forEach((item) => {
66
+ collector.send(item.objects, item.onSuccess, item.onError);
67
+ });
68
+ }
65
69
  }
66
70
  exports.onInit = onInit;
67
71
  function send(collector, objects, onSuccess, onError) {
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AACtC,kDAAkD;AAClD,4CAA0C;A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AAC,CAAC,wBAAwB,CAAC,IAAI;YAC/B,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC;KACnC;AACH,CAAC;AAdD,oDAcC","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 {\n GRPCQueueItem,\n OTLPGRPCExporterConfigNode,\n ServiceClientType,\n} from './types';\nimport {\n CompressionAlgorithm,\n ExportServiceError,\n OTLPExporterError,\n} 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(\n config.credentials,\n collector.getUrlFromConfig(config)\n );\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 = {\n 'grpc.default_compression_algorithm': collector.compression,\n };\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('URL protocol should be http(s)://. Using http://.');\n }\n return target.host;\n}\n\nexport function configureSecurity(\n credentials: grpc.ChannelCredentials | undefined,\n endpoint: string\n): grpc.ChannelCredentials {\n let insecure: boolean;\n\n if (credentials) {\n return credentials;\n } else if (endpoint.startsWith('https://')) {\n insecure = false;\n } else if (\n endpoint.startsWith('http://') ||\n endpoint === DEFAULT_COLLECTOR_URL\n ) {\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(\n rootCertPath,\n privateKeyPath,\n certChainPath\n );\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(\n compression: CompressionAlgorithm\n): 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(\n compression: CompressionAlgorithm | undefined\n): GrpcCompressionAlgorithm {\n if (compression) {\n return toGrpcCompression(compression);\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n\n return definedCompression === 'gzip'\n ? GrpcCompressionAlgorithm.GZIP\n : GrpcCompressionAlgorithm.NONE;\n }\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,sCAAsC;AACtC,4CAA0C;AAC1C,8CAAiE;AACjE,6BAA6B;AAE7B,6BAA0B;AAC1B,yBAAyB;AACzB,mCAIiB;AACjB,0EAI2C;AAE3C,6EAAyE;AACzE,yEAAsE;AACtE,uEAAoE;AAEvD,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,CAC5D,MAAM,CAAC,WAAW,EAClB,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CACnC,CAAC;IAEF,IAAI;QACF,IAAI,SAAS,CAAC,oBAAoB,EAAE,KAAK,yBAAiB,CAAC,KAAK,EAAE;YAChE,MAAM,MAAM,GAAG,IAAI,mDAAwB,CAAC,SAAS,CAAC,GAAG,EAAE,WA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SAAS,CAAC;KAClB;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,WAAiC;IAEjC,IAAI,WAAW,KAAK,yCAAoB,CAAC,IAAI;QAC3C,OAAO,wBAAwB,CAAC,IAAI,CAAC;SAClC,IAAI,WAAW,KAAK,yCAAoB,CAAC,IAAI;QAChD,OAAO,wBAAwB,CAAC,IAAI,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,CAClC,WAA6C;IAE7C,IAAI,WAAW,EAAE;QACf,OAAO,iBAAiB,CAAC,WAAW,CAAC,CAAC;KACvC;SAAM;QACL,MAAM,kBAAkB,GACtB,IAAA,aAAM,GAAE,CAAC,qCAAqC;YAC9C,IAAA,aAAM,GAAE,CAAC,8BAA8B,CAAC;QAE1C,OAAO,kBAAkB,KAAK,MAAM;YAClC,CAAC,CAAC,wBAAwB,CAAC,IAAI;YAC/B,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC;KACnC;AACH,CAAC;AAdD,oDAcC","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 { 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 {\n GRPCQueueItem,\n OTLPGRPCExporterConfigNode,\n ServiceClientType,\n} from './types';\nimport {\n ExportServiceError,\n OTLPExporterError,\n CompressionAlgorithm,\n} from '@opentelemetry/otlp-exporter-base';\n\nimport { MetricExportServiceClient } from './MetricsExportServiceClient';\nimport { TraceExportServiceClient } from './TraceExportServiceClient';\nimport { LogsExportServiceClient } from './LogsExportServiceClient';\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(\n config.credentials,\n collector.getUrlFromConfig(config)\n );\n\n try {\n if (collector.getServiceClientType() === ServiceClientType.SPANS) {\n const client = new TraceExportServiceClient(collector.url, credentials, {\n 'grpc.default_compression_algorithm': collector.compression.valueOf(),\n });\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n collector.serviceClient = client;\n } else if (collector.getServiceClientType() === ServiceClientType.METRICS) {\n const client = new MetricExportServiceClient(collector.url, credentials, {\n 'grpc.default_compression_algorithm': collector.compression.valueOf(),\n });\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n collector.serviceClient = client;\n } else if (collector.getServiceClientType() === ServiceClientType.LOGS) {\n const client = new LogsExportServiceClient(collector.url, credentials, {\n 'grpc.default_compression_algorithm': collector.compression.valueOf(),\n });\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n collector.serviceClient = client;\n }\n } catch (err) {\n globalErrorHandler(err);\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\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('URL protocol should be http(s)://. Using http://.');\n }\n return target.host;\n}\n\nexport function configureSecurity(\n credentials: grpc.ChannelCredentials | undefined,\n endpoint: string\n): grpc.ChannelCredentials {\n let insecure: boolean;\n\n if (credentials) {\n return credentials;\n } else if (endpoint.startsWith('https://')) {\n insecure = false;\n } else if (\n endpoint.startsWith('http://') ||\n endpoint === DEFAULT_COLLECTOR_URL\n ) {\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(\n rootCertPath,\n privateKeyPath,\n certChainPath\n );\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(\n compression: CompressionAlgorithm\n): 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(\n compression: CompressionAlgorithm | undefined\n): GrpcCompressionAlgorithm {\n if (compression) {\n return toGrpcCompression(compression);\n } else {\n const definedCompression =\n getEnv().OTEL_EXPORTER_OTLP_TRACES_COMPRESSION ||\n getEnv().OTEL_EXPORTER_OTLP_COMPRESSION;\n\n return definedCompression === 'gzip'\n ? GrpcCompressionAlgorithm.GZIP\n : GrpcCompressionAlgorithm.NONE;\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.37.0";
1
+ export declare const VERSION = "0.39.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.37.0';
20
+ exports.VERSION = '0.39.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.37.0';\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.39.0';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-grpc-exporter-base",
3
- "version": "0.37.0",
3
+ "version": "0.39.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",
@@ -8,17 +8,17 @@
8
8
  "scripts": {
9
9
  "prepublishOnly": "npm run compile",
10
10
  "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
11
- "compile": "tsc --build",
11
+ "compile": "npm run protos && tsc --build",
12
12
  "clean": "tsc --build --clean",
13
13
  "lint": "eslint . --ext .ts",
14
14
  "lint:fix": "eslint . --ext .ts --fix",
15
- "postcompile": "npm run submodule && npm run protos:copy",
16
- "protos:copy": "cpx protos/opentelemetry/**/*.* build/protos/opentelemetry",
15
+ "protos": "npm run submodule && npm run protos:generate",
16
+ "protos:generate": "node ../../../scripts/generate-protos.js",
17
17
  "submodule": "git submodule sync --recursive && git submodule update --init --recursive",
18
18
  "tdd": "npm run test -- --watch-extensions ts --watch",
19
19
  "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
20
20
  "version": "node ../../../scripts/version-update.js",
21
- "watch": "npm run protos:copy && tsc -w",
21
+ "watch": "npm run protos && tsc -w",
22
22
  "precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
23
23
  "prewatch": "npm run precompile"
24
24
  },
@@ -40,7 +40,6 @@
40
40
  "build/src/**/*.js",
41
41
  "build/src/**/*.js.map",
42
42
  "build/src/**/*.d.ts",
43
- "build/protos/**/*.proto",
44
43
  "doc",
45
44
  "LICENSE",
46
45
  "README.md"
@@ -51,9 +50,9 @@
51
50
  "devDependencies": {
52
51
  "@babel/core": "7.16.0",
53
52
  "@opentelemetry/api": "1.4.1",
54
- "@opentelemetry/otlp-transformer": "0.37.0",
55
- "@opentelemetry/resources": "1.11.0",
56
- "@opentelemetry/sdk-trace-base": "1.11.0",
53
+ "@opentelemetry/otlp-transformer": "0.39.0",
54
+ "@opentelemetry/resources": "1.13.0",
55
+ "@opentelemetry/sdk-trace-base": "1.13.0",
57
56
  "@types/mocha": "10.0.0",
58
57
  "@types/node": "18.6.5",
59
58
  "@types/sinon": "10.0.13",
@@ -61,7 +60,7 @@
61
60
  "cpx": "1.5.0",
62
61
  "mocha": "10.0.0",
63
62
  "nyc": "15.1.0",
64
- "rimraf": "4.1.2",
63
+ "protobufjs-cli": "1.0.2",
65
64
  "sinon": "15.0.0",
66
65
  "ts-loader": "8.4.0",
67
66
  "ts-mocha": "10.0.0",
@@ -72,11 +71,11 @@
72
71
  },
73
72
  "dependencies": {
74
73
  "@grpc/grpc-js": "^1.7.1",
75
- "@grpc/proto-loader": "^0.7.3",
76
- "@opentelemetry/core": "1.11.0",
77
- "@opentelemetry/otlp-exporter-base": "0.37.0"
74
+ "@opentelemetry/core": "1.13.0",
75
+ "@opentelemetry/otlp-exporter-base": "0.39.0",
76
+ "protobufjs": "^7.2.2"
78
77
  },
79
78
  "homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/otlp-grpc-exporter-base",
80
79
  "sideEffects": false,
81
- "gitHead": "1328ee04ae78f9f6cf143af7050c00aaa6d2eb3b"
80
+ "gitHead": "8fc76896595aac912bf9e15d4f19c167317844c8"
82
81
  }
@@ -1,45 +0,0 @@
1
- // Copyright 2020, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.collector.logs.v1;
18
-
19
- import "opentelemetry/proto/logs/v1/logs.proto";
20
-
21
- option java_multiple_files = true;
22
- option java_package = "io.opentelemetry.proto.collector.logs.v1";
23
- option java_outer_classname = "LogsServiceProto";
24
- option go_package = "go.opentelemetry.io/proto/otlp/collector/logs/v1";
25
-
26
- // Service that can be used to push logs between one Application instrumented with
27
- // OpenTelemetry and an collector, or between an collector and a central collector (in this
28
- // case logs are sent/received to/from multiple Applications).
29
- service LogsService {
30
- // For performance reasons, it is recommended to keep this RPC
31
- // alive for the entire life of the application.
32
- rpc Export(ExportLogsServiceRequest) returns (ExportLogsServiceResponse) {}
33
- }
34
-
35
- message ExportLogsServiceRequest {
36
- // An array of ResourceLogs.
37
- // For data coming from a single resource this array will typically contain one
38
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
- // data from multiple origins typically batch the data before forwarding further and
40
- // in that case this array will contain multiple elements.
41
- repeated opentelemetry.proto.logs.v1.ResourceLogs resource_logs = 1;
42
- }
43
-
44
- message ExportLogsServiceResponse {
45
- }
@@ -1,45 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.collector.metrics.v1;
18
-
19
- import "opentelemetry/proto/metrics/v1/metrics.proto";
20
-
21
- option java_multiple_files = true;
22
- option java_package = "io.opentelemetry.proto.collector.metrics.v1";
23
- option java_outer_classname = "MetricsServiceProto";
24
- option go_package = "go.opentelemetry.io/proto/otlp/collector/metrics/v1";
25
-
26
- // Service that can be used to push metrics between one Application
27
- // instrumented with OpenTelemetry and a collector, or between a collector and a
28
- // central collector.
29
- service MetricsService {
30
- // For performance reasons, it is recommended to keep this RPC
31
- // alive for the entire life of the application.
32
- rpc Export(ExportMetricsServiceRequest) returns (ExportMetricsServiceResponse) {}
33
- }
34
-
35
- message ExportMetricsServiceRequest {
36
- // An array of ResourceMetrics.
37
- // For data coming from a single resource this array will typically contain one
38
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
- // data from multiple origins typically batch the data before forwarding further and
40
- // in that case this array will contain multiple elements.
41
- repeated opentelemetry.proto.metrics.v1.ResourceMetrics resource_metrics = 1;
42
- }
43
-
44
- message ExportMetricsServiceResponse {
45
- }
@@ -1,45 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.collector.trace.v1;
18
-
19
- import "opentelemetry/proto/trace/v1/trace.proto";
20
-
21
- option java_multiple_files = true;
22
- option java_package = "io.opentelemetry.proto.collector.trace.v1";
23
- option java_outer_classname = "TraceServiceProto";
24
- option go_package = "go.opentelemetry.io/proto/otlp/collector/trace/v1";
25
-
26
- // Service that can be used to push spans between one Application instrumented with
27
- // OpenTelemetry and a collector, or between a collector and a central collector (in this
28
- // case spans are sent/received to/from multiple Applications).
29
- service TraceService {
30
- // For performance reasons, it is recommended to keep this RPC
31
- // alive for the entire life of the application.
32
- rpc Export(ExportTraceServiceRequest) returns (ExportTraceServiceResponse) {}
33
- }
34
-
35
- message ExportTraceServiceRequest {
36
- // An array of ResourceSpans.
37
- // For data coming from a single resource this array will typically contain one
38
- // element. Intermediary nodes (such as OpenTelemetry Collector) that receive
39
- // data from multiple origins typically batch the data before forwarding further and
40
- // in that case this array will contain multiple elements.
41
- repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
42
- }
43
-
44
- message ExportTraceServiceResponse {
45
- }
@@ -1,87 +0,0 @@
1
- // Copyright 2019, OpenTelemetry Authors
2
- //
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- syntax = "proto3";
16
-
17
- package opentelemetry.proto.common.v1;
18
-
19
- option java_multiple_files = true;
20
- option java_package = "io.opentelemetry.proto.common.v1";
21
- option java_outer_classname = "CommonProto";
22
- option go_package = "go.opentelemetry.io/proto/otlp/common/v1";
23
-
24
- // AnyValue is used to represent any type of attribute value. AnyValue may contain a
25
- // primitive value such as a string or integer or it may contain an arbitrary nested
26
- // object containing arrays, key-value lists and primitives.
27
- message AnyValue {
28
- // The value is one of the listed fields. It is valid for all values to be unspecified
29
- // in which case this AnyValue is considered to be "empty".
30
- oneof value {
31
- string string_value = 1;
32
- bool bool_value = 2;
33
- int64 int_value = 3;
34
- double double_value = 4;
35
- ArrayValue array_value = 5;
36
- KeyValueList kvlist_value = 6;
37
- bytes bytes_value = 7;
38
- }
39
- }
40
-
41
- // ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
42
- // since oneof in AnyValue does not allow repeated fields.
43
- message ArrayValue {
44
- // Array of values. The array may be empty (contain 0 elements).
45
- repeated AnyValue values = 1;
46
- }
47
-
48
- // KeyValueList is a list of KeyValue messages. We need KeyValueList as a message
49
- // since `oneof` in AnyValue does not allow repeated fields. Everywhere else where we need
50
- // a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
51
- // avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
52
- // are semantically equivalent.
53
- message KeyValueList {
54
- // A collection of key/value pairs of key-value pairs. The list may be empty (may
55
- // contain 0 elements).
56
- // The keys MUST be unique (it is not allowed to have more than one
57
- // value with the same key).
58
- repeated KeyValue values = 1;
59
- }
60
-
61
- // KeyValue is a key-value pair that is used to store Span attributes, Link
62
- // attributes, etc.
63
- message KeyValue {
64
- string key = 1;
65
- AnyValue value = 2;
66
- }
67
-
68
- // InstrumentationLibrary is a message representing the instrumentation library information
69
- // such as the fully qualified name and version.
70
- // InstrumentationLibrary is wire-compatible with InstrumentationScope for binary
71
- // Protobuf format.
72
- // This message is deprecated and will be removed on June 15, 2022.
73
- message InstrumentationLibrary {
74
- option deprecated = true;
75
-
76
- // An empty instrumentation library name means the name is unknown.
77
- string name = 1;
78
- string version = 2;
79
- }
80
-
81
- // InstrumentationScope is a message representing the instrumentation scope information
82
- // such as the fully qualified name and version.
83
- message InstrumentationScope {
84
- // An empty instrumentation scope name means the name is unknown.
85
- string name = 1;
86
- string version = 2;
87
- }