-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Extend user-agent with orchestration ID and add default user-agent #2229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
09cb71a
4e1c194
6d9a3fe
32c52bb
557f80f
20596c1
1dc58e3
af6de2c
2215c8e
3f1933e
48a7cdb
97f5a6f
3a191ee
bccbba4
83c13c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -147,7 +147,7 @@ export class HttpClient { | |
| handlers?: ifm.RequestHandler[], | ||
| requestOptions?: ifm.RequestOptions | ||
| ) { | ||
| this.userAgent = userAgent | ||
| this.userAgent = this._getUserAgentWithOrchestrationId(userAgent) | ||
| this.handlers = handlers || [] | ||
| this.requestOptions = requestOptions | ||
| if (requestOptions) { | ||
|
|
@@ -816,6 +816,18 @@ export class HttpClient { | |
| return proxyAgent | ||
| } | ||
|
|
||
| private _getUserAgentWithOrchestrationId(userAgent?: string): string { | ||
| const baseUserAgent = userAgent || 'actions/http-client' | ||
| const orchId = process.env['ACTIONS_ORCHESTRATION_ID'] | ||
| if (orchId) { | ||
| // Sanitize the orchestration ID to ensure it contains only valid characters | ||
| // Valid characters: 0-9, a-z, _, -, . | ||
| const sanitizedId = orchId.replace(/[^a-z0-9_.-]/gi, '_') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we remove invalid characters instead of replacing with underscores?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we shouldn't need to since the orchestrationid we generate always has valid chars. |
||
| return `${baseUserAgent} actions_orchestration_id/${sanitizedId}` | ||
| } | ||
| return baseUserAgent | ||
| } | ||
|
|
||
| private async _performExponentialBackoff(retryNumber: number): Promise<void> { | ||
| retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber) | ||
| const ms: number = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.