Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@lmolkova
Copy link

@lmolkova lmolkova commented Feb 9, 2017

This change introduces IsEnabled(string, object, object) obverload in DiagnosticSource for advanced events filtering based on additional event context.
It also adds DiagnosticListener.Subscribe overload capable of filtering events based on such context.

See #15984 for more details

@lmolkova
Copy link
Author

lmolkova commented Feb 9, 2017

/cc @karolz-ms @brahmnes

/// <param name="arg1">An object that represents the additional context for IsEnabled</param>
/// <param name="arg2">An object that represents the additional context for IsEnabled</param>
/// <seealso cref="IsEnabled(string)"/>
public virtual bool IsEnabled(string name, object arg1, object arg2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a problem with using default args (arg2=null). I would expect this here, in the overload in DiagnosticListener, and in the reference assemblies.

Please put in the comment that arg1, and arg2 can be null.


// Subscription implementation
/// <summary>
/// Add a subscriber (Observer). If 'IsEnabled' == null (or not present), then the Source's IsEnabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Add more description of what the arguments of 'isEnabled' are (the first is the name of the event, the next are context object (which may be null) that are optionally passed to the isEnabled call from the DiagnosticSource.

internal IObserver<KeyValuePair<string, object>> Observer;

internal Predicate<string> IsEnabled;
internal Func<string, object, object, bool> IsEnabledExt;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename IsEnabled -> IsEnabled1Arg, and IsEnabled3Arg Also place a comment that any subscriber must set BOTH of these delegates (either they are both null or both are valid (typically one delegates to the other). ALso indicate the rationale (we do this so that if both the source and receiver agree on the number of args, dispatch is very efficient. Only in a mismatch is a 'fixup' thunk called.

@vancem
Copy link
Contributor

vancem commented Feb 9, 2017

I have left some feedback to document the code a bit more, but substance of the code looks good.

@vancem vancem merged commit d388751 into dotnet:master Feb 10, 2017
@karelz karelz modified the milestone: 2.0.0 Feb 13, 2017
macrogreg pushed a commit to open-telemetry/opentelemetry-dotnet-instrumentation that referenced this pull request Sep 24, 2020
…is_enabled

[WIP] Support IsEnabled with addtional arguments dotnet/corefx#15984

Commit migrated from dotnet/corefx@d388751
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…is_enabled

[WIP] Support IsEnabled with addtional arguments dotnet/corefx#15984

Commit migrated from dotnet/corefx@d388751
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants