@@ -11,7 +11,8 @@ namespace Microsoft.Azure.Cosmos.Tracing
1111 using System . Net . Http ;
1212 using System . Text ;
1313 using Microsoft . Azure . Cosmos . Json ;
14- using Microsoft . Azure . Cosmos . Tracing . TraceData ;
14+ using Microsoft . Azure . Cosmos . Tracing . TraceData ;
15+ using Microsoft . Azure . Cosmos . Util ;
1516 using Microsoft . Azure . Documents ;
1617
1718 internal static partial class TraceWriter
@@ -394,7 +395,7 @@ public void Visit(StoreResult storeResult)
394395 this . jsonWriter . WriteStringValue ( storeResult . StatusCode . ToString ( ) ) ;
395396
396397 this . jsonWriter . WriteFieldName ( nameof ( storeResult . SubStatusCode ) ) ;
397- this . jsonWriter . WriteStringValue ( this . GetSubStatusCodeString ( storeResult . StatusCode , storeResult . SubStatusCode ) ) ;
398+ this . jsonWriter . WriteStringValue ( SubStatusMappingUtil . GetSubStatusCodeString ( storeResult . StatusCode , storeResult . SubStatusCode ) ) ;
398399
399400 this . jsonWriter . WriteFieldName ( nameof ( storeResult . LSN ) ) ;
400401 this . jsonWriter . WriteNumberValue ( storeResult . LSN ) ;
@@ -452,116 +453,6 @@ public void Visit(StoreResult storeResult)
452453 this . jsonWriter . WriteObjectEnd ( ) ;
453454 }
454455
455- internal string GetSubStatusCodeString ( StatusCodes statusCode , SubStatusCodes subStatusCode )
456- {
457- if ( ( int ) subStatusCode == 1002 )
458- {
459- return statusCode == StatusCodes . NotFound
460- ? "ReadSessionNotAvailable"
461- : SubStatusCodes . PartitionKeyRangeGone . ToString ( ) ;
462- }
463-
464- if ( ( int ) subStatusCode == 2001 )
465- {
466- return statusCode == StatusCodes . NoContent
467- ? "MissedTargetLsn"
468- : SubStatusCodes . SplitIsDisabled . ToString ( ) ;
469- }
470-
471- if ( ( int ) subStatusCode == 2002 )
472- {
473- return statusCode == StatusCodes . NoContent
474- ? "MissedTargetLsnOver100"
475- : SubStatusCodes . CollectionsInPartitionGotUpdated . ToString ( ) ;
476- }
477-
478- if ( ( int ) subStatusCode == 2003 )
479- {
480- return statusCode == StatusCodes . NoContent
481- ? "MissedTargetLsnOver1000"
482- : SubStatusCodes . CanNotAcquirePKRangesLock . ToString ( ) ;
483- }
484-
485- if ( ( int ) subStatusCode == 2004 )
486- {
487- return statusCode == StatusCodes . NoContent
488- ? "MissedTargetLsnOver10000"
489- : SubStatusCodes . ResourceNotFound . ToString ( ) ;
490- }
491-
492- if ( ( int ) subStatusCode == 2011 )
493- {
494- return statusCode == StatusCodes . NoContent
495- ? "MissedTargetGlobalCommittedLsn"
496- : SubStatusCodes . StorageSplitConflictingWithNWayThroughputSplit . ToString ( ) ;
497- }
498-
499- if ( ( int ) subStatusCode == 2012 )
500- {
501- return statusCode == StatusCodes . NoContent
502- ? "MissedTargetGlobalCommittedLsnOver100"
503- : SubStatusCodes . MergeIsDisabled . ToString ( ) ;
504- }
505-
506- if ( ( int ) subStatusCode == 1004 )
507- {
508- return statusCode == StatusCodes . BadRequest
509- ? "CrossPartitionQueryNotServable"
510- : SubStatusCodes . ConfigurationNameNotFound . ToString ( ) ;
511- }
512-
513- if ( ( int ) subStatusCode == 1007 )
514- {
515- return statusCode == StatusCodes . Gone
516- ? "CompletingSplit"
517- : SubStatusCodes . InsufficientBindablePartitions . ToString ( ) ;
518- }
519-
520- if ( ( int ) subStatusCode == 1008 )
521- {
522- return statusCode == StatusCodes . Gone
523- ? "CompletingPartitionMigration"
524- : SubStatusCodes . DatabaseAccountNotFound . ToString ( ) ;
525- }
526-
527- if ( ( int ) subStatusCode == 1005 )
528- {
529- return statusCode == StatusCodes . NotFound
530- ? "ConfigurationPropertyNotFound"
531- : SubStatusCodes . ProvisionLimitReached . ToString ( ) ;
532- }
533-
534- if ( ( int ) subStatusCode == 3207 )
535- {
536- return statusCode == StatusCodes . Conflict
537- ? "ConfigurationNameAlreadyExists"
538- : SubStatusCodes . PrepareTimeLimitExceeded . ToString ( ) ;
539- }
540-
541- if ( ( int ) subStatusCode == 6001 )
542- {
543- return statusCode == StatusCodes . ServiceUnavailable
544- ? "AggregatedHealthStateError"
545- : SubStatusCodes . PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringCompleteMigrationFromBackend . ToString ( ) ;
546- }
547-
548- if ( ( int ) subStatusCode == 6002 )
549- {
550- return statusCode == StatusCodes . ServiceUnavailable
551- ? "ApplicationHealthStateError"
552- : SubStatusCodes . PartitionMigrationWaitForFullSyncReceivedInternalServerErrorDuringAbortMigrationFromBackend . ToString ( ) ;
553- }
554-
555- if ( ( int ) subStatusCode == 6003 )
556- {
557- return statusCode == StatusCodes . ServiceUnavailable
558- ? "HealthStateError"
559- : SubStatusCodes . PartitionMigrationFinalizeMigrationsDidNotCompleteInTenRetries . ToString ( ) ;
560- }
561-
562- return subStatusCode . ToString ( ) ;
563- }
564-
565456 public void Visit ( PartitionKeyRangeCacheTraceDatum partitionKeyRangeCacheTraceDatum )
566457 {
567458 this . jsonWriter . WriteObjectStart ( ) ;
0 commit comments