-
Notifications
You must be signed in to change notification settings - Fork 375
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
feat: Transfer Manager Metrics #2305
Merged
Merged
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ad05114
feat: Transfer Manager Metrics
d-goog d36f9aa
fix: Add missing `gccl-gcs-cmd/` prefix
d-goog 25b1546
Merge branch 'main' of github.com:googleapis/nodejs-storage into tm-m…
d-goog 8dccadf
fix: remove unused method
d-goog 1b38854
Merge branch 'main' of github.com:googleapis/nodejs-storage into tm-m…
d-goog d878cee
refactor: update logic for both headers
d-goog adcfa82
refactor: use `Symbol.for` in case the file is evaluated multiple times
d-goog 1d74974
fix: add missing URL param
d-goog 539e429
fix: if header doesn't exist, add it
d-goog 5d590fd
test: Add `GCCL_GCS_CMD_KEY` TM tests
d-goog ab5a3eb
feat: Add base `x-goog-api-client` for XML API
d-goog 3f13ac1
chore: dep type change
d-goog fc8c198
fix: pass `GCCL_GCS_CMD_KEY`
d-goog 643b2c5
refactor: remove unused
d-goog cc9ca89
test: Add `GCCL_GCS_CMD` tests
d-goog f9c16fb
chore: cleanup
d-goog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,14 @@ import {getRuntimeTrackingString} from '../util'; | |
|
||
const packageJson = require('../../../package.json'); | ||
|
||
/** | ||
* A unique symbol for providing a `gccl-gcs-cmd` value | ||
* for the `X-Goog-API-Client` header. | ||
* | ||
* E.g the `V` in `X-Goog-API-Client: gccl-gcs-cmd/V` | ||
**/ | ||
export const GCCL_GCS_CMD_KEY = Symbol('GCCL_GCS_CMD'); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const duplexify: DuplexifyConstructor = require('duplexify'); | ||
|
||
|
@@ -233,6 +241,7 @@ export interface DecorateRequestOptions extends r.CoreOptions { | |
interceptors_?: Interceptor[]; | ||
shouldReturnStream?: boolean; | ||
projectId?: string; | ||
[GCCL_GCS_CMD_KEY]?: string; | ||
} | ||
|
||
export interface ParsedHttpResponseBody { | ||
|
@@ -530,7 +539,9 @@ export class Util { | |
body: writeStream, | ||
}, | ||
], | ||
} as {} as r.OptionsWithUri; | ||
} as {} as r.OptionsWithUri & { | ||
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. This is clever! |
||
[GCCL_GCS_CMD_KEY]?: string; | ||
}; | ||
|
||
options.makeAuthenticatedRequest(reqOpts, { | ||
onAuthenticated(err, authenticatedReqOpts) { | ||
|
@@ -539,7 +550,9 @@ export class Util { | |
return; | ||
} | ||
|
||
requestDefaults.headers = util._getDefaultHeaders(); | ||
requestDefaults.headers = util._getDefaultHeaders( | ||
reqOpts[GCCL_GCS_CMD_KEY] | ||
); | ||
const request = teenyRequest.defaults(requestDefaults); | ||
request(authenticatedReqOpts!, (err, resp, body) => { | ||
util.handleResp(err, resp, body, (err, data) => { | ||
|
@@ -1014,13 +1027,19 @@ export class Util { | |
: [optionsOrCallback as T, cb as C]; | ||
} | ||
|
||
_getDefaultHeaders() { | ||
return { | ||
_getDefaultHeaders(gcclGcsCmd?: string) { | ||
const headers = { | ||
'User-Agent': util.getUserAgentFromPackageJson(packageJson), | ||
'x-goog-api-client': `${getRuntimeTrackingString()} gccl/${ | ||
packageJson.version | ||
} gccl-invocation-id/${uuid.v4()}`, | ||
}; | ||
|
||
if (gcclGcsCmd) { | ||
headers['x-goog-api-client'] += ` gccl-gcs-cmd/${gcclGcsCmd}`; | ||
} | ||
|
||
return headers; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to go look this up, didn't know
Symbol
was a thing.