Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove promise hack #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions packages/otel-exporter-jaeger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@ export const makeJaegerTracingSpanExporter = M.gen(function* (_) {
const spanExporter = yield* _(
pipe(
T.succeedWith(() => new JaegerExporter(config)),
M.make((p) =>
// NOTE Unfortunately this workaround/"hack" is currently needed since Otel doesn't yet provide a graceful
// way to shutdown.
//
// Related issue: https://github.com/open-telemetry/opentelemetry-js/issues/987
pipe(
T.sleep(2_000),
T.zipRight(T.promise(() => p.shutdown())),
T.zipRight(
T.effectAsync<unknown, never, void>((cb) => {
p["_sender"]["_client"].once("close", () => {
cb(T.unit)
})
})
)
)
)
M.make((p) => T.promise(() => p.shutdown()))
)
)

Expand Down
18 changes: 1 addition & 17 deletions packages/otel-exporter-trace-otlp-grpc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@ export const makeTracingSpanExporter = M.gen(function* (_) {
const spanExporter = yield* _(
pipe(
T.succeedWith(() => new OTLPTraceExporter(config)),
// NOTE Unfortunately this workaround/"hack" is currently needed since Otel doesn't yet provide a graceful
// way to shutdown.
//
// Related issue: https://github.com/open-telemetry/opentelemetry-js/issues/987
M.make((p) =>
T.gen(function* (_) {
while (1) {
yield* _(T.sleep(0))
const promises = p["_sendingPromises"] as any[]
if (promises.length > 0) {
yield* _(T.result(T.promise(() => Promise.all(promises))))
} else {
break
}
}
})
)
M.make((p) => T.promise(() => p.shutdown()))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like Managed has been removed. What should it be replaced with?

)
)

Expand Down
18 changes: 1 addition & 17 deletions packages/otel-exporter-trace-otlp-http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,7 @@ export const makeTracingSpanExporter = M.gen(function* (_) {
const spanExporter = yield* _(
pipe(
T.succeedWith(() => new OTLPTraceExporter(config)),
// NOTE Unfortunately this workaround/"hack" is currently needed since Otel doesn't yet provide a graceful
// way to shutdown.
//
// Related issue: https://github.com/open-telemetry/opentelemetry-js/issues/987
M.make((p) =>
T.gen(function* (_) {
while (1) {
yield* _(T.sleep(0))
const promises = p["_sendingPromises"] as any[]
if (promises.length > 0) {
yield* _(T.result(T.promise(() => Promise.all(promises))))
} else {
break
}
}
})
)
M.make((p) => T.promise(() => p.shutdown()))
)
)

Expand Down