@opentelemetry/sdk-node 0.212.0 → 0.214.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/build/src/index.js +1 -12
- package/build/src/index.js.map +1 -1
- package/build/src/sdk.d.ts +3 -3
- package/build/src/sdk.js +22 -29
- package/build/src/sdk.js.map +1 -1
- package/build/src/semconv.d.ts +62 -0
- package/build/src/semconv.js +74 -0
- package/build/src/semconv.js.map +1 -0
- package/build/src/start.d.ts +3 -0
- package/build/src/start.js +86 -21
- package/build/src/start.js.map +1 -1
- package/build/src/types.d.ts +14 -6
- package/build/src/types.js +1 -12
- package/build/src/types.js.map +1 -1
- package/build/src/utils.d.ts +18 -7
- package/build/src/utils.js +299 -19
- package/build/src/utils.js.map +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +2 -13
- package/build/src/version.js.map +1 -1
- package/package.json +27 -26
package/build/src/types.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ContextManager } from '@opentelemetry/api';
|
|
2
|
-
import { TextMapPropagator } from '@opentelemetry/api';
|
|
3
|
-
import { Instrumentation } from '@opentelemetry/instrumentation';
|
|
4
|
-
import { Resource, ResourceDetector } from '@opentelemetry/resources';
|
|
5
|
-
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import type { TextMapPropagator } from '@opentelemetry/api';
|
|
3
|
+
import type { Instrumentation } from '@opentelemetry/instrumentation';
|
|
4
|
+
import type { Resource, ResourceDetector } from '@opentelemetry/resources';
|
|
5
|
+
import type { LoggerProvider, LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
6
|
+
import type { MeterProvider } from '@opentelemetry/sdk-metrics';
|
|
7
|
+
import type { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';
|
|
8
|
+
import type { Sampler, SpanExporter, SpanLimits, SpanProcessor, IdGenerator } from '@opentelemetry/sdk-trace-base';
|
|
8
9
|
export interface NodeSDKConfiguration {
|
|
9
10
|
autoDetectResources: boolean;
|
|
10
11
|
contextManager: ContextManager;
|
|
@@ -33,6 +34,13 @@ export interface NodeSDKConfiguration {
|
|
|
33
34
|
*/
|
|
34
35
|
export interface SDKOptions {
|
|
35
36
|
instrumentations?: (Instrumentation | Instrumentation[])[];
|
|
37
|
+
resourceDetectors?: ResourceDetector[];
|
|
36
38
|
textMapPropagator?: TextMapPropagator | null;
|
|
37
39
|
}
|
|
40
|
+
export interface SDKComponents {
|
|
41
|
+
contextManager: ContextManager;
|
|
42
|
+
loggerProvider?: LoggerProvider;
|
|
43
|
+
meterProvider?: MeterProvider;
|
|
44
|
+
propagator?: TextMapPropagator;
|
|
45
|
+
}
|
|
38
46
|
//# sourceMappingURL=types.d.ts.map
|
package/build/src/types.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
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.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
16
5
|
*/
|
|
17
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
7
|
//# sourceMappingURL=types.js.map
|
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { ContextManager } from '@opentelemetry/api';\nimport type { TextMapPropagator } from '@opentelemetry/api';\nimport type { Instrumentation } from '@opentelemetry/instrumentation';\nimport type { Resource, ResourceDetector } from '@opentelemetry/resources';\nimport type {\n LoggerProvider,\n LogRecordProcessor,\n} from '@opentelemetry/sdk-logs';\nimport type { MeterProvider } from '@opentelemetry/sdk-metrics';\nimport type { IMetricReader, ViewOptions } from '@opentelemetry/sdk-metrics';\nimport type {\n Sampler,\n SpanExporter,\n SpanLimits,\n SpanProcessor,\n IdGenerator,\n} from '@opentelemetry/sdk-trace-base';\n\nexport interface NodeSDKConfiguration {\n autoDetectResources: boolean;\n contextManager: ContextManager;\n textMapPropagator: TextMapPropagator | null;\n /** @deprecated use logRecordProcessors instead*/\n logRecordProcessor: LogRecordProcessor;\n logRecordProcessors?: LogRecordProcessor[];\n /** @deprecated use metricReaders instead*/\n metricReader: IMetricReader;\n metricReaders?: IMetricReader[];\n views: ViewOptions[];\n instrumentations: (Instrumentation | Instrumentation[])[];\n resource: Resource;\n resourceDetectors: Array<ResourceDetector>;\n sampler: Sampler;\n serviceName?: string;\n /** @deprecated use spanProcessors instead*/\n spanProcessor?: SpanProcessor;\n spanProcessors?: SpanProcessor[];\n traceExporter: SpanExporter;\n spanLimits: SpanLimits;\n idGenerator: IdGenerator;\n}\n/**\n * @experimental Options for new experimental SDK setup\n */\nexport interface SDKOptions {\n instrumentations?: (Instrumentation | Instrumentation[])[];\n resourceDetectors?: ResourceDetector[];\n textMapPropagator?: TextMapPropagator | null;\n}\n\nexport interface SDKComponents {\n contextManager: ContextManager;\n loggerProvider?: LoggerProvider;\n meterProvider?: MeterProvider;\n propagator?: TextMapPropagator;\n}\n"]}
|
package/build/src/utils.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
-
import { ResourceDetector } from '@opentelemetry/resources';
|
|
3
|
-
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
|
-
import { ConfigurationModel } from '@opentelemetry/configuration';
|
|
5
|
-
import { IMetricReader, PushMetricExporter } from '@opentelemetry/sdk-metrics';
|
|
6
|
-
import {
|
|
1
|
+
import type { ContextManager, TextMapPropagator } from '@opentelemetry/api';
|
|
2
|
+
import type { Resource, ResourceDetector } from '@opentelemetry/resources';
|
|
3
|
+
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
4
|
+
import type { ConfigurationModel, LogRecordExporterConfigModel, InstrumentTypeConfigModel, AggregationConfigModel, PeriodicMetricReaderConfigModel } from '@opentelemetry/configuration';
|
|
5
|
+
import type { AggregationOption, IMetricReader, PushMetricExporter, ViewOptions } from '@opentelemetry/sdk-metrics';
|
|
6
|
+
import { InstrumentType } from '@opentelemetry/sdk-metrics';
|
|
7
|
+
import type { BufferConfig, LogRecordExporter, LoggerProviderConfig, LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
8
|
+
import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
9
|
+
export declare function getResourceFromConfiguration(config: ConfigurationModel): Resource | undefined;
|
|
7
10
|
export declare function getResourceDetectorsFromEnv(): Array<ResourceDetector>;
|
|
11
|
+
export declare function getResourceDetectorsFromConfiguration(config: ConfigurationModel): Array<ResourceDetector>;
|
|
8
12
|
export declare function getOtlpProtocolFromEnv(): string;
|
|
9
13
|
export declare function getSpanProcessorsFromEnv(): SpanProcessor[];
|
|
10
14
|
/**
|
|
@@ -16,12 +20,12 @@ export declare function getPropagatorFromEnv(): TextMapPropagator | null | undef
|
|
|
16
20
|
*/
|
|
17
21
|
export declare function getPropagatorFromConfiguration(config: ConfigurationModel): TextMapPropagator | null | undefined;
|
|
18
22
|
export declare function setupContextManager(contextManager: ContextManager | null | undefined): void;
|
|
19
|
-
export declare function setupDefaultContextManager(): void;
|
|
20
23
|
export declare function setupPropagator(propagator: TextMapPropagator | null | undefined): void;
|
|
21
24
|
export declare function getKeyListFromObjectArray(obj: object[] | undefined): string[] | undefined;
|
|
22
25
|
export declare function getNonNegativeNumberFromEnv(envVarName: string): number | undefined;
|
|
23
26
|
export declare function getPeriodicExportingMetricReaderFromEnv(exporter: PushMetricExporter): IMetricReader;
|
|
24
27
|
export declare function getOtlpMetricExporterFromEnv(): PushMetricExporter;
|
|
28
|
+
export declare function getPeriodicMetricReaderFromConfiguration(periodic: PeriodicMetricReaderConfigModel): IMetricReader | undefined;
|
|
25
29
|
/**
|
|
26
30
|
* Get LoggerProviderConfig from environment variables.
|
|
27
31
|
*/
|
|
@@ -31,4 +35,11 @@ export declare function getLoggerProviderConfigFromEnv(): LoggerProviderConfig;
|
|
|
31
35
|
*/
|
|
32
36
|
export declare function getBatchLogRecordProcessorConfigFromEnv(): BufferConfig;
|
|
33
37
|
export declare function getBatchLogRecordProcessorFromEnv(exporter: LogRecordExporter): BatchLogRecordProcessor;
|
|
38
|
+
export declare function getLogRecordExporter(exporter: LogRecordExporterConfigModel): LogRecordExporter | undefined;
|
|
39
|
+
export declare function getLogRecordProcessorsFromConfiguration(config: ConfigurationModel): LogRecordProcessor[] | undefined;
|
|
40
|
+
export declare function getMeterReadersFromConfiguration(config: ConfigurationModel): IMetricReader[] | undefined;
|
|
41
|
+
export declare function getInstrumentType(instrument: InstrumentTypeConfigModel): InstrumentType | undefined;
|
|
42
|
+
export declare function getAggregationType(aggregation: AggregationConfigModel): AggregationOption | undefined;
|
|
43
|
+
export declare function getMeterViewsFromConfiguration(config: ConfigurationModel): ViewOptions[] | undefined;
|
|
44
|
+
export declare function getInstanceID(config: ConfigurationModel): string | undefined;
|
|
34
45
|
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
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.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
16
5
|
*/
|
|
17
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.getBatchLogRecordProcessorFromEnv = exports.getBatchLogRecordProcessorConfigFromEnv = exports.getLoggerProviderConfigFromEnv = exports.getOtlpMetricExporterFromEnv = exports.getPeriodicExportingMetricReaderFromEnv = exports.getNonNegativeNumberFromEnv = exports.getKeyListFromObjectArray = exports.setupPropagator = exports.
|
|
7
|
+
exports.getInstanceID = exports.getMeterViewsFromConfiguration = exports.getAggregationType = exports.getInstrumentType = exports.getMeterReadersFromConfiguration = exports.getLogRecordProcessorsFromConfiguration = exports.getLogRecordExporter = exports.getBatchLogRecordProcessorFromEnv = exports.getBatchLogRecordProcessorConfigFromEnv = exports.getLoggerProviderConfigFromEnv = exports.getPeriodicMetricReaderFromConfiguration = exports.getOtlpMetricExporterFromEnv = exports.getPeriodicExportingMetricReaderFromEnv = exports.getNonNegativeNumberFromEnv = exports.getKeyListFromObjectArray = exports.setupPropagator = exports.setupContextManager = exports.getPropagatorFromConfiguration = exports.getPropagatorFromEnv = exports.getSpanProcessorsFromEnv = exports.getOtlpProtocolFromEnv = exports.getResourceDetectorsFromConfiguration = exports.getResourceDetectorsFromEnv = exports.getResourceFromConfiguration = void 0;
|
|
19
8
|
const api_1 = require("@opentelemetry/api");
|
|
20
9
|
const core_1 = require("@opentelemetry/core");
|
|
21
10
|
const exporter_trace_otlp_proto_1 = require("@opentelemetry/exporter-trace-otlp-proto");
|
|
@@ -27,6 +16,10 @@ const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
|
27
16
|
const propagator_b3_1 = require("@opentelemetry/propagator-b3");
|
|
28
17
|
const propagator_jaeger_1 = require("@opentelemetry/propagator-jaeger");
|
|
29
18
|
const context_async_hooks_1 = require("@opentelemetry/context-async-hooks");
|
|
19
|
+
const exporter_logs_otlp_http_1 = require("@opentelemetry/exporter-logs-otlp-http");
|
|
20
|
+
const exporter_logs_otlp_grpc_1 = require("@opentelemetry/exporter-logs-otlp-grpc");
|
|
21
|
+
const exporter_logs_otlp_proto_1 = require("@opentelemetry/exporter-logs-otlp-proto");
|
|
22
|
+
const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");
|
|
30
23
|
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
|
|
31
24
|
const exporter_metrics_otlp_grpc_1 = require("@opentelemetry/exporter-metrics-otlp-grpc");
|
|
32
25
|
const exporter_metrics_otlp_http_1 = require("@opentelemetry/exporter-metrics-otlp-http");
|
|
@@ -37,6 +30,20 @@ const RESOURCE_DETECTOR_HOST = 'host';
|
|
|
37
30
|
const RESOURCE_DETECTOR_OS = 'os';
|
|
38
31
|
const RESOURCE_DETECTOR_PROCESS = 'process';
|
|
39
32
|
const RESOURCE_DETECTOR_SERVICE_INSTANCE_ID = 'serviceinstance';
|
|
33
|
+
function getResourceFromConfiguration(config) {
|
|
34
|
+
if (config.resource && config.resource.attributes) {
|
|
35
|
+
const attr = {};
|
|
36
|
+
for (let i = 0; i < config.resource.attributes.length; i++) {
|
|
37
|
+
const a = config.resource.attributes[i];
|
|
38
|
+
attr[a.name] = a.value;
|
|
39
|
+
}
|
|
40
|
+
return (0, resources_1.resourceFromAttributes)(attr, {
|
|
41
|
+
schemaUrl: config.resource.schema_url,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
exports.getResourceFromConfiguration = getResourceFromConfiguration;
|
|
40
47
|
function getResourceDetectorsFromEnv() {
|
|
41
48
|
// When updating this list, make sure to also update the section `resourceDetectors` on README.
|
|
42
49
|
const resourceDetectors = new Map([
|
|
@@ -62,6 +69,24 @@ function getResourceDetectorsFromEnv() {
|
|
|
62
69
|
});
|
|
63
70
|
}
|
|
64
71
|
exports.getResourceDetectorsFromEnv = getResourceDetectorsFromEnv;
|
|
72
|
+
function getResourceDetectorsFromConfiguration(config) {
|
|
73
|
+
const detectors = config.resource?.['detection/development']?.detectors ?? [];
|
|
74
|
+
return detectors.flatMap(detector => {
|
|
75
|
+
const result = [];
|
|
76
|
+
if (detector.host != null)
|
|
77
|
+
result.push(resources_1.hostDetector);
|
|
78
|
+
if (detector.os != null)
|
|
79
|
+
result.push(resources_1.osDetector);
|
|
80
|
+
if (detector.process != null)
|
|
81
|
+
result.push(resources_1.processDetector);
|
|
82
|
+
if (detector.service != null)
|
|
83
|
+
result.push(resources_1.serviceInstanceIdDetector);
|
|
84
|
+
if (detector.env != null)
|
|
85
|
+
result.push(resources_1.envDetector);
|
|
86
|
+
return result;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.getResourceDetectorsFromConfiguration = getResourceDetectorsFromConfiguration;
|
|
65
90
|
function getOtlpProtocolFromEnv() {
|
|
66
91
|
return ((0, core_1.getStringFromEnv)('OTEL_EXPORTER_OTLP_TRACES_PROTOCOL') ??
|
|
67
92
|
(0, core_1.getStringFromEnv)('OTEL_EXPORTER_OTLP_PROTOCOL') ??
|
|
@@ -242,12 +267,6 @@ function setupContextManager(contextManager) {
|
|
|
242
267
|
api_1.context.setGlobalContextManager(contextManager);
|
|
243
268
|
}
|
|
244
269
|
exports.setupContextManager = setupContextManager;
|
|
245
|
-
function setupDefaultContextManager() {
|
|
246
|
-
const defaultContextManager = new context_async_hooks_1.AsyncLocalStorageContextManager();
|
|
247
|
-
defaultContextManager.enable();
|
|
248
|
-
api_1.context.setGlobalContextManager(defaultContextManager);
|
|
249
|
-
}
|
|
250
|
-
exports.setupDefaultContextManager = setupDefaultContextManager;
|
|
251
270
|
function setupPropagator(propagator) {
|
|
252
271
|
// null means 'do not register'
|
|
253
272
|
if (propagator === null) {
|
|
@@ -334,6 +353,54 @@ function getOtlpMetricExporterFromEnv() {
|
|
|
334
353
|
return new exporter_metrics_otlp_proto_1.OTLPMetricExporter();
|
|
335
354
|
}
|
|
336
355
|
exports.getOtlpMetricExporterFromEnv = getOtlpMetricExporterFromEnv;
|
|
356
|
+
function getPeriodicMetricReaderFromConfiguration(periodic) {
|
|
357
|
+
if (periodic.exporter) {
|
|
358
|
+
let exporter;
|
|
359
|
+
if (periodic.exporter.otlp_http) {
|
|
360
|
+
const encoding = periodic.exporter.otlp_http.encoding;
|
|
361
|
+
if (encoding === 'json') {
|
|
362
|
+
exporter = new exporter_metrics_otlp_http_1.OTLPMetricExporter({
|
|
363
|
+
compression: periodic.exporter.otlp_http.compression === 'gzip'
|
|
364
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
365
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
else if (encoding === 'protobuf') {
|
|
369
|
+
exporter = new exporter_metrics_otlp_proto_1.OTLPMetricExporter({
|
|
370
|
+
compression: periodic.exporter.otlp_http.compression === 'gzip'
|
|
371
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
372
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
api_1.diag.warn(`Unsupported OTLP metrics encoding: ${encoding}.`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (periodic.exporter.otlp_grpc) {
|
|
380
|
+
exporter = new exporter_metrics_otlp_grpc_1.OTLPMetricExporter({
|
|
381
|
+
compression: periodic.exporter.otlp_grpc.compression === 'gzip'
|
|
382
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
383
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
if (exporter) {
|
|
387
|
+
// TODO(6425): add cardinality_limits
|
|
388
|
+
return new sdk_metrics_1.PeriodicExportingMetricReader({
|
|
389
|
+
exportIntervalMillis: periodic.interval ?? 60000,
|
|
390
|
+
exportTimeoutMillis: periodic.timeout ?? 30000,
|
|
391
|
+
exporter,
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (periodic.exporter.console) {
|
|
395
|
+
return new sdk_metrics_1.PeriodicExportingMetricReader({
|
|
396
|
+
exporter: new sdk_metrics_1.ConsoleMetricExporter(),
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
api_1.diag.warn(`Unsupported Metric Exporter.`);
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
403
|
+
exports.getPeriodicMetricReaderFromConfiguration = getPeriodicMetricReaderFromConfiguration;
|
|
337
404
|
/**
|
|
338
405
|
* Get LoggerProviderConfig from environment variables.
|
|
339
406
|
*/
|
|
@@ -363,4 +430,217 @@ function getBatchLogRecordProcessorFromEnv(exporter) {
|
|
|
363
430
|
return new sdk_logs_1.BatchLogRecordProcessor(exporter, getBatchLogRecordProcessorConfigFromEnv());
|
|
364
431
|
}
|
|
365
432
|
exports.getBatchLogRecordProcessorFromEnv = getBatchLogRecordProcessorFromEnv;
|
|
433
|
+
function getLogRecordExporter(exporter) {
|
|
434
|
+
if (exporter.otlp_http) {
|
|
435
|
+
const encoding = exporter.otlp_http.encoding;
|
|
436
|
+
if (encoding === 'json') {
|
|
437
|
+
return new exporter_logs_otlp_http_1.OTLPLogExporter({
|
|
438
|
+
compression: exporter.otlp_http.compression === 'gzip'
|
|
439
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
440
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
if (encoding === 'protobuf') {
|
|
444
|
+
return new exporter_logs_otlp_proto_1.OTLPLogExporter({
|
|
445
|
+
compression: exporter.otlp_http.compression === 'gzip'
|
|
446
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
447
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
api_1.diag.warn(`Unsupported OTLP logs encoding: ${encoding}. Using http/protobuf.`);
|
|
451
|
+
return new exporter_logs_otlp_proto_1.OTLPLogExporter({
|
|
452
|
+
compression: exporter.otlp_http.compression === 'gzip'
|
|
453
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
454
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
else if (exporter.otlp_grpc) {
|
|
458
|
+
return new exporter_logs_otlp_grpc_1.OTLPLogExporter({
|
|
459
|
+
compression: exporter.otlp_grpc.compression === 'gzip'
|
|
460
|
+
? otlp_exporter_base_1.CompressionAlgorithm.GZIP
|
|
461
|
+
: otlp_exporter_base_1.CompressionAlgorithm.NONE,
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
else if (exporter.console) {
|
|
465
|
+
return new sdk_logs_1.ConsoleLogRecordExporter();
|
|
466
|
+
}
|
|
467
|
+
api_1.diag.warn(`Unsupported Exporter value. No Log Record Exporter registered`);
|
|
468
|
+
return undefined;
|
|
469
|
+
}
|
|
470
|
+
exports.getLogRecordExporter = getLogRecordExporter;
|
|
471
|
+
function getLogRecordProcessorsFromConfiguration(config) {
|
|
472
|
+
const logRecordProcessors = [];
|
|
473
|
+
config.logger_provider?.processors?.forEach(processor => {
|
|
474
|
+
if (processor.batch) {
|
|
475
|
+
const exporter = getLogRecordExporter(processor.batch.exporter);
|
|
476
|
+
if (exporter) {
|
|
477
|
+
logRecordProcessors.push(new sdk_logs_1.BatchLogRecordProcessor(exporter, {
|
|
478
|
+
maxQueueSize: processor.batch.max_queue_size,
|
|
479
|
+
maxExportBatchSize: processor.batch.max_export_batch_size,
|
|
480
|
+
scheduledDelayMillis: processor.batch.schedule_delay,
|
|
481
|
+
exportTimeoutMillis: processor.batch.export_timeout,
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (processor.simple) {
|
|
486
|
+
const exporter = getLogRecordExporter(processor.simple.exporter);
|
|
487
|
+
if (exporter) {
|
|
488
|
+
logRecordProcessors.push(new sdk_logs_1.SimpleLogRecordProcessor(exporter));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
if (logRecordProcessors.length > 0) {
|
|
493
|
+
return logRecordProcessors;
|
|
494
|
+
}
|
|
495
|
+
return undefined;
|
|
496
|
+
}
|
|
497
|
+
exports.getLogRecordProcessorsFromConfiguration = getLogRecordProcessorsFromConfiguration;
|
|
498
|
+
function getMeterReadersFromConfiguration(config) {
|
|
499
|
+
const metricReaders = [];
|
|
500
|
+
config.meter_provider?.readers?.forEach(reader => {
|
|
501
|
+
if (reader.periodic) {
|
|
502
|
+
const periodicReader = getPeriodicMetricReaderFromConfiguration(reader.periodic);
|
|
503
|
+
if (periodicReader) {
|
|
504
|
+
metricReaders.push(periodicReader);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
if (metricReaders.length > 0) {
|
|
509
|
+
return metricReaders;
|
|
510
|
+
}
|
|
511
|
+
return undefined;
|
|
512
|
+
}
|
|
513
|
+
exports.getMeterReadersFromConfiguration = getMeterReadersFromConfiguration;
|
|
514
|
+
function getInstrumentType(instrument) {
|
|
515
|
+
switch (instrument) {
|
|
516
|
+
case 'counter':
|
|
517
|
+
return sdk_metrics_1.InstrumentType.COUNTER;
|
|
518
|
+
case 'gauge':
|
|
519
|
+
return sdk_metrics_1.InstrumentType.GAUGE;
|
|
520
|
+
case 'histogram':
|
|
521
|
+
return sdk_metrics_1.InstrumentType.HISTOGRAM;
|
|
522
|
+
case 'observable_counter':
|
|
523
|
+
return sdk_metrics_1.InstrumentType.OBSERVABLE_COUNTER;
|
|
524
|
+
case 'observable_gauge':
|
|
525
|
+
return sdk_metrics_1.InstrumentType.OBSERVABLE_GAUGE;
|
|
526
|
+
case 'observable_up_down_counter':
|
|
527
|
+
return sdk_metrics_1.InstrumentType.OBSERVABLE_UP_DOWN_COUNTER;
|
|
528
|
+
case 'up_down_counter':
|
|
529
|
+
return sdk_metrics_1.InstrumentType.UP_DOWN_COUNTER;
|
|
530
|
+
default:
|
|
531
|
+
api_1.diag.warn(`Unsupported instrument type: ${instrument}`);
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
exports.getInstrumentType = getInstrumentType;
|
|
536
|
+
function getAggregationType(aggregation) {
|
|
537
|
+
if (aggregation.default) {
|
|
538
|
+
return {
|
|
539
|
+
type: sdk_metrics_1.AggregationType.DEFAULT,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
if (aggregation.drop) {
|
|
543
|
+
return {
|
|
544
|
+
type: sdk_metrics_1.AggregationType.DROP,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (aggregation.explicit_bucket_histogram) {
|
|
548
|
+
return {
|
|
549
|
+
type: sdk_metrics_1.AggregationType.EXPLICIT_BUCKET_HISTOGRAM,
|
|
550
|
+
options: {
|
|
551
|
+
recordMinMax: aggregation.explicit_bucket_histogram.record_min_max ?? true,
|
|
552
|
+
boundaries: aggregation.explicit_bucket_histogram.boundaries ?? [
|
|
553
|
+
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500,
|
|
554
|
+
10000,
|
|
555
|
+
],
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
if (aggregation.base2_exponential_bucket_histogram) {
|
|
560
|
+
return {
|
|
561
|
+
type: sdk_metrics_1.AggregationType.EXPONENTIAL_HISTOGRAM,
|
|
562
|
+
options: {
|
|
563
|
+
recordMinMax: aggregation.base2_exponential_bucket_histogram.record_min_max ?? true,
|
|
564
|
+
maxSize: aggregation.base2_exponential_bucket_histogram.max_size,
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
if (aggregation.last_value) {
|
|
569
|
+
return {
|
|
570
|
+
type: sdk_metrics_1.AggregationType.LAST_VALUE,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
if (aggregation.sum) {
|
|
574
|
+
return {
|
|
575
|
+
type: sdk_metrics_1.AggregationType.SUM,
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
api_1.diag.warn(`Unsupported aggregation type`);
|
|
579
|
+
return undefined;
|
|
580
|
+
}
|
|
581
|
+
exports.getAggregationType = getAggregationType;
|
|
582
|
+
function getMeterViewsFromConfiguration(config) {
|
|
583
|
+
const metricViews = [];
|
|
584
|
+
config.meter_provider?.views?.forEach(view => {
|
|
585
|
+
const viewOption = {};
|
|
586
|
+
if (view.selector) {
|
|
587
|
+
if (view.selector.instrument_name) {
|
|
588
|
+
viewOption.instrumentName = view.selector.instrument_name;
|
|
589
|
+
}
|
|
590
|
+
if (view.selector.instrument_type) {
|
|
591
|
+
const instrumentType = getInstrumentType(view.selector.instrument_type);
|
|
592
|
+
if (instrumentType) {
|
|
593
|
+
viewOption.instrumentType = instrumentType;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
if (view.selector.unit) {
|
|
597
|
+
viewOption.instrumentUnit = view.selector.unit;
|
|
598
|
+
}
|
|
599
|
+
if (view.selector.meter_name) {
|
|
600
|
+
viewOption.meterName = view.selector.meter_name;
|
|
601
|
+
}
|
|
602
|
+
if (view.selector.meter_version) {
|
|
603
|
+
viewOption.meterVersion = view.selector.meter_version;
|
|
604
|
+
}
|
|
605
|
+
if (view.selector.meter_schema_url) {
|
|
606
|
+
viewOption.meterSchemaUrl = view.selector.meter_schema_url;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
if (view.stream) {
|
|
610
|
+
viewOption.name = view.stream.name ?? view.selector?.instrument_name;
|
|
611
|
+
viewOption.aggregationCardinalityLimit =
|
|
612
|
+
view.stream.aggregation_cardinality_limit ?? 2000;
|
|
613
|
+
if (view.stream.description) {
|
|
614
|
+
viewOption.description = view.stream.description;
|
|
615
|
+
}
|
|
616
|
+
if (view.stream.aggregation) {
|
|
617
|
+
const aggregationType = getAggregationType(view.stream.aggregation);
|
|
618
|
+
if (aggregationType) {
|
|
619
|
+
viewOption.aggregation = aggregationType;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
// TODO(6427): add support for view.stream.attribute_keys and correspondent attributes processor configuration
|
|
623
|
+
}
|
|
624
|
+
if (Object.keys(viewOption).length > 0) {
|
|
625
|
+
metricViews.push(viewOption);
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
if (metricViews.length > 0) {
|
|
629
|
+
return metricViews;
|
|
630
|
+
}
|
|
631
|
+
return undefined;
|
|
632
|
+
}
|
|
633
|
+
exports.getMeterViewsFromConfiguration = getMeterViewsFromConfiguration;
|
|
634
|
+
function getInstanceID(config) {
|
|
635
|
+
if (config.resource?.attributes) {
|
|
636
|
+
for (let i = 0; i < config.resource.attributes.length; i++) {
|
|
637
|
+
const element = config.resource.attributes[i];
|
|
638
|
+
if (element.name === 'service.instance.id') {
|
|
639
|
+
return element.value?.toString();
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return undefined;
|
|
644
|
+
}
|
|
645
|
+
exports.getInstanceID = getInstanceID;
|
|
366
646
|
//# sourceMappingURL=utils.js.map
|