private Task <TResult> OperationHelperWithRootTraceWithSynchronizationContextAsync <TResult>( string operationName, RequestOptions requestOptions, Func <ITrace, Task <TResult> > task, TraceComponent traceComponent, Tracing.TraceLevel traceLevel) { Debug.Assert(SynchronizationContext.Current != null, "This should only be used when a SynchronizationContext is specified"); string syncContextVirtualAddress = SynchronizationContext.Current.ToString(); // Used on NETFX applications with SynchronizationContext when doing locking calls return(Task.Run(async() => { bool disableDiagnostics = requestOptions != null && requestOptions.DisablePointOperationDiagnostics; using (ITrace trace = disableDiagnostics ? NoOpTrace.Singleton : (ITrace)Tracing.Trace.GetRootTrace(operationName, traceComponent, traceLevel)) { trace.AddDatum("Synchronization Context", syncContextVirtualAddress); return await this.RunWithDiagnosticsHelperAsync( trace, task); } })); }
private async Task <TResult> OperationHelperWithRootTraceAsync <TResult>( string operationName, RequestOptions requestOptions, Func <ITrace, Task <TResult> > task, TraceComponent traceComponent, Tracing.TraceLevel traceLevel) { bool disableDiagnostics = requestOptions != null && requestOptions.DisablePointOperationDiagnostics; using (ITrace trace = disableDiagnostics ? NoOpTrace.Singleton : (ITrace)Tracing.Trace.GetRootTrace(operationName, traceComponent, traceLevel)) { return(await this.RunWithDiagnosticsHelperAsync( trace, task)); } }
internal override Task <TResult> OperationHelperAsync <TResult>( string operationName, RequestOptions requestOptions, Func <ITrace, Task <TResult> > task, TraceComponent traceComponent = TraceComponent.Transport, Tracing.TraceLevel traceLevel = Tracing.TraceLevel.Info) { return(SynchronizationContext.Current == null? this.OperationHelperWithRootTraceAsync(operationName, requestOptions, task, traceComponent, traceLevel) : this.OperationHelperWithRootTraceWithSynchronizationContextAsync(operationName, requestOptions, task, traceComponent, traceLevel)); }
private async Task <TResult> OperationHelperWithRootTraceAsync <TResult>( string operationName, RequestOptions requestOptions, Func <ITrace, Task <TResult> > task, Func <TResult, OpenTelemetryAttributes> openTelemetry, TraceComponent traceComponent, Tracing.TraceLevel traceLevel) { bool disableDiagnostics = requestOptions != null && requestOptions.DisablePointOperationDiagnostics; using (ITrace trace = disableDiagnostics ? NoOpTrace.Singleton : (ITrace)Tracing.Trace.GetRootTrace(operationName, traceComponent, traceLevel)) { trace.AddDatum("Client Configuration", this.client.ClientConfigurationTraceDatum); return(await this.RunWithDiagnosticsHelperAsync( trace, task, openTelemetry, operationName)); } }