-
Notifications
You must be signed in to change notification settings - Fork 825
/
sdk.test.ts
676 lines (584 loc) · 23.1 KB
/
sdk.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
context,
propagation,
ProxyTracerProvider,
trace,
diag,
DiagLogLevel,
} from '@opentelemetry/api';
import { metrics } from '@opentelemetry/api-metrics';
import {
AsyncHooksContextManager,
AsyncLocalStorageContextManager,
} from '@opentelemetry/context-async-hooks';
import { CompositePropagator } from '@opentelemetry/core';
import {
AggregationTemporality,
ConsoleMetricExporter,
InMemoryMetricExporter,
InstrumentType,
MeterProvider,
PeriodicExportingMetricReader,
View,
} from '@opentelemetry/sdk-metrics';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import {
assertServiceResource,
} from './util/resource-assertions';
import {
ConsoleSpanExporter,
SimpleSpanProcessor,
BatchSpanProcessor,
NoopSpanProcessor,
} from '@opentelemetry/sdk-trace-base';
import * as assert from 'assert';
import * as semver from 'semver';
import * as Sinon from 'sinon';
import { NodeSDK } from '../src';
import { env } from 'process';
import { TracerProviderWithEnvExporters } from '../src/TracerProviderWithEnvExporter';
import {
envDetector,
processDetector,
Resource
} from '@opentelemetry/resources';
const DefaultContextManager = semver.gte(process.version, '14.8.0')
? AsyncLocalStorageContextManager
: AsyncHooksContextManager;
describe('Node SDK', () => {
let ctxManager: any;
let propagator: any;
let delegate: any;
beforeEach(() => {
context.disable();
trace.disable();
propagation.disable();
metrics.disable();
ctxManager = context['_getContextManager']();
propagator = propagation['_getGlobalPropagator']();
delegate = (trace.getTracerProvider() as ProxyTracerProvider).getDelegate();
});
describe('Basic Registration', () => {
it('should not register any unconfigured SDK components', async () => {
// need to set OTEL_TRACES_EXPORTER to none since default value is otlp
// which sets up an exporter and affects the context manager
env.OTEL_TRACES_EXPORTER = 'none';
const sdk = new NodeSDK({
autoDetectResources: false,
});
await sdk.start();
assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change');
assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change');
assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, 'tracer provider should not have changed');
assert.ok(!(metrics.getMeterProvider() instanceof MeterProvider));
delete env.OTEL_TRACES_EXPORTER;
});
it('should register a tracer provider if an exporter is provided', async () => {
const sdk = new NodeSDK({
traceExporter: new ConsoleSpanExporter(),
autoDetectResources: false,
});
await sdk.start();
assert.ok(!(metrics.getMeterProvider() instanceof MeterProvider));
assert.ok(
context['_getContextManager']().constructor.name === DefaultContextManager.name
);
assert.ok(
propagation['_getGlobalPropagator']() instanceof CompositePropagator
);
const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider;
assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider);
});
it('should register a tracer provider if a span processor is provided', async () => {
const exporter = new ConsoleSpanExporter();
const spanProcessor = new SimpleSpanProcessor(exporter);
const sdk = new NodeSDK({
spanProcessor,
autoDetectResources: false,
});
await sdk.start();
assert.ok(!(metrics.getMeterProvider() instanceof MeterProvider));
assert.ok(
context['_getContextManager']().constructor.name === DefaultContextManager.name
);
assert.ok(
propagation['_getGlobalPropagator']() instanceof CompositePropagator
);
const apiTracerProvider = trace.getTracerProvider() as ProxyTracerProvider;
assert.ok(apiTracerProvider.getDelegate() instanceof NodeTracerProvider);
});
it('should register a meter provider if a reader is provided', async () => {
// need to set OTEL_TRACES_EXPORTER to none since default value is otlp
// which sets up an exporter and affects the context manager
env.OTEL_TRACES_EXPORTER = 'none';
const exporter = new ConsoleMetricExporter();
const metricReader = new PeriodicExportingMetricReader({
exporter: exporter,
exportIntervalMillis: 100,
exportTimeoutMillis: 100
});
const sdk = new NodeSDK({
metricReader: metricReader,
autoDetectResources: false,
});
await sdk.start();
assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change');
assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change');
assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, 'tracer provider should not have changed');
assert.ok(metrics.getMeterProvider() instanceof MeterProvider);
await sdk.shutdown();
delete env.OTEL_TRACES_EXPORTER;
});
});
async function waitForNumberOfMetrics(exporter: InMemoryMetricExporter, numberOfMetrics: number): Promise<void> {
if (numberOfMetrics <= 0) {
throw new Error('numberOfMetrics must be greater than or equal to 0');
}
let totalExports = 0;
while (totalExports < numberOfMetrics) {
await new Promise(resolve => setTimeout(resolve, 20));
const exportedMetrics = exporter.getMetrics();
totalExports = exportedMetrics.length;
}
}
it('should register meter views when provided', async () => {
// need to set OTEL_TRACES_EXPORTER to none since default value is otlp
// which sets up an exporter and affects the context manager
env.OTEL_TRACES_EXPORTER = 'none';
const exporter = new InMemoryMetricExporter(AggregationTemporality.CUMULATIVE);
const metricReader = new PeriodicExportingMetricReader({
exporter: exporter,
exportIntervalMillis: 100,
exportTimeoutMillis: 100
});
const sdk = new NodeSDK({
metricReader: metricReader,
views: [
new View({
name: 'test-view',
instrumentName: 'test_counter',
instrumentType: InstrumentType.COUNTER,
})
],
autoDetectResources: false,
});
await sdk.start();
assert.strictEqual(context['_getContextManager'](), ctxManager, 'context manager should not change');
assert.strictEqual(propagation['_getGlobalPropagator'](), propagator, 'propagator should not change');
assert.strictEqual((trace.getTracerProvider() as ProxyTracerProvider).getDelegate(), delegate, 'tracer provider should not have changed');
const meterProvider = metrics.getMeterProvider() as MeterProvider;
assert.ok(meterProvider);
const meter = meterProvider.getMeter('NodeSDKViews', '1.0.0');
const counter = meter.createCounter('test_counter', {
description: 'a test description',
});
counter.add(10);
await waitForNumberOfMetrics(exporter, 1);
const exportedMetrics = exporter.getMetrics();
const [firstExportedMetric] = exportedMetrics;
assert.ok(firstExportedMetric, 'should have one exported metric');
const [firstScopeMetric] = firstExportedMetric.scopeMetrics;
assert.ok(firstScopeMetric, 'should have one scope metric');
assert.ok(firstScopeMetric.scope.name === 'NodeSDKViews', 'scope should match created view');
assert.ok(firstScopeMetric.metrics.length > 0, 'should have at least one metrics entry');
const [firstMetricRecord] = firstScopeMetric.metrics;
assert.ok(firstMetricRecord.descriptor.name === 'test-view', 'should have renamed counter metric');
await sdk.shutdown();
delete env.OTEL_TRACES_EXPORTER;
});
it('should throw error when calling configureMeterProvider when views are already configured', () => {
const exporter = new InMemoryMetricExporter(AggregationTemporality.CUMULATIVE);
const metricReader = new PeriodicExportingMetricReader({
exporter: exporter,
exportIntervalMillis: 100,
exportTimeoutMillis: 100
});
const sdk = new NodeSDK({
metricReader: metricReader,
views: [
new View({
name: 'test-view',
instrumentName: 'test_counter',
instrumentType: InstrumentType.COUNTER,
})
],
autoDetectResources: false,
});
assert.throws(() => {
sdk.configureMeterProvider({
reader: metricReader,
views: [
new View({
name: 'test-view',
instrumentName: 'test_counter',
instrumentType: InstrumentType.COUNTER,
})
]
});
}, (error: Error) => {
return error.message.includes('Views passed but Views have already been configured');
});
});
it('should throw error when calling configureMeterProvider when metricReader is already configured', () => {
const exporter = new InMemoryMetricExporter(AggregationTemporality.CUMULATIVE);
const metricReader = new PeriodicExportingMetricReader({
exporter: exporter,
exportIntervalMillis: 100,
exportTimeoutMillis: 100
});
const sdk = new NodeSDK({
metricReader: metricReader,
views: [
new View({
name: 'test-view',
instrumentName: 'test_counter',
instrumentType: InstrumentType.COUNTER,
})
],
autoDetectResources: false,
});
assert.throws(() => {
sdk.configureMeterProvider({
reader: metricReader,
});
}, (error: Error) => {
return error.message.includes('MetricReader passed but MetricReader has already been configured.');
});
});
describe('detectResources', async () => {
beforeEach(() => {
process.env.OTEL_RESOURCE_ATTRIBUTES =
'service.instance.id=627cc493,service.name=my-service,service.namespace=default,service.version=0.0.1';
});
afterEach(() => {
delete process.env.OTEL_RESOURCE_ATTRIBUTES;
});
describe('with a custom resource', () => {
it('returns a merged resource', async () => {
const sdk = new NodeSDK({
autoDetectResources: true,
resourceDetectors: [processDetector, {
async detect(): Promise<Resource> {
return new Resource({'customAttr': 'someValue'});
}
},
envDetector]
});
await sdk.detectResources();
const resource = sdk['_resource'];
assert.strictEqual(
resource.attributes['customAttr'],
'someValue'
);
assertServiceResource(resource, {
instanceId: '627cc493',
name: 'my-service',
namespace: 'default',
version: '0.0.1',
});
});
});
describe('with a buggy detector', () => {
it('returns a merged resource', async () => {
const sdk = new NodeSDK({
autoDetectResources: true,
resourceDetectors: [processDetector, {
detect() {
throw new Error('Buggy detector');
}
},
envDetector]
});
await sdk.detectResources();
const resource = sdk['_resource'];
assertServiceResource(resource, {
instanceId: '627cc493',
name: 'my-service',
namespace: 'default',
version: '0.0.1',
});
});
});
describe('with a debug logger', () => {
// Local functions to test if a mocked method is ever called with a specific argument or regex matching for an argument.
// Needed because of race condition with parallel detectors.
const callArgsContains = (
mockedFunction: sinon.SinonSpy,
arg: any
): boolean => {
return mockedFunction.getCalls().some(call => {
return call.args.some(callarg => arg === callarg);
});
};
const callArgsMatches = (
mockedFunction: sinon.SinonSpy,
regex: RegExp
): boolean => {
return mockedFunction.getCalls().some(call => {
return call.args.some(callArgs => regex.test(callArgs.toString()));
});
};
it('prints detected resources and debug messages to the logger', async () => {
const sdk = new NodeSDK({
autoDetectResources: true,
});
// This test depends on the env detector to be functioning as intended
const mockedLoggerMethod = Sinon.fake();
const mockedVerboseLoggerMethod = Sinon.fake();
diag.setLogger(
{
debug: mockedLoggerMethod,
verbose: mockedVerboseLoggerMethod,
} as any,
DiagLogLevel.VERBOSE
);
await sdk.detectResources();
// Test that the Env Detector successfully found its resource and populated it with the right values.
assert.ok(
callArgsContains(mockedLoggerMethod, 'EnvDetector found resource.')
);
// Regex formatting accounts for whitespace variations in util.inspect output over different node versions
assert.ok(
callArgsMatches(
mockedVerboseLoggerMethod,
/{\s+'service\.instance\.id':\s+'627cc493',\s+'service\.name':\s+'my-service',\s+'service\.namespace':\s+'default',\s+'service\.version':\s+'0\.0\.1'\s+}\s*/
)
);
});
describe('with a faulty environment variable', () => {
beforeEach(() => {
process.env.OTEL_RESOURCE_ATTRIBUTES = 'bad=~attribute';
});
it('prints correct error messages when EnvDetector has an invalid variable', async () => {
const sdk = new NodeSDK({
autoDetectResources: true,
});
const mockedLoggerMethod = Sinon.fake();
diag.setLogger(
{
debug: mockedLoggerMethod,
} as any,
DiagLogLevel.DEBUG
);
await sdk.detectResources();
assert.ok(
callArgsContains(
mockedLoggerMethod,
'EnvDetector failed: Attribute value should be a ASCII string with a length not exceed 255 characters.'
)
);
});
});
});
});
describe('configureServiceName', async () => {
it('should configure service name via config', async () => {
const sdk = new NodeSDK({
serviceName: 'config-set-name',
});
await sdk.start();
const resource = sdk['_resource'];
assertServiceResource(resource, {
name: 'config-set-name',
});
});
it('should configure service name via OTEL_SERVICE_NAME env var', async () => {
process.env.OTEL_SERVICE_NAME = 'env-set-name';
const sdk = new NodeSDK();
await sdk.start();
const resource = sdk['_resource'];
assertServiceResource(resource, {
name: 'env-set-name',
});
delete process.env.OTEL_SERVICE_NAME;
});
it('should favor config set service name over OTEL_SERVICE_NAME env set service name', async () => {
process.env.OTEL_SERVICE_NAME = 'env-set-name';
const sdk = new NodeSDK({
serviceName: 'config-set-name',
});
await sdk.start();
const resource = sdk['_resource'];
assertServiceResource(resource, {
name: 'config-set-name',
});
delete process.env.OTEL_SERVICE_NAME;
});
it('should configure service name via OTEL_RESOURCE_ATTRIBUTES env var', async () => {
process.env.OTEL_RESOURCE_ATTRIBUTES = 'service.name=resource-env-set-name';
const sdk = new NodeSDK();
await sdk.start();
const resource = sdk['_resource'];
assertServiceResource(resource, {
name: 'resource-env-set-name',
});
delete process.env.OTEL_RESOURCE_ATTRIBUTES;
});
it('should favor config set service name over OTEL_RESOURCE_ATTRIBUTES env set service name', async () => {
process.env.OTEL_RESOURCE_ATTRIBUTES = 'service.name=resource-env-set-name';
const sdk = new NodeSDK({
serviceName: 'config-set-name',
});
await sdk.start();
const resource = sdk['_resource'];
assertServiceResource(resource, {
name: 'config-set-name',
});
delete process.env.OTEL_RESOURCE_ATTRIBUTES;
});
});
});
describe('setup exporter from env', () => {
let spyGetOtlpProtocol: Sinon.SinonSpy;
let stubLoggerError: Sinon.SinonStub;
beforeEach(() => {
spyGetOtlpProtocol = Sinon.spy(TracerProviderWithEnvExporters, 'getOtlpProtocol');
stubLoggerError = Sinon.stub(diag, 'warn');
});
afterEach(() => {
spyGetOtlpProtocol.restore();
stubLoggerError.restore();
});
it('use default exporter - TracerProviderWithEnvExporters', async () => {
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters);
assert(listOfProcessors.length === 1);
assert(listOfProcessors[0] instanceof BatchSpanProcessor);
});
it('ignore env exporter when user provides exporter to sdk config', async () => {
const traceExporter = new ConsoleSpanExporter();
const sdk = new NodeSDK({
traceExporter
});
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters === false);
assert(listOfProcessors.length === 1);
assert(listOfProcessors[0] instanceof SimpleSpanProcessor === false);
assert(listOfProcessors[0] instanceof BatchSpanProcessor);
});
it('ignore env exporter when user provides span processor to sdk config', async () => {
const traceExporter = new ConsoleSpanExporter();
const spanProcessor = new SimpleSpanProcessor(traceExporter);
const sdk = new NodeSDK({
spanProcessor
});
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters === false);
assert(listOfProcessors.length === 1);
assert(listOfProcessors[0] instanceof SimpleSpanProcessor);
assert(listOfProcessors[0] instanceof BatchSpanProcessor === false);
});
it('use otlp exporter and defined exporter protocol env value', async () => {
env.OTEL_TRACES_EXPORTER = 'otlp';
env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = 'grpc';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters);
assert(listOfProcessors.length === 1);
assert(listOfProcessors[0] instanceof BatchSpanProcessor);
delete env.OTEL_TRACES_EXPORTER;
delete env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL;
});
it('use noop span processor when user sets env exporter to none', async () => {
env.OTEL_TRACES_EXPORTER = 'none';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
const activeProcessor = sdk['_tracerProvider']?.getActiveSpanProcessor();
assert(listOfProcessors.length === 0);
assert(activeProcessor instanceof NoopSpanProcessor);
delete env.OTEL_TRACES_EXPORTER;
});
it('log warning that sdk will not be initalized when exporter is set to none', async () => {
env.OTEL_TRACES_EXPORTER = 'none';
const sdk = new NodeSDK();
await sdk.start();
assert.strictEqual(stubLoggerError.args[0][0], 'OTEL_TRACES_EXPORTER contains "none" or is empty. SDK will not be initialized.');
delete env.OTEL_TRACES_EXPORTER;
});
it('do not use any exporters when empty value is provided for exporter', async () => {
env.OTEL_TRACES_EXPORTER = '';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
const activeProcessor = sdk['_tracerProvider']?.getActiveSpanProcessor();
assert(listOfProcessors.length === 0);
assert(activeProcessor instanceof NoopSpanProcessor);
env.OTEL_TRACES_EXPORTER = '';
});
it('use only default exporter when none value is provided with other exporters', async () => {
env.OTEL_TRACES_EXPORTER = 'otlp,zipkin,none';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters);
assert(listOfProcessors.length === 1);
assert(listOfProcessors[0] instanceof BatchSpanProcessor);
delete env.OTEL_TRACES_EXPORTER;
});
it('log warning that only default exporter will be used since exporter list contains none with other exports ', async () => {
env.OTEL_TRACES_EXPORTER = 'otlp,zipkin,none';
const sdk = new NodeSDK();
await sdk.start();
assert.strictEqual(
stubLoggerError.args[0][0], 'OTEL_TRACES_EXPORTER contains "none" along with other exporters. Using default otlp exporter.'
);
delete env.OTEL_TRACES_EXPORTER;
});
it('should warn that provided exporter value is unrecognized and not able to be set up', async () => {
env.OTEL_TRACES_EXPORTER = 'invalid';
const sdk = new NodeSDK();
await sdk.start();
assert.strictEqual(
stubLoggerError.args[0][0], 'Unrecognized OTEL_TRACES_EXPORTER value: invalid.'
);
assert.strictEqual(
stubLoggerError.args[1][0], 'Unable to set up trace exporter(s) due to invalid exporter and/or protocol values.'
);
delete env.OTEL_TRACES_EXPORTER;
});
it('setup zipkin, jaeger and otlp exporters', async () => {
env.OTEL_TRACES_EXPORTER = 'zipkin, otlp, jaeger';
env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL = 'grpc';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(sdk['_tracerProvider'] instanceof TracerProviderWithEnvExporters);
assert(listOfProcessors.length === 3);
assert(listOfProcessors[0] instanceof BatchSpanProcessor);
assert(listOfProcessors[1] instanceof BatchSpanProcessor);
assert(listOfProcessors[2] instanceof BatchSpanProcessor);
delete env.OTEL_TRACES_EXPORTER;
delete env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL;
});
it('use the console exporter', async () => {
env.OTEL_TRACES_EXPORTER = 'console, otlp';
const sdk = new NodeSDK();
await sdk.start();
const listOfProcessors = sdk['_tracerProvider']!['_registeredSpanProcessors']!;
assert(listOfProcessors.length === 2);
assert(listOfProcessors[0] instanceof SimpleSpanProcessor);
assert(listOfProcessors[1] instanceof BatchSpanProcessor);
delete env.OTEL_TRACES_EXPORTER;
});
});