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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forceFlush does not flush synchronously, should it? #73

Open
ktoso opened this issue Dec 12, 2023 · 1 comment
Open

forceFlush does not flush synchronously, should it? #73

ktoso opened this issue Dec 12, 2023 · 1 comment

Comments

@ktoso
Copy link
Collaborator

ktoso commented Dec 12, 2023

Need to check what otel expects here but it tripped up some developers using swift-otel in CLI like situations so they didn't get their spans.

Should we also flush during a graceful shutdown, integrated with swift-service-lifecycle?

@slashmo
Copy link
Owner

slashmo commented Dec 12, 2023

Thanks for bringing this up!

Quoting the OTel spec:

This method provides a way for provider to immediately export all spans that have not yet been exported for all the internal processors.
ForceFlush SHOULD provide a way to let the caller know whether it succeeded, failed or timed out.
ForceFlush SHOULD complete or abort within some timeout. ForceFlush can be implemented as a blocking API or an asynchronous API which notifies the caller via a callback or an event. OpenTelemetry client authors can decide if they want to make the flush timeout configurable.
ForceFlush MUST invoke ForceFlush on all registered SpanProcessors.

https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/sdk.md#forceflush

I guess we have two options here. Either we change the Tracer API to make it async or make the implementation blocking in Swift OTel. The first option is not very feasible I guess because it would break API. The second option feels weird when the rest of the API is async, but possible.


Should we also flush during a graceful shutdown, integrated with swift-service-lifecycle?

AFAIK it's up to the individual processor how to handle shut down. In the batch span processor e.g. I do force-flush before shutting down the exporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants