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

EDU-1873: [Typo] Observability Testing with DefaultLogger unclear #2640

Open
cloudbring opened this issue Feb 15, 2024 · 1 comment
Open
Labels
community This issue was submitted external to Temporal tracking-internally A JIRA ticket has been generated and the EDU number is attached to the title of this issue or PR

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.

@fairlydurable
Copy link
Contributor

Thank you for this issue. Is it still valid?

@fairlydurable fairlydurable changed the title [ Documentation request ] [Typo] Observability Testing with DefaultLogger unclear EDU-1873: [Typo] Observability Testing with DefaultLogger unclear Jan 21, 2025
@fairlydurable fairlydurable added tracking-internally A JIRA ticket has been generated and the EDU number is attached to the title of this issue or PR community This issue was submitted external to Temporal labels Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community This issue was submitted external to Temporal tracking-internally A JIRA ticket has been generated and the EDU number is attached to the title of this issue or PR
Projects
None yet
Development

No branches or pull requests

2 participants