Skip to content

Commit

Permalink
feat(instrumentation-bunyan): add log sending to Logs Bridge API (#1713)
Browse files Browse the repository at this point in the history
* feat(instrumentation-bunyan): add log sending to Logs Bridge API

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

* markdown lint fixes

* markdown lint fixes

* catch up with recent core-deps update

* some type tweaks suggested by David

* more specific type

Co-authored-by: Amir Blum <amirgiraffe@gmail.com>

* use more self-explanatory code for mapping Bunyan level to OTel severity, from blumamir

* export OpenTelemetryBunyanStream for direct usage in Bunyan loggers without the instrumentation

* .apply over .call suggestion

* consistency suggestion

* suggestion to use the longer (perhaps clearer) logger var name

* switch to false-by-default config vars to avoid surprises with undefined values

See https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md#boolean-value
Suggestion from blumamir.

* document using OpenTelemetryBunyanStream without the instrumentation

* fix https://eslint.org/docs/latest/rules/prefer-spread lint error

* drop options to OpenTelemetryBunyanStream constructor because YAGNI

* temporarily drop CI caching to test theory on unit-test (18) CI failure

* more CI debugging: restore cache, add some 'npm ls -a' to look into NoopContextManager being used

* elide Bunyan 'pid' and 'hostname' fields in OTel log record attributes

Because they are redundant with 'process.pid' and 'host.name'
resource attributes. Add some docs on how to use resource detectors
to the example, because the HostDetector is not on by default in
the NodeSDK.

* update test for having elided 'pid' and 'hostname' fields

* CI debugging: ignore the 'npm ls -a' exit status, they shouldn't break the build

* fix lint and compile errors

* CI debugging: turn on diag DEBUG to test a theory

* turn off diag in this example

* undo CI debugging changes

* update deps to current releases and sync package-lock.json

* disableInjection -> disableLogCorrelation

* disableLogsBridge -> disableLogSending

Avoid using 'bridge' terminology at suggestion from specs that the Bridge API is an internal detail.

* correct the default instrumentation scope name (as discussed earlier)

* tests: fix test for intrumentationScope.name change in previous commit

* fix lint

---------

Co-authored-by: Amir Blum <amirgiraffe@gmail.com>
Co-authored-by: Hector Hernandez <39923391+hectorhdzg@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 28, 2023
1 parent 60d60d0 commit 4a1d83c
Show file tree
Hide file tree
Showing 13 changed files with 971 additions and 110 deletions.
92 changes: 54 additions & 38 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4a1d83c

Please sign in to comment.