27 instantiations of Activity
Microsoft.AspNetCore.Diagnostics (1)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
Microsoft.AspNetCore.Hosting (1)
Microsoft.AspNetCore.Http.Connections.Tests (1)
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
Microsoft.AspNetCore.SignalR.Client.Core (1)
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (3)
Microsoft.AspNetCore.SignalR.Core (1)
Microsoft.AspNetCore.SignalR.Tests (8)
Microsoft.Extensions.Telemetry.Tests (7)
System.Diagnostics.DiagnosticSource (1)
System.Net.Http (1)
522 references to Activity
Aspire.Components.Common.Tests (11)
Aspire.Dashboard (1)
Aspire.Elastic.Clients.Elasticsearch.Tests (1)
Aspire.Microsoft.Data.SqlClient (9)
Aspire.Microsoft.EntityFrameworkCore.SqlServer (9)
Aspire.NATS.Net.Tests (1)
Aspire.Oracle.EntityFrameworkCore.Tests (1)
Aspire.RabbitMQ.Client (1)
Aspire.StackExchange.Redis (11)
Aspire.StackExchange.Redis.Tests (1)
ClaimsTransformation (1)
Cookies (1)
DynamicSchemes (1)
HostedBlazorWebassemblyApp.Server (1)
Identity.DefaultUI.WebSite (1)
Identity.ExternalClaims (1)
Microsoft.AspNetCore.Diagnostics (2)
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (2)
Microsoft.AspNetCore.Hosting (12)
Microsoft.AspNetCore.Hosting.Tests (54)
HostingApplicationDiagnosticsTests.cs (47)
172Activity measurementActivity = null;
201measurementActivity = Activity.Current;
487Assert.Null(Activity.Current);
527Assert.Null(Activity.Current);
558Assert.Null(Activity.Current);
595Assert.NotNull(Activity.Current);
615Assert.NotNull(Activity.Current);
616Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
622Assert.NotNull(Activity.Current);
639Assert.NotNull(Activity.Current);
640Assert.True(Activity.Current.Duration > TimeSpan.Zero);
641Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
663Assert.NotNull(Activity.Current);
664Assert.True(Activity.Current.Duration > TimeSpan.Zero);
665Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
687Assert.NotNull(Activity.Current);
688Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
715Assert.NotNull(Activity.Current);
716Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
744Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
745Assert.Equal("ParentId1", Activity.Current.ParentId);
746Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
747Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
774Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
775Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
776Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
804Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
805Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
806Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
835Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
836Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value3");
837Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value4");
865Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
874Assert.Equal(expectedBaggage, Activity.Current.Baggage.ToArray());
902Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
903Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1/1");
932Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName);
933Assert.Equal(ActivityIdFormat.W3C, Activity.Current.IdFormat);
934Assert.Equal("0123456789abcdef0123456789abcdef", Activity.Current.TraceId.ToHexString());
935Assert.Equal("0123456789abcdef", Activity.Current.ParentSpanId.ToHexString());
936Assert.Equal("TraceState1", Activity.Current.TraceStateString);
938Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1");
939Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2");
999Assert.Null(Activity.Current);
1010Assert.NotNull(Activity.Current);
1011Assert.True(Activity.Current.Recorded);
1026parentSpanId = 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.Client.Core (13)
Internal\InvocationRequest.cs (6)
26public Activity? Activity { get; }
28protected InvocationRequest(CancellationToken cancellationToken, Type resultType, string invocationId, ILogger logger, HubConnection hubConnection, Activity? activity)
48public static InvocationRequest Invoke(CancellationToken cancellationToken, Type resultType, string invocationId, ILoggerFactory loggerFactory, HubConnection hubConnection, Activity? activity, out Task<object?> result)
56ILoggerFactory loggerFactory, HubConnection hubConnection, Activity? activity, out ChannelReader<object?> result)
83public Streaming(CancellationToken cancellationToken, Type resultType, string invocationId, ILoggerFactory loggerFactory, HubConnection hubConnection, Activity? activity)
171public NonStreaming(CancellationToken cancellationToken, Type resultType, string invocationId, ILoggerFactory loggerFactory, HubConnection hubConnection, Activity? activity)
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (26)
Microsoft.AspNetCore.SignalR.Client.Tests (6)
Microsoft.AspNetCore.SignalR.Core (22)
Internal\DefaultHubDispatcher.cs (18)
89Activity? activity = null;
125Activity? activity = null;
399var previousActivity = Activity.Current;
402Activity.Current = null;
407var activity = StartActivity(SignalRServerActivitySource.InvocationIn, ActivityKind.Server, connection.OriginalActivity, scope.ServiceProvider, hubMethodInvocationMessage.Target, hubMethodInvocationMessage.Headers, logger);
428if (Activity.Current != previousActivity)
430Activity.Current = previousActivity;
519var previousActivity = Activity.Current;
522Activity.Current = null;
525var activity = StartActivity(SignalRServerActivitySource.InvocationIn, ActivityKind.Server, connection.OriginalActivity, scope.ServiceProvider, hubMethodInvocationMessage.Target, hubMethodInvocationMessage.Headers, _logger);
592if (Activity.Current != previousActivity)
594Activity.Current = previousActivity;
834private static Activity? StartActivity(string operationName, ActivityKind kind, Activity? linkedActivity, IServiceProvider serviceProvider, string methodName, IDictionary<string, string>? headers, ILogger logger)
859Activity? activity;
894private static void SetActivityError(Activity? activity, Exception ex)
Microsoft.AspNetCore.SignalR.Tests (48)
Microsoft.Extensions.Logging (7)
Microsoft.Extensions.Logging.EventSource (2)
Microsoft.Extensions.Telemetry (7)
Microsoft.Extensions.Telemetry.Tests (12)
MvcFormSample (1)
OrderProcessor (2)
PathSchemeSelection (1)
Seq.ApiService (1)
StaticFilesAuth (1)
Stress.ApiService (25)
TraceCreator.cs (11)
17private readonly List<Activity> _allActivities = new List<Activity>();
19public Activity? CreateActivity(string name, string? spandId)
21var activity = s_activitySource.StartActivity(name, ActivityKind.Client);
27typeof(Activity).GetField("_spanId", BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(activity, spandId);
28typeof(Activity).GetField("_traceId", BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(activity, activity.TraceId.ToString());
37var activityStack = new Stack<Activity>();
47using var activity = s_activitySource.StartActivity(rootName ?? name, ActivityKind.Client);
75using var activity = s_activitySource.StartActivity(ActivityKind.Client, name: name, links: links.DistinctBy(l => l.Context.SpanId));
93private static void AddEvents(Activity activity)
128var a = _allActivities[Random.Shared.Next(0, _allActivities.Count)];
System.Diagnostics.DiagnosticSource (145)
System\Diagnostics\Activity.cs (43)
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; }
65private static readonly AsyncLocal<Activity?> s_current = new AsyncLocal<Activity?>();
79/// Event occur when the <see cref="Activity.Current"/> value changes.
117private Activity? _previousActiveActivity;
138public static Activity? Current
160public Activity SetStatus(ActivityStatusCode code, string? description = null)
203public Activity? Parent { get; private set; }
380for (Activity? activity = this; activity != null; activity = activity.Parent)
390static IEnumerable<KeyValuePair<string, string?>> Iterate(Activity? activity)
476public Activity AddTag(string key, string? value) => AddTag(key, (object?)value);
486public Activity AddTag(string key, object? value)
510public Activity SetTag(string key, object? value)
527public Activity AddEvent(ActivityEvent e)
552public Activity AddException(Exception exception, in TagList tags = default, DateTimeOffset timestamp = default)
615public Activity AddLink(ActivityLink link)
634public Activity AddBaggage(string key, string? value)
658public Activity SetBaggage(string key, string? value)
679public Activity SetParentId(string parentId)
709public Activity SetParentId(ActivityTraceId traceId, ActivitySpanId spanId, ActivityTraceFlags activityTraceFlags = ActivityTraceFlags.None)
739public Activity SetStartTime(DateTime startTimeUtc)
759public Activity SetEndTime(DateTime endTimeUtc)
788/// Use <see cref="DiagnosticSource.StartActivity(Activity, object)"/> to start activity and write start event.
790/// <seealso cref="DiagnosticSource.StartActivity(Activity, object)"/>
792public Activity Start()
844/// Use <see cref="DiagnosticSource.StopActivity(Activity, object)"/> to stop activity and write stop event.
846/// <seealso cref="DiagnosticSource.StopActivity(Activity, object)"/>
889for (Activity? activity = this; activity != null; activity = activity.Parent)
1049public Activity SetIdFormat(ActivityIdFormat format)
1178internal static Activity Create(ActivitySource source, string name, ActivityKind kind, string? parentId, ActivityContext parentContext,
1182Activity activity = new Activity(name);
1261private static void SetCurrent(Activity? activity)
1270Activity? previous = s_current.Value;
1410private static bool ValidateSetCurrent(Activity? activity)
1473/// Indicates whether this <see cref="Activity"/> object is stopped
1476/// 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)
502public 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 (34)
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http1.cs (2)
296(Stream stream, TransportContext? transportContext, Activity? activity, IPEndPoint? remoteEndPoint) = await ConnectAsync(request, async, cancellationToken).ConfigureAwait(false);
300private async ValueTask<HttpConnection> ConstructHttp11ConnectionAsync(bool async, Stream stream, TransportContext? transportContext, HttpRequestMessage request, Activity? activity, IPEndPoint? remoteEndPoint, CancellationToken cancellationToken)
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http2.cs (3)
187(Stream stream, TransportContext? transportContext, Activity? activity, IPEndPoint? remoteEndPoint) = await ConnectAsync(queueItem.Request, true, cts.Token).ConfigureAwait(false);
246private async ValueTask<Http2Connection> ConstructHttp2ConnectionAsync(Stream stream, HttpRequestMessage request, Activity? activity, IPEndPoint? remoteEndPoint, CancellationToken cancellationToken)
289private async Task HandleHttp11Downgrade(HttpRequestMessage request, Stream stream, TransportContext? transportContext, Activity? activity, IPEndPoint? remoteEndPoint, CancellationToken cancellationToken)
System.Net.NameResolution (4)
System.Net.Security (4)
System.Net.Sockets (12)