Skip to content

fix(node): Avoid using dynamic require for fastify integration #16789

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

Merged
merged 2 commits into from
Jul 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable jsdoc/require-jsdoc */
/* eslint-disable max-lines */
/* eslint-disable no-param-reassign */
Expand All @@ -44,6 +43,7 @@ import {
ATTR_HTTP_ROUTE,
ATTR_SERVICE_NAME,
} from '@opentelemetry/semantic-conventions';
import * as minimatch from 'minimatch';

// SENTRY VENDOR NOTE
// Instead of using the package.json file, we hard code the package name and version here.
Expand Down Expand Up @@ -97,18 +97,12 @@ export class FastifyOtelInstrumentation extends InstrumentationBase {
throw new TypeError('ignorePaths must be a string or a function');
}

let globMatcher = null;
const globMatcher = minimatch.minimatch;

this[kIgnorePaths] = routeOptions => {
if (typeof ignorePaths === 'function') {
return ignorePaths(routeOptions);
} else {
// Using minimatch to match the path until path.matchesGlob is out of experimental
// path.matchesGlob uses minimatch internally
if (globMatcher == null) {
globMatcher = require('minimatch').minimatch;
}

return globMatcher(routeOptions.url, ignorePaths);
}
};
Expand Down
Loading