Browse Source

respect OTEL_* env vars as far as possible

Syunsuke Komma 2 years ago
parent
commit
886fb9dee3

+ 2 - 5
apps/app/src/server/crowi/opentelemetry.ts

@@ -32,9 +32,9 @@ export class OpenTelemetry {
         [SEMRESATTRS_SERVICE_INSTANCE_ID]: configManager.getConfig('crowi', 'instrumentation:serviceInstanceId'),
         [SEMRESATTRS_SERVICE_VERSION]: this.version,
       }),
-      traceExporter: new OTLPTraceExporter({ url: configManager.getConfig('crowi', 'instrumentation:otlpTracesEndpoint') }),
+      traceExporter: new OTLPTraceExporter(),
       metricReader: new PeriodicExportingMetricReader({
-        exporter: new OTLPMetricExporter({ url: configManager.getConfig('crowi', 'instrumentation:otlpMetricsEndpoint') }),
+        exporter: new OTLPMetricExporter(),
         exportIntervalMillis: 10000,
       }),
       instrumentations: [getNodeAutoInstrumentations({
@@ -44,9 +44,6 @@ export class OpenTelemetry {
           enabled: false,
         },
       })],
-      // send the half of all traces
-      // see: https://opentelemetry.io/docs/languages/js/sampling/
-      sampler: new TraceIdRatioBasedSampler(0.5),
     };
   }
 

+ 1 - 13
apps/app/src/server/service/config-loader.ts

@@ -717,23 +717,11 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
     type: ValueType.NUMBER,
     default: 172800, // 2 days
   },
-  OPENTELEMETRY_OTLP_METRICS_ENDPOINT: {
-    ns: 'crowi',
-    key: 'instrumentation:otlpMetricsEndpoint',
-    type: ValueType.STRING,
-    default: null,
-  },
-  OPENTELEMETRY_OTLP_TRACES_ENDPOINT: {
-    ns: 'crowi',
-    key: 'instrumentation:otlpTracesEndpoint',
-    type: ValueType.STRING,
-    default: null,
-  },
   OPENTELEMETRY_INSTRUMENTATION_ENABLED: {
     ns: 'crowi',
     key: 'instrumentation:enabled',
     type: ValueType.BOOLEAN,
-    default: true,
+    default: null,
   },
   // TODO: fix after the decision of the instrumentation data specification
   // https://redmine.weseek.co.jp/issues/144351