-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen-telemetry.config.ts
More file actions
executable file
·131 lines (112 loc) · 5.53 KB
/
open-telemetry.config.ts
File metadata and controls
executable file
·131 lines (112 loc) · 5.53 KB
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
// import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
// import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
// import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
// import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
// import { ZipkinExporter } from '@opentelemetry/exporter-zipkin';
// import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';
// import { Resource } from '@opentelemetry/resources';
// //import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
// //import { NodeSDKConfiguration } from '@opentelemetry/sdk-node';
// import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
// import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
// import os from 'os';
// import { loadConfig } from './common/configs/config.helper';
// import { MeterProvider, PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
// //import { OpenTelemetryModuleConfig } from '@metinseylan/nestjs-opentelemetry';
// const APP_CONFIG = loadConfig();
// const config: Partial<any> = {
// resource: new Resource({
// [SemanticResourceAttributes.SERVICE_NAME]: 'sss',
// [SemanticResourceAttributes.SERVICE_VERSION]: APP_CONFIG['SERVICE_VERSION'],
// [SemanticResourceAttributes.HOST_NAME]: process.env.HOSTNAME || os.hostname(),
// }) as any,
// autoDetectResources: false,
// textMapPropagator: new B3Propagator({
// injectEncoding: B3InjectEncoding.MULTI_HEADER,
// }),
// instrumentations: [
// getNodeAutoInstrumentations({
// // We use `@metinseylan/nestjs-opentelemetry` instead, because it has better auto instrumentation
// '@opentelemetry/instrumentation-nestjs-core': { enabled: false },
// // We use a custom instrumentation in LogService instead, because the auto instrumentation
// // only injects the trace and span id but does not trigger span events
// '@opentelemetry/instrumentation-winston': { enabled: false },
// }),
// ],
// };
// /*
// const config: Partial<NodeSDKConfiguration> = {
// resource: new Resource({
// [SemanticResourceAttributes.SERVICE_NAME]: 'sss',
// [SemanticResourceAttributes.SERVICE_VERSION]: APP_CONFIG['SERVICE_VERSION'],
// [SemanticResourceAttributes.HOST_NAME]:
// process.env.HOSTNAME || os.hostname(),
// }) as any,
// autoDetectResources: false,
// textMapPropagator: new B3Propagator({
// injectEncoding: B3InjectEncoding.MULTI_HEADER,
// }),
// instrumentations: [
// getNodeAutoInstrumentations({
// // We use `@metinseylan/nestjs-opentelemetry` instead, because it has better auto instrumentation
// '@opentelemetry/instrumentation-nestjs-core': { enabled: false },
// // We use a custom instrumentation in LogService instead, because the auto instrumentation
// // only injects the trace and span id but does not trigger span events
// '@opentelemetry/instrumentation-winston': { enabled: false },
// }),
// ],
// };*/
// // Export to local Zipkin instance for trace analysis in development
// if (APP_CONFIG['OPEN_TELEMETRY_ZIPKIN_ENABLED'] && !APP_CONFIG['OPEN_TELEMETRY_COLLECTOR_URL']) {
// config.spanProcessor = new SimpleSpanProcessor(
// new ZipkinExporter({
// url: 'http://localhost:9411/api/v2/spans',
// })
// );
// }
// // Export to local Prometheus instance for metrics analysis in development
// if (APP_CONFIG['OPEN_TELEMETRY_PROMETHEUS_ENABLED'] && !APP_CONFIG['OPEN_TELEMETRY_LIGHTSTEP_ACCESS_TOKEN']) {
// config.metricReader = new PrometheusExporter({
// endpoint: 'metrics',
// port: 9464,
// });
// }
// // Export to Collector gateway for trace and metrics analysis in production
// if (APP_CONFIG['OPEN_TELEMETRY_COLLECTOR_URL']) {
// config.traceExporter = new OTLPTraceExporter({
// url: APP_CONFIG['OPEN_TELEMETRY_COLLECTOR_URL'] + '/v1/traces',
// });
// // TODO Re-enable metrics pipeline once the Node SDK supports the Collector format,
// // and remove Lightstep exporter below.
// // https://github.com/open-telemetry/opentelemetry-js/issues/2774
// const collectorOptions = {
// url: APP_CONFIG['OPEN_TELEMETRY_COLLECTOR_URL'] + '/v1/metrics', // url is optional and can be omitted - default is http://localhost:4317/v1/metrics
// concurrencyLimit: 1, // an optional limit on pending requests
// };
// const metricExporter = new OTLPMetricExporter(collectorOptions);
// const meterProvider = new MeterProvider();
// meterProvider.addReader(
// new PeriodicExportingMetricReader({
// exporter: metricExporter,
// })
// );
// }
// // Export to Lightstep for metrics analysis in production
// if (APP_CONFIG['OPEN_TELEMETRY_LIGHTSTEP_ACCESS_TOKEN']) {
// const collectorOptions = {
// url: 'https://ingest.lightstep.com/metrics/otlp/v0.6',
// headers: {
// 'Lightstep-Access-Token': APP_CONFIG['OPEN_TELEMETRY_LIGHTSTEP_ACCESS_TOKEN'],
// },
// concurrencyLimit: 1, // an optional limit on pending requests
// };
// const metricExporter = new OTLPMetricExporter(collectorOptions);
// const meterProvider = new MeterProvider();
// meterProvider.addReader(
// new PeriodicExportingMetricReader({
// exporter: metricExporter,
// exportIntervalMillis: 60 * 1000,
// })
// );
// }
// export const openTelemetryConfig = config;