Open andsens opened 3 weeks ago
Hi @andsens, thanks for reaching out.
Is this happening when shutting down or force flush the TracerProvider
or while the app is running? :thinking:
I tested this locally and was only able to repro this when I called TracerProvider#shutdown()
without considereing rejections. The stack trace was the same as you received, and it also did not mention anything about shutdown()
or forceFlush()
. During normal operation (scheduled exports) the rejection was properly handled.
Oh yeah, that might be it. I have a shutdown procedure with a function that looks like this:
export async function closeTracer(context: RootLogContext) {
if (isTracerContext(context)) {
const { rootLog, tracerProvider } = context;
rootLog.verbose('shutdown: close tracer connection');
tracerProvider.shutdown();
const [timeout, cancelTimout] = throwAfter(500, 'shutdown: Timed out waiting for tracer to close.');
await Promise.race([timeout, tracerProvider.shutdown]);
cancelTimout();
}
}
The function call itself is wrapped in a try/catch, so the error should simply be logged.
The error is from a short running script, so the tracerProvider.shutdown()
call is likely to get the responsibility of having to flush everything, since no timers are likely to be triggered.
What happened?
Steps to Reproduce
Without an opentelemetry agent running provide
OTEL_EXPORTER_OTLP_ENDPOINT="http://opentelemetry-agent:4317"
through the environment and register a trace provider.I believe you will need to trace something as well, though the stacktrace is not very heavy on the details, so that's a guess.
Expected Result
The instrumentation logs an error about DNS resolution failing.
Actual Result
The instrumentation rejects with an unhandled Promise about DNS resolution failing.
Additional Details
OpenTelemetry Setup Code
package.json
Relevant log output