opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Introduce internal Console API to encapsulate console related calls to manage them from a single point

Open serkan-ozal opened this issue 1 year ago • 6 comments
trafficstars

Which problem is this PR solving?

This PR neither adds new functionality or fixes a bug, but refactors the code base to use console methods over internal Console API instead of calling console methods directly.

This can be helpful for us in the future (https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1560) once we add patching console methods to automatically exporting them as logs. The point is that, we may not want to capture our own console exports for traces, metrics and logs to the console and export them as log again. So, when we patch the console methods, we can configure Console API (over Console.configure()) with the original unpatched console methods, so they will not be intercepted.

Short description of the changes

All the direct console calls are refactored to be done over internal Console API. So, when needed, console log behaviors can be managed from this single point.

Type of change

Neither fix, nor new feature, but refactor for further new features.

How Has This Been Tested?

Existing tests of the following files test the changes in this PR:

  • [x] ConsoleTraceExporter
  • [x] ConsoleMetricExporter
  • [x] ConsoleLogRecordExporter

Checklist:

  • [x] Followed the style guidelines of this project
  • [ ] Unit tests have been added
  • [ ] Documentation has been updated

serkan-ozal avatar Aug 22 '24 20:08 serkan-ozal