Skip to content
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: add request/response debug logging to gapics #1671

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ac86d6e
fix: template was missing curly brackets, fix for https://github.com/…
feywind Nov 27, 2024
5e684f8
feat: preliminary cjs support for debug request/response logging
feywind Dec 3, 2024
e96ed59
feat: more logs added
feywind Dec 13, 2024
2eae35b
fix: handle callbacks (as opposed to promises) for logging followups
feywind Dec 17, 2024
3c706c9
build: use bazeliskrc to fix bazel version
feywind Dec 17, 2024
67c83de
chore: merge remote-tracking branch 'remotes/origin/main' into debug-…
feywind Dec 17, 2024
84167b8
fix: improve debug log instantiation
feywind Dec 17, 2024
ed7c130
feat: show streaming call options with log lines
feywind Dec 17, 2024
5695463
tests: update baselines
feywind Dec 17, 2024
33dfa6b
feat: update esm templates as well
feywind Dec 19, 2024
e8abb7b
tests: update baselines for esm changes
feywind Dec 19, 2024
dee2d67
Merge remote-tracking branch 'remotes/origin/main' into debug-logging
feywind Feb 10, 2025
3949ae2
wip: naming updates
feywind Feb 10, 2025
924c84c
tests: finish the unit test for loggingName
feywind Feb 10, 2025
08e40a6
chore: fix linter issue
feywind Feb 11, 2025
ec72bae
fix: typescript compiler can't quite follow the flow control, bypass …
feywind Feb 11, 2025
8ef2183
tests: update baselines for bang changes
feywind Feb 11, 2025
e365550
fix: esm updates to match cjs
feywind Feb 11, 2025
c0700e5
fix: correct LRO function signatures
feywind Feb 11, 2025
f742fc0
tests: update esm baselines
feywind Feb 11, 2025
c1c4128
fix: remove extraneous import line from esm
feywind Feb 11, 2025
52f47f8
fix: more type fixes for callbacks, and updated baselines
feywind Feb 12, 2025
3a7d6e0
fix: revert some incorrect callback changes for LROs
feywind Feb 13, 2025
a68ca9a
fix: missing paren
feywind Feb 18, 2025
4f9aed2
tests: update baseline for compute esm
feywind Feb 18, 2025
b536b1c
fix: update package.json for google logging utils release
feywind Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# See https://github.com/bazelbuild/bazelisk
USE_BAZEL_VERSION=6.3.0
USE_BAZEL_VERSION=6.3.0
137 changes: 130 additions & 7 deletions baselines/asset-esm/esm/src/v1/asset_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {fileURLToPath} from 'url';
import {getJSON} from '../json-helper.cjs';
// @ts-ignore
const dirname = path.dirname(fileURLToPath(import.meta.url));
import * as logging from 'google-logging-utils';

