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

Updating ActivityProcessor #975

Merged
merged 19 commits into from
Aug 4, 2020
Merged

Updating ActivityProcessor #975

merged 19 commits into from
Aug 4, 2020

Conversation

eddynaka
Copy link
Contributor

@eddynaka eddynaka commented Aug 2, 2020

Fixes #974

Changes

  • ActivityProcessor now implements IDisposable
  • Moved some of dispose logic to ActivityProcessor, so every processor would use the same code as base.
  • Refactor

Please provide a brief description of the changes here. Update the
CHANGELOG.md for non-trivial changes.

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

  • Design discussion issue #
  • Changes in public API reviewed

@eddynaka eddynaka requested a review from a team August 2, 2020 15:52
@codecov
Copy link

codecov bot commented Aug 2, 2020

Codecov Report

Merging #975 into master will increase coverage by 0.05%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
+ Coverage   68.14%   68.19%   +0.05%     
==========================================
  Files         218      219       +1     
  Lines        5983     5974       -9     
  Branches      978      978              
==========================================
- Hits         4077     4074       -3     
+ Misses       1632     1626       -6     
  Partials      274      274              
Impacted Files Coverage Δ
...c/OpenTelemetry.Exporter.ZPages/ZPagesProcessor.cs 85.71% <ø> (ø)
src/OpenTelemetry/Trace/SimpleActivityProcessor.cs 46.15% <0.00%> (+8.65%) ⬆️
...Exporter.Jaeger/Implementation/JaegerUdpBatcher.cs 78.10% <100.00%> (ø)
src/OpenTelemetry/Trace/ActivityProcessor.cs 100.00% <100.00%> (ø)
...c/OpenTelemetry/Trace/BatchingActivityProcessor.cs 80.82% <100.00%> (-0.76%) ⬇️
...metry/Trace/Internal/BroadcastActivityProcessor.cs 92.50% <100.00%> (+5.54%) ⬆️
src/OpenTelemetry/Metrics/CounterMetricSdkBase.cs 80.00% <0.00%> (-13.34%) ⬇️
...nTelemetry/Trace/Internal/NoopActivityProcessor.cs 50.00% <0.00%> (+16.66%) ⬆️

updating tests

updating tests - 2

updating merge

updating tests - 3

updating tests - 4

using inrange instead of equal

updating tests
@@ -2,7 +2,11 @@

## Unreleased

* `ActivityProcessor` implements IDisposable
* `ActivityProcessor` implements IDisposable.
* When `Dispose` occurs, it calls `ShutdownAsync`.
Copy link
Member

Choose a reason for hiding this comment

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

Need to highlight that user should override their Dispose method, if they want to achieve custom behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just updated


protected virtual void Dispose(bool disposing)
{
try
Copy link
Member

Choose a reason for hiding this comment

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

I guess this block should only be called when disposing == true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in our actual code, it's doing every time. So, I'm not sure.

Copy link
Member

Choose a reason for hiding this comment

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

I think typically Close/Shutdown call goes outside of the check. Eg:

protected virtual void Dispose(bool disposing)
{
   Close();

   if (disposing)
   {
       // Free managed resources.
   }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

after I moved, i saw some problems from BroadcastActivityProcessor:

protected override void Dispose(bool disposing)
        {
            if (disposing && !this.disposed)
            {
                foreach (var processor in this.processors)
                {
                    try
                    {
                        if (processor is IDisposable disposable)
                        {
                            disposable.Dispose();
                        }
                    }
                    catch (Exception e)
                    {
                        OpenTelemetrySdkEventSource.Log.SpanProcessorException("Dispose", e);
                    }
                }

                this.disposed = true;
            }

            base.Dispose(disposing);
        }

we are disposing the processors and, then, the base.dispose will call the shutdown...

I will revert to the base calling before, and we can think in another way.

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.

@cijothomas cijothomas merged commit 5cdfd30 into open-telemetry:master Aug 4, 2020
@eddynaka eddynaka deleted the feature/updating-activity-processor branch August 14, 2020 00:07
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.

TracerProviderSdk expects that ActivtyProcessor is Disposable
5 participants