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

Add Testing for Shutdown Scenarios. #1514

Open
hdost opened this issue Feb 7, 2024 · 4 comments
Open

Add Testing for Shutdown Scenarios. #1514

hdost opened this issue Feb 7, 2024 · 4 comments
Labels
A-log Area: Issues related to logs M-api M-sdk

Comments

@hdost
Copy link
Contributor

hdost commented Feb 7, 2024

          > > And will calling shutdown on the global loggerProvider ensure that the logs through these loggers are not exported ?

It would be good to validate this use-case. It seems shutdown_logger_provider will invoke shutdown on the LogProcessors when the inner instance is dropped. And now if any of the loggers have it's reference in separate thread, the shutdown will not be invoked. One option can be to add a new LoggerProvider::Shutdown() method, and explicitly invoke it from within shutdown_logger_provider . This new method will invoke shutdown on all processors, and so ensure that all the existing logs are flushed. And no new logs can be exported with processors in shutdown state.

Thinking about this scenario again, it seems that the potential issue of leaking providers might not be as significant if we can document it clearly to explain the risk. Specifically, providers could be leaked if any of the tasks indefinitely retain their reference, which can result in a shutdown not triggering.

Originally posted by @lalitb in #1455 (comment)

@bIgBV
Copy link
Contributor

bIgBV commented Feb 19, 2024

Looking into this, I'd love some clarification on how the scenario would work. My current approach has been to set up an integration test based on https://github.com/open-telemetry/opentelemetry-rust/blob/main/examples/logs-basic/src/main.rs and extend it such that we have multiple background tasks with set up with references to the LoggerProvider instance through an Arc.

The shutdown I wanted to test was to create a forced shutdown through an interrupt. I initially tried this with setting up multiple exporters with a single LoggerProvider and got a panic from this line

.expect("cannot shutdown LoggerProvider when child Loggers are still active")
which I think is expected behavior.

Would taking the same approach with multiple LoggerProvider references in separate tasks be a similar scenario?

@hdost
Copy link
Contributor Author

hdost commented Feb 20, 2024

The shutdown I wanted to test was to create a forced shutdown through an interrupt. I initially tried this with setting up multiple exporters with a single LoggerProvider and got a panic from this line

.expect("cannot shutdown LoggerProvider when child Loggers are still active")
which I think is expected behavior.

Would taking the same approach with multiple LoggerProvider references in separate tasks be a similar scenario?

Looking at our API and the spec I actually think we might need a change. https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/sdk.md#shutdown

Right now i think this panic isn't actually doing what I would want/expect. There's already a result being returned. In this case it's a vec of results but I feel like we should be passing back a default of Vec error result.

Shutdown SHOULD provide a way to let the caller know whether it succeeded, failed or timed out.

Panics don't really "let the caller know".

@hdost hdost added A-log Area: Issues related to logs M-api M-sdk labels Feb 21, 2024
@cijothomas
Copy link
Member

Tests are added now and we should be good to close this.
#1042 (comment) is still required to be resolved, but that is separate (though shutdown related!)

@cijothomas
Copy link
Member

Reopening, as few topics were discussed here, but not really resolved.. (Will check how to expand the tests to cover everything.)

@cijothomas cijothomas reopened this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-log Area: Issues related to logs M-api M-sdk
Projects
None yet
Development

No branches or pull requests

3 participants