@@ -129,6 +129,8 @@ public final class RegistryClient: Cancellable {
129
129
return completion ( . failure( RegistryError . registryNotConfigured ( scope: registryIdentity. scope) ) )
130
130
}
131
131
132
+ observabilityScope. emit ( debug: " registry for \( package ) : \( registry) " )
133
+
132
134
let underlying = {
133
135
self . _getPackageMetadata (
134
136
registry: registry,
@@ -184,9 +186,15 @@ public final class RegistryClient: Cancellable {
184
186
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
185
187
)
186
188
189
+ let start = DispatchTime . now ( )
190
+ observabilityScope. emit ( info: " retrieving \( package ) metadata from \( request. url) " )
187
191
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
188
192
completion (
189
193
result. tryMap { response in
194
+ observabilityScope
195
+ . emit (
196
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
197
+ )
190
198
switch response. statusCode {
191
199
case 200 :
192
200
let packageMetadata = try response. parseJSON (
@@ -358,9 +366,15 @@ public final class RegistryClient: Cancellable {
358
366
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
359
367
)
360
368
369
+ let start = DispatchTime . now ( )
370
+ observabilityScope. emit ( info: " retrieving \( package ) \( version) metadata from \( request. url) " )
361
371
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
362
372
completion (
363
373
result. tryMap { response in
374
+ observabilityScope
375
+ . emit (
376
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
377
+ )
364
378
switch response. statusCode {
365
379
case 200 :
366
380
let metadata = try response. parseJSON (
@@ -467,9 +481,15 @@ public final class RegistryClient: Cancellable {
467
481
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
468
482
)
469
483
484
+ let start = DispatchTime . now ( )
485
+ observabilityScope. emit ( info: " retrieving available manifests for \( package ) \( version) from \( request. url) " )
470
486
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
471
487
completion (
472
488
result. tryMap { response in
489
+ observabilityScope
490
+ . emit (
491
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
492
+ )
473
493
switch response. statusCode {
474
494
case 200 :
475
495
try response. validateAPIVersion ( )
@@ -601,9 +621,15 @@ public final class RegistryClient: Cancellable {
601
621
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
602
622
)
603
623
624
+ let start = DispatchTime . now ( )
625
+ observabilityScope. emit ( info: " retrieving \( package ) \( version) manifest from \( request. url) " )
604
626
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
605
627
completion (
606
628
result. tryMap { response -> String in
629
+ observabilityScope
630
+ . emit (
631
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
632
+ )
607
633
switch response. statusCode {
608
634
case 200 :
609
635
try response. validateAPIVersion ( isOptional: true )
@@ -768,11 +794,17 @@ public final class RegistryClient: Cancellable {
768
794
destination: downloadPath
769
795
)
770
796
797
+ let downloadStart = DispatchTime . now ( )
798
+ observabilityScope. emit ( info: " downloading \( package ) \( version) source archive from \( request. url) " )
771
799
self . httpClient
772
800
. execute ( request, observabilityScope: observabilityScope, progress: progressHandler) { result in
773
801
switch result {
774
802
case . success( let response) :
775
803
do {
804
+ observabilityScope
805
+ . emit (
806
+ debug: " server response for \( request. url) : \( response. statusCode) in \( downloadStart. distance ( to: . now( ) ) . descriptionInSeconds) "
807
+ )
776
808
switch response. statusCode {
777
809
case 200 :
778
810
try response. validateAPIVersion ( isOptional: true )
@@ -784,6 +816,10 @@ public final class RegistryClient: Cancellable {
784
816
let actualChecksum = checksumAlgorithm. hash ( . init( archiveContent) )
785
817
. hexadecimalRepresentation
786
818
819
+ observabilityScope
820
+ . emit (
821
+ debug: " performing TOFU checks on \( package ) \( version) source archive (checksum: ' \( actualChecksum) ' "
822
+ )
787
823
signatureValidation. validate (
788
824
registry: registry,
789
825
package : package ,
@@ -821,6 +857,11 @@ public final class RegistryClient: Cancellable {
821
857
recursive: true
822
858
)
823
859
// extract the content
860
+ let extractStart = DispatchTime . now ( )
861
+ observabilityScope
862
+ . emit (
863
+ debug: " extracting \( package ) \( version) source archive to ' \( destinationPath) ' "
864
+ )
824
865
let archiver = self . archiverProvider ( fileSystem)
825
866
// TODO: Bail if archive contains relative paths or overlapping files
826
867
archiver
@@ -831,6 +872,10 @@ public final class RegistryClient: Cancellable {
831
872
defer {
832
873
try ? fileSystem. removeFileTree ( downloadPath)
833
874
}
875
+ observabilityScope
876
+ . emit (
877
+ debug: " extracted \( package ) \( version) source archive to ' \( destinationPath) ' in \( extractStart. distance ( to: . now( ) ) . descriptionInSeconds) "
878
+ )
834
879
completion ( result. tryMap {
835
880
// strip first level component
836
881
try fileSystem
@@ -841,6 +886,10 @@ public final class RegistryClient: Cancellable {
841
886
component: RegistryReleaseMetadataStorage
842
887
. fileName
843
888
)
889
+ observabilityScope
890
+ . emit (
891
+ debug: " saving \( package ) \( version) metadata to ' \( registryMetadataPath) ' "
892
+ )
844
893
try RegistryReleaseMetadataStorage . save (
845
894
metadata: versionMetadata,
846
895
signingEntity: signingEntity,
@@ -976,15 +1025,22 @@ public final class RegistryClient: Cancellable {
976
1025
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
977
1026
)
978
1027
1028
+ let start = DispatchTime . now ( )
1029
+ observabilityScope. emit ( info: " looking up identity for \( scmURL) from \( request. url) " )
979
1030
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
980
1031
completion (
981
1032
result. tryMap { response in
1033
+ observabilityScope
1034
+ . emit (
1035
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1036
+ )
982
1037
switch response. statusCode {
983
1038
case 200 :
984
1039
let packageIdentities = try response. parseJSON (
985
1040
Serialization . PackageIdentifiers. self,
986
1041
decoder: self . jsonDecoder
987
1042
)
1043
+ observabilityScope. emit ( debug: " matched identities for \( scmURL) : \( packageIdentities) " )
988
1044
return Set ( packageIdentities. identifiers. map {
989
1045
PackageIdentity . plain ( $0)
990
1046
} )
@@ -1016,9 +1072,15 @@ public final class RegistryClient: Cancellable {
1016
1072
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
1017
1073
)
1018
1074
1075
+ let start = DispatchTime . now ( )
1076
+ observabilityScope. emit ( info: " logging-in into \( request. url) " )
1019
1077
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
1020
1078
completion (
1021
1079
result. tryMap { response in
1080
+ observabilityScope
1081
+ . emit (
1082
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1083
+ )
1022
1084
switch response. statusCode {
1023
1085
case 200 :
1024
1086
return ( )
@@ -1134,13 +1196,18 @@ public final class RegistryClient: Cancellable {
1134
1196
request. headers. add ( name: " X-Swift-Package-Signature-Format " , value: signatureFormat. rawValue)
1135
1197
}
1136
1198
1199
+ let start = DispatchTime . now ( )
1200
+ observabilityScope. emit ( info: " publishing \( packageIdentity) \( packageVersion) to \( request. url) " )
1137
1201
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
1138
1202
completion (
1139
1203
result. tryMap { response in
1204
+ observabilityScope
1205
+ . emit (
1206
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1207
+ )
1140
1208
switch response. statusCode {
1141
1209
case 201 :
1142
1210
try response. validateAPIVersion ( )
1143
-
1144
1211
let location = response. headers. get ( " Location " ) . first. flatMap { URL ( string: $0) }
1145
1212
return PublishResult . published ( location)
1146
1213
case 202 :
@@ -1190,9 +1257,15 @@ public final class RegistryClient: Cancellable {
1190
1257
options: self . defaultRequestOptions ( timeout: timeout, callbackQueue: callbackQueue)
1191
1258
)
1192
1259
1260
+ let start = DispatchTime . now ( )
1261
+ observabilityScope. emit ( info: " checking availability of \( registry. url) using \( request. url) " )
1193
1262
self . httpClient. execute ( request, observabilityScope: observabilityScope, progress: nil ) { result in
1194
1263
completion (
1195
1264
result. tryMap { response in
1265
+ observabilityScope
1266
+ . emit (
1267
+ debug: " server response for \( request. url) : \( response. statusCode) in \( start. distance ( to: . now( ) ) . descriptionInSeconds) "
1268
+ )
1196
1269
switch response. statusCode {
1197
1270
case 200 :
1198
1271
return . available
0 commit comments