Skip to content

Commit aa3f5e4

Browse files
committed
fix(gax): reuse buildLogAttributes exception attributes in logNetworkAttempt
1 parent a046646 commit aa3f5e4

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎core/packages/gax/src/observability/LoggerHelper.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,6 @@ export function logNetworkAttempt<T = GaxCallResult>(
319319
}
320320

321321
// Emit structured DEBUG log for the failed attempt.
322-
const message = resolveExceptionMessage(err, attemptDynamicArgs.rpcType);
323322
logger(
324323
{
325324
severity: resolveLogSeverity('DEBUG'),
@@ -328,7 +327,7 @@ export function logNetworkAttempt<T = GaxCallResult>(
328327
other: attributes,
329328
},
330329
'RPC attempt failed: %s',
331-
message || err,
330+
attributes['exception.message'] || err,
332331
);
333332
};
334333

‎core/packages/gax/test/unit/loggerHelper.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -748,14 +748,15 @@ describe('LoggerHelper', () => {
748748
'rpc.system.name': 'grpc',
749749
'rpc.method': 'google.storage.v2.Storage/GetObject',
750750
'url.domain': 'storage.googleapis.com',
751+
'server.address': 'storage.googleapis.com',
751752
'rpc.response.status_code': 'UNAVAILABLE',
752753
'error.type': 'UNAVAILABLE',
754+
'exception.type': 'GoogleError',
755+
'exception.message': 'Unavailable',
756+
'exception.stacktrace': errWithMeta.stack,
753757
'response.payload':
754758
'{"x-goog-request-id":"req-123","trace-bin":"YWJj"}',
755759
});
756-
assert.strictEqual('exception.type' in other, false);
757-
assert.strictEqual('exception.message' in other, false);
758-
assert.strictEqual('exception.stacktrace' in other, false);
759760

760761
sink.reset();
761762
const preConnectGrpcErr = Object.assign(
@@ -803,9 +804,13 @@ describe('LoggerHelper', () => {
803804
]);
804805
const otherWithoutMeta = sink.logs[0].fields.other as LogPayload;
805806
assert.strictEqual('response.payload' in otherWithoutMeta, false);
806-
assert.strictEqual('exception.type' in otherWithoutMeta, false);
807-
assert.strictEqual('exception.message' in otherWithoutMeta, false);
808-
assert.strictEqual('exception.stacktrace' in otherWithoutMeta, false);
807+
assert.strictEqual('server.address' in otherWithoutMeta, false);
808+
assert.strictEqual(otherWithoutMeta['exception.type'], 'TypeError');
809+
assert.strictEqual(otherWithoutMeta['exception.message'], 'client error');
810+
assert.strictEqual(
811+
otherWithoutMeta['exception.stacktrace'],
812+
errWithoutMeta.stack,
813+
);
809814
});
810815

811816
it('emits response.payload on HTTP REST error responses and omits it on empty or transport failures', async () => {

0 commit comments

Comments
 (0)