-
Notifications
You must be signed in to change notification settings - Fork 455
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
[Feature]: opentelemetry::logs::Logger (or LoggerProvider) should offer a flush or force_flush method #2388
Comments
See if the example helps. It shows shutdown() being called, but flush can also be called the exact same way. Or https://github.com/open-telemetry/opentelemetry-rust/blob/main/opentelemetry-otlp/examples/basic-otlp/src/main.rs#L144 example which uses OTLP and the BatchLogRecordProcessor. |
Thanks! When I have an instance of Provider struct, then this is no problem. However, the biggest issue is trying to flush() from interfaces when all I have is an impl of the Logger Trait or LoggerProvider trait. This is the case when using Also I should point out that it seems the |
Not clear, sorry. Can you elaborate? Flush/shutdown is only expected to be called by applications and they'll always have to the sdk_loggerproviders. |
OpenTelemetryLogBridge consumes the LoggerProvider struct. |
Maybe more succinctly, I think this is a bug: |
The bridges are expected to only depend on the OpenTelemetry API (i.e opentelemetry crate), and there is no flush method on API defined. I am not sure if we need to do something about this method, as it is not called by logging macros.. @rrichardson Can you describe a potential fix, so I can understand if I am missing something. |
Related Problems?
No response
Describe the solution you'd like:
Presently, there is no way to invoke a flush() call through the OpenTelemetryLog Bridge or most other usages of the Logger Trait.
For anyone using a Batched Processor, a properly working
flush()
is critical for Panic handlers or any other (graceful or not) shutdown procedures.force_flush()
is implemented in thesdk::logs::LoggerProvider
struct, as well as thesdk::logs::BatchLogProcessor
. The LoggerProvider struct directly implements the LoggerProvider trait, and the BatchLogProcessor is wrapped by LoggerProvider to provide the Logger trait. Despite this, there is no way to actually invoke thatforce_flush()
method on either type.If either Logger or LoggerProvider had flush as a method, one would be able to activate it from whatever container owned those types.
Additionally, the
log::Log
trait features aflush()
method, but currently, the impl ofLog
by OpenTelemetryLogBridge does not conform to the spec, because it has no way to execute a flush()Considered Alternatives
I have been trying to figure out a way to make a ShutdownGuard with a handle to the concrete LoggerProvider struct so I could at least make a ShutdownGuard that would flush on drop. so far I've not found a straightforward way to do this without violating a bunch of encapsulation rules.
Additional Context
No response
The text was updated successfully, but these errors were encountered: