Skip to content

Commit

Permalink
Decouple enabling console span exporter from enabling debug logs (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalSumislawski authored Nov 4, 2024
1 parent 436f3d0 commit a2dc73a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions nodejs/packages/cx-wrapper/provider-init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { diag } from '@opentelemetry/api';
import { DiagLogLevel, metrics } from '@opentelemetry/api';
import { diag, metrics } from '@opentelemetry/api';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
Expand All @@ -8,7 +7,7 @@ import { detectResourcesSync, envDetector, processDetector } from '@opentelemetr
import { MeterProvider, MeterProviderOptions, PeriodicExportingMetricReader, AggregationTemporality } from '@opentelemetry/sdk-metrics';
import { BatchSpanProcessor, ConsoleSpanExporter, SDKRegistrationConfig, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { logLevel, parseIntEnvvar } from './common';
import { parseBooleanEnvvar, parseIntEnvvar } from './common';

declare global {
// in case of downstream configuring span processors etc
Expand Down Expand Up @@ -64,8 +63,8 @@ export function initializeProvider(instrumentations: any[]): void {
/*
}
*/
// logging for debug
if (logLevel === DiagLogLevel.DEBUG) {

if (parseBooleanEnvvar("OTEL_CONSOLE_SPAN_EXPORTER_ENABLED") ?? false) {
tracerProvider.addSpanProcessor(
new SimpleSpanProcessor(new ConsoleSpanExporter())
);
Expand Down

0 comments on commit a2dc73a

Please sign in to comment.