11 instantiations of Activity
Microsoft.AspNetCore.Hosting (1)
Microsoft.AspNetCore.Http.Connections.Tests (1)
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
Microsoft.AspNetCore.SignalR.Tests (6)
System.Diagnostics.DiagnosticSource (1)
System.Net.Http (1)
289 references to Activity
ClaimsTransformation (1)
Cookies (1)
DynamicSchemes (1)
HostedBlazorWebassemblyApp.Server (1)
Identity.DefaultUI.WebSite (1)
Identity.ExternalClaims (1)
Microsoft.AspNetCore.Hosting (10)
Microsoft.AspNetCore.Hosting.Tests (49)
HostingApplicationDiagnosticsTests.cs (42)
256Assert.Null(Activity.Current);
296Assert.Null(Activity.Current);
327Assert.Null(Activity.Current);
364Assert.NotNull(Activity.Current);
384Assert.NotNull(Activity.Current);
385Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
391Assert.NotNull(Activity.Current);
408Assert.NotNull(Activity.Current);
409Assert.True(Activity.Current.Duration > TimeSpan.Zero);
410Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
432Assert.NotNull(Activity.Current);
433Assert.True(Activity.Current.Duration > TimeSpan.Zero);
434Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
456Assert.NotNull(Activity.Current);
457Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
484Assert.NotNull(Activity.Current);
485Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
513Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
514Assert.Equal("ParentId1", Activity.Current.ParentId);
515Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
516Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
544Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
545Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
546Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
575Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
576Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value3");
577Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value4");
605Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
614Assert.Equal(expectedBaggage, Activity.Current.Baggage.ToArray());
642Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
643Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1/1");
672Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
673Assert.Equal(ActivityIdFormat.W3C, Activity.Current.IdFormat);
674Assert.Equal("0123456789abcdef0123456789abcdef", Activity.Current.TraceId.ToHexString());
675Assert.Equal("0123456789abcdef", Activity.Current.ParentSpanId.ToHexString());
676Assert.Equal("TraceState1", Activity.Current.TraceStateString);
678Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
679Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
739Assert.Null(Activity.Current);
750Assert.NotNull(Activity.Current);
751Assert.True(Activity.Current.Recorded);
766parentSpanId = Activity.Current.ParentSpanId.ToHexString();
Microsoft.AspNetCore.Http (1)
Microsoft.AspNetCore.Http.Connections.Tests (3)
Microsoft.AspNetCore.Http.Extensions (1)
Microsoft.AspNetCore.Http.Extensions.Tests (14)
Microsoft.AspNetCore.Identity.UI (2)
Microsoft.AspNetCore.Mvc.Core (1)
Microsoft.AspNetCore.Mvc.Core.Test (2)
Microsoft.AspNetCore.Mvc.Core.TestCommon (2)
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
Microsoft.AspNetCore.SignalR.Core (9)
Microsoft.AspNetCore.SignalR.Tests (27)
Microsoft.Extensions.Logging (7)
MvcFormSample (1)
PathSchemeSelection (1)
StaticFilesAuth (1)
System.Diagnostics.DiagnosticSource (145)
System\Diagnostics\Activity.cs (38)
18/// Carries the <see cref="Activity.Current"/> changed event data.
22internal ActivityChangedEventArgs(Activity? previous, Activity? current)
29/// Gets <see cref="Activity"/> object before the event.
31public Activity? Previous { get; init; }
34/// Gets <see cref="Activity"/> object after the event.
36public Activity? Current { get; init; }
78/// Event occur when the <see cref="Activity.Current"/> value changes.
116private Activity? _previousActiveActivity;
143public Activity SetStatus(ActivityStatusCode code, string? description = null)
186public Activity? Parent { get; private set; }
363for (Activity? activity = this; activity != null; activity = activity.Parent)
373static IEnumerable<KeyValuePair<string, string?>> Iterate(Activity? activity)
459public Activity AddTag(string key, string? value) => AddTag(key, (object?)value);
469public Activity AddTag(string key, object? value)
493public Activity SetTag(string key, object? value)
510public Activity AddEvent(ActivityEvent e)
535public Activity AddException(Exception exception, in TagList tags = default, DateTimeOffset timestamp = default)
598public Activity AddLink(ActivityLink link)
617public Activity AddBaggage(string key, string? value)
641public Activity SetBaggage(string key, string? value)
662public Activity SetParentId(string parentId)
692public Activity SetParentId(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags = ActivityTraceFlags.None)
722public Activity SetStartTime(DateTime startTimeUtc)
742public Activity SetEndTime(DateTime endTimeUtc)
771/// Use <see cref="DiagnosticSource.StartActivity(Activity, object)"/> to start activity and write start event.
773/// <seealso cref="DiagnosticSource.StartActivity(Activity, object)"/>
775public Activity Start()
827/// Use <see cref="DiagnosticSource.StopActivity(Activity, object)"/> to stop activity and write stop event.
829/// <seealso cref="DiagnosticSource.StopActivity(Activity, object)"/>
872for (Activity? activity = this; activity != null; activity = activity.Parent)
1032public Activity SetIdFormat(ActivityIdFormat format)
1161internal static Activity Create(ActivitySource source, string name, ActivityKind kind, string? parentId, ActivityContext parentContext,
1165Activity activity = new Activity(name);
1378private static bool ValidateSetCurrent(Activity? activity)
1441/// Indicates whether this <see cref="Activity"/> object is stopped
1444/// When subscribing to <see cref="Activity"/> stop event using <see cref="ActivityListener.ActivityStopped"/>, the received <see cref="Activity"/> object in the event callback will have <see cref="IsStopped"/> as true.
System\Diagnostics\ActivitySource.cs (38)
100/// Creates a new <see cref="Activity"/> object if there is any listener to the Activity, returns null otherwise.
104/// <returns>The created <see cref="Activity"/> object or null if there is no any event listener.</returns>
106/// If the Activity object is created, it will not start automatically. Callers need to call <see cref="Activity.Start()"/> to start it.
108public Activity? CreateActivity(string name, ActivityKind kind)
112/// Creates a new <see cref="Activity"/> object if there is any listener to the Activity, returns null otherwise.
113/// If the Activity object is created, it will not automatically start. Callers will need to call <see cref="Activity.Start()"/> to start it.
121/// <returns>The created <see cref="Activity"/> object or null if there is no any listener.</returns>
123/// If the Activity object is created, it will not start automatically. Callers need to call <see cref="Activity.Start()"/> to start it.
125public Activity? CreateActivity(string name, ActivityKind kind, ActivityContext parentContext, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, ActivityIdFormat idFormat = ActivityIdFormat.Unknown)
129/// Creates a new <see cref="Activity"/> object if there is any listener to the Activity, returns null otherwise.
137/// <returns>The created <see cref="Activity"/> object or null if there is no any listener.</returns>
139/// If the Activity object is created, it will not start automatically. Callers need to call <see cref="Activity.Start()"/> to start it.
141public Activity? CreateActivity(string name, ActivityKind kind, string? parentId, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, ActivityIdFormat idFormat = ActivityIdFormat.Unknown)
145/// Creates and starts a new <see cref="Activity"/> object if there is any listener to the Activity, returns null otherwise.
149/// <returns>The created <see cref="Activity"/> object or null if there is no any event listener.</returns>
150public Activity? StartActivity([CallerMemberName] string name = "", ActivityKind kind = ActivityKind.Internal)
154/// Creates and starts a new <see cref="Activity"/> object if there is any listener to the Activity events, returns null otherwise.
162/// <returns>The created <see cref="Activity"/> object or null if there is no any listener.</returns>
163public Activity? StartActivity(string name, ActivityKind kind, ActivityContext parentContext, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default)
167/// Creates and starts a new <see cref="Activity"/> object if there is any listener to the Activity events, returns null otherwise.
175/// <returns>The created <see cref="Activity"/> object or null if there is no any listener.</returns>
176public Activity? StartActivity(string name, ActivityKind kind, string? parentId, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default)
180/// Creates and starts a new <see cref="Activity"/> object if there is any listener to the Activity events, returns null otherwise.
188/// <returns>The created <see cref="Activity"/> object or null if there is no any listener.</returns>
189public Activity? StartActivity(ActivityKind kind, ActivityContext parentContext = default, IEnumerable<KeyValuePair<string, object?>>? tags = null, IEnumerable<ActivityLink>? links = null, DateTimeOffset startTime = default, [CallerMemberName] string name = "")
192private Activity? CreateActivity(string name, ActivityKind kind, ActivityContext context, string? parentId, IEnumerable<KeyValuePair<string, object?>>? tags,
202Activity? activity = null;
288bool useCurrentActivityContext = context == default && Activity.Current != null;
289var aco = new ActivityCreationOptions<ActivityContext>(this, name, useCurrentActivityContext ? Activity.Current!.Context : context, kind, tags, links, idFormat);
317activity = Activity.Create(this, name, kind, parentId, context, tags, links, startTime, samplerTags, samplingResult, startIt, idFormat, traceState);
333/// Add a listener to the <see cref="Activity"/> starting and stopping events.
335/// <param name="listener"> The <see cref="ActivityListener"/> object to use for listening to the <see cref="Activity"/> events.</param>
373internal void NotifyActivityStart(Activity activity)
381listeners.EnumWithAction((listener, obj) => listener.ActivityStarted?.Invoke((Activity)obj), activity);
385internal void NotifyActivityStop(Activity activity)
393listeners.EnumWithAction((listener, obj) => listener.ActivityStopped?.Invoke((Activity)obj), activity);
397internal void NotifyActivityAddException(Activity activity, Exception exception, ref TagList tags)
513public void EnumWithExceptionNotification(Activity activity, Exception exception, ref TagList tags)
System\Diagnostics\DiagnosticSourceActivity.cs (17)
19/// was started. Consumers could access <see cref="Activity.Current"/>
27/// <seealso cref="Activity"/>
29public Activity StartActivity(Activity activity, object? args)
39public Activity StartActivity<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(Activity activity, T args)
44/// that Activity was stopped. Consumers could access <see cref="Activity.Current"/>
51/// <seealso cref="Activity"/>
53public void StopActivity(Activity activity, object? args)
58activity.SetEndTime(Activity.GetUtcNow());
66public void StopActivity<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(Activity activity, T args)
93public virtual void OnActivityImport(Activity activity, object? payload) { }
119public virtual void OnActivityExport(Activity activity, object? payload) { }
124public override void OnActivityImport(Activity activity, object? payload)
130public override void OnActivityExport(Activity activity, object? payload)
144Action<Activity, object?>? onActivityImport = null, Action<Activity, object?>? onActivityExport = null)
System.Net.Http (6)