Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Documentation request ] [Typo] Observability Testing with DefaultLogger unclear #2640

Open
cloudbring opened this issue Feb 15, 2024 · 0 comments

Comments

@cloudbring
Copy link

Brief description

There is a typo on the Observability Typescript Guide ➡️

typo

import { DefaultLogger, LogEntry } from '@temporalio/worker';

const logs: LogEntry[] = [];
const logger = new DefaultLogger('TRACE', (entry) => logs.push(entry));
log.debug('hey', { a: 1 });
log.info('ho');
log.warn('lets', { a: 1 });
log.error('go');

The code doesn't make sense as it is written. I think the intent was that the log object referenced should be logger. If it's not a typo, it isn't clear to me what the 'log' object is and it's relationship to logs and logger.

The context of this was for a section "Accumulate logs for testing and reporting" but, the code above doesn't show how it can be used in a test.

A testing question I think would be useful answered in the documentation is:

  1. How could you iterate through the <LogEntry> objects in logs to assert/expect an outcome?
  • How do you access the LEVEL in a <LogEntry> object?
  • How do you access the metadata object in a <LogEntry> object?

    Example: log.debug('hey', { a: 1, foo: 'bar' }) ➡️ { a: 1, foo: 'bar' }

Your recommended content

I'd be more than happy to fix the typo above and look up so that a more useful code snippet for testing Observability can be made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant