/// <summary> /// Construct an ActivitySource object with the input name /// </summary> /// <param name="name">The name of the ActivitySource object</param> /// <param name="version">The version of the component publishing the tracing info.</param> public ActivitySource(string name, string?version = "") { Name = name ?? throw new ArgumentNullException(nameof(name)); Version = version; s_activeSources.Add(this); if (s_allListeners.Count > 0) { s_allListeners.EnumWithAction((listener, source) => { Func <ActivitySource, bool>?shouldListenTo = listener.ShouldListenTo; if (shouldListenTo != null) { var activitySource = (ActivitySource)source; if (shouldListenTo(activitySource)) { activitySource.AddListener(listener); } } }, this); } GC.KeepAlive(DiagnosticSourceEventSource.Log); }
/// <summary> /// Construct an ActivitySource object with the input name /// </summary> /// <param name="name">The name of the ActivitySource object</param> /// <param name="version">The version of the component publishing the tracing info.</param> public ActivitySource(string name, string?version = "") { if (name == null) { throw new ArgumentNullException(nameof(name)); } Name = name; Version = version; s_activeSources.Add(this); if (s_allListeners.Count > 0) { s_allListeners.EnumWithAction(listener => { var shouldListenTo = listener.ShouldListenTo; if (shouldListenTo != null && shouldListenTo(this)) { AddListener(listener); } }); } }