Skip to content

Commit cddfdee

Browse files
cindy-pengcindy-pengmeredithslota
authored
fix: Fix trace_sampled type to be consistent with API documentation (#830)
* fix: Fix timestamp drift due to prototype comparison * fix: Fix traceSampled to be boolean as documented * Revert timestamp change --------- Co-authored-by: cindy-peng <cindypeng@google.com> Co-authored-by: meredithslota <meredithslota@google.com>
1 parent 5c252fa commit cddfdee

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/nodejs-logging-winston/src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export class LoggingCommon {
277277
}
278278

279279
if (LOGGING_SAMPLED_KEY in metadata) {
280-
entryMetadata.traceSampled = metadata[LOGGING_SAMPLED_KEY] === '1';
280+
entryMetadata.traceSampled = metadata[LOGGING_SAMPLED_KEY] === true;
281281
}
282282

283283
// we have tests that assert that metadata is always passed.

packages/nodejs-logging-winston/test/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ describe('logging-common', () => {
395395
// eslint-disable-next-line @typescript-eslint/no-explicit-any
396396
(metadataWithTrace as any)[loggingSpanKey] = 'span1';
397397
// eslint-disable-next-line @typescript-eslint/no-explicit-any
398-
(metadataWithTrace as any)[loggingSampledKey] = '1';
398+
(metadataWithTrace as any)[loggingSampledKey] = true;
399399

400400
loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => {
401401
assert.deepStrictEqual(entryMetadata, {

packages/nodejs-logging-winston/test/middleware/make-child-logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe('makeChildLogger', () => {
120120
child.debug('hello world', {
121121
[LOGGING_TRACE_KEY]: 'to-be-clobbered',
122122
[LOGGING_SPAN_KEY]: 'to-be-clobbered',
123-
[LOGGING_SAMPLED_KEY]: '0',
123+
[LOGGING_SAMPLED_KEY]: false,
124124
});
125125
assert.notStrictEqual(trace, FAKE_TRACE);
126126
assert.notStrictEqual(span, FAKE_SPAN);

0 commit comments

Comments
 (0)