File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
include/opentelemetry/sdk/trace Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ class TracerContext
8787 /* *
8888 * Shutdown the span processor associated with this tracer provider.
8989 */
90- bool Shutdown () noexcept ;
90+ bool Shutdown (std::chrono::microseconds timeout = (std::chrono::microseconds::max)() ) noexcept ;
9191
9292private:
9393 // order of declaration is important here - resource object should be destroyed after processor.
Original file line number Diff line number Diff line change @@ -104,12 +104,22 @@ nostd::shared_ptr<trace_api::Span> Tracer::StartSpan(
104104
105105void Tracer::ForceFlushWithMicroseconds (uint64_t timeout) noexcept
106106{
107- (void )timeout;
107+ if (context_)
108+ {
109+ context_->ForceFlush (
110+ std::chrono::microseconds{static_cast <std::chrono::microseconds::rep>(timeout)});
111+ }
108112}
109113
110114void Tracer::CloseWithMicroseconds (uint64_t timeout) noexcept
111115{
112- (void )timeout;
116+ // Trace context is shared by many tracers.So we just call ForceFlush to flush all pending spans
117+ // and do not shutdown it.
118+ if (context_)
119+ {
120+ context_->ForceFlush (
121+ std::chrono::microseconds{static_cast <std::chrono::microseconds::rep>(timeout)});
122+ }
113123}
114124} // namespace trace
115125} // namespace sdk
Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ bool TracerContext::ForceFlush(std::chrono::microseconds timeout) noexcept
5353 return processor_->ForceFlush (timeout);
5454}
5555
56- bool TracerContext::Shutdown () noexcept
56+ bool TracerContext::Shutdown (std::chrono::microseconds timeout ) noexcept
5757{
58- return processor_->Shutdown ();
58+ return processor_->Shutdown (timeout );
5959}
6060
6161} // namespace trace
You can’t perform that action at this time.
0 commit comments