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

feat(instrumentation-bunyan): add log sending to Logs Bridge API #1713

Merged
merged 38 commits into from
Nov 28, 2023

Conversation

trentm
Copy link
Contributor

@trentm trentm commented Oct 3, 2023

This extends the Bunyan instrumentation to automatically add a Bunyan stream to created loggers that will send log records to the Logs Bridge API: https://opentelemetry.io/docs/specs/otel/logs/bridge-api/

Now that the instrumentation supports separate "injection" of fields and "bridging" of log records functionality, this also adds two boolean options to disable those independently: enableInjection and enableLogsBridge.

This also updates the instrumentation to work with ES module usage.

Closes: #1559

This extends the Bunyan instrumentation to automatically add a
Bunyan stream to created loggers that will send log records to
the Logs Bridge API: https://opentelemetry.io/docs/specs/otel/logs/bridge-api/

Now that the instrumentation supports separate "injection" of fields
and "bridging" of log records functionality, this also adds two boolean
options to disable those independently: `enableInjection` and
`enableLogsBridge`.

This also updates the instrumentation to work with ES module usage.

Closes: open-telemetry#1559
@trentm trentm requested a review from a team October 3, 2023 17:52
@github-actions github-actions bot requested a review from seemk October 3, 2023 17:52
@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Merging #1713 (ca18034) into main (60d60d0) will increase coverage by 0.07%.
The diff coverage is 98.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1713      +/-   ##
==========================================
+ Coverage   91.42%   91.50%   +0.07%     
==========================================
  Files         143      144       +1     
  Lines        7303     7369      +66     
  Branches     1461     1467       +6     
==========================================
+ Hits         6677     6743      +66     
  Misses        626      626              
Files Coverage Δ
...umentation-bunyan/src/OpenTelemetryBunyanStream.ts 100.00% <100.00%> (ø)
...etry-instrumentation-bunyan/src/instrumentation.ts 98.70% <97.56%> (+0.78%) ⬆️

Copy link
Member

@blumamir blumamir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Great work 🥇

Left a few optional nit comments

@trentm
Copy link
Contributor Author

trentm commented Nov 8, 2023

@blumamir Thanks for the thoughtful review! I agree with everything you've suggested. I'll need today to re-educate myself on some of this code. :)

@blumamir
Copy link
Member

blumamir commented Nov 8, 2023

@blumamir Thanks for the thoughtful review! I agree with everything you've suggested. I'll need today to re-educate myself on some of this code. :)

Sure take all the time you need. Feel free to write here if there is something you want to discuss

@trentm
Copy link
Contributor Author

trentm commented Nov 8, 2023

@blumamir This is ready for review again, whenever you have a chance. I have questions or thoughts on three of the "conversations" from your initial review above.

@trentm
Copy link
Contributor Author

trentm commented Nov 9, 2023

I don't know why unit-test (18) is failing now. My total guess is that there is something funky with the versions of deps installed, resulting in getting an @opentelemetry/api mismatch such that a NoopTracerProvider is registered. The "Cache Dependencies" step could be related here.

My inclination is to wait for the explicit package version handling from #1771 before digging into this too much.

@blumamir
Copy link
Member

blumamir commented Nov 9, 2023

I don't know why unit-test (18) is failing now. My total guess is that there is something funky with the versions of deps installed, resulting in getting an @opentelemetry/api mismatch such that a NoopTracerProvider is registered. The "Cache Dependencies" step could be related here.

My inclination is to wait for the explicit package version handling from #1771 before digging into this too much.

There was an issue with the CI yesterday due to this, was fixed in contrib by #1779 . Can you please try to rebase?

@hectorhdzg
Copy link
Member

Related open-telemetry/opentelemetry-js#4314

@trentm
Copy link
Contributor Author

trentm commented Nov 21, 2023

Related open-telemetry/opentelemetry-js#4314

@hectorhdzg IIUC, this was considered/discussed earlier on this PR: #1713 (comment)

@hectorhdzg
Copy link
Member

Thanks for the reference @trentm, hard to follow up with resolved comments, well then it would be good to have a specific Log Instrumentation then or similar, let use the other PR to discuss it.

@trentm
Copy link
Contributor Author

trentm commented Nov 21, 2023

hard to follow up with resolved comments

Totally agree.

Avoid using 'bridge' terminology at suggestion from specs that the Bridge API is an internal detail.
@trentm
Copy link
Contributor Author

trentm commented Nov 23, 2023

@hectorhdzg Thanks for the review! I've addressed the two terminology changes, and created a separate issue for the log level discussion.

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for working on this and sticking with us through the review process @trentm 🚀

@pichlermarc
Copy link
Member

pichlermarc commented Nov 27, 2023

I'll merge this by tomorrow evening (16:00 GMT+1) 🙂

@seemk (component-owner) any objections?

Copy link
Member

@hectorhdzg hectorhdzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@seemk
Copy link
Contributor

seemk commented Nov 28, 2023

I'll merge this by tomorrow evening (16:00 GMT+1) 🙂

@seemk (component-owner) any objections?

My only concern is that it is enabled by default and upgrading the instrumentation in existing pipelines which have the log provider already set up suddenly start sending more (perhaps unwanted) logs.

I'm fine with this as long we explicitly mention it in the release notes.

Otherwise it's a much needed feature, thanks for all the work!

@pichlermarc
Copy link
Member

pichlermarc commented Nov 28, 2023

My only concern is that it is enabled by default and upgrading the instrumentation in existing pipelines which have the log provider already set up suddenly start sending more (perhaps unwanted) logs.

Yep I agree, I'll add some info to the squashed commit so that release please adds that info to the changelog 🙂

EDIT: I added a override message hidden in the PR body so that release-please picks it up 🙂

@pichlermarc pichlermarc merged commit 4a1d83c into open-telemetry:main Nov 28, 2023
16 checks passed
@dyladan dyladan mentioned this pull request Nov 28, 2023
@trentm
Copy link
Contributor Author

trentm commented Nov 28, 2023

Thanks!

EDIT: I added a override message hidden in the PR body so that release-please picks it up 🙂

@pichlermarc Was there a slight Markdown formatting error in your override block?

-  * upgrading to this version will start sending logs if a [Logs SDK]([Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/sdk-logs) is registered with the [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/api-logs)
+  * upgrading to this version will start sending logs if a [Logs SDK](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/sdk-logs) is registered with the [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/api-logs)

Also, I'm curious, is there a particular reason for putting the override inside an HTML comment to somewhat hide it?

@trentm trentm deleted the trentm/logs-bridge-bunyan branch November 28, 2023 16:10
@pichlermarc
Copy link
Member

Thanks!

EDIT: I added a override message hidden in the PR body so that release-please picks it up 🙂

@pichlermarc Was there a slight Markdown formatting error in your override block?

-  * upgrading to this version will start sending logs if a [Logs SDK]([Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/sdk-logs) is registered with the [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/api-logs)
+  * upgrading to this version will start sending logs if a [Logs SDK](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/sdk-logs) is registered with the [Logs Bridge API](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/api-logs)

Yep thanks for catching that. I fixed it. Looks like release-please didn't pick it up though, I must've done something wrong, I'll keep an eye on it and see if it appears. Worst case I'll manually edit the auto-generated github release notes.

Also, I'm curious, is there a particular reason for putting the override inside an HTML comment to somewhat hide it?

Ah I was trying to keep the visible PR body unchanged. The commit override is a bit unsightly.

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

Successfully merging this pull request may close these issues.

Add Bunyan stream for OpenTelemetry
5 participants