From ca95a0dd64b02bafe6b3692fbab965098e9fd44d Mon Sep 17 00:00:00 2001 From: Michael Pysson Date: Fri, 16 Jun 2023 02:35:06 -0700 Subject: [PATCH] Revert "Merged PR 722185: Revert "Merged PR 718998: Revert "Merged PR 717355: Send ETW events on symbol..." This reverts commit f6583652b40b865293d0778f8fe8823956925986. --- Public/Src/Tools/SymbolDaemon/SymbolDaemon.cs | 104 ++++++------------ .../Src/Tools/SymbolDaemon/VsoSymbolClient.cs | 10 +- 2 files changed, 38 insertions(+), 76 deletions(-) diff --git a/Public/Src/Tools/SymbolDaemon/SymbolDaemon.cs b/Public/Src/Tools/SymbolDaemon/SymbolDaemon.cs index 49b2d625e1..952ecddc9c 100644 --- a/Public/Src/Tools/SymbolDaemon/SymbolDaemon.cs +++ b/Public/Src/Tools/SymbolDaemon/SymbolDaemon.cs @@ -15,9 +15,8 @@ using BuildXL.Ipc.ExternalApi; using BuildXL.Ipc.Interfaces; using BuildXL.Storage; -using BuildXL.Tracing.CloudBuild; -using BuildXL.Utilities.CLI; using BuildXL.Utilities.Core; +using BuildXL.Utilities.CLI; using BuildXL.Utilities.Core.Tasks; using Microsoft.VisualStudio.Services.Common; using Microsoft.VisualStudio.Services.Symbol.App.Core.Tracing; @@ -161,7 +160,7 @@ public sealed class SymbolDaemon : ServicePipDaemon.FinalizedByCreatorServicePip IsRequired = false, DefaultValue = true, }); - + internal static readonly StrOption PersonalAccessTokenEnv = RegisterSymbolConfigOption(new StrOption("PersonalAccessTokenEnv") { ShortName = "patenv", @@ -731,11 +730,20 @@ internal static void EnsureCommandsInitialized() /// protected override async Task DoCreateAsync(string name = null) { - var dropCreationEvent = await HandleResultAndSendSymbolEtwEventAsync(InternalCreateAsync()); + // TODO(olkonone): add logging + Request createRequestResult; + + try + { + createRequestResult = await InternalCreateAsync(); + } + catch (Exception e) + { + return new IpcResult(IpcResultStatus.GenericError, e.DemystifyToString()); + } - return dropCreationEvent.Succeeded - ? IpcResult.Success(I($"Symbol request '{RequestName}' created (url: '{dropCreationEvent.DropUrl}').")) - : new IpcResult(IpcResultStatus.GenericError, dropCreationEvent.ErrorMessage); + // get and return RequestId ? + return IpcResult.Success(I($"Symbol request '{RequestName}' created (assigned request ID: '{createRequestResult.Id}').")); } /// @@ -769,11 +777,19 @@ private async Task AddSymbolFileAsync(SymbolFile file) /// protected override async Task DoFinalizeAsync() { - var dropFinalizationEvent = await HandleResultAndSendSymbolEtwEventAsync(InternalFinalizeAsync()); + // TODO(olkonone): add logging + Request finalizeRequestResult; + + try + { + finalizeRequestResult = await InternalFinalizeAsync(); + } + catch (Exception e) + { + return new IpcResult(IpcResultStatus.GenericError, e.DemystifyToString()); + } - return dropFinalizationEvent.Succeeded - ? IpcResult.Success(I($"Symbol request '{RequestName}' finalized.")) - : new IpcResult(IpcResultStatus.GenericError, dropFinalizationEvent.ErrorMessage); + return IpcResult.Success(I($"Symbol request '{RequestName}' finalized; the request expires on '{finalizeRequestResult.ExpirationDate}'.")); } /// @@ -789,27 +805,17 @@ public override void Dispose() base.Dispose(); } - private async Task InternalCreateAsync() + private async Task InternalCreateAsync() { var symbolClient = await m_symbolServiceClientTask; var result = await symbolClient.CreateAsync(); Contract.Assert(result.Status == RequestStatus.Created); - var serializedResult = SymbolRequesToString(result); - m_logger.Info($"CreateAsync completed:{Environment.NewLine}{serializedResult}"); - - return new DropCreationEvent() - { - Succeeded = true, - DropUrl = result.Url.ToString(), - // For Symbols, expiration is set during finalization, so we are using a value we will be assigning later. - DropExpirationInDays = (int)SymbolConfig.Retention.TotalDays, - AdditionalInformation = serializedResult - }; + return result; } - private async Task InternalFinalizeAsync() + private async Task InternalFinalizeAsync() { var symbolClient = await m_symbolServiceClientTask; var result = await symbolClient.FinalizeAsync(); @@ -817,14 +823,7 @@ private async Task InternalFinalizeAsync() Contract.Assert(result.Status == RequestStatus.Sealed); Contract.Assert(result.ExpirationDate.HasValue); - var serializedResult = SymbolRequesToString(result); - m_logger.Info($"FinalizeAsync completed:{Environment.NewLine}{serializedResult}"); - - return new DropFinalizationEvent() - { - Succeeded = true, - DropUrl = result.Url.ToString(), - }; + return result; } private async Task ReportStatisticsAsync() @@ -871,46 +870,5 @@ private async Task ReportStatisticsAsync() m_logger.Warning("No stats recorded by symbol client of type " + symbolClient.GetType().Name); } } - - private async Task HandleResultAndSendSymbolEtwEventAsync(Task task) where T : DropOperationBaseEvent - { - var sw = Stopwatch.StartNew(); - T dropEvent; - try - { - dropEvent = await task; - } - catch (Exception e) - { - dropEvent = Activator.CreateInstance(); - dropEvent.Succeeded = false; - dropEvent.ErrorMessage = e.DemystifyToString(); - // For symbols, url is something that is only defined for successful operations - // (it's based on a requestId which is not available until successful execution of 'symbol create'). - dropEvent.DropUrl = null; - } - - // common properties: execution time, drop type - dropEvent.ElapsedTimeTicks = sw.ElapsedTicks; - dropEvent.DropType = "SymbolIndex"; - - // send event - m_etwLogger.Log(dropEvent); - - return dropEvent; - } - - private static string SymbolRequesToString(Request request) - { - try - { - return request.ToJson(); - } - catch (Exception e) - { - // The value is only used for debugging, so it's not a big deal if we fail to create the string. - return $"Failed to serialized Request. Exception: {e}"; - } - } } } diff --git a/Public/Src/Tools/SymbolDaemon/VsoSymbolClient.cs b/Public/Src/Tools/SymbolDaemon/VsoSymbolClient.cs index 480f9ca9b9..64f4b121da 100644 --- a/Public/Src/Tools/SymbolDaemon/VsoSymbolClient.cs +++ b/Public/Src/Tools/SymbolDaemon/VsoSymbolClient.cs @@ -11,13 +11,17 @@ using BuildXL.Ipc.Common; using BuildXL.Ipc.ExternalApi; using BuildXL.Ipc.Interfaces; -using BuildXL.Utilities.Authentication; using BuildXL.Utilities.Core; -using BuildXL.Utilities.Core.Tasks; +using BuildXL.Utilities.Authentication; +using BuildXL.Utilities.Collections; using BuildXL.Utilities.ParallelAlgorithms; +using BuildXL.Utilities.Core.Tasks; +using BuildXL.Utilities.Tracing; +using Microsoft.IdentityModel.Clients.ActiveDirectory; using Microsoft.VisualStudio.Services.BlobStore.Common; using Microsoft.VisualStudio.Services.Common; using Microsoft.VisualStudio.Services.Content.Common; +using Microsoft.VisualStudio.Services.Content.Common.Authentication; using Microsoft.VisualStudio.Services.Content.Common.Tracing; using Microsoft.VisualStudio.Services.Symbol.App.Core; using Microsoft.VisualStudio.Services.Symbol.App.Core.Telemetry; @@ -467,7 +471,7 @@ public async Task FinalizeAsync(CancellationToken token) var result = await m_symbolClient.FinalizeRequestAsync( RequestId, ComputeExpirationDate(m_config.Retention), - // isUpdateOperation != true => request will be marked as 'Sealed', + // isUpdateOperation == true => request will be marked as 'Sealed', // i.e., no more DebugEntries could be added to it isUpdateOperation: false, token);