-
Notifications
You must be signed in to change notification settings - Fork 773
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
Changes from all commits
1283315
95412d5
4609d92
bfce11e
8989bb8
75e7516
a568d33
6726a49
d050af8
49567fc
1716c04
4b6b181
ad135e6
6541ac9
e1e975b
af7ce79
100ffa2
7aafbc4
cf3b1a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,16 +13,19 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using OpenTelemetry.Internal; | ||
|
||
namespace OpenTelemetry.Trace | ||
{ | ||
/// <summary> | ||
/// Activity processor base class. | ||
/// </summary> | ||
public abstract class ActivityProcessor | ||
public abstract class ActivityProcessor : IDisposable | ||
eddynaka marked this conversation as resolved.
Show resolved
Hide resolved
eddynaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
/// <summary> | ||
/// Activity start hook. | ||
|
@@ -49,5 +52,24 @@ public abstract class ActivityProcessor | |
/// <param name="cancellationToken">Cancellation token.</param> | ||
/// <returns>Returns <see cref="Task"/>.</returns> | ||
public abstract Task ForceFlushAsync(CancellationToken cancellationToken); | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
this.Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
try | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this block should only be called when There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
{ | ||
this.ShutdownAsync(CancellationToken.None).GetAwaiter().GetResult(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
OpenTelemetrySdkEventSource.Log.SpanProcessorException(nameof(this.Dispose), ex); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updated