Skip to content

Commit 7615e48

Browse files
committed
simplify otel shutdown
1 parent 35cdc1d commit 7615e48

File tree

1 file changed

+1
-17
lines changed

1 file changed

+1
-17
lines changed

packages/@contentlayer/utils/src/tracing-effect/otel-exporter-trace-otlp-grpc.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,7 @@ export const makeTracingSpanExporter = M.gen(function* (_) {
3434
const spanExporter = yield* _(
3535
pipe(
3636
T.succeedWith(() => new OTLPTraceExporter(config)),
37-
// NOTE Unfortunately this workaround/"hack" is currently needed since Otel doesn't yet provide a graceful
38-
// way to shutdown.
39-
//
40-
// Related issue: https://github.com/open-telemetry/opentelemetry-js/issues/987
41-
M.make((p) =>
42-
T.gen(function* (_) {
43-
while (1) {
44-
yield* _(T.sleep(0))
45-
const promises = p['_sendingPromises'] as any[]
46-
if (promises.length > 0) {
47-
yield* _(T.result(T.promise(() => Promise.all(promises))))
48-
} else {
49-
break
50-
}
51-
}
52-
}),
53-
),
37+
M.make((exporter) => T.promise(() => exporter.shutdown())),
5438
),
5539
)
5640

0 commit comments

Comments
 (0)