Skip to content

Commit 3a9dc00

Browse files
authored
Better Artifact Telemetry + Increase Upload chunk size (#535)
* Differentiate user-agents for better internal telemetry * Bump chunk size from 4 to 8 MB * Update User-Agent Strings
1 parent ccad190 commit 3a9dc00

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

packages/artifact/src/internal/config-variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function getUploadFileConcurrency(): number {
66
// When uploading large files that can't be uploaded with a single http call, this controls
77
// the chunk size that is used during upload
88
export function getUploadChunkSize(): number {
9-
return 4 * 1024 * 1024 // 4 MB Chunks
9+
return 8 * 1024 * 1024 // 8 MB Chunks
1010
}
1111

1212
// The maximum number of retries that can be attempted before an upload or download fails

packages/artifact/src/internal/download-http-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export class DownloadHttpClient {
2727
private statusReporter: StatusReporter
2828

2929
constructor() {
30-
this.downloadHttpManager = new HttpManager(getDownloadFileConcurrency())
30+
this.downloadHttpManager = new HttpManager(
31+
getDownloadFileConcurrency(),
32+
'@actions/artifact-download'
33+
)
3134
// downloads are usually significantly faster than uploads so display status information every second
3235
this.statusReporter = new StatusReporter(1000)
3336
}

packages/artifact/src/internal/http-manager.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import {createHttpClient} from './utils'
66
*/
77
export class HttpManager {
88
private clients: HttpClient[]
9+
private userAgent: string
910

10-
constructor(clientCount: number) {
11+
constructor(clientCount: number, userAgent: string) {
1112
if (clientCount < 1) {
1213
throw new Error('There must be at least one client')
1314
}
14-
this.clients = new Array(clientCount).fill(createHttpClient())
15+
this.userAgent = userAgent
16+
this.clients = new Array(clientCount).fill(createHttpClient(userAgent))
1517
}
1618

1719
getClient(index: number): HttpClient {
@@ -22,7 +24,7 @@ export class HttpManager {
2224
// for more information see: https://github.com/actions/http-client/blob/04e5ad73cd3fd1f5610a32116b0759eddf6570d2/index.ts#L292
2325
disposeAndReplaceClient(index: number): void {
2426
this.clients[index].dispose()
25-
this.clients[index] = createHttpClient()
27+
this.clients[index] = createHttpClient(this.userAgent)
2628
}
2729

2830
disposeAndReplaceAllClients(): void {

packages/artifact/src/internal/upload-http-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export class UploadHttpClient {
4242
private statusReporter: StatusReporter
4343

4444
constructor() {
45-
this.uploadHttpManager = new HttpManager(getUploadFileConcurrency())
45+
this.uploadHttpManager = new HttpManager(
46+
getUploadFileConcurrency(),
47+
'@actions/artifact-upload'
48+
)
4649
this.statusReporter = new StatusReporter(10000)
4750
}
4851

packages/artifact/src/internal/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ export function getUploadHeaders(
204204
return requestOptions
205205
}
206206

207-
export function createHttpClient(): HttpClient {
208-
return new HttpClient('actions/artifact', [
207+
export function createHttpClient(userAgent: string): HttpClient {
208+
return new HttpClient(userAgent, [
209209
new BearerCredentialHandler(getRuntimeToken())
210210
])
211211
}

0 commit comments

Comments
 (0)