diff --git a/docs/trace/extending-the-sdk/MyFilteringProcessor.cs b/docs/trace/extending-the-sdk/MyFilteringProcessor.cs index 22cf898f3b5..ed74678decf 100644 --- a/docs/trace/extending-the-sdk/MyFilteringProcessor.cs +++ b/docs/trace/extending-the-sdk/MyFilteringProcessor.cs @@ -17,16 +17,28 @@ using System; using System.Diagnostics; using OpenTelemetry; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; -internal class MyFilteringProcessor : BaseProcessor +/// +/// A custom processor for filtering instances. +/// +/// +/// Note: is used as the base class because +/// the SDK needs to understand that MyFilteringProcessor wraps an inner +/// processor. Without that understanding some features such as would be unavailable because the SDK needs to push state +/// about the parent to all processors in the +/// chain. +/// +internal sealed class MyFilteringProcessor : CompositeProcessor { private readonly Func filter; - private readonly BaseProcessor processor; public MyFilteringProcessor(BaseProcessor processor, Func filter) + : base(new[] { processor }) { this.filter = filter ?? throw new ArgumentNullException(nameof(filter)); - this.processor = processor ?? throw new ArgumentNullException(nameof(processor)); } public override void OnEnd(Activity activity) @@ -35,7 +47,7 @@ public override void OnEnd(Activity activity) // only if the Filter returns true. if (this.filter(activity)) { - this.processor.OnEnd(activity); + base.OnEnd(activity); } } }