Skip to content

Commit

Permalink
Add timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mhennoch committed Jan 13, 2025
1 parent 7b3f7db commit 32a622e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
32 changes: 16 additions & 16 deletions test/loginjection.bunyan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ describe('log injection', () => {
delete process.env.OTEL_RESOURCE_ATTRIBUTES;
});

// it('injects service version and service environment if available', () => {
// startTracing({ serviceName: 'test-service' });

// const logger: bunyan = require('bunyan').createLogger({
// name: 'test',
// stream: logStream.stream,
// });

// assertInjection(logStream, logger, [
// ['service.name', 'test-service'],
// ['service.version', '1'],
// ['service.environment', 'test'],
// ]);

// stopTracing();
// });
it('injects service version and service environment if available', () => {
startTracing({ serviceName: 'test-service' });

const logger: bunyan = require('bunyan').createLogger({
name: 'test',
stream: logStream.stream,
});

assertInjection(logStream, logger, [
['service.name', 'test-service'],
['service.version', '1'],
['service.environment', 'test'],
]);

stopTracing();
});
});
});
22 changes: 12 additions & 10 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ export function assertInjection(
logger.info('my-log-message');
});

assert.strictEqual(stream.record['trace_id'], traceId);
assert.strictEqual(stream.record['span_id'], spanId);

for (const [key, value] of extra || []) {
assert.strictEqual(
stream.record[key],
value,
`Invalid value for "${key}": ${util.inspect(stream.record[key])}`
);
}
setTimeout( () => {

Check failure on line 103 in test/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `·`
assert.strictEqual(stream.record['trace_id'], traceId);
assert.strictEqual(stream.record['span_id'], spanId);

Check failure on line 106 in test/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `··`
for (const [key, value] of extra || []) {
assert.strictEqual(
stream.record[key],
value,
`Invalid value for "${key}": ${util.inspect(stream.record[key])}`
);
}

Check failure on line 113 in test/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Delete `····`
}, 20)

Check failure on line 114 in test/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `;`
}

export function exporterUrl(exporter: any) {
Expand Down

0 comments on commit 32a622e

Please sign in to comment.