/**
* Client JSON configuration object, loaded from
Expand Down Expand Up @@ -62,6 +63,7 @@ export class AssetServiceClient {
private _defaults: {[method: string]: gax.CallSettings};
private _universeDomain: string;
private _servicePath: string;
private _log = logging.log('asset');
auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
Expand Down Expand Up @@ -472,7 +474,24 @@ export class AssetServiceClient {
'parent': request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.batchGetAssetsHistory(request, options, callback);
this._log.info('batchGetAssetsHistory request %j', request);
const wrappedCallback: Callback<
protos.google.cloud.asset.v1.IBatchGetAssetsHistoryResponse,
protos.google.cloud.asset.v1.IBatchGetAssetsHistoryRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('batchGetAssetsHistory response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.batchGetAssetsHistory(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.cloud.asset.v1.IBatchGetAssetsHistoryResponse,
protos.google.cloud.asset.v1.IBatchGetAssetsHistoryRequest|undefined, {}|undefined
]) => {
this._log.info('batchGetAssetsHistory response %j', response);
return [response, options, rawResponse];
});
}
/**
* Creates a feed in a parent project/folder/organization to listen to its
Expand Down Expand Up @@ -556,7 +575,24 @@ export class AssetServiceClient {
'parent': request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.createFeed(request, options, callback);
this._log.info('createFeed request %j', request);
const wrappedCallback: Callback<
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.ICreateFeedRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('createFeed response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.createFeed(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.ICreateFeedRequest|undefined, {}|undefined
]) => {
this._log.info('createFeed response %j', response);
return [response, options, rawResponse];
});
}
/**
* Gets details about an asset feed.
Expand Down Expand Up @@ -629,7 +665,24 @@ export class AssetServiceClient {
'name': request.name ?? '',
});
this.initialize();
return this.innerApiCalls.getFeed(request, options, callback);
this._log.info('getFeed request %j', request);
const wrappedCallback: Callback<
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.IGetFeedRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('getFeed response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.getFeed(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.IGetFeedRequest|undefined, {}|undefined
]) => {
this._log.info('getFeed response %j', response);
return [response, options, rawResponse];
});
}
/**
* Lists all asset feeds in a parent project/folder/organization.
Expand Down Expand Up @@ -701,7 +754,24 @@ export class AssetServiceClient {
'parent': request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.listFeeds(request, options, callback);
this._log.info('listFeeds request %j', request);
const wrappedCallback: Callback<
protos.google.cloud.asset.v1.IListFeedsResponse,
protos.google.cloud.asset.v1.IListFeedsRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('listFeeds response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.listFeeds(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.cloud.asset.v1.IListFeedsResponse,
protos.google.cloud.asset.v1.IListFeedsRequest|undefined, {}|undefined
]) => {
this._log.info('listFeeds response %j', response);
return [response, options, rawResponse];
});
}
/**
* Updates an asset feed configuration.
Expand Down Expand Up @@ -779,7 +849,24 @@ export class AssetServiceClient {
'feed.name': request.feed!.name ?? '',
});
this.initialize();
return this.innerApiCalls.updateFeed(request, options, callback);
this._log.info('updateFeed request %j', request);
const wrappedCallback: Callback<
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.IUpdateFeedRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('updateFeed response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.updateFeed(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.cloud.asset.v1.IFeed,
protos.google.cloud.asset.v1.IUpdateFeedRequest|undefined, {}|undefined
]) => {
this._log.info('updateFeed response %j', response);
return [response, options, rawResponse];
});
}
/**
* Deletes an asset feed.
Expand Down Expand Up @@ -852,7 +939,24 @@ export class AssetServiceClient {
'name': request.name ?? '',
});
this.initialize();
return this.innerApiCalls.deleteFeed(request, options, callback);
this._log.info('deleteFeed request %j', request);
const wrappedCallback: Callback<
protos.google.protobuf.IEmpty,
protos.google.cloud.asset.v1.IDeleteFeedRequest|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, options, rawResponse) => {
this._log.info('deleteFeed response %j', response);
callback!(error, response, options, rawResponse);
}
: undefined;
return this.innerApiCalls.deleteFeed(request, options, wrappedCallback)
?.then(([response, options, rawResponse]: [
protos.google.protobuf.IEmpty,
protos.google.cloud.asset.v1.IDeleteFeedRequest|undefined, {}|undefined
]) => {
this._log.info('deleteFeed response %j', response);
return [response, options, rawResponse];
});
}

/**
Expand Down Expand Up @@ -949,7 +1053,24 @@ export class AssetServiceClient {
'parent': request.parent ?? '',
});
this.initialize();
return this.innerApiCalls.exportAssets(request, options, callback);
const wrappedCallback: Callback<
LROperation<protos.google.cloud.asset.v1.IExportAssetsResponse, protos.google.cloud.asset.v1.IExportAssetsRequest>,
protos.google.longrunning.IOperation|null|undefined,
{}|null|undefined>|undefined = callback
? (error, response, rawResponse, _) => {
this._log.info('exportAssets response %j', rawResponse);
callback!(error, response, rawResponse, _); // We verified `callback` above.
}
: undefined;
this._log.info('exportAssets request %j', request);
return this.innerApiCalls.exportAssets(request, options, wrappedCallback)
?.then(([response, rawResponse, _]: [
LROperation<protos.google.cloud.asset.v1.IExportAssetsResponse, protos.google.cloud.asset.v1.IExportAssetsRequest>,
protos.google.longrunning.IOperation|undefined, {}|undefined
]) => {
this._log.info('exportAssets response %j', rawResponse);
return [response, rawResponse, _];
});
}
/**
* Check the status of the long running operation returned by `exportAssets()`.
Expand All @@ -963,6 +1084,7 @@ export class AssetServiceClient {
* region_tag:cloudasset_v1_generated_AssetService_ExportAssets_async
*/
async checkExportAssetsProgress(name: string): Promise<LROperation<protos.google.cloud.asset.v1.ExportAssetsResponse, protos.google.cloud.asset.v1.ExportAssetsRequest>>{
this._log.info('exportAssets long-running');
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name});
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportAssets, this._gaxModule.createDefaultBackoffSettings());
Expand Down Expand Up @@ -1089,6 +1211,7 @@ export class AssetServiceClient {
close(): Promise<void> {
if (this.assetServiceStub && !this._terminated) {
return this.assetServiceStub.then(stub => {
this._log.info('ending gRPC channel');
this._terminated = true;
stub.close();
this.operationsClient.close();
Expand Down
3 changes: 2 additions & 1 deletion baselines/asset-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"samples-test": "cd samples/ && npm link ../ && npm i && npm test"
},
"dependencies": {
"google-gax": "^4.4.0"
"google-gax": "^4.4.0",
"google-logging-utils": "^1.0.1"
},
"devDependencies": {
"@babel/cli": "^7.25.6",
Expand Down
3 changes: 2 additions & 1 deletion baselines/asset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"test": "c8 mocha build/test"
},
"dependencies": {
"google-gax": "^4.4.0"
"google-gax": "^4.4.0",
"google-logging-utils": "^1.0.1"
},
"devDependencies": {
"@types/mocha": "^10.0.7",
Expand Down
Loading
Loading