public void Dispose() { if (SdkTracingInterceptor != null) { ServiceClientTracing.RemoveTracingInterceptor(SdkTracingInterceptor); } if (TextListener != null) { if (Trace.Listeners.Contains(TextListener)) { Trace.Listeners.Remove(TextListener); } TextListener.Dispose(); } if (TraceStream != null) { TraceStream.Dispose(); } Trace.AutoFlush = PreviousAutoFlush; AdalTrace.TraceSource.Switch.Level = PreviousAdalSourceLevel; AdalTrace.LegacyTraceSwitch.Level = PreviousAdalTraceLevel; }
public static void RemoveTracingInterceptor(ServiceClientTracingInterceptor interceptor) { if (interceptor != null) { ServiceClientTracing.RemoveTracingInterceptor(interceptor); } }
public virtual void RemoveTracer(IServiceTracer tracer) { if (tracer is ClientRuntimeServiceTracer) { ServiceClientTracing.RemoveTracingInterceptor((ClientRuntimeServiceTracer)tracer); } }
/// <summary> /// Operations that happend after the cmdlet is invoked. /// </summary> protected override void EndProcessing() { if (cancellationSource != null) { if (!cancellationSource.IsCancellationRequested) { cancellationSource.Cancel(); } cancellationSource.Dispose(); cancellationSource = null; } ServiceClientTracing.RemoveTracingInterceptor(httpTracingInterceptor); base.EndProcessing(); }
public void CanSetMultipleDelegateHandlers() { using (var context = FluentMockContext.Start(GetType().FullName)) { string rgName = TestUtilities.GenerateName("rg"); string stgName = TestUtilities.GenerateName("stg"); IAzure azure = null; // Sets the interceptor so that logging and user agent in log can be asserted. var logAndUserAgentInterceptor = new LogAndUserAgentInterceptor(); ServiceClientTracing.AddTracingInterceptor(logAndUserAgentInterceptor); ServiceClientTracing.IsEnabled = true; try { AzureCredentials credentials = SdkContext.AzureCredentialsFactory.FromFile(Environment.GetEnvironmentVariable("AZURE_AUTH_LOCATION")); credentials.WithDefaultSubscription(null); // Clearing subscriptionId loaded from the auth // file so that below WithDefaultSubscription() // will force listing subscriptions and fetching // the first. azure = Microsoft.Azure.Management.Fluent.Azure .Configure() .WithUserAgent("azure-fluent-test", "1.0.0-prelease") .WithLogLevel(HttpLoggingDelegatingHandler.Level.BodyAndHeaders) .WithDelegatingHandlers(TestHelper.GetHandlers()) .Authenticate(credentials) .WithDefaultSubscription(); IStorageAccount storageAccount = azure.StorageAccounts .Define(stgName) .WithRegion(Region.USEast) .WithNewResourceGroup(rgName) .Create(); Assert.Equal(storageAccount.ResourceGroupName, rgName); } finally { ServiceClientTracing.RemoveTracingInterceptor(logAndUserAgentInterceptor); ServiceClientTracing.IsEnabled = false; if (azure != null) { azure.ResourceGroups.DeleteByName(rgName); } } Assert.True(logAndUserAgentInterceptor.FoundUserAgentInLog); } }
public override async Task Run() { ServicePointManager.DefaultConnectionLimit = 64; ServicePointManager.MaxServicePointIdleTime = 10000; var tracingInterceptor = _serviceProvider.GetRequiredService <IServiceClientTracingInterceptor>(); try { ServiceClientTracing.IsEnabled = true; ServiceClientTracing.AddTracingInterceptor(tracingInterceptor); await _serviceProvider.GetRequiredService <T>().ExecuteAsync(); } finally { ServiceClientTracing.RemoveTracingInterceptor(tracingInterceptor); } }
public void CaptureAllExamples() { // Note: This should take under two minutes if everything works as expected try { // Delete factory if it exists, before turning on tracing, to give consistent clean state for capture EnsureResourceGroupExists(); EnsureFactoryDoesNotExist(); ServiceClientTracing.IsEnabled = true; // Start Factories operations, leaving factory available CaptureFactories_CreateOrUpdate(); // 200 CaptureFactories_Update(); // 200 CaptureFactories_ConfigureRepo(); // 200 CaptureFactories_Get(); // 200 CaptureFactories_ListByResourceGroup(); // 200 CaptureFactories_List(); CaptureFactories_GetGitHubAccessToken(); // 200, needs real github code in order to return valid access token // All Integration runtime operations, creating/deleting integration runtime CaptureIntegrationRuntimes_Create(); // 200 // Before running this method, please make sure the SQL Database "SSISDB" does *NOT* exist in yandongeverest.database.windows.net by SSMS, // otherwise the operation will fail. The connection string for this server could be found in GetIntegrationRuntimeResource(). // Note this operation is quite time consuming, normally it will take more than 30 minutes to finish the starting process. CaptureIntegrationRuntimes_Start(); // 200, 202 CaptureIntegrationRuntimes_Stop(); // 200, 202 CaptureIntegrationRuntimes_Update(); // 200 CaptureIntegrationRuntimes_Get(); // 200 CaptureIntegrationRuntimes_ListByFactory(); // 200 CaptureIntegrationRuntimes_GetConnectionInfo(); // 200 CaptureIntegrationRuntimes_ListAuthKeys(); // 200 CaptureIntegrationRuntimes_RegenerateAuthKey(); // 200 CaptureIntegrationRuntimes_GetStatus(); // 200 CaptureIntegrationRuntimes_Upgrade(); // The following 3 methods invovling a mannual step as prerequisites. We need to install an integration runtime node and register it. // After the integration runtime node is online, we can run methods. CaptureIntegrationRuntimeNodes_GetIpAddress(); CaptureIntegrationRuntimeNodes_Update(); // 200 CaptureIntegrationRuntimeNodes_Delete(); // 200 CaptureIntegrationRuntimeNodes_Delete(); // 204 // Start LinkedServices operations, leaving linked service available CaptureLinkedServices_Create(); // 200 CaptureLinkedServices_Update(); // 200 CaptureLinkedServices_Get(); // 200 CaptureLinkedServices_ListByFactory(); // 200 // Start Datasets operations, leaving dataset available CaptureDatasets_Create(); // 200 CaptureDatasets_Update(); // 200 CaptureDatasets_Get(); // 200 CaptureDatasets_ListByFactory(); // 200 // All Pipelines and PipelineRuns operations, creating/running/monitoring/deleting pipeline CapturePipelines_Create(); // 200 CapturePipelines_Update(); // 200 CapturePipelines_Get(); // 200 CapturePipelines_ListByFactory(); // 200 DateTime beforeStartTime = DateTime.UtcNow.AddMinutes(-1); // allow 1 minute for clock skew string runId = CapturePipelines_CreateRun(); // 200 System.Threading.Thread.Sleep(TimeSpan.FromSeconds(120)); // Prefer to get succeeded monitoring result on first attempt even if it slows capture DateTime afterEndTime = DateTime.UtcNow.AddMinutes(10); // allow 10 minutes for run time, monitoring latency, and clock skew CapturePipelineRuns_Cancel(); CapturePipelineRuns_QueryByFactory(runId, beforeStartTime, afterEndTime); // 200, waits until succeeded so ready to get logs CapturePipelineRuns_Get(runId); // 200 CaptureActivityRuns_QueryByPipelineRun(runId, beforeStartTime, afterEndTime); // 200 // Start Trigger operations, leaving triggers available CaptureTriggers_Create(); // 200 CaptureTriggers_Update(); // 200 CaptureTriggers_Get(); // 200 CaptureTriggers_Start(); // 202 CaptureTriggers_ListByFactory(); // 200 CaptureTriggerRuns_QueryByFactory(beforeStartTime, afterEndTime); // 200 CaptureTriggers_Stop(); // 202 // Finish Triggers operations, deleting triggers CaptureTriggers_Delete(); // 200 CaptureTriggers_Delete(); // 204 CapturePipelines_Delete(); // 200 CapturePipelines_Delete(); // 204 // Finish Datasets operations, deleting dataset CaptureDatasets_Delete(); // 200 CaptureDatasets_Delete(); // 204 // Finish LinkedServices operations, deleting linked service CaptureLinkedServices_Delete(); // 200 CaptureLinkedServices_Delete(); // 204 // Finish integration runtime operations, deleting integration runtime CaptureIntegrationRuntimes_Delete(); // 202 CaptureIntegrationRuntimes_Delete(); // 204 // Finish Factories operations, deleting factory CaptureFactories_Delete(); // 200 CaptureFactories_Delete(); // 204 CaptureOperations_List(); // 200 } catch (Exception e) { Console.WriteLine(e.Message); } finally { ServiceClientTracing.IsEnabled = false; ServiceClientTracing.RemoveTracingInterceptor(this.interceptor); // Merge and write all captured examples, whether or not the entire run was successful List <Example> examples = ExampleHelpers.GetMergedExamples(interceptor); ExampleHelpers.FixExampleModelParameters(examples, client); ExampleHelpers.WriteExamples(examples, outputFolder, secrets); if (outputFolderWorkarounds != null) { ExampleHelpers.ApplyTemporaryWorkaroundsForServiceDefects(examples, client); ExampleHelpers.WriteExamples(examples, outputFolderWorkarounds, secrets); } } }