-
Notifications
You must be signed in to change notification settings - Fork 42
/
OpenTelemetryModuleConfig.ts
61 lines (59 loc) · 2.48 KB
/
OpenTelemetryModuleConfig.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
import { Provider } from '@nestjs/common/interfaces/modules/provider.interface';
import { Injector } from './Trace/Injectors/Injector';
import { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
import { ControllerInjector } from './Trace/Injectors/ControllerInjector';
import { GuardInjector } from './Trace/Injectors/GuardInjector';
import { EventEmitterInjector } from './Trace/Injectors/EventEmitterInjector';
import { ScheduleInjector } from './Trace/Injectors/ScheduleInjector';
import { PipeInjector } from './Trace/Injectors/PipeInjector';
import { LoggerInjector } from './Trace/Injectors/LoggerInjector';
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
import { Resource } from '@opentelemetry/resources';
import { NoopSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { CompositePropagator } from '@opentelemetry/core';
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';
import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
import { alibabaCloudEcsDetector } from '@opentelemetry/resource-detector-alibaba-cloud';
import { awsEc2Detector } from '@opentelemetry/resource-detector-aws';
import { containerDetector } from '@opentelemetry/resource-detector-container';
import { gcpDetector } from '@opentelemetry/resource-detector-gcp';
import { instanaAgentDetector } from '@opentelemetry/resource-detector-instana';
export interface OpenTelemetryModuleConfig
extends Partial<NodeSDKConfiguration> {
traceAutoInjectors?: Provider<Injector>[];
}
export const OpenTelemetryModuleDefaultConfig = {
serviceName: 'UNKNOWN',
traceAutoInjectors: [
ControllerInjector,
GuardInjector,
EventEmitterInjector,
ScheduleInjector,
PipeInjector,
LoggerInjector,
],
autoDetectResources: false,
resourceDetectors: [
alibabaCloudEcsDetector,
awsEc2Detector,
containerDetector,
gcpDetector,
instanaAgentDetector,
],
contextManager: new AsyncLocalStorageContextManager(),
resource: new Resource({
lib: '@metinseylan/nestjs-opentelemetry',
}),
instrumentations: [getNodeAutoInstrumentations()],
spanProcessor: new NoopSpanProcessor(),
textMapPropagator: new CompositePropagator({
propagators: [
new JaegerPropagator(),
new B3Propagator(),
new B3Propagator({
injectEncoding: B3InjectEncoding.MULTI_HEADER,
}),
],
}),
} as OpenTelemetryModuleConfig;