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: Esbuild plugin diag channel #5334

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

drewcorlin1
Copy link
Contributor

@drewcorlin1 drewcorlin1 commented Jan 12, 2025

Which problem is this PR solving?

Providing a way for users to auto instrument their bundled code. Diag channels based alternative to open-telemetry/opentelemetry-js-contrib#1856.

This should supersede (and is heavily inspired by) https://github.com/open-telemetry/opentelemetry-js/pull/4818/files

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Short description of the changes

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tested with open-telemetry/opentelemetry-js-contrib#2640.

Steps to test

  1. From this repo npm run compile
  2. From this repo create a script experimental/packages/opentelemetry-instrumentation/scripts/dev-install.sh
#!/usr/bin/env bash

if [[ ! -e package.json ]]; then
  echo 'Must be run from the directory containing package.json'
  exit 1
fi

set -e

src_root="$(dirname $0)/.."

rsync --recursive --exclude '**/node_modules/' "$src_root/build/" "node_modules/@opentelemetry/instrumentation/build"
  1. From the root of opentelemetry-js-contrib run that script (eg ../opentelemetry-js/experimental/packages/opentelemetry-instrumentation/scripts/dev-install.sh)
  2. From opentelemetry-js-contrib run npm run compile
  3. From opentelemetry-js-contrib/packages/esbuild-plugin-node/ run npm run test

Checklist:

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

Copy link

codecov bot commented Jan 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.56%. Comparing base (6864c2f) to head (b8c98f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5334   +/-   ##
=======================================
  Coverage   94.56%   94.56%           
=======================================
  Files         322      322           
  Lines        8132     8132           
  Branches     1715     1715           
=======================================
  Hits         7690     7690           
  Misses        442      442           

@drewcorlin1 drewcorlin1 changed the title Esbuild plugin diag channel feat: Esbuild plugin diag channel Jan 12, 2025
NodeJS 14 support will be dropped in 2.0 of the SDKs, which will
land before this is merged
);
return;
}
const names = [message.name, message.file].filter(Boolean) as string[];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trentm this differed from your original implementation. Idea here is to handle instrumentations that patch just the top level module (eg fastify) and instrumentations that patch specific files (eg graphQL)

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.

2 participants