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 ForceFlush to TracerProvider in SDK #588

Merged
merged 2 commits into from
Feb 27, 2021

Conversation

ThomsonTan
Copy link
Contributor

Fixes #587

Changes

Add ForceFlush to TracerProvider as per the spec PR open-telemetry/opentelemetry-specification#1452

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@ThomsonTan ThomsonTan requested a review from a team February 25, 2021 19:02
@codecov
Copy link

codecov bot commented Feb 25, 2021

Codecov Report

Merging #588 (aa73133) into main (3848295) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #588      +/-   ##
==========================================
+ Coverage   94.41%   94.46%   +0.04%     
==========================================
  Files         200      200              
  Lines        9080     9087       +7     
==========================================
+ Hits         8573     8584      +11     
+ Misses        507      503       -4     
Impacted Files Coverage Δ
.../include/opentelemetry/sdk/trace/tracer_provider.h 100.00% <ø> (ø)
sdk/src/logs/logger.cc 65.90% <ø> (ø)
sdk/src/trace/tracer_provider.cc 68.18% <100.00%> (+3.18%) ⬆️
sdk/test/trace/tracer_provider_test.cc 100.00% <100.00%> (ø)
sdk/test/common/circular_buffer_test.cc 100.00% <0.00%> (+1.04%) ⬆️
sdk/test/metrics/counter_aggregator_test.cc 100.00% <0.00%> (+1.78%) ⬆️
...include/opentelemetry/sdk/trace/simple_processor.h 100.00% <0.00%> (+11.11%) ⬆️


bool TracerProvider::ForceFlush(std::chrono::microseconds timeout) noexcept
{
return GetProcessor()->Shutdown(timeout);
Copy link
Member

Choose a reason for hiding this comment

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

Curious - do we want to call ForceFlush or Shutdown? (I thought the latter)

Copy link
Member

@lalitb lalitb Feb 26, 2021

Choose a reason for hiding this comment

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

As per the specs (https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#forceflush):
ForceFlush MUST invoke ForceFlush on all registered SpanProcessors.

So ForceFlush() method needs to be defined both for SpanProcessor and Exporter. This can be done as separate PR and in that case Shutdown() call can be removed for now from above.

Note: PR to update specs for adding ForceFlush in Exporter is still open ( open-telemetry/opentelemetry-specification#1467 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch, @reyang

@lalitb I think we only support one SpanProcessor now. I'd prefer to add ForceFlush to SpanExporter in a separate PR.

Copy link
Member

@reyang reyang Feb 26, 2021

Choose a reason for hiding this comment

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

I think we only support one SpanProcessor now.

That's fine, I think we could support multiple processors by using a de-mux processor (so from the provider perspective, there is only one processor).

Here are some examples:

Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM.

@lalitb lalitb merged commit f4dd108 into open-telemetry:main Feb 27, 2021
@reyang reyang mentioned this pull request Mar 2, 2021
3 tasks
@ThomsonTan ThomsonTan deleted the AddForceFlushToTracerProvider branch November 9, 2022 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ForceFlush to TracerProvider (SDK only)
4 participants