dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

Integrate browser-bunyan

Open ngbrown opened this issue 3 years ago • 8 comments

What does this PR do?

This pull requests integrates dd-trace with the logging library browser-bunyan, when it is running on the server-side in Node.js.

Motivation

As frameworks such as Next.js and Remix focus on isomorphic React, the logging library should be isomorphic. I've found browser-bunyan to fit the bill of something lightweight and very usable.

For example, if a web app is attempting to follow the twelve-factor methodology, then it only needs to write its event stream, unbuffered, to stdout, so a simpler the logging library is better.

Plugin Checklist

Additional Notes

This updates all the upstream tests to remove package-lock.json from the upstream repos to better simulate installing as a library and to clear any non-public resolved URLs that were saved in the repo.

ngbrown avatar Mar 28 '22 06:03 ngbrown

This library only supports Node and not the browser. If you need support for the browser that's handled by the browser SDK for RUM.

rochdev avatar Mar 28 '22 16:03 rochdev

@rochdev Hi I understand that dd-trace only runs on node. I want to use the same logging library in both the browser and node because I'm using it in an isomorphic React framework. So this instruments the browser-bunyan library, when it's running on node.

ngbrown avatar Mar 28 '22 17:03 ngbrown

Makes sense, I completely misunderstood what this does, sorry for the confusion.

rochdev avatar Mar 28 '22 17:03 rochdev

The upstream tests clone the target library repo, but there's some weirdness around the package-lock.json file that is attempting to pull from localhost on some packages.

I could just drop the upstream tests?

Or maybe this could be resolved with a .npmrc and registry= setting?

ngbrown avatar Mar 28 '22 18:03 ngbrown

Another option would be to skip using the lockfile entirely. This would actually also be closer to reality since installing a library as a dependency wouldn't use the library lockfile in the first place.

rochdev avatar Mar 28 '22 20:03 rochdev

@rochdev good idea on removing package-lock.json from the upstream repos. It does affect multiple tests, so it's a separate commit. I don't think the node-elasticsearch-16 failure is related, so maybe you can force a rerun on that test to see if it is flaky?

ngbrown avatar Mar 28 '22 20:03 ngbrown

I've re-based this code to integrate browser-bunyan as an light-weight logging framework. The tests run locally. It looks like something needs to happen to run the GitHub actions.

ngbrown avatar Jul 13 '23 08:07 ngbrown

Codecov Report

Merging #1935 (79c2377) into master (ea81490) will decrease coverage by 0.02%. Report is 77 commits behind head on master. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #1935      +/-   ##
==========================================
- Coverage   84.71%   84.70%   -0.02%     
==========================================
  Files         211      211              
  Lines        8256     8257       +1     
  Branches       33       33              
==========================================
  Hits         6994     6994              
- Misses       1262     1263       +1     
Files Changed Coverage Δ
packages/dd-trace/src/plugins/index.js 5.71% <0.00%> (-0.09%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Aug 02 '23 20:08 codecov[bot]