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-express): Add support for Express v5 #2437

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

Conversation

timfish
Copy link
Contributor

@timfish timfish commented Sep 18, 2024

Which problem is this PR solving?

Closes #2435

Short description of the changes

This PR adds support for express v5. The migration docs show few user facing API changes although the internals have changed quite a bit.

Express v5 has made Node v18 the minimum supported version although it looks like the tests only fail on v14 so far and >= v16 still pass.

The v5 tests are a copy of the v4 tests with some minor changes:

  • Instrumented Express v5 emits middleware spans but the middleware - query and middleware - expressInit spans are missing, no doubt due to reworking of the internals.
  • Some tests needed modifying because express no longer supports * paths. Instead /.*/ regex should be used.
  • The complex regex tests expect the span names to contain '/test/arr/:id,/\\/test\\/arr[0-9]*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?/' but a couple of them instead contain /test,6,/test/. This is either a bug in express or caused by a change to their regex support mentioned in the migration guide. In these instances, the integration does not have access to the "correct" path in any other property.

The v4 and v5 tests passed in isolation but when run though mocha together, many v4 tests failed with strange duplicate or missing spans. My best guess is that there's some incompatibility when running both express versions in the same process. To work around this I changed it to run these tests in isolated calls to mocha and then combine the nyc coverage in a posttest script.

Copy link

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.53%. Comparing base (dfb2dff) to head (3aa1c9e).
Report is 242 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2437      +/-   ##
==========================================
- Coverage   90.97%   90.53%   -0.45%     
==========================================
  Files         146      152       +6     
  Lines        7492     7489       -3     
  Branches     1502     1530      +28     
==========================================
- Hits         6816     6780      -36     
- Misses        676      709      +33     

see 78 files with indirect coverage changes

@timfish timfish marked this pull request as ready for review September 18, 2024 16:15
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 support for Express v5
3 participants