diff --git a/experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts b/experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts index add81c7c91..5e7d163e75 100644 --- a/experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts +++ b/experimental/packages/opentelemetry-sdk-node/src/TracerProviderWithEnvExporter.ts @@ -32,7 +32,6 @@ import { OTLPTraceExporter as OTLPProtoTraceExporter } from '@opentelemetry/expo import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'; import { OTLPTraceExporter as OTLPGrpcTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc'; import { ZipkinExporter } from '@opentelemetry/exporter-zipkin'; -import { JaegerExporter } from '@opentelemetry/exporter-jaeger'; export class TracerProviderWithEnvExporters extends NodeTracerProvider { private _configuredExporters: SpanExporter[] = []; @@ -74,7 +73,23 @@ export class TracerProviderWithEnvExporters extends NodeTracerProvider { >([ ['otlp', () => this.configureOtlp()], ['zipkin', () => new ZipkinExporter()], - ['jaeger', () => new JaegerExporter()], + [ + 'jaeger', + () => { + // The JaegerExporter does not support being required in bundled + // environments. By delaying the require statement to here, we only crash when + // the exporter is actually used in such an environment. + try { + // eslint-disable-next-line @typescript-eslint/no-var-requires + const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); + return new JaegerExporter(); + } catch (e) { + throw new Error( + `Could not instantiate JaegerExporter. This could be due to the JaegerExporter's lack of support for bundling. If possible, use @opentelemetry/exporter-trace-otlp-proto instead. Original Error: ${e}` + ); + } + }, + ], ['console', () => new ConsoleSpanExporter()], ]); diff --git a/packages/opentelemetry-exporter-jaeger/README.md b/packages/opentelemetry-exporter-jaeger/README.md index 4adceb9b74..7e662a345e 100644 --- a/packages/opentelemetry-exporter-jaeger/README.md +++ b/packages/opentelemetry-exporter-jaeger/README.md @@ -9,6 +9,8 @@ - `@opentelemetry/exporter-trace-otlp-grpc` - `@opentelemetry/exporter-trace-otlp-http` +**NOTE: Bundling (with e.g. `webpack`, `rollup`, `esbuild`, ...) is not supported by this package. Please use `@opentelemetry/exporter-trace-otlp-proto` instead.** + OpenTelemetry Jaeger Trace Exporter allows the user to send collected traces to Jaeger. [Jaeger](https://jaeger.readthedocs.io/en/latest/), inspired by [Dapper](https://research.google.com/pubs/pub36356.html) and [OpenZipkin](http://zipkin.io/), is a distributed tracing system released as open source by [Uber Technologies](http://uber.github.io/). It is used for monitoring and troubleshooting microservices-based distributed systems, including: