Repository navigation
feat(gax): call logNetworkAttempt and logCall in createApiCall - #9760
shivanee-p wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request integrates telemetry logging capabilities into createApiCall by conditionally wrapping API calls and network attempts with logging functions, supported by a comprehensive suite of new unit tests. The feedback advises against weakening test coverage in loggerHelper.ts where assertions for the absence of exception fields were removed, suggesting instead to assert that these fields are undefined.
I am having trouble creating individual review comments. Click here to see my feedback.
core/packages/gax/test/unit/loggerHelper.ts (580-582)
Removing these assertions weakens the test coverage for verifying that exception fields are not present in successful logs. If these assertions were removed because the keys might be present with undefined values (e.g., due to changes in the logging backend), we should instead assert that their values are undefined. This maintains robust test coverage without being fragile to the physical presence of the keys in the object.
assert.strictEqual(otherWithoutMeta['exception.type'], undefined);
assert.strictEqual(otherWithoutMeta['exception.message'], undefined);
assert.strictEqual(otherWithoutMeta['exception.stacktrace'], undefined);
References
- Do not weaken test assertions (e.g., changing a specific minimum count assertion to a simple greater-than-zero check) solely to avoid fragility, as this reduces test coverage.
247d0f2 to
c8ac3d9
Compare
quirogas
left a comment
There was a problem hiding this comment.
LGTM! Approving to unblock—left a few minor non-blocking nits inline.
| assert.strictEqual('exception.type' in otherWithoutMeta, false); | ||
| assert.strictEqual('exception.message' in otherWithoutMeta, false); | ||
| assert.strictEqual('exception.stacktrace' in otherWithoutMeta, false); |
There was a problem hiding this comment.
Nit: This PR deletes 3 assertions in test/unit/loggerHelper.ts (exception.type, exception.message, exception.stacktrace absence on otherWithoutMeta) that were added in #9757. Drop this unrelated hunk so #9760 stays scoped to createApiCall.ts and test/unit/apiCallable.ts.
c8ac3d9 to
c14d2c5
Compare
ef8645e to
b0d358d
Compare
b0d358d to
a4963ed
Compare
d996b2e to
2860ce2
Compare
f8f4684 to
04ef833
Compare
04ef833 to
d557804
Compare
40bbcd5 to
db436d6
Compare
0a572cb to
c5a5f41
Compare
a8c285e to
e1afd60
Compare
e1afd60 to
952d3f1
Compare
25710ee to
94bf47b
Compare
…nly mode, and test stream error logs
94bf47b to
9edb32a
Compare
This pull request integrates
logNetworkAttemptandlogCallintocreateApiCall.Key Changes:
checkLoggingEnabled(settings)increateApiCalland initializedstaticArgs,dynamicArgs, andattemptDynamicArgswhen either tracing or logging is enabled.createApiCallwithlogNetworkAttemptwhen telemetry logging is enabled, nested insidetraceAttemptwhen tracing is also enabled so attempt logs capture the active T4 attempt span context.createApiCallwithlogCall(passingattemptDynamicArgssorpc.methodincludes the RPC service and method name) when telemetry logging is enabled, nested insidetraceCallwhen tracing is also enabled so terminal error logs capture the active T3 client request span context.