1515using BuildXL . Ipc . ExternalApi ;
1616using BuildXL . Ipc . Interfaces ;
1717using BuildXL . Storage ;
18- using BuildXL . Tracing . CloudBuild ;
19- using BuildXL . Utilities . CLI ;
2018using BuildXL . Utilities . Core ;
19+ using BuildXL . Utilities . CLI ;
2120using BuildXL . Utilities . Core . Tasks ;
2221using Microsoft . VisualStudio . Services . Common ;
2322using Microsoft . VisualStudio . Services . Symbol . App . Core . Tracing ;
@@ -161,7 +160,7 @@ public sealed class SymbolDaemon : ServicePipDaemon.FinalizedByCreatorServicePip
161160 IsRequired = false ,
162161 DefaultValue = true ,
163162 } ) ;
164-
163+
165164 internal static readonly StrOption PersonalAccessTokenEnv = RegisterSymbolConfigOption ( new StrOption ( "PersonalAccessTokenEnv" )
166165 {
167166 ShortName = "patenv" ,
@@ -731,11 +730,20 @@ internal static void EnsureCommandsInitialized()
731730 /// </summary>
732731 protected override async Task < IIpcResult > DoCreateAsync ( string name = null )
733732 {
734- var dropCreationEvent = await HandleResultAndSendSymbolEtwEventAsync ( InternalCreateAsync ( ) ) ;
733+ // TODO(olkonone): add logging
734+ Request createRequestResult ;
735+
736+ try
737+ {
738+ createRequestResult = await InternalCreateAsync ( ) ;
739+ }
740+ catch ( Exception e )
741+ {
742+ return new IpcResult ( IpcResultStatus . GenericError , e . DemystifyToString ( ) ) ;
743+ }
735744
736- return dropCreationEvent . Succeeded
737- ? IpcResult . Success ( I ( $ "Symbol request '{ RequestName } ' created (url: '{ dropCreationEvent . DropUrl } ').") )
738- : new IpcResult ( IpcResultStatus . GenericError , dropCreationEvent . ErrorMessage ) ;
745+ // get and return RequestId ?
746+ return IpcResult . Success ( I ( $ "Symbol request '{ RequestName } ' created (assigned request ID: '{ createRequestResult . Id } ').") ) ;
739747 }
740748
741749 /// <summary>
@@ -769,11 +777,19 @@ private async Task<IIpcResult> AddSymbolFileAsync(SymbolFile file)
769777 /// </summary>
770778 protected override async Task < IIpcResult > DoFinalizeAsync ( )
771779 {
772- var dropFinalizationEvent = await HandleResultAndSendSymbolEtwEventAsync ( InternalFinalizeAsync ( ) ) ;
780+ // TODO(olkonone): add logging
781+ Request finalizeRequestResult ;
782+
783+ try
784+ {
785+ finalizeRequestResult = await InternalFinalizeAsync ( ) ;
786+ }
787+ catch ( Exception e )
788+ {
789+ return new IpcResult ( IpcResultStatus . GenericError , e . DemystifyToString ( ) ) ;
790+ }
773791
774- return dropFinalizationEvent . Succeeded
775- ? IpcResult . Success ( I ( $ "Symbol request '{ RequestName } ' finalized.") )
776- : new IpcResult ( IpcResultStatus . GenericError , dropFinalizationEvent . ErrorMessage ) ;
792+ return IpcResult . Success ( I ( $ "Symbol request '{ RequestName } ' finalized; the request expires on '{ finalizeRequestResult . ExpirationDate } '.") ) ;
777793 }
778794
779795 /// <nodoc />
@@ -789,42 +805,25 @@ public override void Dispose()
789805 base . Dispose ( ) ;
790806 }
791807
792- private async Task < DropCreationEvent > InternalCreateAsync ( )
808+ private async Task < Request > InternalCreateAsync ( )
793809 {
794810 var symbolClient = await m_symbolServiceClientTask ;
795811 var result = await symbolClient . CreateAsync ( ) ;
796812
797813 Contract . Assert ( result . Status == RequestStatus . Created ) ;
798814
799- var serializedResult = SymbolRequesToString ( result ) ;
800- m_logger . Info ( $ "CreateAsync completed:{ Environment . NewLine } { serializedResult } ") ;
801-
802- return new DropCreationEvent ( )
803- {
804- Succeeded = true ,
805- DropUrl = result . Url . ToString ( ) ,
806- // For Symbols, expiration is set during finalization, so we are using a value we will be assigning later.
807- DropExpirationInDays = ( int ) SymbolConfig . Retention . TotalDays ,
808- AdditionalInformation = serializedResult
809- } ;
815+ return result ;
810816 }
811817
812- private async Task < DropFinalizationEvent > InternalFinalizeAsync ( )
818+ private async Task < Request > InternalFinalizeAsync ( )
813819 {
814820 var symbolClient = await m_symbolServiceClientTask ;
815821 var result = await symbolClient . FinalizeAsync ( ) ;
816822
817823 Contract . Assert ( result . Status == RequestStatus . Sealed ) ;
818824 Contract . Assert ( result . ExpirationDate . HasValue ) ;
819825
820- var serializedResult = SymbolRequesToString ( result ) ;
821- m_logger . Info ( $ "FinalizeAsync completed:{ Environment . NewLine } { serializedResult } ") ;
822-
823- return new DropFinalizationEvent ( )
824- {
825- Succeeded = true ,
826- DropUrl = result . Url . ToString ( ) ,
827- } ;
826+ return result ;
828827 }
829828
830829 private async Task ReportStatisticsAsync ( )
@@ -871,46 +870,5 @@ private async Task ReportStatisticsAsync()
871870 m_logger . Warning ( "No stats recorded by symbol client of type " + symbolClient . GetType ( ) . Name ) ;
872871 }
873872 }
874-
875- private async Task < T > HandleResultAndSendSymbolEtwEventAsync < T > ( Task < T > task ) where T : DropOperationBaseEvent
876- {
877- var sw = Stopwatch . StartNew ( ) ;
878- T dropEvent ;
879- try
880- {
881- dropEvent = await task ;
882- }
883- catch ( Exception e )
884- {
885- dropEvent = Activator . CreateInstance < T > ( ) ;
886- dropEvent . Succeeded = false ;
887- dropEvent . ErrorMessage = e . DemystifyToString ( ) ;
888- // For symbols, url is something that is only defined for successful operations
889- // (it's based on a requestId which is not available until successful execution of 'symbol create').
890- dropEvent . DropUrl = null ;
891- }
892-
893- // common properties: execution time, drop type
894- dropEvent . ElapsedTimeTicks = sw . ElapsedTicks ;
895- dropEvent . DropType = "SymbolIndex" ;
896-
897- // send event
898- m_etwLogger . Log ( dropEvent ) ;
899-
900- return dropEvent ;
901- }
902-
903- private static string SymbolRequesToString ( Request request )
904- {
905- try
906- {
907- return request . ToJson ( ) ;
908- }
909- catch ( Exception e )
910- {
911- // The value is only used for debugging, so it's not a big deal if we fail to create the string.
912- return $ "Failed to serialized Request. Exception: { e } ";
913- }
914- }
915873 }
916874}
0 commit comments