Skip to content

Commit

Permalink
fix(sdk-node): lazy require @opentelemetry/exporter-jaeger
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Apr 18, 2023
1 parent 5b9534b commit 921900f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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()],
]);

Expand Down
2 changes: 2 additions & 0 deletions packages/opentelemetry-exporter-jaeger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 921900f

Please sign in to comment.