public ActivityScope(string name, string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentException($"{nameof(id)} is null or empty.", nameof(id));
            }

            Name = name;
            Id   = id;

            ActivityTracker.Start(this);
        }
 public void Dispose()
 {
     ActivityTracker.End(this);
 }
Example #3
0
 /// <summary>
 /// Clears all parents for <see cref="ActivityScope"/>, and
 /// creates new instance of <see cref="ActivityScope"/>.<see cref="Current"/> for given ID and name.<para />
 /// <para />
 /// Use only if you wish to clear all active <see cref="ActivityScope"/>, you may be looking for <see cref="ActivityScope"/>.<see cref="Child"/>.
 /// </summary>
 /// <param name="name">Human readable name for <see cref="ActivityScope"/></param>
 /// <param name="id">Optional, will default to <see cref="Guid"/>.<see cref="Guid.NewGuid"/>. Please ensure provided IDs are unique.</param>
 /// <returns></returns>
 public static ActivityScope Create(string name, string id = null)
 {
     ActivityTracker.Clear();
     return(new ActivityScope(name, id ?? Guid.NewGuid().ToString()));
 }