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): add patch and unpatch diag log messages #4641

Merged
merged 6 commits into from
Apr 19, 2024

Conversation

blumamir
Copy link
Member

@blumamir blumamir commented Apr 17, 2024

This PR introduces diag.debug message for @opentelemetry/instrumentation patch and unpatch function for nodejs.

It is a common practice for instrumentations that implement InstrumentationBase to define patch and unpatch functions for modules and module files, and emit a diag message on each invocation. Since we have dozens of instrumentations that does the same thing, the current practice introduces unnecessary repetitions, inconsistencies and degraded user and maintainer experience.

This PR hoists the diag printing to the @opentelemetry/instrumentation package where the diag message is written once and applied to all instrumentations.

Instrumentation implementors will need to remove the current diag.debug call in patch and unpatch if they apply any, so the message will only be printed one by the base class.

example of the message content with DiagConsoleLogger:

@opentelemetry/instrumentation-mongoose Applying instrumentation patch for module on require {
  module: 'mongoose',
  version: '6.12.8',
  baseDir: '/Users/amirblum/repos/node-pg/node_modules/mongoose'
}

The message is formatted as constant message and attributes.

I created a contrib PR: open-telemetry/opentelemetry-js-contrib#2107 to apply the changes, so once we release this feature we can immediately rebase the contrib PR and release instrumentations based on this change

@blumamir blumamir requested a review from a team April 17, 2024 09:47
@blumamir blumamir changed the title feat(instrumentation): add patch and unpatch diag log messages feat!(instrumentation): add patch and unpatch diag log messages Apr 17, 2024
@pichlermarc pichlermarc merged commit 31eb60d into open-telemetry:main Apr 19, 2024
18 checks passed
Zirak pushed a commit to Zirak/opentelemetry-js that referenced this pull request Sep 14, 2024
…-telemetry#4641)

* refactor(@opentelemetry/instrumentation): add patch and unpatch diag log messages

* chore: CHANGELOG

* fix: exclude version in core packages

---------

Co-authored-by: Marc Pichler <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants