@opentelemetry/otlp-grpc-exporter-base 0.28.0 → 0.29.2

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.
@@ -21,11 +21,13 @@ import "opentelemetry/proto/common/v1/common.proto";
21
21
  option java_multiple_files = true;
22
22
  option java_package = "io.opentelemetry.proto.resource.v1";
23
23
  option java_outer_classname = "ResourceProto";
24
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/resource/v1";
24
+ option go_package = "go.opentelemetry.io/proto/otlp/resource/v1";
25
25
 
26
26
  // Resource information.
27
27
  message Resource {
28
- // Set of labels that describe the resource.
28
+ // Set of attributes that describe the resource.
29
+ // Attribute keys MUST be unique (it is not allowed to have more than one
30
+ // attribute with the same key).
29
31
  repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
30
32
 
31
33
  // dropped_attributes_count is the number of dropped attributes. If the value is 0, then
@@ -22,26 +22,101 @@ import "opentelemetry/proto/resource/v1/resource.proto";
22
22
  option java_multiple_files = true;
23
23
  option java_package = "io.opentelemetry.proto.trace.v1";
24
24
  option java_outer_classname = "TraceProto";
25
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/trace/v1";
25
+ option go_package = "go.opentelemetry.io/proto/otlp/trace/v1";
26
26
 
27
- // A collection of InstrumentationLibrarySpans from a Resource.
27
+ // TracesData represents the traces data that can be stored in a persistent storage,
28
+ // OR can be embedded by other protocols that transfer OTLP traces data but do
29
+ // not implement the OTLP protocol.
30
+ //
31
+ // The main difference between this message and collector protocol is that
32
+ // in this message there will not be any "control" or "metadata" specific to
33
+ // OTLP protocol.
34
+ //
35
+ // When new fields are added into this message, the OTLP request MUST be updated
36
+ // as well.
37
+ message TracesData {
38
+ // An array of ResourceSpans.
39
+ // For data coming from a single resource this array will typically contain
40
+ // one element. Intermediary nodes that receive data from multiple origins
41
+ // typically batch the data before forwarding further and in that case this
42
+ // array will contain multiple elements.
43
+ repeated ResourceSpans resource_spans = 1;
44
+ }
45
+
46
+ // A collection of ScopeSpans from a Resource.
28
47
  message ResourceSpans {
29
48
  // The resource for the spans in this message.
30
49
  // If this field is not set then no resource info is known.
31
50
  opentelemetry.proto.resource.v1.Resource resource = 1;
32
51
 
52
+ // A list of ScopeSpans that originate from a resource.
53
+ repeated ScopeSpans scope_spans = 2;
54
+
33
55
  // A list of InstrumentationLibrarySpans that originate from a resource.
34
- repeated InstrumentationLibrarySpans instrumentation_library_spans = 2;
56
+ // This field is deprecated and will be removed after grace period expires on June 15, 2022.
57
+ //
58
+ // During the grace period the following rules SHOULD be followed:
59
+ //
60
+ // For Binary Protobufs
61
+ // ====================
62
+ // Binary Protobuf senders SHOULD NOT set instrumentation_library_spans. Instead
63
+ // scope_spans SHOULD be set.
64
+ //
65
+ // Binary Protobuf receivers SHOULD check if instrumentation_library_spans is set
66
+ // and scope_spans is not set then the value in instrumentation_library_spans
67
+ // SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans.
68
+ // If scope_spans is set then instrumentation_library_spans SHOULD be ignored.
69
+ //
70
+ // For JSON
71
+ // ========
72
+ // JSON senders that set instrumentation_library_spans field MAY also set
73
+ // scope_spans to carry the same spans, essentially double-publishing the same data.
74
+ // Such double-publishing MAY be controlled by a user-settable option.
75
+ // If double-publishing is not used then the senders SHOULD set scope_spans and
76
+ // SHOULD NOT set instrumentation_library_spans.
77
+ //
78
+ // JSON receivers SHOULD check if instrumentation_library_spans is set and
79
+ // scope_spans is not set then the value in instrumentation_library_spans
80
+ // SHOULD be used instead by converting InstrumentationLibrarySpans into ScopeSpans.
81
+ // If scope_spans is set then instrumentation_library_spans field SHOULD be ignored.
82
+ repeated InstrumentationLibrarySpans instrumentation_library_spans = 1000 [deprecated = true];
83
+
84
+ // This schema_url applies to the data in the "resource" field. It does not apply
85
+ // to the data in the "scope_spans" field which have their own schema_url field.
86
+ string schema_url = 3;
87
+ }
88
+
89
+ // A collection of Spans produced by an InstrumentationScope.
90
+ message ScopeSpans {
91
+ // The instrumentation scope information for the spans in this message.
92
+ // Semantically when InstrumentationScope isn't set, it is equivalent with
93
+ // an empty instrumentation scope name (unknown).
94
+ opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
95
+
96
+ // A list of Spans that originate from an instrumentation scope.
97
+ repeated Span spans = 2;
98
+
99
+ // This schema_url applies to all spans and span events in the "spans" field.
100
+ string schema_url = 3;
35
101
  }
36
102
 
37
103
  // A collection of Spans produced by an InstrumentationLibrary.
104
+ // InstrumentationLibrarySpans is wire-compatible with ScopeSpans for binary
105
+ // Protobuf format.
106
+ // This message is deprecated and will be removed on June 15, 2022.
38
107
  message InstrumentationLibrarySpans {
108
+ option deprecated = true;
109
+
39
110
  // The instrumentation library information for the spans in this message.
40
- // If this field is not set then no library info is known.
111
+ // Semantically when InstrumentationLibrary isn't set, it is equivalent with
112
+ // an empty instrumentation library name (unknown).
41
113
  opentelemetry.proto.common.v1.InstrumentationLibrary instrumentation_library = 1;
42
114
 
43
115
  // A list of Spans that originate from an instrumentation library.
44
116
  repeated Span spans = 2;
117
+
118
+ // This schema_url applies to all spans and span events in the "spans" field.
119
+ string schema_url = 3;
45
120
  }
46
121
 
47
122
  // Span represents a single operation within a trace. Spans can be
@@ -91,9 +166,7 @@ message Span {
91
166
  // This makes it easier to correlate spans in different traces.
92
167
  //
93
168
  // This field is semantically required to be set to non-empty string.
94
- // When null or empty string received - receiver may use string "name"
95
- // as a replacement. There might be smarted algorithms implemented by
96
- // receiver to fix the empty span name.
169
+ // Empty value is equivalent to an unknown span name.
97
170
  //
98
171
  // This field is required.
99
172
  string name = 5;
@@ -106,7 +179,7 @@ message Span {
106
179
  SPAN_KIND_UNSPECIFIED = 0;
107
180
 
108
181
  // Indicates that the span represents an internal operation within an application,
109
- // as opposed to an operations happening at the boundaries. Default value.
182
+ // as opposed to an operation happening at the boundaries. Default value.
110
183
  SPAN_KIND_INTERNAL = 1;
111
184
 
112
185
  // Indicates that the span covers server-side handling of an RPC or other
@@ -149,14 +222,18 @@ message Span {
149
222
  // This field is semantically required and it is expected that end_time >= start_time.
150
223
  fixed64 end_time_unix_nano = 8;
151
224
 
152
- // attributes is a collection of key/value pairs. The value can be a string,
153
- // an integer, a double or the Boolean values `true` or `false`. Note, global attributes
225
+ // attributes is a collection of key/value pairs. Note, global attributes
154
226
  // like server name can be set using the resource API. Examples of attributes:
155
227
  //
156
228
  // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
157
229
  // "/http/server_latency": 300
158
230
  // "abc.com/myattribute": true
159
231
  // "abc.com/score": 10.239
232
+ //
233
+ // The OpenTelemetry API specification further restricts the allowed value types:
234
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/common.md#attributes
235
+ // Attribute keys MUST be unique (it is not allowed to have more than one
236
+ // attribute with the same key).
160
237
  repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
161
238
 
162
239
  // dropped_attributes_count is the number of attributes that were discarded. Attributes
@@ -175,6 +252,8 @@ message Span {
175
252
  string name = 2;
176
253
 
177
254
  // attributes is a collection of attribute key/value pairs on the event.
255
+ // Attribute keys MUST be unique (it is not allowed to have more than one
256
+ // attribute with the same key).
178
257
  repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
179
258
 
180
259
  // dropped_attributes_count is the number of dropped attributes. If the value is 0,
@@ -205,6 +284,8 @@ message Span {
205
284
  string trace_state = 3;
206
285
 
207
286
  // attributes is a collection of attribute key/value pairs on the link.
287
+ // Attribute keys MUST be unique (it is not allowed to have more than one
288
+ // attribute with the same key).
208
289
  repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
209
290
 
210
291
  // dropped_attributes_count is the number of dropped attributes. If the value is 0,
@@ -228,78 +309,13 @@ message Span {
228
309
  // The Status type defines a logical error model that is suitable for different
229
310
  // programming environments, including REST APIs and RPC APIs.
230
311
  message Status {
231
- // IMPORTANT: Backward compatibility notes:
232
- //
233
- // To ensure any pair of senders and receivers continues to correctly signal and
234
- // interpret erroneous situations, the senders and receivers MUST follow these rules:
235
- //
236
- // 1. Old senders and receivers that are not aware of `code` field will continue using
237
- // the `deprecated_code` field to signal and interpret erroneous situation.
238
- //
239
- // 2. New senders, which are aware of the `code` field MUST set both the
240
- // `deprecated_code` and `code` fields according to the following rules:
241
- //
242
- // if code==STATUS_CODE_UNSET then `deprecated_code` MUST be
243
- // set to DEPRECATED_STATUS_CODE_OK.
244
- //
245
- // if code==STATUS_CODE_OK then `deprecated_code` MUST be
246
- // set to DEPRECATED_STATUS_CODE_OK.
247
- //
248
- // if code==STATUS_CODE_ERROR then `deprecated_code` MUST be
249
- // set to DEPRECATED_STATUS_CODE_UNKNOWN_ERROR.
250
- //
251
- // These rules allow old receivers to correctly interpret data received from new senders.
252
- //
253
- // 3. New receivers MUST look at both the `code` and `deprecated_code` fields in order
254
- // to interpret the overall status:
255
- //
256
- // If code==STATUS_CODE_UNSET then the value of `deprecated_code` is the
257
- // carrier of the overall status according to these rules:
258
- //
259
- // if deprecated_code==DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret
260
- // the overall status to be STATUS_CODE_UNSET.
261
- //
262
- // if deprecated_code!=DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret
263
- // the overall status to be STATUS_CODE_ERROR.
264
- //
265
- // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be
266
- // ignored, the `code` field is the sole carrier of the status.
267
- //
268
- // These rules allow new receivers to correctly interpret data received from old senders.
269
-
270
- enum DeprecatedStatusCode {
271
- DEPRECATED_STATUS_CODE_OK = 0;
272
- DEPRECATED_STATUS_CODE_CANCELLED = 1;
273
- DEPRECATED_STATUS_CODE_UNKNOWN_ERROR = 2;
274
- DEPRECATED_STATUS_CODE_INVALID_ARGUMENT = 3;
275
- DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED = 4;
276
- DEPRECATED_STATUS_CODE_NOT_FOUND = 5;
277
- DEPRECATED_STATUS_CODE_ALREADY_EXISTS = 6;
278
- DEPRECATED_STATUS_CODE_PERMISSION_DENIED = 7;
279
- DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED = 8;
280
- DEPRECATED_STATUS_CODE_FAILED_PRECONDITION = 9;
281
- DEPRECATED_STATUS_CODE_ABORTED = 10;
282
- DEPRECATED_STATUS_CODE_OUT_OF_RANGE = 11;
283
- DEPRECATED_STATUS_CODE_UNIMPLEMENTED = 12;
284
- DEPRECATED_STATUS_CODE_INTERNAL_ERROR = 13;
285
- DEPRECATED_STATUS_CODE_UNAVAILABLE = 14;
286
- DEPRECATED_STATUS_CODE_DATA_LOSS = 15;
287
- DEPRECATED_STATUS_CODE_UNAUTHENTICATED = 16;
288
- };
289
-
290
- // The deprecated status code. This is an optional field.
291
- //
292
- // This field is deprecated and is replaced by the `code` field below. See backward
293
- // compatibility notes below. According to our stability guarantees this field
294
- // will be removed in 12 months, on Oct 22, 2021. All usage of old senders and
295
- // receivers that do not understand the `code` field MUST be phased out by then.
296
- DeprecatedStatusCode deprecated_code = 1 [deprecated=true];
312
+ reserved 1;
297
313
 
298
314
  // A developer-facing human readable error message.
299
315
  string message = 2;
300
316
 
301
317
  // For the semantics of status codes see
302
- // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status
318
+ // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/api.md#set-status
303
319
  enum StatusCode {
304
320
  // The default status.
305
321
  STATUS_CODE_UNSET = 0;
@@ -19,7 +19,7 @@ package opentelemetry.proto.trace.v1;
19
19
  option java_multiple_files = true;
20
20
  option java_package = "io.opentelemetry.proto.trace.v1";
21
21
  option java_outer_classname = "TraceConfigProto";
22
- option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/collector/trace/v1";
22
+ option go_package = "go.opentelemetry.io/proto/otlp/collector/trace/v1";
23
23
 
24
24
  // Global configuration of the trace service. All fields must be specified, or
25
25
  // the default (zero) values will be used for each type.
@@ -1,4 +1,4 @@
1
1
  export * from './OTLPGRPCExporterNodeBase';
2
2
  export { ServiceClientType, OTLPGRPCExporterConfigNode } from './types';
3
- export { validateAndNormalizeUrl, GrpcCompressionAlgorithm } from './util';
3
+ export { DEFAULT_COLLECTOR_URL, validateAndNormalizeUrl, GrpcCompressionAlgorithm } from './util';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -25,11 +25,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
25
25
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.GrpcCompressionAlgorithm = exports.validateAndNormalizeUrl = exports.ServiceClientType = void 0;
28
+ exports.GrpcCompressionAlgorithm = exports.validateAndNormalizeUrl = exports.DEFAULT_COLLECTOR_URL = exports.ServiceClientType = void 0;
29
29
  __exportStar(require("./OTLPGRPCExporterNodeBase"), exports);
30
30
  var types_1 = require("./types");
31
31
  Object.defineProperty(exports, "ServiceClientType", { enumerable: true, get: function () { return types_1.ServiceClientType; } });
32
32
  var util_1 = require("./util");
33
+ Object.defineProperty(exports, "DEFAULT_COLLECTOR_URL", { enumerable: true, get: function () { return util_1.DEFAULT_COLLECTOR_URL; } });
33
34
  Object.defineProperty(exports, "validateAndNormalizeUrl", { enumerable: true, get: function () { return util_1.validateAndNormalizeUrl; } });
34
35
  Object.defineProperty(exports, "GrpcCompressionAlgorithm", { enumerable: true, get: function () { return util_1.GrpcCompressionAlgorithm; } });
35
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;AAEH,6DAA2C;AAC3C,iCAAwE;AAA/D,0GAAA,iBAAiB,OAAA;AAC1B,+BAA2E;AAAlE,+GAAA,uBAAuB,OAAA;AAAE,gHAAA,wBAAwB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './OTLPGRPCExporterNodeBase';\nexport { ServiceClientType, OTLPGRPCExporterConfigNode } from './types';\nexport { validateAndNormalizeUrl, GrpcCompressionAlgorithm } from './util';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;AAEH,6DAA2C;AAC3C,iCAAwE;AAA/D,0GAAA,iBAAiB,OAAA;AAC1B,+BAAkG;AAAzF,6GAAA,qBAAqB,OAAA;AAAE,+GAAA,uBAAuB,OAAA;AAAE,gHAAA,wBAAwB,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './OTLPGRPCExporterNodeBase';\nexport { ServiceClientType, OTLPGRPCExporterConfigNode } from './types';\nexport { DEFAULT_COLLECTOR_URL, validateAndNormalizeUrl, GrpcCompressionAlgorithm } from './util';\n"]}
@@ -13,7 +13,7 @@ export interface GRPCQueueItem<ExportedItem> {
13
13
  * Service Client for sending spans or metrics
14
14
  */
15
15
  export interface ServiceClient extends grpc.Client {
16
- export: (request: any, metadata: grpc.Metadata, callback: Function) => {};
16
+ export: (request: any, metadata: grpc.Metadata, options: grpc.CallOptions, callback: Function) => {};
17
17
  }
18
18
  /**
19
19
  * OTLP Exporter Config for Node
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAoCH,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 { CompressionAlgorithm, OTLPExporterConfigBase, OTLPExporterError } 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 callback: Function\n ) => {};\n}\n\n/**\n * OTLP Exporter Config for Node\n */\nexport interface OTLPGRPCExporterConfigNode\n 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;;;AAqCH,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 { CompressionAlgorithm, OTLPExporterConfigBase, OTLPExporterError } 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\n 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,9 +1,13 @@
1
+ import * as grpc from '@grpc/grpc-js';
1
2
  import { OTLPGRPCExporterNodeBase } from './OTLPGRPCExporterNodeBase';
2
3
  import { OTLPGRPCExporterConfigNode } from './types';
3
4
  import { CompressionAlgorithm, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';
5
+ export declare const DEFAULT_COLLECTOR_URL = "http://localhost:4317";
4
6
  export declare function onInit<ExportItem, ServiceRequest>(collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>, config: OTLPGRPCExporterConfigNode): void;
5
7
  export declare function send<ExportItem, ServiceRequest>(collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>, objects: ExportItem[], onSuccess: () => void, onError: (error: OTLPExporterError) => void): void;
6
8
  export declare function validateAndNormalizeUrl(url: string): string;
9
+ export declare function configureSecurity(credentials: grpc.ChannelCredentials | undefined, endpoint: string): grpc.ChannelCredentials;
10
+ export declare function useSecureConnection(): grpc.ChannelCredentials;
7
11
  /**
8
12
  * These values are defined by grpc client
9
13
  */
package/build/src/util.js CHANGED
@@ -15,18 +15,20 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.configureCompression = exports.GrpcCompressionAlgorithm = exports.validateAndNormalizeUrl = exports.send = exports.onInit = void 0;
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
20
  const protoLoader = require("@grpc/proto-loader");
21
21
  const api_1 = require("@opentelemetry/api");
22
22
  const core_1 = require("@opentelemetry/core");
23
23
  const path = require("path");
24
24
  const url_1 = require("url");
25
+ const fs = require("fs");
25
26
  const types_1 = require("./types");
26
27
  const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
28
+ exports.DEFAULT_COLLECTOR_URL = 'http://localhost:4317';
27
29
  function onInit(collector, config) {
28
30
  collector.grpcQueue = [];
29
- const credentials = config.credentials || grpc.credentials.createInsecure();
31
+ const credentials = configureSecurity(config.credentials, collector.url);
30
32
  const includeDirs = [path.resolve(__dirname, '..', 'protos')];
31
33
  protoLoader
32
34
  .load(collector.getServiceProtoPath(), {
@@ -63,7 +65,8 @@ exports.onInit = onInit;
63
65
  function send(collector, objects, onSuccess, onError) {
64
66
  if (collector.serviceClient) {
65
67
  const serviceRequest = collector.convert(objects);
66
- collector.serviceClient.export(serviceRequest, collector.metadata || new grpc.Metadata(), (err) => {
68
+ const deadline = Date.now() + collector.timeoutMillis;
69
+ collector.serviceClient.export(serviceRequest, collector.metadata || new grpc.Metadata(), { deadline: deadline }, (err) => {
67
70
  if (err) {
68
71
  api_1.diag.error('Service request', serviceRequest);
69
72
  onError(err);
@@ -93,12 +96,99 @@ function validateAndNormalizeUrl(url) {
93
96
  if (target.pathname && target.pathname !== '/') {
94
97
  api_1.diag.warn('URL path should not be set when using grpc, the path part of the URL will be ignored.');
95
98
  }
96
- if (target.protocol !== '' && !((_a = target.protocol) === null || _a === void 0 ? void 0 : _a.match(/(http|grpc)s?/))) {
97
- api_1.diag.warn('URL protocol should be http(s):// or grpc(s)://. Using grpc://.');
99
+ if (target.protocol !== '' && !((_a = target.protocol) === null || _a === void 0 ? void 0 : _a.match(/^(http)s?:$/))) {
100
+ api_1.diag.warn('URL protocol should be http(s)://. Using http://.');
98
101
  }
99
102
  return target.host;
100
103
  }
101
104
  exports.validateAndNormalizeUrl = validateAndNormalizeUrl;
105
+ function configureSecurity(credentials, endpoint) {
106
+ let insecure;
107
+ if (credentials) {
108
+ return credentials;
109
+ }
110
+ else if (endpoint.startsWith('https://')) {
111
+ insecure = false;
112
+ }
113
+ else if (endpoint.startsWith('http://') || endpoint === exports.DEFAULT_COLLECTOR_URL) {
114
+ insecure = true;
115
+ }
116
+ else {
117
+ insecure = getSecurityFromEnv();
118
+ }
119
+ if (insecure) {
120
+ return grpc.credentials.createInsecure();
121
+ }
122
+ else {
123
+ return useSecureConnection();
124
+ }
125
+ }
126
+ exports.configureSecurity = configureSecurity;
127
+ function getSecurityFromEnv() {
128
+ const definedInsecure = (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_INSECURE ||
129
+ (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_INSECURE;
130
+ if (definedInsecure) {
131
+ return definedInsecure.toLowerCase() === 'true';
132
+ }
133
+ else {
134
+ return false;
135
+ }
136
+ }
137
+ function useSecureConnection() {
138
+ const rootCertPath = retrieveRootCert();
139
+ const privateKeyPath = retrievePrivateKey();
140
+ const certChainPath = retrieveCertChain();
141
+ return grpc.credentials.createSsl(rootCertPath, privateKeyPath, certChainPath);
142
+ }
143
+ exports.useSecureConnection = useSecureConnection;
144
+ function retrieveRootCert() {
145
+ const rootCertificate = (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE ||
146
+ (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_CERTIFICATE;
147
+ if (rootCertificate) {
148
+ try {
149
+ return fs.readFileSync(path.resolve(process.cwd(), rootCertificate));
150
+ }
151
+ catch (_a) {
152
+ api_1.diag.warn('Failed to read root certificate file');
153
+ return undefined;
154
+ }
155
+ }
156
+ else {
157
+ return undefined;
158
+ }
159
+ }
160
+ function retrievePrivateKey() {
161
+ const clientKey = (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_CLIENT_KEY ||
162
+ (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_CLIENT_KEY;
163
+ if (clientKey) {
164
+ try {
165
+ return fs.readFileSync(path.resolve(process.cwd(), clientKey));
166
+ }
167
+ catch (_a) {
168
+ api_1.diag.warn('Failed to read client certificate private key file');
169
+ return undefined;
170
+ }
171
+ }
172
+ else {
173
+ return undefined;
174
+ }
175
+ }
176
+ function retrieveCertChain() {
177
+ const clientChain = (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_TRACES_CLIENT_CERTIFICATE ||
178
+ (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE;
179
+ if (clientChain) {
180
+ try {
181
+ return fs.readFileSync(path.resolve(process.cwd(), clientChain));
182
+ }
183
+ catch (_a) {
184
+ api_1.diag.warn('Failed to read client certificate chain file');
185
+ return undefined;
186
+ }
187
+ }
188
+ else {
189
+ return undefined;
190
+ }
191
+ }
102
192
  function toGrpcCompression(compression) {
103
193
  if (compression === otlp_exporter_base_1.CompressionAlgorithm.NONE)
104
194
  return GrpcCompressionAlgorithm.NONE;
@@ -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,mCAAwF;AACxF,0EAAgH;AAEhH,SAAgB,MAAM,CACpB,SAA+D,EAC/D,MAAkC;IAElC,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;IACzB,MAAM,WAAW,GACf,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC;IAE1D,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,MAAM,OAAO,GAAG,EAAE,oCAAoC,EAAE,SAAS,CAAC,WAAW,EAAE,CAAC;QAEhF,IAAI,SAAS,CAAC,oBAAoB,EAAE,KAAK,yBAAiB,CAAC,KAAK,EAAE;YAChE,SAAS,CAAC,aAAa;gBACrB,IAAI,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,S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,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,CAAA,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC;KACrG;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 { GRPCQueueItem, OTLPGRPCExporterConfigNode, ServiceClientType, } from './types';\nimport { CompressionAlgorithm, ExportServiceError, OTLPExporterError } from '@opentelemetry/otlp-exporter-base';\n\nexport function onInit<ExportItem, ServiceRequest>(\n collector: OTLPGRPCExporterNodeBase<ExportItem, ServiceRequest>,\n config: OTLPGRPCExporterConfigNode\n): void {\n collector.grpcQueue = [];\n const credentials: grpc.ChannelCredentials =\n config.credentials || grpc.credentials.createInsecure();\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\n collector.serviceClient.export(\n serviceRequest,\n collector.metadata || new grpc.Metadata(),\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|grpc)s?/)) {\n diag.warn(\n 'URL protocol should be http(s):// or grpc(s)://. Using grpc://.'\n );\n }\n return target.host;\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/**\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,GAAG,CAAC,CAAC;IAElG,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,M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1D,IAAG,WAAW,KAAK,yCAAoB,CAAC,IAAI;QAC1C,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,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,CAAA,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC;KACrG;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.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,2 +1,2 @@
1
- export declare const VERSION = "0.28.0";
1
+ export declare const VERSION = "0.29.2";
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.28.0';
20
+ exports.VERSION = '0.29.2';
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.28.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.29.2';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/otlp-grpc-exporter-base",
3
- "version": "0.28.0",
3
+ "version": "0.29.2",
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",
@@ -51,9 +51,9 @@
51
51
  "devDependencies": {
52
52
  "@babel/core": "7.16.0",
53
53
  "@opentelemetry/api": "^1.0.0",
54
- "@opentelemetry/exporter-trace-otlp-http": "0.28.0",
55
- "@opentelemetry/resources": "1.2.0",
56
- "@opentelemetry/sdk-trace-base": "1.2.0",
54
+ "@opentelemetry/otlp-transformer": "0.29.2",
55
+ "@opentelemetry/resources": "1.3.1",
56
+ "@opentelemetry/sdk-trace-base": "1.3.1",
57
57
  "@types/mocha": "8.2.3",
58
58
  "@types/node": "14.17.33",
59
59
  "@types/sinon": "10.0.6",
@@ -64,7 +64,7 @@
64
64
  "rimraf": "3.0.2",
65
65
  "sinon": "12.0.1",
66
66
  "ts-loader": "8.3.0",
67
- "ts-mocha": "8.0.0",
67
+ "ts-mocha": "9.0.2",
68
68
  "typescript": "4.4.4"
69
69
  },
70
70
  "peerDependencies": {
@@ -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.2.0",
77
- "@opentelemetry/otlp-exporter-base": "0.28.0"
76
+ "@opentelemetry/core": "1.3.1",
77
+ "@opentelemetry/otlp-exporter-base": "0.29.2"
78
78
  },
79
- "gitHead": "a0a670a03fd35b0799bee8cc466f79e93b5b6dd2"
79
+ "gitHead": "51afd54bd63e46d5d530266761144c7be2f6b3a7"
80
80
  }