Skip to content

Commit

Permalink
fix: Fix trace_sampled type to be consistent with API documentation (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Co-authored-by: meredithslota <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent 3079a9d commit 33103dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export class LoggingCommon {
}

if (LOGGING_SAMPLED_KEY in metadata) {
entryMetadata.traceSampled = metadata[LOGGING_SAMPLED_KEY] === '1';
entryMetadata.traceSampled = metadata[LOGGING_SAMPLED_KEY] === true;
}

// we have tests that assert that metadata is always passed.
Expand Down
2 changes: 1 addition & 1 deletion test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ describe('logging-common', () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(metadataWithTrace as any)[loggingSpanKey] = 'span1';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(metadataWithTrace as any)[loggingSampledKey] = '1';
(metadataWithTrace as any)[loggingSampledKey] = true;

loggingCommon.cloudLog.entry = (entryMetadata: {}, data: {}) => {
assert.deepStrictEqual(entryMetadata, {
Expand Down
2 changes: 1 addition & 1 deletion test/middleware/make-child-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('makeChildLogger', () => {
child.debug('hello world', {
[LOGGING_TRACE_KEY]: 'to-be-clobbered',
[LOGGING_SPAN_KEY]: 'to-be-clobbered',
[LOGGING_SAMPLED_KEY]: '0',
[LOGGING_SAMPLED_KEY]: false,
});
assert.notStrictEqual(trace, FAKE_TRACE);
assert.notStrictEqual(span, FAKE_SPAN);
Expand Down

0 comments on commit 33103dc

Please sign in to comment.