22 writes to Current
Microsoft.AspNetCore.SignalR.Core (4)
Internal\DefaultHubDispatcher.cs (4)
402Activity.Current = null; 430Activity.Current = previousActivity; 522Activity.Current = null; 594Activity.Current = previousActivity;
Microsoft.AspNetCore.SignalR.Tests (8)
HubConnectionHandlerTests.Activity.cs (8)
46Activity.Current = mockHttpRequestActivity; 121Activity.Current = mockHttpRequestActivity; 190Activity.Current = mockHttpRequestActivity; 249Activity.Current = mockHttpRequestActivity; 322Activity.Current = mockHttpRequestActivity; 369Activity.Current = mockHttpRequestActivity; 421Activity.Current = mockHttpRequestActivity; 472Activity.Current = mockHttpRequestActivity;
Microsoft.Extensions.AI (3)
ChatCompletion\FunctionInvokingChatClient.cs (2)
302Activity.Current = activity; // workaround for https://github.com/dotnet/runtime/issues/47802 342Activity.Current = activity; // workaround for https://github.com/dotnet/runtime/issues/47802
ChatCompletion\OpenTelemetryChatClient.cs (1)
203Activity.Current = activity; // workaround for https://github.com/dotnet/runtime/issues/47802
Stress.ApiService (4)
Program.cs (4)
91Activity.Current = null; 105Activity.Current = current; 276Activity.Current = null; 283Activity.Current = current;
System.Net.Http (1)
System\Net\Http\SocketsHttpHandler\ConnectionPool\ConnectionSetupDistributedTracing.cs (1)
22Activity.Current = null;
System.Net.NameResolution (1)
System\Net\Dns.cs (1)
733Activity.Current = activityToRestore;
System.Net.Sockets (1)
System\Net\Sockets\SocketsTelemetry.cs (1)
101Activity.Current = activityToReset;
131 references to Current
Aspire.Dashboard (1)
Components\Pages\Error.razor.cs (1)
18RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
Aspire.Microsoft.Data.SqlClient (2)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Implementation\SqlClientDiagnosticListener.cs (1)
49var activity = Activity.Current;
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceListener.cs (1)
35if (!this.handler.SupportsNullActivity && Activity.Current == null)
Aspire.Microsoft.EntityFrameworkCore.SqlServer (2)
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Implementation\SqlClientDiagnosticListener.cs (1)
49var activity = Activity.Current;
src\Vendoring\OpenTelemetry.Instrumentation.SqlClient\Shared\DiagnosticSourceInstrumentation\DiagnosticSourceListener.cs (1)
35if (!this.handler.SupportsNullActivity && Activity.Current == null)
Aspire.StackExchange.Redis (1)
src\Vendoring\OpenTelemetry.Instrumentation.StackExchangeRedis\StackExchangeRedisConnectionInstrumentation.cs (1)
77var parent = Activity.Current;
ClaimsTransformation (1)
Controllers\HomeController.cs (1)
26return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
Cookies (1)
Controllers\HomeController.cs (1)
26return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
DynamicSchemes (1)
Pages\Error.cshtml.cs (1)
21RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
HostedBlazorWebassemblyApp.Server (1)
Pages\Error.cshtml.cs (1)
32RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
Identity.DefaultUI.WebSite (1)
Pages\Error.cshtml.cs (1)
19RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
Identity.ExternalClaims (1)
Pages\Error.cshtml.cs (1)
21RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
Microsoft.AspNetCore.Hosting.Tests (50)
HostingApplicationDiagnosticsTests.cs (46)
205measurementActivity = Activity.Current; 491Assert.Null(Activity.Current); 531Assert.Null(Activity.Current); 562Assert.Null(Activity.Current); 599Assert.NotNull(Activity.Current); 619Assert.NotNull(Activity.Current); 620Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 626Assert.NotNull(Activity.Current); 643Assert.NotNull(Activity.Current); 644Assert.True(Activity.Current.Duration > TimeSpan.Zero); 645Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 667Assert.NotNull(Activity.Current); 668Assert.True(Activity.Current.Duration > TimeSpan.Zero); 669Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 691Assert.NotNull(Activity.Current); 692Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 719Assert.NotNull(Activity.Current); 720Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 748Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 749Assert.Equal("ParentId1", Activity.Current.ParentId); 750Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1"); 751Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); 778Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 779Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1"); 780Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); 808Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 809Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1"); 810Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); 839Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 840Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value3"); 841Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value4"); 869Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 878Assert.Equal(expectedBaggage, Activity.Current.Baggage.ToArray()); 906Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 907Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1/1"); 936Assert.Equal("Microsoft.AspNetCore.Hosting.HttpRequestIn", Activity.Current.OperationName); 937Assert.Equal(ActivityIdFormat.W3C, Activity.Current.IdFormat); 938Assert.Equal("0123456789abcdef0123456789abcdef", Activity.Current.TraceId.ToHexString()); 939Assert.Equal("0123456789abcdef", Activity.Current.ParentSpanId.ToHexString()); 940Assert.Equal("TraceState1", Activity.Current.TraceStateString); 942Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key1" && pair.Value == "value1"); 943Assert.Contains(Activity.Current.Baggage, pair => pair.Key == "Key2" && pair.Value == "value2"); 1003Assert.Null(Activity.Current); 1014Assert.NotNull(Activity.Current); 1015Assert.True(Activity.Current.Recorded); 1030parentSpanId = Activity.Current.ParentSpanId.ToHexString();
HostingApplicationTests.cs (4)
113var initialActivity = Activity.Current; 118Assert.Equal(Activity.Current, dummyActivity); 122Assert.Equal(activityFeature.Activity.Id, Activity.Current.ParentId); 123Assert.NotEqual(Activity.Current, activityFeature.Activity);
Microsoft.AspNetCore.Http.Connections.Tests (1)
HttpConnectionDispatcherTests.cs (1)
3129Assert.Equal("true", Activity.Current.GetTagItem("http.long_running"));
Microsoft.AspNetCore.Http.Extensions (1)
DefaultProblemDetailsWriter.cs (1)
58var traceId = Activity.Current?.Id ?? httpContext.TraceIdentifier;
Microsoft.AspNetCore.Http.Extensions.Tests (15)
ProblemDetailsDefaultWriterTest.cs (15)
29var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 66var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 98var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 132var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 174var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 214var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 251var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 294var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 337var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 380var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 423var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 464var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 511var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 552var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier; 718var expectedTraceId = Activity.Current?.Id ?? context.TraceIdentifier;
Microsoft.AspNetCore.Identity.UI (2)
Areas\Identity\Pages\V4\Error.cshtml.cs (1)
37RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
Areas\Identity\Pages\V5\Error.cshtml.cs (1)
37RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
Microsoft.AspNetCore.Mvc.Core (1)
Infrastructure\DefaultProblemDetailsFactory.cs (1)
105var traceId = Activity.Current?.Id ?? httpContext?.TraceIdentifier;
Microsoft.AspNetCore.Mvc.Core.Test (2)
DependencyInjection\ApiBehaviorOptionsSetupTest.cs (1)
110Assert.Equal(Activity.Current.Id, problemDetails.Extensions["traceId"]);
Infrastructure\ProblemDetalsClientErrorFactoryTest.cs (1)
91Assert.Equal(Activity.Current.Id, problemDetails.Extensions["traceId"]);
Microsoft.AspNetCore.Mvc.Core.TestCommon (1)
ActivityReplacer.cs (1)
20Debug.Assert(Activity.Current == _activity);
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
XmlSerializerFormattersWrappingTest.cs (1)
211$"<traceId>{Activity.Current.Id}</traceId>" +
Microsoft.AspNetCore.SignalR.Client.Core (1)
HubConnection.cs (1)
1111if (activity is null && Activity.Current is not null && _logger.IsEnabled(LogLevel.Critical))
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (4)
HubConnectionTests.Tracing.cs (4)
86Assert.Equal(clientParentActivity1, Activity.Current); 108Assert.Equal(clientParentActivity2, Activity.Current); 280Assert.Equal(clientParentActivity, Activity.Current); 704Assert.Null(Activity.Current);
Microsoft.AspNetCore.SignalR.Core (5)
HubConnectionHandler.cs (1)
136OriginalActivity = Activity.Current,
Internal\DefaultHubDispatcher.cs (4)
399var previousActivity = Activity.Current; 428if (Activity.Current != previousActivity) 519var previousActivity = Activity.Current; 592if (Activity.Current != previousActivity)
Microsoft.Build.Engine.UnitTests (1)
BackEnd\OpenTelemetryActivities_Tests.cs (1)
187if (Activity.Current?.HasRemoteParent == true)
Microsoft.Build.Framework (2)
Telemetry\MSBuildActivitySource.cs (2)
28var activity = Activity.Current?.HasRemoteParent == true 29? _source.StartActivity($"{TelemetryConstants.EventPrefix}{name}", ActivityKind.Internal, parentId: Activity.Current.ParentId)
Microsoft.Extensions.Logging (1)
LoggerFactoryScopeProvider.cs (1)
37Activity? activity = Activity.Current;
Microsoft.Extensions.Logging.EventSource (1)
EventSourceLogger.cs (1)
75Activity? activity = Activity.Current;
Microsoft.Extensions.Telemetry (2)
Logging\Import\LoggerFactoryScopeProvider.cs (1)
56Activity? activity = Activity.Current;
Sampling\TraceBasedSampler.cs (1)
13Activity.Current?.Recorded ?? true;
Microsoft.Extensions.Telemetry.Tests (1)
Logging\ExtendedLoggerFactoryTests.cs (1)
128Activity activity = Activity.Current!;
MvcFormSample (1)
Controllers\HomeController.cs (1)
48return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
OrderProcessor (2)
OrderProcessingWorker.cs (2)
68Activity.Current?.AddTag("order-id", order.Id); 69Activity.Current?.AddTag("product-count", order.Items.Count);
PathSchemeSelection (1)
Controllers\HomeController.cs (1)
26return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
StaticFilesAuth (1)
Controllers\HomeController.cs (1)
24return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
Stress.ApiService (2)
Program.cs (2)
90var current = Activity.Current; 275var current = Activity.Current;
System.Diagnostics.DiagnosticSource (14)
System\Diagnostics\Activity.cs (6)
18/// Carries the <see cref="Activity.Current"/> changed event data. 79/// Event occur when the <see cref="Activity.Current"/> value changes. 783/// <item>Sets <see cref="Parent"/> to hold <see cref="Current"/>.</item> 784/// <item>Sets <see cref="Current"/> to this activity.</item> 801_previousActiveActivity = Current; 842/// Stops activity: sets <see cref="Current"/> to <see cref="Parent"/>.
System\Diagnostics\ActivityCreationOptions.cs (2)
80IdFormat = Activity.Current != null ? Activity.Current.IdFormat : Activity.DefaultIdFormat;
System\Diagnostics\ActivitySource.cs (2)
302bool useCurrentActivityContext = context == default && Activity.Current != null; 303var aco = new ActivityCreationOptions<ActivityContext>(this, name, useCurrentActivityContext ? Activity.Current!.Context : context, kind, tags, links, idFormat);
System\Diagnostics\DiagnosticSourceActivity.cs (2)
19/// was started. Consumers could access <see cref="Activity.Current"/> 44/// that Activity was stopped. Consumers could access <see cref="Activity.Current"/>
System\Diagnostics\DsesFilterAndTransform.cs (1)
929return Activity.Current;
System\Diagnostics\PassThroughPropagator.cs (1)
46Activity? activity = Activity.Current;
System.Net.Http (4)
System\Net\Http\DiagnosticsHandler.cs (2)
51return Activity.Current != null || 65(Activity.Current is not null ||
System\Net\Http\SocketsHttpHandler\ConnectionPool\ConnectionSetupDistributedTracing.cs (1)
90Activity? requestActivity = Activity.Current;
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionWaiter.cs (1)
22return HttpTelemetry.Log.IsEnabled() || pool.Settings._metrics!.RequestsQueueDuration.Enabled || Activity.Current?.Source == DiagnosticsHandler.s_activitySource
System.Net.NameResolution (1)
System\Net\Dns.cs (1)
728Activity? activityToRestore = tracingEnabled ? Activity.Current : null;
System.Net.Sockets (1)
System\Net\Sockets\SocketsTelemetry.cs (1)
96Activity? activityToReset = keepActivityCurrent ? Activity.Current : null;